Advertisement
hnOsmium0001

2019-11-25 .vimrc simple

Nov 25th, 2019
1,110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 5.62 KB | None | 0 0
  1. " ================================================================
  2. " # Settings for coc.nvim
  3. " ================================================================
  4.  
  5. call plug#begin('~/.vim/plugged')
  6.  
  7. Plug 'neoclide/coc.nvim', {'branch': 'release'}
  8. Plug 'itchyny/lightline.vim'
  9. Plug 'junegunn/seoul256.vim'
  10.  
  11. call plug#end()
  12.  
  13.  
  14. " ================================================================
  15. " # Settings for coc.nvim
  16. " ================================================================
  17.  
  18. " if hidden is not set, TextEdit might fail.
  19. set hidden
  20.  
  21. " Some servers have issues with backup files, see #649
  22. set nobackup
  23. set nowritebackup
  24.  
  25. " Better display for messages
  26. set cmdheight=2
  27.  
  28. " You will have bad experience for diagnostic messages when it's default 4000.
  29. set updatetime=300
  30.  
  31. " don't give |ins-completion-menu| messages.
  32. set shortmess+=c
  33.  
  34. " always show signcolumns
  35. set signcolumn=yes
  36.  
  37. " Use tab for trigger completion with characters ahead and navigate.
  38. " Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin.
  39. inoremap <silent><expr> <TAB>
  40.       \ pumvisible() ? "\<C-n>" :
  41.       \ <SID>check_back_space() ? "\<TAB>" :
  42.       \ coc#refresh()
  43. inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
  44.  
  45. function! s:check_back_space() abort
  46.   let col = col('.') - 1
  47.   return !col || getline('.')[col - 1]  =~# '\s'
  48. endfunction
  49.  
  50. " Use <c-space> to trigger completion.
  51. inoremap <silent><expr> <c-space> coc#refresh()
  52.  
  53. " Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position.
  54. " Coc only does snippet and additional edit on confirm.
  55. inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
  56. " Or use `complete_info` if your vim support it, like:
  57. " inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>"
  58.  
  59. " Use `[g` and `]g` to navigate diagnostics
  60. nmap <silent> [g <Plug>(coc-diagnostic-prev)
  61. nmap <silent> ]g <Plug>(coc-diagnostic-next)
  62.  
  63. " Remap keys for gotos
  64. nmap <silent> gd <Plug>(coc-definition)
  65. nmap <silent> gy <Plug>(coc-type-definition)
  66. nmap <silent> gi <Plug>(coc-implementation)
  67. nmap <silent> gr <Plug>(coc-references)
  68.  
  69. " Use K to show documentation in preview window
  70. nnoremap <silent> K :call <SID>show_documentation()<CR>
  71.  
  72. function! s:show_documentation()
  73.   if (index(['vim','help'], &filetype) >= 0)
  74.     execute 'h '.expand('<cword>')
  75.   else
  76.     call CocAction('doHover')
  77.   endif
  78. endfunction
  79.  
  80. " Highlight symbol under cursor on CursorHold
  81. autocmd CursorHold * silent call CocActionAsync('highlight')
  82.  
  83. " Remap for rename current word
  84. nmap <leader>rn <Plug>(coc-rename)
  85.  
  86. " Remap for format selected region
  87. xmap <leader>f  <Plug>(coc-format-selected)
  88. nmap <leader>f  <Plug>(coc-format-selected)
  89.  
  90. augroup mygroup
  91.   autocmd!
  92.   " Setup formatexpr specified filetype(s).
  93.   autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
  94.   " Update signature help on jump placeholder
  95.   autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
  96. augroup end
  97.  
  98. " Remap for do codeAction of selected region, ex: `<leader>aap` for current paragraph
  99. xmap <leader>a  <Plug>(coc-codeaction-selected)
  100. nmap <leader>a  <Plug>(coc-codeaction-selected)
  101.  
  102. " Remap for do codeAction of current line
  103. nmap <leader>ac  <Plug>(coc-codeaction)
  104. " Fix autofix problem of current line
  105. nmap <leader>qf  <Plug>(coc-fix-current)
  106.  
  107. " Create mappings for function text object, requires document symbols feature of languageserver.
  108. xmap if <Plug>(coc-funcobj-i)
  109. xmap af <Plug>(coc-funcobj-a)
  110. omap if <Plug>(coc-funcobj-i)
  111. omap af <Plug>(coc-funcobj-a)
  112.  
  113. " Use <C-d> for select selections ranges, needs server support, like: coc-tsserver, coc-python
  114. nmap <silent> <C-d> <Plug>(coc-range-select)
  115. xmap <silent> <C-d> <Plug>(coc-range-select)
  116.  
  117. " Use `:Format` to format current buffer
  118. command! -nargs=0 Format :call CocAction('format')
  119.  
  120. " Use `:Fold` to fold current buffer
  121. command! -nargs=? Fold :call     CocAction('fold', <f-args>)
  122.  
  123. " use `:OR` for organize import of current buffer
  124. command! -nargs=0 OR   :call     CocAction('runCommand', 'editor.action.organizeImport')
  125.  
  126. " Add status line support, for integration with other plugin, checkout `:h coc-status`
  127. set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
  128.  
  129. " Using CocList
  130. " Show all diagnostics
  131. nnoremap <silent> <space>a  :<C-u>CocList diagnostics<cr>
  132. " Manage extensions
  133. nnoremap <silent> <space>e  :<C-u>CocList extensions<cr>
  134. " Show commands
  135. nnoremap <silent> <space>c  :<C-u>CocList commands<cr>
  136. " Find symbol of current document
  137. nnoremap <silent> <space>o  :<C-u>CocList outline<cr>
  138. " Search workspace symbols
  139. nnoremap <silent> <space>s  :<C-u>CocList -I symbols<cr>
  140. " Do default action for next item.
  141. nnoremap <silent> <space>j  :<C-u>CocNext<CR>
  142. " Do default action for previous item.
  143. nnoremap <silent> <space>k  :<C-u>CocPrev<CR>
  144. " Resume latest coc list
  145. nnoremap <silent> <space>p  :<C-u>CocListResume<CR>
  146.  
  147. " Comments for json file
  148. autocmd FileType json syntax match Comment +\/\/.\+$+
  149.  
  150.  
  151.  
  152.  
  153. " ================================================================
  154. " # Regular Vim Settings
  155. " ================================================================
  156.  
  157. " # Settings for seoul256.vim
  158. let g:seoul256_background = 233
  159. colo seoul256
  160.  
  161. " # Settings for lightline.vim
  162. set laststatus=2
  163.  
  164.  
  165.  
  166.  
  167. " ================================================================
  168. " # Regular Vim Settings
  169. " ================================================================
  170.  
  171. set number
  172. set nowrap
  173.  
  174. " Tab configurations
  175. set tabstop=4
  176. set softtabstop=4
  177. set shiftwidth=4
  178.  
  179. " Ctrl+J to switch to normal mode
  180. inoremap <C-j> <Esc>
  181. vnoremap <C-j> <Esc>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement