Linux

  1. let g:python_host_prog = '/usr/bin/python'
  2. "space replace tab
  3. set ts=4
  4. set softtabstop=4
  5. set shiftwidth=4
  6. set expandtab
  7. "use plug
  8. call plug#begin()
  9. "*************json*******************
  10. Plug 'kevinoid/vim-jsonc'
  11. "gruvbox 主题
  12. Plug 'morhetz/gruvbox'
  13. "*************代码补全*******************
  14. "Use release branch (recommend)
  15. "Plug 'neoclide/coc.nvim', {'branch': 'release'}
  16. Plug 'https://gitee.com/yzhrex/coc.nvim.git', {'branch': 'master'}
  17. "*************状态栏优化*******************
  18. Plug 'liuchengxu/eleline.vim'
  19. "*************效率工具*******************
  20. "vim-autopep8,python自动格式化
  21. Plug 'tell-k/vim-autopep8'
  22. "nerdtree 文件树
  23. Plug 'preservim/nerdtree'
  24. "代码注释
  25. Plug 'preservim/nerdcommenter'
  26. "DeBug
  27. Plug 'puremourning/vimspector'
  28. "括号优化
  29. Plug 'jiangmiao/auto-pairs'
  30. call plug#end()
  31. "*************DEBUG*******************
  32. let g:vimspector_enable_mappings = 'VISUAL_STUDIO'
  33. colo gruvbox
  34. "************快捷键设置*******************
  35. "F3 开启关闭文件树
  36. nm <C-b> :NERDTreeToggle<CR>
  37. "设置当前目录为nerdtree的起始目录
  38. let NERDTreeChDirMode=2
  39. "使得窗口有更好看的效果
  40. let NERDChristmasTree=1
  41. "设置窗口宽度为25
  42. "let NERDTreeWinSize=25
  43. "打开一个文件时nerdtree分栏自动关闭
  44. let NERDTreeQuitOnOpen=1
  45. "翻译视图模式选中的单词
  46. vm <C-T> "*y <Esc>:!trans &<CR><CR>
  47. "go代码格式优化加自动导包
  48. au FileType go no <buffer> <a-f> :call CocAction('runCommand', 'editor.action.organizeImport')<CR> :w<CR> :!gofmt -w %<CR> :e<CR>
  49. "添加go源码追踪,需要先安装ctags5.8+ 然后在$GOROOT/src 文件夹下执行命令ctags -R --exclude='cmd/*' --exclude='*test*' . 生成tags文件
  50. au FileType go exe "set tags+=/usr/local/go/src/tags"
  51. "python代码自动格式优化
  52. au FileType python no <buffer> <a-f> :call Autopep8()<CR>
  53. "添加python源码追踪 ctags --languages="Python" --exclude='*test*' -R .
  54. au FileType python exe "set tags+=/usr/lib/python3.8/tags"
  55. "vim-autopep8设置,关闭diff提示
  56. let g:autopep8_disable_show_diff=1
  57. " Remap <C-f> and <C-b> for scroll float windows/popups.
  58. if has('nvim-0.4.0') || has('patch-8.2.0750')
  59. nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
  60. nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
  61. inoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>"
  62. inoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>"
  63. vnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
  64. vnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
  65. endif
  66. "Ctrl+/注释
  67. map <C-_> <leader>c<space>

Windows

  1. let g:python3_host_prog = 'C:\Python39\python.exe'
  2. "space replace tab
  3. set ts=4
  4. set softtabstop=4
  5. set shiftwidth=4
  6. set expandtab
  7. "自动加入文件头
  8. autocmd bufnewfile *.py,*.sh so C:\tools\neovim\Neovim\share\nvim\runtime\macros\metadata.vim
  9. autocmd bufnewfile *.py,*.sh exe "1,6g/File Name:.*/s//File Name: " .expand("%")
  10. autocmd bufnewfile *.py,*.sh exe "1,6g/Creation Time:.*/s//Creation Time: " .strftime("%Y-%m-%d %H:%M:%S")
  11. autocmd Bufwritepre,filewritepre *.py,*.sh exe "normal ma"
  12. autocmd Bufwritepre,filewritepre *.py,*.sh exe "1,6g/Last Modified:.*/s//Last Modified: " .strftime("%Y-%m-%d %H:%M:%S")
  13. autocmd bufwritepost,filewritepost *.py,*.sh exe "normal `a"
  14. "有道词典快捷键
  15. vnoremap <silent> <C-T> :<C-u>Ydv<CR>
  16. nnoremap <silent> <C-T> :<C-u>Ydc<CR>
  17. noremap <leader>yd :<C-u>Yde<CR>
  18. " Remap <C-f> and <C-b> for scroll float windows/popups.
  19. if has('nvim-0.4.0') || has('patch-8.2.0750')
  20. nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
  21. nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
  22. inoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>"
  23. inoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>"
  24. vnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
  25. vnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
  26. endif
  27. call plug#begin()
  28. Plug 'ianva/vim-youdao-translater'
  29. Plug 'morhetz/gruvbox'
  30. Plug 'bling/vim-airline'
  31. Plug 'scrooloose/nerdtree'
  32. Plug 'tell-k/vim-autopep8'
  33. Plug 'neoclide/coc.nvim'
  34. Plug 'puremourning/vimspector'
  35. Plug 'jiangmiao/auto-pairs'
  36. Plug 'scrooloose/nerdcommenter'
  37. call plug#end()
  38. colorscheme gruvbox
  39. " F3 开启关闭文件树
  40. nnoremap <C-b> :NERDTreeToggle<CR>
  41. "go格式化加自动导包
  42. au FileType go noremap <buffer> <a-f> :call CocAction('runCommand', 'editor.action.organizeImport')<CR> :w<CR> :!gofmt -w %<CR> :e<CR>
  43. au FileType go exe "set tags+=C:/Go/src/tags"
  44. "注释
  45. map <C-_> <leader>c<space>
  46. "python格式化
  47. au FileType python noremap <buffer> <a-f> :call Autopep8()<CR>
  48. au FileType Python exe "set tags+=C:/Python39/lib/tags"
  49. "vim-autopep8设置,关闭diff提示
  50. let g:autopep8_disable_show_diff=1
  51. "*********** NERDTree插件配置 ***********
  52. let NERDTreeChDirMode=2 " 设置当前目录为nerdtree的起始目录
  53. let NERDChristmasTree=1 " 使得窗口有更好看的效果
  54. let g:vimspector_enable_mappings = 'VISUAL_STUDIO'