共计 12504 个字符,预计需要花费 32 分钟才能阅读完成。
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.tgz
wget https://www.python.org/ftp/python/3.9.13/Python-3.9.13.tgz
wget 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-extensions
make -j4
make install
把 /home/harriszh/.local/lib
退出到 LD_LIBRARY_PATH
中
装置 gcc9
yum install centos-release-scl -y
yum clean all
yum 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/.local
make -j4
make install
装置 powerline
pip3 install --user git+https://github.com/powerline/powerline
装置 vim
而后用源码装 vim
git clone https://github.com/vim/vim.git
cd 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-cscope
make && 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 配置
#fzf
export LD_LIBRARY_PATH=/usr/local/lib:/lib64:/usr/lib64:/usr/lib:/lib
if [${CURSHELL} = "bash" ]; then
[-f ~/.fzf.bash] && source ~/.fzf.bash
elif [${CURSHELL} = "zsh" ]; then
[-f ~/.fzf.zsh] && source ~/.fzf.zsh
fi
export 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 history
fh() {eval $( ([ -n "$ZSH_NAME"] && fc -l 1 || history) | fzf +s --tac | sed 's/ *[0-9]* *//')
}
# fd - cd to selected directory
fd() {
local dir
dir=$(fd ${1:-.} --type d -print 2> /dev/null | fzf +m) &&
cd "$dir"
}
# fda - including hidden directories
fda() {
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 execute
fzf-history-widget-accept() {
fzf-history-widget
zle accept-line
}
zle -N fzf-history-widget-accept
bindkey '^X^R' fzf-history-widget-accept
# interactive cd
source ~/.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 = 1
Plug 'zhuzhzh/verilog_emacsauto.vim'
Plug 'junegunn/fzf', {'dir':'~/.fzf', 'do': './install --all'}
Plug 'junegunn/fzf.vim'
let s:my_loading_fzf = 1
if 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 = 1
endif
Plug 'preservim/nerdtree', {'on': 'NERDTreeToggle'}
let s:my_loading_nerdtree = 1
Plug 'junegunn/vim-easy-align'
let s:my_loading_vimeasyalign = 1
Plug '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_setup
endif
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
正文完