hnOsmium0001

.vimrc with Ubuntu WSL

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

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×