Advertisement
Guest User

my neovim config

a guest
Oct 20th, 2019
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 10.89 KB | None | 0 0
  1. "=============== Neovim specifics ===================
  2.  
  3. let g:python3_host_prog='/usr/local/bin/python3'
  4. let g:python3_host_skip_check = 1
  5.  
  6. " =============== Plug Initialization ===============
  7.  
  8. call plug#begin('~/.local/share/nvim/site/plugged')
  9.  
  10. Plug 'fatih/vim-go', { 'do': ':GoInstallBinaries', 'for': 'go'}
  11. Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
  12. Plug 'junegunn/fzf.vim'
  13. Plug 'tomtom/tcomment_vim'
  14. Plug 'matze/vim-move'
  15. Plug 'uarun/vim-protobuf'
  16. Plug 'ntpeters/vim-better-whitespace'
  17. Plug 'ayu-theme/ayu-vim'
  18. Plug 'neoclide/coc.nvim', {'branch': 'release'}
  19. Plug 'tpope/vim-fugitive'
  20. Plug 'airblade/vim-gitgutter'
  21. call plug#end()
  22.  
  23. "============ vim-better-whitespace =================
  24.  
  25. let g:better_whitespace_enabled=1   "Enable highlighting whitespaces
  26. let g:strip_whitespace_on_save=1    "When I hit save, then strip all unnecessary white spaces
  27.  
  28. "=============== General ============================
  29. let &t_8f="\<Esc>[38;2;%lu;%lu;%lum"
  30. let &t_8b="\<Esc>[48;2;%lu;%lu;%lum"
  31.  
  32. set termguicolors
  33. let ayucolor="dark"
  34. colorscheme ayu
  35.  
  36. set completeopt-=preview        "Make this lways off because this drives me insane
  37. set completeopt+=noselect
  38. set showmode                    "Show current mode down the bottom
  39. set gcr=a:blinkon0              "Disable cursor blink
  40. set noerrorbells                "No annoying sounds on errors
  41. set novisualbell
  42. set textwidth=80               "Maximum columns to be inserted
  43. set colorcolumn=80             "Assign the vertical lign to be at a certain column position
  44. set clipboard=unnamed           "Make the same clipboard with the OS
  45. set laststatus=2
  46. set number
  47. set list                        "Display hidden characters
  48. set listchars=tab:▸\ ,eol:¬     "Use listchars like in textmate
  49. set mouse=a                     "Enable mouse support, forgive me vim father because I have sin
  50. set t_vb=
  51. set tm=500
  52. set autowrite                   "Write file when switching buffers
  53. set formatoptions=qrnj1
  54. set fileformats=unix,dos,mac
  55. set updatetime=300              "Smaller updatetime for CursorHold & CursorHoldI
  56. set bomb
  57. set binary
  58. set ffs=unix,dos,mac            "Use Unix as the standard file type
  59. let $LANG='en'                  "Avoid garbled characters in Chinese language windows OS
  60. set langmenu=en
  61. set showmatch                   "Show matching brackets when text indicator is over them
  62. set lazyredraw                  "Don't redraw while executing macros (good performance config)
  63. set magic                       "For regular expressions turn magic on
  64. set mat=2                       "How many tenths of a second to blink when matching brackets
  65. set cmdheight=2
  66. set updatetime=300
  67. set shortmess+=c
  68. set signcolumn=yes
  69. " This makes vim act like all other editors, buffers can
  70. " exist in the background without being in a window.
  71. " http://items.sjbach.com/319/configuring-vim-right
  72. set hidden
  73. " I type Wq more often than wq
  74. cmap Wq wq
  75. "cmap W w
  76. set undofile
  77. set undodir=/tmp                "Don't use xdg path use this instead
  78.  
  79. set smartindent                 "Do smart autoindenting when starting a new line
  80. set softtabstop=4               "Number of spaces that a <Tab> counts for while performing editing ops
  81. set shiftwidth=4
  82. set tabstop=4                   "Number of spaces that a <Tab> in the file counts for
  83. set expandtab                   "Use the appropiate number of spaces to insert a <Tab> in insert mode
  84.  
  85. filetype plugin on              "Enable filetype plugins
  86. filetype indent on
  87.  
  88. set lbr                         "Linebreak on 500 characters
  89. set wrap                        "Enable wrap mode
  90.  
  91. " ================ Scrolling ========================
  92.  
  93. set scrolloff=8         "Start scrolling when we're 8 lines away from margins
  94. "
  95. " ================ Search ===========================
  96.  
  97. " Always when search ignore casing for down case characters
  98. nnoremap / /\v
  99. vnoremap / /\v
  100. set ignorecase      " Ignore case when searching...
  101. set smartcase       " ...unless we type a capital
  102.  
  103. " ================ Folds ============================
  104.  
  105. set foldmethod=indent   "fold based on indent
  106. set foldnestmax=3       "deepest fold is 3 levels
  107. set nofoldenable        "dont fold by default<Plug>_
  108.  
  109. " ================ Turn Off Swap Files ==============
  110. set noswapfile
  111. set nobackup
  112. set nowritebackup
  113. set nowb
  114.  
  115. " ================ Completion =======================
  116.  
  117. set wildignore=*.o,*.obj,*~ "stuff to ignore when tab completing
  118. set wildignore+=*vim/backups*
  119. set wildignore+=*sass-cache*
  120. set wildignore+=*DS_Store*
  121. set wildignore+=vendor/rails/**
  122. set wildignore+=vendor/cache/**
  123. set wildignore+=*.gem
  124. set wildignore+=log/**
  125. set wildignore+=tmp/**
  126. set wildignore+=*.png,*.jpg,*.gif<Plug>
  127.  
  128. "================= Mapping ==========================
  129. " Change leader to a comma because the backslash is too far away
  130. " That means all \x commands turn into ,x
  131. " The mapleader has to be set before vundle starts loading all
  132. " the plugins.
  133. let mapleader=","
  134. let maplocalleader = "\\"
  135. inoremap <c-f> <c-x><c-f>
  136. vnoremap <c-/> :TComment<cr>
  137. vmap < <gv
  138. vmap > >gv
  139. let g:move_key_modifier = 'C'
  140. map <Leader>a :bprev<Return>
  141. map <Leader>s :bnext<Return>
  142. map <Leader>d :bd<Return>
  143. nnoremap <C-p> :FZF<cr>
  144. " Fast saving
  145. nmap <leader>w :w!<cr>
  146. map <C-n> :cnext<CR>
  147. map <C-m> :cprevious<CR>
  148. nmap <Leader>o :setlocal spell! spelllang=en_us<CR>
  149.  
  150. " Better vertical movement for wrapped lines
  151. nnoremap j gj
  152. nnoremap k gk
  153.  
  154. " quickly cancel search highlighting
  155. nnoremap <leader><space> :nohlsearch<cr>
  156.  
  157. " Toggle between column widths
  158. nnoremap <leader>f :call ToggleColumnWidth()<cr>
  159. let g:wide_column = 1
  160. function! ToggleColumnWidth()
  161.     if g:wide_column
  162.         set textwidth=80
  163.         set colorcolumn=80
  164.         let g:wide_column = 0
  165.     else
  166.         set textwidth=110
  167.         set colorcolumn=110
  168.         let g:wide_column = 1
  169.     endif
  170. endfunction
  171.  
  172. " ============= vim-go =============================
  173.  
  174. let g:go_fmt_command = "goimports"
  175. " metalinter
  176. let g:go_metalinter_autosave = 1
  177. let g:go_metalinter_autosave_enabled = ['vet']
  178. let g:go_metalinter_enabled = ['govet', 'errcheck']
  179. let g:go_metalinter_disabled = ['golint']
  180.  
  181. " go def
  182. let g:go_def_mode = 'godef'
  183. let g:go_asmfmt_autosave = 1
  184.  
  185. let g:go_highlight_function_arguments=1
  186. let g:go_highlight_function_calls = 1
  187. let g:go_highlight_types = 1
  188. let g:go_highlight_functions = 1
  189. let g:go_highlight_methods = 1
  190. let g:go_highlight_operators = 1
  191. let g:go_highlight_build_constraints = 1
  192. let g:go_highlight_fields = 1
  193. let g:go_highlight_extra_types = 1
  194. let g:go_highlight_format_strings = 1
  195. let g:go_highlight_generate_tags = 1
  196.  
  197. let g:go_def_mapping_enabled = 1
  198. let g:go_fmt_fail_silently = 1
  199. let g:go_term_enabled = 1
  200. let g:go_addtags_transform = "snakecase"
  201.  
  202. autocmd BufReadPost * if @% !~# '\.git[\/\\]COMMIT_EDITMSG$' && line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
  203.  
  204. "========================== coc.vim ===============================
  205.  
  206.  
  207. " Use tab for trigger completion with characters ahead and navigate.
  208. " Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin.
  209. inoremap <silent><expr> <TAB>
  210.       \ pumvisible() ? "\<C-n>" :
  211.       \ <SID>check_back_space() ? "\<TAB>" :
  212.       \ coc#refresh()
  213. inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
  214.  
  215. function! s:check_back_space() abort
  216.   let col = col('.') - 1
  217.   return !col || getline('.')[col - 1]  =~# '\s'
  218. endfunction
  219.  
  220. " Use <c-space> to trigger completion.
  221. inoremap <silent><expr> <c-space> coc#refresh()
  222.  
  223. " Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position.
  224. " Coc only does snippet and additional edit on confirm.
  225. inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
  226. " Or use `complete_info` if your vim support it, like:
  227. " inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>"
  228.  
  229. " Use `[g` and `]g` to navigate diagnostics
  230. nmap <silent> [g <Plug>(coc-diagnostic-prev)
  231. nmap <silent> ]g <Plug>(coc-diagnostic-next)
  232.  
  233. " Remap keys for gotos
  234. nmap <silent> gd <Plug>(coc-definition)
  235. nmap <silent> gy <Plug>(coc-type-definition)
  236. nmap <silent> gi <Plug>(coc-implementation)
  237. nmap <silent> gr <Plug>(coc-references)
  238.  
  239. " Use K to show documentation in preview window
  240. nnoremap <silent> K :call <SID>show_documentation()<CR>
  241.  
  242. function! s:show_documentation()
  243.   if (index(['vim','help'], &filetype) >= 0)
  244.     execute 'h '.expand('<cword>')
  245.   else
  246.     call CocAction('doHover')
  247.   endif
  248. endfunction
  249.  
  250. " Highlight symbol under cursor on CursorHold
  251. autocmd CursorHold * silent call CocActionAsync('highlight')
  252.  
  253. " Remap for rename current word
  254. nmap <leader>rn <Plug>(coc-rename)
  255.  
  256. " Remap for format selected region
  257. xmap <leader>f  <Plug>(coc-format-selected)
  258. nmap <leader>f  <Plug>(coc-format-selected)
  259.  
  260. augroup mygroup
  261.   autocmd!
  262.   " Setup formatexpr specified filetype(s).
  263.   autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
  264.   " Update signature help on jump placeholder
  265.   autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
  266. augroup end
  267.  
  268. " Remap for do codeAction of selected region, ex: `<leader>aap` for current paragraph
  269. xmap <leader>a  <Plug>(coc-codeaction-selected)
  270. nmap <leader>a  <Plug>(coc-codeaction-selected)
  271.  
  272. " Remap for do codeAction of current line
  273. nmap <leader>ac  <Plug>(coc-codeaction)
  274. " Fix autofix problem of current line
  275. nmap <leader>qf  <Plug>(coc-fix-current)
  276.  
  277. " Create mappings for function text object, requires document symbols feature of languageserver.
  278. xmap if <Plug>(coc-funcobj-i)
  279. xmap af <Plug>(coc-funcobj-a)
  280. omap if <Plug>(coc-funcobj-i)
  281. omap af <Plug>(coc-funcobj-a)
  282.  
  283. " Use <C-d> for select selections ranges, needs server support, like: coc-tsserver, coc-python
  284. nmap <silent> <C-d> <Plug>(coc-range-select)
  285. xmap <silent> <C-d> <Plug>(coc-range-select)
  286.  
  287. " Use `:Format` to format current buffer
  288. command! -nargs=0 Format :call CocAction('format')
  289.  
  290. " Use `:Fold` to fold current buffer
  291. command! -nargs=? Fold :call     CocAction('fold', <f-args>)
  292.  
  293. " use `:OR` for organize import of current buffer
  294. command! -nargs=0 OR   :call     CocAction('runCommand', 'editor.action.organizeImport')
  295.  
  296. " Add status line support, for integration with other plugin, checkout `:h coc-status`
  297. set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
  298.  
  299. " Using CocList
  300. " Show all diagnostics
  301. nnoremap <silent> <space>a  :<C-u>CocList diagnostics<cr>
  302. " Manage extensions
  303. nnoremap <silent> <space>e  :<C-u>CocList extensions<cr>
  304. " Show commands
  305. nnoremap <silent> <space>c  :<C-u>CocList commands<cr>
  306. " Find symbol of current document
  307. nnoremap <silent> <space>o  :<C-u>CocList outline<cr>
  308. " Search workspace symbols
  309. nnoremap <silent> <space>s  :<C-u>CocList -I symbols<cr>
  310. " Do default action for next item.
  311. nnoremap <silent> <space>j  :<C-u>CocNext<CR>
  312. " Do default action for previous item.
  313. nnoremap <silent> <space>k  :<C-u>CocPrev<CR>
  314. " Resume latest coc list
  315. nnoremap <silent> <space>p  :<C-u>CocListResume<CR>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement