Advertisement
bal_gennady

benawad_init.vimrc

Nov 19th, 2019
1,368
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 7.27 KB | None | 0 0
  1. " Specify a directory for plugins
  2. call plug#begin('~/.vim/plugged')
  3.  
  4. Plug 'neoclide/coc.nvim', {'branch': 'release'}
  5. Plug 'scrooloose/nerdtree'
  6. "Plug 'tsony-tsonev/nerdtree-git-plugin'
  7. Plug 'Xuyuanp/nerdtree-git-plugin'
  8. Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
  9. Plug 'ryanoasis/vim-devicons'
  10. Plug 'airblade/vim-gitgutter'
  11. Plug 'ctrlpvim/ctrlp.vim' " fuzzy find files
  12. Plug 'scrooloose/nerdcommenter'
  13. "Plug 'prettier/vim-prettier', { 'do': 'yarn install' }
  14.  
  15. Plug 'christoomey/vim-tmux-navigator'
  16.  
  17. Plug 'morhetz/gruvbox'
  18.  
  19. Plug 'HerringtonDarkholme/yats.vim' " TS Syntax
  20.  
  21. " Initialize plugin system
  22. call plug#end()
  23.  
  24. inoremap jk <ESC>
  25. nmap <C-n> :NERDTreeToggle<CR>
  26. vmap ++ <plug>NERDCommenterToggle
  27. nmap ++ <plug>NERDCommenterToggle
  28.  
  29. " open NERDTree automatically
  30. "autocmd StdinReadPre * let s:std_in=1
  31. "autocmd VimEnter * NERDTree
  32.  
  33. let g:NERDTreeGitStatusWithFlags = 1
  34. "let g:WebDevIconsUnicodeDecorateFolderNodes = 1
  35. "let g:NERDTreeGitStatusNodeColorization = 1
  36. "let g:NERDTreeColorMapCustom = {
  37.     "\ "Staged"    : "#0ee375",  
  38.     "\ "Modified"  : "#d9bf91",  
  39.     "\ "Renamed"   : "#51C9FC",  
  40.     "\ "Untracked" : "#FCE77C",  
  41.     "\ "Unmerged"  : "#FC51E6",  
  42.     "\ "Dirty"     : "#FFBD61",  
  43.     "\ "Clean"     : "#87939A",  
  44.     "\ "Ignored"   : "#808080"  
  45.     "\ }                        
  46.  
  47.  
  48. let g:NERDTreeIgnore = ['^node_modules$']
  49.  
  50. " vim-prettier
  51. "let g:prettier#quickfix_enabled = 0
  52. "let g:prettier#quickfix_auto_focus = 0
  53. " prettier command for coc
  54. command! -nargs=0 Prettier :CocCommand prettier.formatFile
  55. " run prettier on save
  56. "let g:prettier#autoformat = 0
  57. "autocmd BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.md,*.vue,*.yaml,*.html PrettierAsync
  58.  
  59.  
  60. " ctrlp
  61. let g:ctrlp_user_command = ['.git/', 'git --git-dir=%s/.git ls-files -oc --exclude-standard']
  62.  
  63. " j/k will move virtual lines (lines that wrap)
  64. noremap <silent> <expr> j (v:count == 0 ? 'gj' : 'j')
  65. noremap <silent> <expr> k (v:count == 0 ? 'gk' : 'k')
  66.  
  67. set relativenumber
  68.  
  69. set smarttab
  70. set cindent
  71. set tabstop=2
  72. set shiftwidth=2
  73. " always uses spaces instead of tab characters
  74. set expandtab
  75.  
  76. colorscheme gruvbox
  77.  
  78. " sync open file with NERDTree
  79. " " Check if NERDTree is open or active
  80. function! IsNERDTreeOpen()        
  81.   return exists("t:NERDTreeBufName") && (bufwinnr(t:NERDTreeBufName) != -1)
  82. endfunction
  83.  
  84. " Call NERDTreeFind iff NERDTree is active, current window contains a modifiable
  85. " file, and we're not in vimdiff
  86. function! SyncTree()
  87.   if &modifiable && IsNERDTreeOpen() && strlen(expand('%')) > 0 && !&diff
  88.     NERDTreeFind
  89.     wincmd p
  90.   endif
  91. endfunction
  92.  
  93. " Highlight currently open buffer in NERDTree
  94. autocmd BufEnter * call SyncTree()
  95.  
  96. " coc config
  97. let g:coc_global_extensions = [
  98.   \ 'coc-snippets',
  99.   \ 'coc-pairs',
  100.   \ 'coc-tsserver',
  101.   \ 'coc-eslint',
  102.   \ 'coc-prettier',
  103.   \ 'coc-json',
  104.   \ ]
  105. " from readme
  106. " if hidden is not set, TextEdit might fail.
  107. set hidden " Some servers have issues with backup files, see #649 set nobackup set nowritebackup " Better display for messages set cmdheight=2 " You will have bad experience for diagnostic messages when it's default 4000.
  108. set updatetime=300
  109.  
  110. " don't give |ins-completion-menu| messages.
  111. set shortmess+=c
  112.  
  113. " always show signcolumns
  114. set signcolumn=yes
  115.  
  116. " Use tab for trigger completion with characters ahead and navigate.
  117. " Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin.
  118. inoremap <silent><expr> <TAB>
  119.       \ pumvisible() ? "\<C-n>" :
  120.       \ <SID>check_back_space() ? "\<TAB>" :
  121.       \ coc#refresh()
  122. inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
  123.  
  124. function! s:check_back_space() abort
  125.   let col = col('.') - 1
  126.   return !col || getline('.')[col - 1]  =~# '\s'
  127. endfunction
  128.  
  129. " Use <c-space> to trigger completion.
  130. inoremap <silent><expr> <c-space> coc#refresh()
  131.  
  132. " Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position.
  133. " Coc only does snippet and additional edit on confirm.
  134. inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
  135. " Or use `complete_info` if your vim support it, like:
  136. " inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>"
  137.  
  138. " Use `[g` and `]g` to navigate diagnostics
  139. nmap <silent> [g <Plug>(coc-diagnostic-prev)
  140. nmap <silent> ]g <Plug>(coc-diagnostic-next)
  141.  
  142. " Remap keys for gotos
  143. nmap <silent> gd <Plug>(coc-definition)
  144. nmap <silent> gy <Plug>(coc-type-definition)
  145. nmap <silent> gi <Plug>(coc-implementation)
  146. nmap <silent> gr <Plug>(coc-references)
  147.  
  148. " Use K to show documentation in preview window
  149. nnoremap <silent> K :call <SID>show_documentation()<CR>
  150.  
  151. function! s:show_documentation()
  152.   if (index(['vim','help'], &filetype) >= 0)
  153.     execute 'h '.expand('<cword>')
  154.   else
  155.     call CocAction('doHover')
  156.   endif
  157. endfunction
  158.  
  159. " Highlight symbol under cursor on CursorHold
  160. autocmd CursorHold * silent call CocActionAsync('highlight')
  161.  
  162. " Remap for rename current word
  163. nmap <F2> <Plug>(coc-rename)
  164.  
  165. " Remap for format selected region
  166. xmap <leader>f  <Plug>(coc-format-selected)
  167. nmap <leader>f  <Plug>(coc-format-selected)
  168.  
  169. augroup mygroup
  170.   autocmd!
  171.   " Setup formatexpr specified filetype(s).
  172.   autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
  173.   " Update signature help on jump placeholder
  174.   autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
  175. augroup end
  176.  
  177. " Remap for do codeAction of selected region, ex: `<leader>aap` for current paragraph
  178. xmap <leader>a  <Plug>(coc-codeaction-selected)
  179. nmap <leader>a  <Plug>(coc-codeaction-selected)
  180.  
  181. " Remap for do codeAction of current line
  182. nmap <leader>ac  <Plug>(coc-codeaction)
  183. " Fix autofix problem of current line
  184. nmap <leader>qf  <Plug>(coc-fix-current)
  185.  
  186. " Create mappings for function text object, requires document symbols feature of languageserver.
  187. xmap if <Plug>(coc-funcobj-i)
  188. xmap af <Plug>(coc-funcobj-a)
  189. omap if <Plug>(coc-funcobj-i)
  190. omap af <Plug>(coc-funcobj-a)
  191.  
  192. " Use <C-d> for select selections ranges, needs server support, like: coc-tsserver, coc-python
  193. nmap <silent> <C-d> <Plug>(coc-range-select)
  194. xmap <silent> <C-d> <Plug>(coc-range-select)
  195.  
  196. " Use `:Format` to format current buffer
  197. command! -nargs=0 Format :call CocAction('format')
  198.  
  199. " Use `:Fold` to fold current buffer
  200. command! -nargs=? Fold :call     CocAction('fold', <f-args>)
  201.  
  202. " use `:OR` for organize import of current buffer
  203. command! -nargs=0 OR   :call     CocAction('runCommand', 'editor.action.organizeImport')
  204.  
  205. " Add status line support, for integration with other plugin, checkout `:h coc-status`
  206. set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
  207.  
  208. " Using CocList
  209. " Show all diagnostics
  210. nnoremap <silent> <space>a  :<C-u>CocList diagnostics<cr>
  211. " Manage extensions
  212. nnoremap <silent> <space>e  :<C-u>CocList extensions<cr>
  213. " Show commands
  214. nnoremap <silent> <space>c  :<C-u>CocList commands<cr>
  215. " Find symbol of current document
  216. nnoremap <silent> <space>o  :<C-u>CocList outline<cr>
  217. " Search workspace symbols
  218. nnoremap <silent> <space>s  :<C-u>CocList -I symbols<cr>
  219. " Do default action for next item.
  220. nnoremap <silent> <space>j  :<C-u>CocNext<CR>
  221. " Do default action for previous item.
  222. nnoremap <silent> <space>k  :<C-u>CocPrev<CR>
  223. " Resume latest coc list
  224. nnoremap <silent> <space>p  :<C-u>CocListResume<CR>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement