hnOsmium0001

init.vim 2020-6-6

Jun 6th, 2020
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.75 KB | None | 0 0
  1. " ================================================================
  2.  
  3. call plug#begin('~/.vim/plugged')
  4.  
  5. " Editing Enhancement
  6. Plug 'neoclide/coc.nvim', {'branch': 'release'}
  7. Plug 'liuchengxu/vista.vim'
  8. Plug 'junegunn/vim-easy-align'
  9.  
  10. " GUI Enhancement
  11. Plug 'itchyny/lightline.vim'
  12. Plug 'tomasiser/vim-code-dark'
  13.  
  14. Plug 'scrooloose/nerdtree'
  15. Plug 'scrooloose/nerdcommenter'
  16. Plug 'Xuyuanp/nerdtree-git-plugin'
  17. Plug 'Shougo/deol.nvim'
  18. " Plug 'Shougo/neosnippet.vim' | Plug 'Shougo/neosnippet-snippets'
  19.  
  20. call plug#end()
  21.  
  22.  
  23.  
  24.  
  25. " ================================================================
  26. " # coc.nvim Settings
  27. " ================================================================
  28.  
  29. " if hidden is not set, TextEdit might fail.
  30. set hidden
  31.  
  32. " Some servers have issues with backup files, see #649
  33. set nobackup
  34. set nowritebackup
  35.  
  36. " Better display for messages
  37. set cmdheight=2
  38.  
  39. " You will have bad experience for diagnostic messages when it's default 4000.
  40. set updatetime=300
  41.  
  42. " don't give |ins-completion-menu| messages.
  43. set shortmess+=c
  44.  
  45. " always show signcolumns
  46. set signcolumn=yes
  47.  
  48. " Use tab for trigger completion with characters ahead and navigate.
  49. " Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin.
  50. inoremap <silent><expr> <TAB>
  51. \ pumvisible() ? "\<C-n>" :
  52. \ <SID>check_back_space() ? "\<TAB>" :
  53. \ coc#refresh()
  54. inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
  55.  
  56. function! s:check_back_space() abort
  57. let col = col('.') - 1
  58. return !col || getline('.')[col - 1] =~# '\s'
  59. endfunction
  60.  
  61. " Use <c-space> to trigger completion.
  62. inoremap <silent><expr> <c-space> coc#refresh()
  63.  
  64. " Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position.
  65. " Coc only does snippet and additional edit on confirm.
  66. inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
  67. " Or use `complete_info` if your vim support it, like:
  68. " inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>"
  69.  
  70. " Use `[g` and `]g` to navigate diagnostics
  71. nmap <silent> [g <Plug>(coc-diagnostic-prev)
  72. nmap <silent> ]g <Plug>(coc-diagnostic-next)
  73.  
  74. " Remap keys for gotos
  75. nmap <silent> gd <Plug>(coc-definition)
  76. nmap <silent> gy <Plug>(coc-type-definition)
  77. nmap <silent> gi <Plug>(coc-implementation)
  78. nmap <silent> gr <Plug>(coc-references)
  79.  
  80. " Use K to show documentation in preview window
  81. nnoremap <silent> K :call <SID>show_documentation()<CR>
  82.  
  83. function! s:show_documentation()
  84. if (index(['vim','help'], &filetype) >= 0)
  85. execute 'h '.expand('<cword>')
  86. else
  87. call CocAction('doHover')
  88. endif
  89. endfunction
  90.  
  91. " Highlight symbol under cursor on CursorHold
  92. autocmd CursorHold * silent call CocActionAsync('highlight')
  93.  
  94. " Remap for rename current word
  95. nmap <leader>rn <Plug>(coc-rename)
  96.  
  97. " Remap for format selected region
  98. xmap <leader>f <Plug>(coc-format-selected)
  99. nmap <leader>f <Plug>(coc-format-selected)
  100.  
  101. augroup mygroup
  102. autocmd!
  103. " Setup formatexpr specified filetype(s).
  104. autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
  105. " Update signature help on jump placeholder
  106. autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
  107. augroup end
  108.  
  109. " Remap for do codeAction of selected region, ex: `<leader>aap` for current paragraph
  110. xmap <leader>a <Plug>(coc-codeaction-selected)
  111. nmap <leader>a <Plug>(coc-codeaction-selected)
  112.  
  113. " Remap for do codeAction of current line
  114. nmap <leader>ac <Plug>(coc-codeaction)
  115. " Fix autofix problem of current line
  116. nmap <leader>qf <Plug>(coc-fix-current)
  117.  
  118. " Create mappings for function text object, requires document symbols feature of languageserver.
  119. xmap if <Plug>(coc-funcobj-i)
  120. xmap af <Plug>(coc-funcobj-a)
  121. omap if <Plug>(coc-funcobj-i)
  122. omap af <Plug>(coc-funcobj-a)
  123.  
  124. " Use <C-d> for select selections ranges, needs server support, like: coc-tsserver, coc-python
  125. nmap <silent> <C-d> <Plug>(coc-range-select)
  126. xmap <silent> <C-d> <Plug>(coc-range-select)
  127.  
  128. " Use `:Format` to format current buffer
  129. command! -nargs=0 Format :call CocAction('format')
  130.  
  131. " Use `:Fold` to fold current buffer
  132. command! -nargs=? Fold :call CocAction('fold', <f-args>)
  133.  
  134. " use `:OR` for organize import of current buffer
  135. command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
  136.  
  137. " Add status line support, for integration with other plugin, checkout `:h coc-status`
  138. set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
  139.  
  140. " Using CocList
  141. " Show all diagnostics
  142. nnoremap <silent> <space>a :<C-u>CocList diagnostics<cr>
  143. " Manage extensions
  144. nnoremap <silent> <space>e :<C-u>CocList extensions<cr>
  145. " Show commands
  146. nnoremap <silent> <space>c :<C-u>CocList commands<cr>
  147. " Find symbol of current document
  148. nnoremap <silent> <space>o :<C-u>CocList outline<cr>
  149. " Search workspace symbols
  150. nnoremap <silent> <space>s :<C-u>CocList -I symbols<cr>
  151. " Do default action for next item.
  152. nnoremap <silent> <space>j :<C-u>CocNext<CR>
  153. " Do default action for previous item.
  154. nnoremap <silent> <space>k :<C-u>CocPrev<CR>
  155. " Resume latest coc list
  156. nnoremap <silent> <space>p :<C-u>CocListResume<CR>
  157.  
  158. " Comments for json file
  159. autocmd FileType json syntax match Comment +\/\/.\+$+
  160.  
  161.  
  162.  
  163.  
  164. " ================================================================
  165. " # Other Plugin Settigs
  166. " ================================================================
  167.  
  168. " # Settings for lightline.vim
  169. set laststatus=2
  170.  
  171. " # Settings for vim-code-dark
  172. colorscheme codedark
  173.  
  174.  
  175.  
  176. " ================================================================
  177. " # Regular Vim settings
  178. " ================================================================
  179.  
  180. " Force use xTerm 256 coloring
  181. if !has('gui_running')
  182. set t_Co=256
  183. endif
  184.  
  185. " Visual stuff
  186. set number
  187. set relativenumber
  188. set nowrap
  189.  
  190. " Permanent undo
  191. set undodir=~/.vim/undo
  192. set undofile
  193.  
  194. " Tab configuration
  195. set shiftwidth=2
  196. set softtabstop=2
  197. set tabstop=2
  198. set noexpandtab
  199.  
  200. " Keymap for saving files
  201. nnoremap <leader>s :w<CR>
  202. nnoremap <leader>sa :wa<CR>
  203.  
  204. " Keymap for toggling paste mode
  205. nnoremap <leader>p :set paste<CR>
  206. nnoremap <leader>np :set nopaste<CR>
  207.  
  208. " Esc to unfocus from Deol.nvim terminal
  209. tnoremap <Esc> <C-\><C-n>
  210.  
  211. " Ctrl+J to switch to normal mode
  212. inoremap <C-j> <Esc>
  213. vnoremap <C-j> <Esc>
  214.  
  215. " Force set language regardless of system language
  216. set langmenu=en_US
  217. let $LANG = 'en_US'
  218. source $VIMRUNTIME/delmenu.vim
  219. source $VIMRUNTIME/menu.vim
  220.  
  221. " Open NerdTree hotkey in the directory of the current open file ('%')
  222. nmap <leader>ne :NERDTree<CR>
  223. nmap <leader>nc :NERDTree %<CR>
  224. " Open deol.nvim terminal hotkey
  225. nmap <leader>to :Deol<CR>
  226.  
  227. " Enable mouse mode
  228. set mouse=a
  229.  
  230. " Search visual selection
  231. vnoremap // y/\V<C-R>=escape(@",'/\')<CR><CR>s
  232. " Close all search highlights
  233. nnoremap <leader>noh :noh<CR>
Add Comment
Please, Sign In to add comment