VIM 在Centos7上的装置与配置

VIM8是目前的最新版本,它有十分多的个性能够进步咱们的生产效率,所以咱们这里以VIM8为例

VIM8 编译前的筹备

咱们须要装置两个重要的插件,一个是leaderf, 一个是coc.nvim, 前者依赖python, 后者依赖node.js. 所以咱们须要先装置这两个

装置python3

源代码装置, 能够下载3.8.x或3.9.x

wget https://www.python.org/ftp/python/3.8.13/Python-3.8.13.tgzwget https://www.python.org/ftp/python/3.9.13/Python-3.9.13.tgzwget https://www.python.org/ftp/python/3.10.4/Python-3.10.4.tgz

要生成动态链接库,不能开优化

./configure --prefix=/home/harriszh/.local --enable-shared --with-system-ffi --with-computed-gotos --enable-loadable-sqlite-extensionsmake -j4make install

/home/harriszh/.local/lib退出到LD_LIBRARY_PATH

装置gcc9

yum install centos-release-scl -yyum clean allyum install devtoolset-9-* -y

不倡议始终开着,只在须要时source /opt/rh/devtoolset-9/enable(须要用bash或zsh)

装置node.js

须要用gcc9

下载源码:

wget https://nodejs.org/dist/v16.15.0/node-v16.15.0.tar.gz

官网要求如下:

    gcc and g++ >= 8.3 or newer    GNU Make 3.81 or newer    Python 3.6, 3.7, 3.8, 3.9, or 3.10 (see note above)        For test coverage, your Python installation must include pip.

解压后

./configuration --prefix=/home/harriszh/.localmake -j4make install

装置powerline

pip3 install --user git+https://github.com/powerline/powerline

装置vim

而后用源码装vim

git clone https://github.com/vim/vim.gitcd vim/src./configure --with-features=huge \            --enable-multibyte \            --enable-rubyinterp \            --enable-python3interp \            --with-python3-config-dir=/home/harriszh/.local/lib/python3.8/config-3.8m-x86_64-linux-gnu/ \            --with-python3-command=/home/harriszh/.local/bin/python3 \            --enable-perlinterp \            --enable-luainterp \            --with-lua_prefix=/home/harriszh/.local \            --enable-gui=gtk2 --enable-cscopemake && make install

Ripgrep

先装置 RUST

curl https://sh.rustup.rs -sSf | sh

而后一路 enter 就好了

用 RUST 装置 rigpre

cargo install ripgrep

默认放在~/.cargo/bin

间接拷贝

最简略的办法是从他人那边拷贝一份rg的可执行程序

fd

cargo install fd-find

默认放在~/.cargo/bin

fzf

fzf装置

git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf~/.fzf/install

fzf配置

#fzfexport LD_LIBRARY_PATH=/usr/local/lib:/lib64:/usr/lib64:/usr/lib:/libif [ ${CURSHELL} = "bash" ]; then    [ -f ~/.fzf.bash ] && source ~/.fzf.bashelif [ ${CURSHELL} = "zsh" ]; then    [ -f ~/.fzf.zsh ] && source ~/.fzf.zshfiexport FZF_DEFAULT_COMMAND='fd --type f --hidden --follow --exclude .git'export FZF_CTRL_T_DEFAULT_COMMAND="$FZF_DEFAULT_COMMAND"export FZF_ALT_C_COMMAND='rg --sort-files --files --null 2> /dev/null | xargs -0 dirname | uniq'#Use fd instead of the default find command for listing candidates_fzf_compgen_path() {    rg -g "" -- "$1"}# Use fd to generate the list for directory completion_fzf_compgen_dir() {  fd --type d --hidden --follow --exclude ".git" . "$1"}# repeat historyfh() {  eval $( ([ -n "$ZSH_NAME" ] && fc -l 1 || history) | fzf +s --tac | sed 's/ *[0-9]* *//')}# fd - cd to selected directoryfd() {  local dir  dir=$(fd ${1:-.} --type d -print 2> /dev/null | fzf +m) &&  cd "$dir"}# fda - including hidden directoriesfda() {  local dir  dir=$(fd ${1:-.} --type d 2> /dev/null | fzf +m) && cd "$dir"}fzfp() {  fzf --preview '[[ $(file --mime {}) =~ binary ]] && echo {} is a binary file || (rougify {}  || highlight -O ansi -l {} || coderay {} || cat {}) 2> /dev/null | head -500'}# click Ctrl-X+Ctrl-R to executefzf-history-widget-accept() {  fzf-history-widget  zle accept-line}zle    -N    fzf-history-widget-acceptbindkey '^X^R' fzf-history-widget-accept# interactive cdsource ~/.fzf/shell/zsh-interactive-cd.zshrc

装置vim-plug

curl -fLo ~/.vim/autoload/plug.vim --create-dirs \    https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

如果不能下载的话, 手工从https://github.com/junegunn/vim-plug里把plug.vim下载后放到~/.vim/autoload

而后在~/.vimrc加上

call plug#begin()Plug 'junegunn/seoul256.vim'Plug 'yianwillis/vimcdoc'Plug 'honza/vim-snippets'let s:my_loading_vim_snippets = 1Plug 'zhuzhzh/verilog_emacsauto.vim'Plug 'junegunn/fzf', { 'dir':'~/.fzf', 'do': './install --all' }Plug 'junegunn/fzf.vim'let s:my_loading_fzf = 1if version >= 800    if is_win        Plug 'liuchengxu/vim-clap', { 'do': { -> clap#installer#force_download() } }    else        Plug 'liuchengxu/vim-clap', { 'do': ':Clap install-binary' }    endif    let s:my_loading_vim_clap = 1    Plug 'dense-analysis/ale', { 'for': ['cpp', 'c']}    let s:my_loading_ale = 1    Plug 'neoclide/coc.nvim', {'branch': 'release'}    let s:my_coc_nvim = 1    Plug 'nanotee/zoxide.vim'    let s:my_loading_zoxide = 1    Plug 'Yggdroot/LeaderF', {'do': ':LeaderfInstallCExtension'}    let s:my_loading_leaderf = 1    Plug 'skywind3000/asyncrun.vim'    let s:my_loading_asyncrun = 1endifPlug 'preservim/nerdtree', {'on': 'NERDTreeToggle'}let s:my_loading_nerdtree = 1Plug 'junegunn/vim-easy-align'let s:my_loading_vimeasyalign = 1Plug 'plasticboy/vim-markdown', { 'for': 'markdown' }call plug#end()

退出vim后, 再进入vim, 输出:PlugInstall

配置插件

powerline

if !is_win    python3 from powerline.vim import setup as powerline_setup    python3 powerline_setup()    python3 del powerline_setupendif

vim-clap

"-----------------------------------------------------------------------------" plugin - vim-clap"-----------------------------------------------------------------------------if exists("s:my_loading_vim_clap")    let g:clap_theme = 'material_design_dark'    let g:clap_builtin_fuzzy_filter_threshold = 0    noremap <Leader>ff :Clap files<cr>    noremap <Leader>ft :Clap tags<cr>    noremap <Leader>fl :Clap lines<cr>    noremap <Leader>fm :Clap history<cr>    noremap <Leader>fb :Clap buffers<cr>    noremap <Leader>fc :Clap colors<cr>    noremap <Leader>fg :Clap grep<cr>    noremap <Leader>fj :Clap jumps<cr>    noremap <Leader>fk :Clap marks<cr>    noremap <Leader>fq :Clap quickfix<cr>    noremap <Leader>fd :Clap dumb_jump<cr>    noremap <Leader>fr :Clap filer<cr>    noremap <Leader>fo :Clap gfiles<cr>    noremap <Leader>fu :Clap git_diff_files<cr>endif"------------------------END vim-clap--------------------------------------

LeaderF

可选的还有fzf.vim

"----------------------------------------------------------------------------- " plugin - LeaderF"----------------------------------------------------------------------------- if exists("s:my_loading_leaderf")    " don't show the help in normal mode    let g:Lf_HideHelp = 1    let g:Lf_UseCache = 0    let g:Lf_UseVersionControlTool = 0    let g:Lf_IgnoreCurrentBufferName = 1    " popup mode    let g:Lf_WindowPosition = 'popup'    let g:Lf_PreviewInPopup = 1    let g:Lf_StlSeparator = { 'left': "\ue0b0", 'right': "\ue0b2", 'font': "MesloLGS Nerd Font Mono" }    let g:Lf_PreviewResult = {'Function': 0, 'BufTag': 0 }    let g:Lf_ShowDevIcons = 1    let g:Lf_DevIconsFont = "MesloLGS Nerd Font Mono"     let g:Lf_ShortcutF = "<leader>ff"    noremap <leader>fb :<C-U><C-R>=printf("Leaderf buffer %s", "")<CR><CR>    noremap <leader>fm :<C-U><C-R>=printf("Leaderf mru %s", "")<CR><CR>    noremap <leader>ft :<C-U><C-R>=printf("Leaderf bufTag %s", "")<CR><CR>    noremap <leader>fl :<C-U><C-R>=printf("Leaderf line %s", "")<CR><CR>    noremap <leader>fc :<C-U><C-R>=printf("Leaderf! rg --current-buffer -e %s ", expand("<cword>"))<CR>    noremap <leader>fa :<C-U><C-R>=printf("Leaderf! rg -e %s ", expand("<cword>"))<CR>    " search visually selected text literally    xnoremap gf :<C-U><C-R>=printf("Leaderf! rg -F -e %s ", leaderf#Rg#visual())<CR>    noremap go :<C-U>Leaderf! rg --recall<CR>    " should use `Leaderf gtags --update` first    let g:Lf_GtagsAutoGenerate = 0    let g:Lf_Gtagslabel = 'native-pygments'    noremap <leader>fg :<C-U><C-R>=printf("Leaderf! gtags --update")<CR><CR>    noremap <leader>fr :<C-U><C-R>=printf("Leaderf! gtags -r %s --auto-jump", expand("<cword>"))<CR><CR>    noremap <leader>fd :<C-U><C-R>=printf("Leaderf! gtags -d %s --auto-jump", expand("<cword>"))<CR><CR>    noremap <leader>fo :<C-U><C-R>=printf("Leaderf! gtags --recall %s", "")<CR><CR>    noremap <leader>fn :<C-U><C-R>=printf("Leaderf gtags --next %s", "")<CR><CR>    noremap <leader>fp :<C-U><C-R>=printf("Leaderf gtags --previous %s", "")<CR><CR>    let g:Lf_ShowHidden = 1    let g:Lf_RgConfig = [    \ "--hidden",    \ "--no-messages",    \ "--color never",    \ "--no-ignore"    \ ]    let g:Lf_WildIgnore = {      \ 'dir': ['.root','.svn','.git','.hg','.ccls-cache'],      \ 'file': ['*.sw?','~$*', '*swp', '*.bak','*.exe','*.o','*.so','*.py[co]']      \}    let g:Lf_RootMarkers = ['.project', '.root', '.svn', '.git', '.root']endif"------------------------END LeaderF--------------------------------------

coc.nvim

"----------------------------------------------------------------------------- " plugin -coc.nvim"----------------------------------------------------------------------------- if exists("s:my_coc_nvim")    " NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by    " other plugin before putting this into your config.     inoremap <silent><expr> <TAB>      \ pumvisible() ? coc#_select_confirm() :      \ coc#expandableOrJumpable() ? "\<C-r>=coc#rpc#request('doKeymap', ['snippets-expand-jump',''])\<CR>" :      \ <SID>check_back_space() ? "\<TAB>" :      \ coc#refresh()    inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"    function! s:check_back_space() abort        let col = col('.') - 1        return !col || getline('.')[col - 1]  =~# '\s'    endfunction    inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()                              \: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"    "let g:coc_snippet_next = '<tab>'    " Use <C-l> for trigger snippet expand.    imap <C-l> <Plug>(coc-snippets-expand)    " Use <C-j> for select text for visual placeholder of snippet.    vmap <C-j> <Plug>(coc-snippets-select)    " Use <C-j> for jump to next placeholder, it's default of coc.nvim    let g:coc_snippet_next = '<c-j>'    " Use <C-k> for jump to previous placeholder, it's default of coc.nvim    let g:coc_snippet_prev = '<c-k>'    " Use <C-j> for both expand and jump (make expand higher priority.)    imap <C-j> <Plug>(coc-snippets-expand-jump)    " Use <leader>x for convert visual selected code to snippet    xmap <leader>x  <Plug>(coc-convert-snippet)    " GoTo code navigation.    nmap <silent> gd <Plug>(coc-definition)    nmap <silent> gD <Plug>(coc-type-definition)    nmap <silent> gi <Plug>(coc-implementation)    nmap <silent> gr <Plug>(coc-references)    " Use K to show documentation in preview window.    nnoremap <silent> K :call <SID>show_documentation()<CR>    function! s:show_documentation()      if CocAction('hasProvider', 'hover')        call CocActionAsync('doHover')      else        call feedkeys('K', 'in')      endif    endfunction    " Highlight the symbol and its references when holding the cursor.    autocmd CursorHold * silent call CocActionAsync('highlight')    " Symbol renaming.    nmap <leader>rn <Plug>(coc-rename)    " Remap <C-f> and <C-b> for scroll float windows/popups.    if has('nvim-0.4.0') || has('patch-8.2.0750')      nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"      nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"      inoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>"      inoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>"      vnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"      vnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"    endif    " Using Coc-explorer    noremap <leader>ee :CocCommand explorer<CR>    " Close Coc-explorer if it is the only window    autocmd BufEnter * if (&ft == 'coc-explorer' && winnr("$") == 1) | q | endif    autocmd CursorHold * silent call CocActionAsync('highlight')    " Run the Code Lens action on the current line.    nmap <leader>cl  <Plug>(coc-codelens-action)        " Map function and class text objects    " NOTE: Requires 'textDocument.documentSymbol' support from the language server.    xmap if <Plug>(coc-funcobj-i)    omap if <Plug>(coc-funcobj-i)    xmap af <Plug>(coc-funcobj-a)    omap af <Plug>(coc-funcobj-a)    xmap ic <Plug>(coc-classobj-i)    omap ic <Plug>(coc-classobj-i)    xmap ac <Plug>(coc-classobj-a)    omap ac <Plug>(coc-classobj-a)    " Mappings for CoCList    " Show all diagnostics.    nnoremap <silent><nowait> <leader>ca  :<C-u>CocList diagnostics<cr>    " Manage extensions.    nnoremap <silent><nowait> <leader>ce  :<C-u>CocList extensions<cr>    " Show commands.    nnoremap <silent><nowait> <leader>cc  :<C-u>CocList commands<cr>    " Find symbol of current document.    nnoremap <silent><nowait> <leader>co  :<C-u>CocList outline<cr>    " Search workspace symbols.    nnoremap <silent><nowait> <leader>cs  :<C-u>CocList -I symbols<cr>    " Do default action for next item.    nnoremap <silent><nowait> <leader>cj  :<C-u>CocNext<CR>    " Do default action for previous item.    nnoremap <silent><nowait> <leader>ck  :<C-u>CocPrev<CR>    " Resume latest coc list.    nnoremap <silent><nowait> <leader>cp  :<C-u>CocListResume<CR>    command! SvBuildIndex call CocRequest("svlangserver", 'workspace/executeCommand', {'command': 'systemverilog.build_index'})    command! -range SvReportHierarchy call CocRequest("svlangserver", 'workspace/executeCommand', {'command': 'systemverilog.report_hierarchy', 'arguments': [input('Module/interface: ', <range> == 0 ? "" : expand("<cword>"))]})endif"----------------------END coc.nvim--------------------------------------

vista.vim

vista依赖带有json输入性能的ctags

if exists("s:my_loading_vista")    " How each level is indented and what to prepend.    " This could make the display more compact or more spacious.    " e.g., more compact: ["▸ ", ""]    " Note: this option only works for the kind renderer, not the tree renderer.    let g:vista_icon_indent = ["╰─▸ ", "├─▸ "]        " Executive used when opening vista sidebar without specifying it.    " See all the avaliable executives via `:echo g:vista#executives`.    let g:vista_default_executive = 'ctags'    " To enable fzf's preview window set g:vista_fzf_preview.    " The elements of g:vista_fzf_preview will be passed as arguments to fzf#vim#with_preview()    " For example:    let g:vista_fzf_preview = ['right:50%']    " Ensure you have installed some decent font to show these pretty symbols, then you can enable icon for the kind.    let g:vista#renderer#enable_icon = 1    " The default icons can't be suitable for all the filetypes, you can extend it as you wish.    let g:vista#renderer#icons = {    \   "function": "\uf794",    \   "variable": "\uf71b",    \  }    nnoremap <leader>vt :Vista ctags<CR>    nnoremap <leader>vo :Vista coc<CR>    nnoremap <leader>vft :Vista finder ctags<CR>    nnoremap <leader>vfo :Vista finder coc<CR>endif