.vimrc (17231B)
1 " vim:fdm=marker:fdl=0 2 3 " vim-plug {{{ 4 5 " Install vim-plug without my interference 6 if has('nvim') 7 if empty(glob('~/.vim/autoload/plug.vim')) 8 silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs 9 \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim 10 autocmd! 11 autocmd VimEnter * PlugInstall 12 endif 13 14 endif 15 16 " }}} 17 " Plugins {{{ 18 19 " Specify plugin directory 20 call plug#begin('~/.vim/plugged') 21 22 Plug 'airblade/vim-gitgutter' 23 Plug 'alvan/vim-closetag' 24 Plug 'itchyny/calendar.vim' 25 Plug 'jparise/vim-graphql' 26 Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } 27 Plug 'junegunn/fzf.vim' 28 Plug 'junegunn/vim-easy-align' 29 Plug 'morhetz/gruvbox' 30 Plug 'qpkorr/vim-bufkill' 31 Plug 'ryym/vim-riot' 32 Plug 'scrooloose/nerdtree' 33 Plug 'sheerun/vim-polyglot' 34 " Plug 'ternjs/tern_for_vim', { 'do': 'npm install' } 35 Plug 'tpope/vim-commentary' 36 Plug 'tpope/vim-fugitive' 37 Plug 'tpope/vim-eunuch' 38 Plug 'vim-airline/vim-airline' 39 Plug 'vim-airline/vim-airline-themes' 40 " Plug 'w0rp/ale' 41 Plug 'sQVe/sort.nvim' 42 43 Plug 'neoclide/coc.nvim', {'branch': 'master', 'do': 'npm ci'} 44 Plug 'neoclide/coc.nvim', {'branch': 'master', 'do': 'npm ci'} 45 46 " if has('nvim') 47 " Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } 48 " else 49 " Plug 'Shougo/deoplete.nvim' 50 " Plug 'roxma/nvim-yarp' 51 " Plug 'roxma/vim-hug-neovim-rpc' 52 " endif 53 54 " " PHP-specific 55 " Plug 'StanAngeloff/php.vim', {'for': 'php'} 56 " Plug 'padawan-php/deoplete-padawan', { 'do': 'composer install' } 57 58 " " JS-specific 59 " Plug 'carlitux/deoplete-ternjs' 60 61 62 " Initialize plugin system 63 call plug#end() 64 65 " }}} 66 " Basics {{{ 67 set nocompatible " be iMproved, required 68 filetype off " required 69 let mapleader = "\<space>" " leader is space 70 71 72 set smarttab " Smarter tabs 73 set tabstop=2 " Tabs = 2 columns 74 set shiftwidth=0 " 75 set shiftround " 76 set expandtab " soft tabs 77 set encoding=utf-8 " enable unicode support 78 let g:editorconfig = 1 79 80 set scrolloff=8 " keep 8 lines above/below cursor 81 set sidescroll=1 " enable horizontal scoll 82 set sidescrolloff=15 " keep 15 columns before/after cursor 83 84 set switchbuf=usetab " search in buffers before opening window 85 set hidden " hide buffers instead of asking to save them 86 87 set noerrorbells " disable annoying beeps 88 set visualbell " bell = blink 89 90 set wildmenu " visual command autocomplete 91 set wildmode=longest,full " autocomplete as much as you can 92 93 set wrap linebreak " enable line wrapping 94 set showbreak=" " " show by indent 95 set list " show whitespace 96 set listchars=nbsp:⦸ " CIRCLED REVERSE SOLIDUS (U+29B8, UTF-8: E2 A6 B8) 97 set listchars+=tab:▷┅ " WHITE RIGHT-POINTING TRIANGLE (U+25B7, UTF-8: E2 96 B7) 98 " + BOX DRAWINGS HEAVY TRIPLE DASH HORIZONTAL (U+2505, UTF-8: E2 94 85) 99 set listchars+=extends:» " RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK (U+00BB, UTF-8: C2 BB) 100 set listchars+=precedes:« " LEFT-POINTING DOUBLE ANGLE QUOTATION MARK (U+00AB, UTF-8: C2 AB) 101 set listchars+=trail:• " BULLET (U+2022, UTF-8: E2 80 A2) 102 103 set cursorline " highlight current line 104 set number " show line numbers 105 set ruler " show the cursor position at all times 106 set showcmd " display incomplete commands 107 set cmdheight=1 " command box = 1 row 108 set showmatch " highlight matching [{()}] 109 110 set incsearch " incremental searching 111 set ignorecase " ignore case during search 112 set smartcase " don't ignore capitals in search 113 114 " auto-center on matched string 115 nnoremap n nzz 116 nnoremap N Nzz 117 118 " move to beginning/end of line 119 nnoremap B ^ 120 nnoremap E $ 121 122 " $/^ doesn't do anything 123 nnoremap $ <nop> 124 nnoremap ^ <nop> 125 126 set iskeyword+=- " Use dash as word separator 127 128 set autoread " reload unchanged files automatically 129 set fileformats+=mac " support all kind of EOLs by default 130 131 " Y yanks from cursor to EOL as expected 132 nnoremap Y y$ 133 134 " allow backspacing over everything in insert mode 135 set backspace=indent,eol,start 136 137 " in many terminal emulators the mouse works just fine 138 if has('mouse') 139 set mouse=a 140 endif 141 142 " in makefiles, don't expand tabs to spaces, since actual tab characters are 143 " needed, and have indentation at 8 chars to be sure that all indents are tabs 144 " (despite the mappings later): 145 autocmd FileType make set noexpandtab shiftwidth=2 softtabstop=0 146 147 " }}} 148 " Colors {{{ 149 150 set bg=dark " dark mode 151 set termguicolors " use colors instead of styles 152 syntax enable " enable syntax highlighting 153 colorscheme gruvbox " nice theme 154 155 " }}} 156 " Custom keybindings {{{ 157 nnoremap <leader>c :nohlsearch<cr> 158 nnoremap <leader>s :Ag<cr> 159 nnoremap <leader>o :Files<cr> 160 nnoremap <silent> <leader><enter> :Buffers<cr> 161 nnoremap <tab> :bnext<cr> 162 nnoremap <s-tab> :bprevious<cr> 163 nnoremap <c-w> :BD<cr> 164 nnoremap <c-n> :NERDTreeToggle<cr> 165 nnoremap <c-h> <c-w><c-h> 166 nnoremap <c-j> <c-w><c-j> 167 nnoremap <c-k> <c-w><c-k> 168 nnoremap <c-l> <c-w><c-l> 169 " }}} 170 " X11 Clipboard support {{{ 171 172 " Copy to clipboard 173 vnoremap <leader>y "+y 174 nnoremap <leader>Y "+yg_ 175 nnoremap <leader>y "+y 176 177 " Paste from clipboard 178 nnoremap <leader>p "+p 179 nnoremap <leader>P "+P 180 vnoremap <leader>p "+p 181 vnoremap <leader>P "+P 182 183 " }}} 184 " Airline {{{ 185 let g:airline#extensions#tabline#enabled = 1 186 let g:airline_powerline_fonts = 1 187 let g:airline_theme='gruvbox' 188 set laststatus=2 189 " }}} 190 " fzf {{{ 191 let g:fzf_files_options = 192 \ '--preview "(highlight -O ansi {} || cat {}) 2> /dev/null | head -'.&lines.'"' 193 let g:fzf_buffers_jump = 1 194 let g:fzf_commits_log_options = '--graph --color=always --format="%C(auto)%h%d %s %C(black)%C(bold)%cr"' 195 let g:fzf_tags_command = 'ctags -R' 196 let g:fzf_commands_expext = 'alt-enter,ctrl-x' 197 " }}} 198 " NERDTree {{{ 199 200 " Highlighting of nerd dev icons and filenames in nerd tree 201 let g:NERDTreeFileExtensionsHighlightFullName = 1 202 let g:NERDTreeExactMatchHighlightFullName = 1 203 let g:NERDTreePatternMatchHighlightFullName = 1 204 " }}} 205 " ALE {{{ 206 207 " " Don't restrict JSX syntax highlighting to .jsx files 208 " let g:jsx_ext_required = 0 209 " 210 " " Enable completion where available 211 " let g:ale_sign_error = '✘' 212 " let g:ale_sign_warning = '•' 213 " let g:ale_sign_column_always = 1 214 " 215 " " What programs handle what 216 " let g:ale_fixers = {} 217 " let g:ale_fixers['javascript'] = ['eslint'] 218 " let g:ale_fixers['typescript'] = ['eslint'] 219 " let g:ale_fixers['vue'] = ['eslint'] 220 " let g:ale_fixers['scss'] = ['stylelint'] 221 " 222 " " Automagically fix 223 " let g:ale_open_list= 0 224 " let g:ale_fix_on_save = 1 225 " 226 " " Don't run every keystroke 227 " let g:ale_lint_on_insert_leave = 1 228 " let g:ale_lint_on_text_changed = 'never' 229 " let g:ale_lint_on_enter = 0 230 231 " }}} 232 " CoC {{{ 233 234 let g:coc_global_extensions = [ 235 \ 'coc-clangd', 236 \ 'coc-css', 237 \ 'coc-docker', 238 \ 'coc-eslint', 239 \ 'coc-gitignore', 240 \ 'coc-html', 241 \ 'coc-json', 242 \ 'coc-sh', 243 \ 'coc-tsserver', 244 \ 'coc-vetur', 245 \ 'coc-yaml' 246 \ ] 247 248 " Having longer updatetime (default is 4000 ms = 4s) leads to noticeable 249 " delays and poor user experience 250 set updatetime=300 251 252 " Always show the signcolumn, otherwise it would shift the text each time 253 " diagnostics appear/become resolved 254 set signcolumn=yes 255 256 " Use tab for trigger completion with characters ahead and navigate 257 " NOTE: There's always complete item selected by default, you may want to enable 258 " no select by `"suggest.noselect": true` in your configuration file 259 " NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by 260 " other plugin before putting this into your config 261 inoremap <silent><expr> <TAB> 262 \ coc#pum#visible() ? coc#pum#next(1) : 263 \ CheckBackspace() ? "\<Tab>" : 264 \ coc#refresh() 265 inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>" 266 267 " Make <CR> to accept selected completion item or notify coc.nvim to format 268 " <C-g>u breaks current undo, please make your own choice 269 inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm() 270 \: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>" 271 272 function! CheckBackspace() abort 273 let col = col('.') - 1 274 return !col || getline('.')[col - 1] =~# '\s' 275 endfunction 276 277 " Use <c-space> to trigger completion 278 if has('nvim') 279 inoremap <silent><expr> <c-space> coc#refresh() 280 else 281 inoremap <silent><expr> <c-@> coc#refresh() 282 endif 283 284 " Use `[g` and `]g` to navigate diagnostics 285 " Use `:CocDiagnostics` to get all diagnostics of current buffer in location list 286 nmap <silent> [g <Plug>(coc-diagnostic-prev) 287 nmap <silent> ]g <Plug>(coc-diagnostic-next) 288 289 " GoTo code navigation 290 nmap <silent> gd <Plug>(coc-definition) 291 nmap <silent> gy <Plug>(coc-type-definition) 292 nmap <silent> gi <Plug>(coc-implementation) 293 nmap <silent> gr <Plug>(coc-references) 294 295 " Use K to show documentation in preview window 296 nnoremap <silent> K :call ShowDocumentation()<CR> 297 298 function! ShowDocumentation() 299 if CocAction('hasProvider', 'hover') 300 call CocActionAsync('doHover') 301 else 302 call feedkeys('K', 'in') 303 endif 304 endfunction 305 306 " Highlight the symbol and its references when holding the cursor 307 autocmd CursorHold * silent call CocActionAsync('highlight') 308 309 " Symbol renaming 310 nmap <leader>rn <Plug>(coc-rename) 311 312 " Formatting selected code 313 xmap <leader>f <Plug>(coc-format-selected) 314 nmap <leader>f <Plug>(coc-format-selected) 315 316 augroup mygroup 317 autocmd! 318 " Setup formatexpr specified filetype(s) 319 autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') 320 " Update signature help on jump placeholder 321 autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') 322 augroup end 323 324 " Applying code actions to the selected code block 325 " Example: `<leader>aap` for current paragraph 326 xmap <leader>a <Plug>(coc-codeaction-selected) 327 nmap <leader>a <Plug>(coc-codeaction-selected) 328 329 " Remap keys for applying code actions at the cursor position 330 nmap <leader>ac <Plug>(coc-codeaction-cursor) 331 " Remap keys for apply code actions affect whole buffer 332 nmap <leader>as <Plug>(coc-codeaction-source) 333 " Apply the most preferred quickfix action to fix diagnostic on the current line 334 nmap <leader>qf <Plug>(coc-fix-current) 335 336 " Remap keys for applying refactor code actions 337 nmap <silent> <leader>re <Plug>(coc-codeaction-refactor) 338 xmap <silent> <leader>r <Plug>(coc-codeaction-refactor-selected) 339 nmap <silent> <leader>r <Plug>(coc-codeaction-refactor-selected) 340 341 " Run the Code Lens action on the current line 342 nmap <leader>cl <Plug>(coc-codelens-action) 343 344 " Map function and class text objects 345 " NOTE: Requires 'textDocument.documentSymbol' support from the language server 346 xmap if <Plug>(coc-funcobj-i) 347 omap if <Plug>(coc-funcobj-i) 348 xmap af <Plug>(coc-funcobj-a) 349 omap af <Plug>(coc-funcobj-a) 350 xmap ic <Plug>(coc-classobj-i) 351 omap ic <Plug>(coc-classobj-i) 352 xmap ac <Plug>(coc-classobj-a) 353 omap ac <Plug>(coc-classobj-a) 354 355 " Remap <C-f> and <C-b> to scroll float windows/popups 356 if has('nvim-0.4.0') || has('patch-8.2.0750') 357 nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>" 358 nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>" 359 inoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>" 360 inoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>" 361 vnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>" 362 vnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>" 363 endif 364 365 " Use CTRL-S for selections ranges 366 " Requires 'textDocument/selectionRange' support of language server 367 nmap <silent> <C-s> <Plug>(coc-range-select) 368 xmap <silent> <C-s> <Plug>(coc-range-select) 369 370 " Add `:Format` command to format current buffer 371 command! -nargs=0 Format :call CocActionAsync('format') 372 373 " Add `:Fold` command to fold current buffer 374 command! -nargs=? Fold :call CocAction('fold', <f-args>) 375 376 " Add `:OR` command for organize imports of the current buffer 377 command! -nargs=0 OR :call CocActionAsync('runCommand', 'editor.action.organizeImport') 378 379 " Add (Neo)Vim's native statusline support 380 " NOTE: Please see `:h coc-status` for integrations with external plugins that 381 " provide custom statusline: lightline.vim, vim-airline 382 set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} 383 384 " " Mappings for CoCList 385 " " Show all diagnostics 386 " nnoremap <silent><nowait> <space>a :<C-u>CocList diagnostics<cr> 387 " " Manage extensions 388 " nnoremap <silent><nowait> <space>e :<C-u>CocList extensions<cr> 389 " " Show commands 390 " nnoremap <silent><nowait> <space>c :<C-u>CocList commands<cr> 391 " " Find symbol of current document 392 " nnoremap <silent><nowait> <space>o :<C-u>CocList outline<cr> 393 " " Search workspace symbols 394 " nnoremap <silent><nowait> <space>s :<C-u>CocList -I symbols<cr> 395 " " Do default action for next item 396 " nnoremap <silent><nowait> <space>j :<C-u>CocNext<CR> 397 " " Do default action for previous item 398 " nnoremap <silent><nowait> <space>k :<C-u>CocPrev<CR> 399 " " Resume latest coc list 400 " nnoremap <silent><nowait> <space>p :<C-u>CocListResume<CR> 401 402 " }}} 403 " Deoplete {{{ 404 405 "" Basics 406 "call deoplete#enable() 407 "" let g:deoplete#enable_at_startup = 1 408 "" call deoplete#custom#option('auto_complete_delay', 0) 409 "let g:echodoc_enable_at_startup = 1 410 "set splitbelow 411 "set completeopt+=menuone,noinsert,noselect 412 "autocmd CompleteDone * pclose 413 414 "" Define basic sources 415 "function! Multiple_cursors_before() 416 " let b:deoplete_disable_auto_complete=2 417 "endfunction 418 "function! Multiple_cursors_after() 419 " let b:deoplete_disable_auto_complete=0 420 "endfunction 421 "call deoplete#custom#option('enable_buffer_path', 1) 422 "call deoplete#custom#source('buffer', 'mark', 'ℬ') 423 "call deoplete#custom#source('tern', 'mark', '') 424 "call deoplete#custom#source('padawan', 'mark', "\ue608") 425 "call deoplete#custom#source('omni', 'mark', '⌾') 426 "call deoplete#custom#source('file', 'mark', '') 427 "" call deoplete#custom#source('jedi', 'mark', '') 428 "call deoplete#custom#source('neosnippet', 'mark', '') 429 "call deoplete#custom#source('LanguageClient', 'mark', '') 430 "call deoplete#custom#source('typescript', 'rank', 630) 431 "" call deoplete#custom#source('_', 'matchers', ['matcher_cpsm']) 432 "" call deoplete#custom#source('_', 'sorters', []) 433 "let g:deoplete#omni_patterns = { 434 " \ 'html': '', 435 " \ 'css': '', 436 " \ 'scss': '' 437 " \} 438 "function! Preview_func() 439 " if &pvw 440 " setlocal nonumber norelativenumber 441 " endif 442 "endfunction 443 "autocmd WinEnter * call Preview_func() 444 "call deoplete#custom#option('ignore_sources', {'_': ['around', 'buffer' ]}) 445 446 "" Whether to include the types of the completions in the result data. Default: 0 447 "let g:deoplete#sources#ternjs#types = 1 448 449 "" Whether to include the distance (in scopes for variables, in prototypes for 450 "" properties) between the completions and the origin position in the result 451 "" data. Default: 0 452 "let g:deoplete#sources#ternjs#depths = 1 453 454 "" Whether to include documentation strings (if found) in the result data. 455 "" Default: 0 456 "let g:deoplete#sources#ternjs#docs = 1 457 458 "" When on, only completions that match the current word at the given point will 459 "" be returned. Turn this off to get all results, so that you can filter on the 460 "" client side. Default: 1 461 "let g:deoplete#sources#ternjs#filter = 0 462 463 "" Whether to use a case-insensitive compare between the current word and 464 "" potential completions. Default 0 465 "let g:deoplete#sources#ternjs#case_insensitive = 1 466 467 "" When completing a property and no completions are found, Tern will use some 468 "" heuristics to try and return some properties anyway. Set this to 0 to 469 "" turn that off. Default: 1 470 "let g:deoplete#sources#ternjs#guess = 0 471 472 "" Determines whether the result set will be sorted. Default: 1 473 "let g:deoplete#sources#ternjs#sort = 1 474 475 "" When disabled, only the text before the given position is considered part of 476 "" the word. When enabled (the default), the whole variable name that the cursor 477 "" is on will be included. Default: 1 478 "let g:deoplete#sources#ternjs#expand_word_forward = 0 479 480 "" Whether to ignore the properties of Object.prototype unless they have been 481 "" spelled out by at least two characters. Default: 1 482 "let g:deoplete#sources#ternjs#omit_object_prototype = 0 483 484 "" Whether to include JavaScript keywords when completing something that is not 485 "" a property. Default: 0 486 "let g:deoplete#sources#ternjs#include_keywords = 1 487 488 "" If completions should be returned when inside a literal. Default: 1 489 "let g:deoplete#sources#ternjs#in_literal = 0 490 491 492 ""Add extra filetypes 493 "let g:deoplete#sources#ternjs#filetypes = [ 494 " \ 'tsx', 495 " \ 'tavascript.tsx', 496 " \ 'jsx', 497 " \ 'javascript.jsx', 498 " \ 'vue', 499 " \ '...' 500 " \ ] 501 502 "" }}} 503 " Providers {{{ 504 let g:loaded_ruby_provider = 0 505 let g:loaded_perl_provider = 0 506 " }}} 507 " Calendar {{{ 508 let g:calendar_google_calendar = 1 509 let g:calendar_first_day = "Monday" 510 " }}} 511 " EasyAlign {{{ 512 513 " Start interactive EasyAlign in visual mode (e.g. vipga) 514 xmap ga <Plug>(EasyAlign) 515 516 " Start interactive EasyAlgin for a motion/text object (e.g. gaip) 517 nmap ga <Plug>(EasyAlign) 518 519 " }}} 520 " Syntax detection {{{ 521 au BufNewFile,BufRead,BufReadPost *.hbs set syntax=handlebars 522 " }}} 523 " Sort config {{{ 524 nnoremap <silent> go <Cmd>Sort<CR> 525 vnoremap <silent> go <Esc><Cmd>Sort<CR> 526 " }}}