init.vim 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815
  1. " vim-bootstrap 2021-10-06 10:50:20
  2. "*****************************************************************************
  3. "" Vim-Plug core
  4. "*****************************************************************************
  5. let vimplug_exists=expand('~/.config/nvim/autoload/plug.vim')
  6. if has('win32')&&!has('win64')
  7. let curl_exists=expand('C:\Windows\Sysnative\curl.exe')
  8. else
  9. let curl_exists=expand('curl')
  10. endif
  11. let g:vim_bootstrap_langs = "c,html,javascript,php,python"
  12. let g:vim_bootstrap_editor = "neovim" " nvim or vim
  13. let g:vim_bootstrap_theme = ""
  14. let g:vim_bootstrap_frams = ""
  15. if !filereadable(vimplug_exists)
  16. if !executable(curl_exists)
  17. echoerr "You have to install curl or first install vim-plug yourself!"
  18. execute "q!"
  19. endif
  20. echo "Installing Vim-Plug..."
  21. echo ""
  22. silent exec "!"curl_exists" -fLo " . shellescape(vimplug_exists) . " --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim"
  23. let g:not_finish_vimplug = "yes"
  24. autocmd VimEnter * PlugInstall
  25. endif
  26. " Required:
  27. call plug#begin(expand('~/.config/nvim/plugged'))
  28. "*****************************************************************************
  29. "" Plug install packages
  30. "*****************************************************************************
  31. "Doxygen
  32. Plug 'vim-scripts/DoxygenToolkit.vim'
  33. "Vue.js
  34. Plug 'posva/vim-vue'
  35. Plug 'leafOfTree/vim-vue-plugin'
  36. Plug 'scrooloose/nerdtree'
  37. Plug 'jistr/vim-nerdtree-tabs'
  38. Plug 'tpope/vim-commentary'
  39. Plug 'tpope/vim-fugitive'
  40. Plug 'vim-airline/vim-airline'
  41. Plug 'vim-airline/vim-airline-themes'
  42. Plug 'airblade/vim-gitgutter'
  43. Plug 'vim-scripts/grep.vim'
  44. Plug 'vim-scripts/CSApprox'
  45. Plug 'Raimondi/delimitMate'
  46. Plug 'majutsushi/tagbar'
  47. Plug 'dense-analysis/ale'
  48. Plug 'mikelue/vim-maven-plugin'
  49. "Plug 'Yggdroot/indentLine'
  50. Plug 'lukas-reineke/indent-blankline.nvim'
  51. Plug 'editor-bootstrap/vim-bootstrap-updater'
  52. Plug 'tpope/vim-rhubarb' " required by fugitive to :Gbrowse
  53. Plug 'dracula/vim', { 'as': 'dracula' }
  54. Plug 'neoclide/coc.nvim', {'branch': 'release'}
  55. Plug 'bitc/vim-bad-whitespace'
  56. if isdirectory('/usr/local/opt/fzf')
  57. Plug '/usr/local/opt/fzf' | Plug 'junegunn/fzf.vim'
  58. else
  59. Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --bin' }
  60. Plug 'junegunn/fzf.vim'
  61. endif
  62. let g:make = 'gmake'
  63. if exists('make')
  64. let g:make = 'make'
  65. endif
  66. Plug 'Shougo/vimproc.vim', {'do': g:make}
  67. "" Vim-Session
  68. Plug 'xolox/vim-misc'
  69. Plug 'xolox/vim-session'
  70. "" Snippets
  71. "Plug 'SirVer/ultisnips'
  72. Plug 'honza/vim-snippets'
  73. "*****************************************************************************
  74. "" Custom bundles
  75. "*****************************************************************************
  76. " c
  77. Plug 'vim-scripts/c.vim', {'for': ['c', 'cpp']}
  78. Plug 'ludwig/split-manpage.vim'
  79. " html
  80. "" HTML Bundle
  81. Plug 'hail2u/vim-css3-syntax'
  82. Plug 'gko/vim-coloresque'
  83. Plug 'tpope/vim-haml'
  84. Plug 'mattn/emmet-vim'
  85. " javascript
  86. "" Javascript Bundle
  87. Plug 'jelera/vim-javascript-syntax'
  88. " php
  89. "" PHP Bundle
  90. Plug 'phpactor/phpactor', {'for': 'php', 'do': 'composer install --no-dev -o'}
  91. Plug 'stephpy/vim-php-cs-fixer'
  92. " python
  93. "" Python Bundle
  94. Plug 'raimon49/requirements.txt.vim', {'for': 'requirements'}
  95. " color
  96. Plug 'altercation/vim-colors-solarized'
  97. " comments
  98. Plug 'preservim/nerdcommenter'
  99. "*****************************************************************************
  100. "*****************************************************************************
  101. "" Include user's extra bundle
  102. if filereadable(expand("~/.config/nvim/local_bundles.vim"))
  103. source ~/.config/nvim/local_bundles.vim
  104. endif
  105. call plug#end()
  106. " Required:
  107. filetype plugin indent on
  108. "*****************************************************************************
  109. "" Basic Setup
  110. "*****************************************************************************"
  111. "" Encoding
  112. set encoding=utf-8
  113. set fileencoding=utf-8
  114. set fileencodings=utf-8
  115. set ttyfast
  116. "" Fix backspace indent
  117. set backspace=indent,eol,start
  118. "" Tabs. May be overridden by autocmd rules
  119. set tabstop=4
  120. set softtabstop=0
  121. set shiftwidth=4
  122. set noexpandtab
  123. "" Map leader to ,
  124. let mapleader=','
  125. "" Enable hidden buffers
  126. set hidden
  127. "" Searching
  128. set hlsearch
  129. set incsearch
  130. set ignorecase
  131. set smartcase
  132. set fileformats=unix,dos,mac
  133. if exists('$SHELL')
  134. set shell=$SHELL
  135. else
  136. set shell=/bin/sh
  137. endif
  138. " session management
  139. let g:session_directory = "~/.config/nvim/session"
  140. let g:session_autoload = "no"
  141. let g:session_autosave = "no"
  142. let g:session_command_aliases = 1
  143. "*****************************************************************************
  144. "" Visual Settings
  145. "*****************************************************************************
  146. syntax on
  147. set ruler
  148. set number
  149. let no_buffers_menu=1
  150. "colorscheme solarized
  151. colorscheme dracula
  152. set mousemodel=popup
  153. set t_Co=256
  154. set guioptions=egmrti
  155. set gfn=Monospace\ 10
  156. if has("gui_running")
  157. if has("gui_mac") || has("gui_macvim")
  158. set guifont=Menlo:h12
  159. set transparency=7
  160. endif
  161. else
  162. let g:CSApprox_loaded = 1
  163. " IndentBlankLine
  164. map <silent> <F5> :IndentBlanklineToggle!<CR>
  165. lua << EOF
  166. vim.cmd [[highlight IndentBlanklineIndent1 guifg=#E06C75 gui=nocombine]]
  167. vim.cmd [[highlight IndentBlanklineIndent2 guifg=#E5C07B gui=nocombine]]
  168. vim.cmd [[highlight IndentBlanklineIndent3 guifg=#98C379 gui=nocombine]]
  169. vim.cmd [[highlight IndentBlanklineIndent4 guifg=#56B6C2 gui=nocombine]]
  170. vim.cmd [[highlight IndentBlanklineIndent5 guifg=#61AFEF gui=nocombine]]
  171. vim.cmd [[highlight IndentBlanklineIndent6 guifg=#C678DD gui=nocombine]]
  172. vim.opt.list = true
  173. vim.opt.listchars:append("space:⋅")
  174. require("indent_blankline").setup {
  175. space_char_blankline = " ",
  176. char_highlight_list = {
  177. "IndentBlanklineIndent1",
  178. "IndentBlanklineIndent2",
  179. "IndentBlanklineIndent3",
  180. "IndentBlanklineIndent4",
  181. "IndentBlanklineIndent5",
  182. "IndentBlanklineIndent6",
  183. },
  184. }
  185. EOF
  186. if $COLORTERM == 'gnome-terminal'
  187. set term=gnome-256color
  188. else
  189. if $TERM == 'xterm'
  190. set term=xterm-256color
  191. endif
  192. endif
  193. endif
  194. if &term =~ '256color'
  195. set t_ut=
  196. endif
  197. if has("termguicolors")
  198. set termguicolors
  199. endif
  200. "" Disable the blinking cursor.
  201. set gcr=a:blinkon0
  202. set scrolloff=3
  203. "" Status bar
  204. set laststatus=2
  205. "" Use modeline overrides
  206. set modeline
  207. set modelines=10
  208. set title
  209. set titleold="Terminal"
  210. set titlestring=%F
  211. set statusline=%F%m%r%h%w%=(%{&ff}/%Y)\ (line\ %l\/%L,\ col\ %c)\
  212. " Search mappings: These will make it so that going to the next one in a
  213. " search will center on the line it's found in.
  214. nnoremap n nzzzv
  215. nnoremap N Nzzzv
  216. if exists("*fugitive#statusline")
  217. set statusline+=%{fugitive#statusline()}
  218. endif
  219. " vim-airline
  220. let g:airline_theme = 'powerlineish'
  221. let g:airline#extensions#branch#enabled = 1
  222. let g:airline#extensions#ale#enabled = 1
  223. let g:airline#extensions#tabline#enabled = 1
  224. let g:airline#extensions#tagbar#enabled = 1
  225. let g:airline_skip_empty_sections = 1
  226. "*****************************************************************************
  227. "" Abbreviations
  228. "*****************************************************************************
  229. "" no one is really happy until you have this shortcuts
  230. cnoreabbrev W! w!
  231. cnoreabbrev Q! q!
  232. cnoreabbrev Qall! qall!
  233. cnoreabbrev Wq wq
  234. cnoreabbrev Wa wa
  235. cnoreabbrev wQ wq
  236. cnoreabbrev WQ wq
  237. cnoreabbrev W w
  238. cnoreabbrev Q q
  239. cnoreabbrev Qall qall
  240. "" NERDTree configuration
  241. let g:NERDTreeChDirMode=2
  242. let g:NERDTreeIgnore=['\.rbc$', '\~$', '\.pyc$', '\.db$', '\.sqlite$', '__pycache__']
  243. let g:NERDTreeSortOrder=['^__\.py$', '\/$', '*', '\.swp$', '\.bak$', '\~$']
  244. let g:NERDTreeShowBookmarks=1
  245. let g:nerdtree_tabs_focus_on_files=1
  246. let g:NERDTreeMapOpenInTabSilent = '<S-T>'
  247. let g:NERDTreeWinSize = 50
  248. set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.pyc,*.db,*.sqlite
  249. nnoremap <silent> <F2> :NERDTreeFind<CR>
  250. nnoremap <silent> <F3> :NERDTreeToggle<CR>
  251. " grep.vim
  252. nnoremap <silent> <leader>f :Rgrep<CR>
  253. let Grep_Default_Options = '-IR'
  254. let Grep_Skip_Files = '*.log *.db'
  255. let Grep_Skip_Dirs = '.git node_modules'
  256. " terminal emulation
  257. nnoremap <silent> <leader>sh :terminal<CR>
  258. "*****************************************************************************
  259. "" Commands
  260. "*****************************************************************************
  261. " remove trailing whitespaces
  262. command! FixWhitespace :%s/\s\+$//e
  263. "*****************************************************************************
  264. "" Functions
  265. "*****************************************************************************
  266. if !exists('*s:setupWrapping')
  267. function s:setupWrapping()
  268. set wrap
  269. set wm=2
  270. set textwidth=79
  271. endfunction
  272. endif
  273. "*****************************************************************************
  274. "" Autocmd Rules
  275. "*****************************************************************************
  276. "" The PC is fast enough, do syntax highlight syncing from start unless 200 lines
  277. augroup vimrc-sync-fromstart
  278. autocmd!
  279. autocmd BufEnter * :syntax sync maxlines=200
  280. augroup END
  281. "" Remember cursor position
  282. augroup vimrc-remember-cursor-position
  283. autocmd!
  284. autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
  285. augroup END
  286. "" txt
  287. augroup vimrc-wrapping
  288. autocmd!
  289. autocmd BufRead,BufNewFile *.txt call s:setupWrapping()
  290. augroup END
  291. "" make/cmake
  292. augroup vimrc-make-cmake
  293. autocmd!
  294. autocmd FileType make setlocal noexpandtab
  295. autocmd BufNewFile,BufRead CMakeLists.txt setlocal filetype=cmake
  296. augroup END
  297. "augroup disable-indentLine
  298. " autocmd!
  299. " autocmd VimEnter * :IndentBlanklineDisable!
  300. "augroup END
  301. set autoread
  302. "*****************************************************************************
  303. "" Mappings
  304. "*****************************************************************************
  305. "" Split
  306. noremap <Leader>h :<C-u>split<CR>
  307. noremap <Leader>v :<C-u>vsplit<CR>
  308. "" Git
  309. noremap <Leader>ga :Gwrite<CR>
  310. noremap <Leader>gc :Git commit --verbose<CR>
  311. noremap <Leader>gsh :Gpush<CR>
  312. noremap <Leader>gll :Gpull<CR>
  313. noremap <Leader>gs :Gstatus<CR>
  314. noremap <Leader>gb :Gblame<CR>
  315. noremap <Leader>gd :Gvdiff<CR>
  316. noremap <Leader>gr :Gremove<CR>
  317. " session management
  318. nnoremap <leader>so :OpenSession<Space>
  319. nnoremap <leader>ss :SaveSession<Space>
  320. nnoremap <leader>sd :DeleteSession<CR>
  321. nnoremap <leader>sc :CloseSession<CR>
  322. "" Tabs
  323. "nmap j gj
  324. "nmap k gk
  325. nnoremap <Tab> gt
  326. nnoremap <S-Tab> gT
  327. "nnoremap <silent> <S-t> :tabnew<CR>
  328. "" Set working directory
  329. nnoremap <leader>. :lcd %:p:h<CR>
  330. "" Opens an edit command with the path of the currently edited file filled in
  331. noremap <Leader>e :e <C-R>=expand("%:p:h") . "/" <CR>
  332. "" Opens a tab edit command with the path of the currently edited file filled
  333. noremap <Leader>te :tabe <C-R>=expand("%:p:h") . "/" <CR>
  334. "" fzf.vim
  335. set wildmode=list:longest,list:full
  336. set wildignore+=*.o,*.obj,.git,*.rbc,*.pyc,__pycache__
  337. let $FZF_DEFAULT_COMMAND = "find * -path '*/\.*' -prune -o -path 'node_modules/**' -prune -o -path 'target/**' -prune -o -path 'dist/**' -prune -o -type f -print -o -type l -print 2> /dev/null"
  338. " The Silver Searcher
  339. if executable('ag')
  340. let $FZF_DEFAULT_COMMAND = 'ag --hidden --ignore .git -g ""'
  341. set grepprg=ag\ --nogroup\ --nocolor
  342. endif
  343. " ripgrep
  344. if executable('rg')
  345. let $FZF_DEFAULT_COMMAND = 'rg --files --hidden --follow --glob "!.git/*"'
  346. set grepprg=rg\ --vimgrep
  347. command! -bang -nargs=* Find call fzf#vim#grep('rg --column --line-number --no-heading --fixed-strings --ignore-case --hidden --follow --glob "!.git/*" --color "always" '.shellescape(<q-args>).'| tr -d "\017"', 1, <bang>0)
  348. endif
  349. cnoremap <C-P> <C-R>=expand("%:p:h") . "/" <CR>
  350. nnoremap <silent> <leader>b :Buffers<CR>
  351. nnoremap <silent> <leader>e :FZF -m<CR>
  352. "Recovery commands from history through FZF
  353. nmap <leader>y :History:<CR>
  354. " snippets
  355. "let g:UltiSnipsExpandTrigger="<tab>"
  356. "let g:UltiSnipsJumpForwardTrigger="<tab>"
  357. "let g:UltiSnipsJumpBackwardTrigger="<c-b>"
  358. "let g:UltiSnipsEditSplit="vertical"
  359. " ale
  360. let g:ale_linters = {}
  361. " Tagbar
  362. nmap <silent> <F4> :TagbarToggle<CR>
  363. let g:tagbar_autofocus = 1
  364. " Disable visualbell
  365. set noerrorbells visualbell t_vb=
  366. if has('autocmd')
  367. autocmd GUIEnter * set visualbell t_vb=
  368. endif
  369. "" Copy/Paste/Cut
  370. if has('unnamedplus')
  371. set clipboard=unnamed,unnamedplus
  372. endif
  373. noremap YY "+y<CR>
  374. noremap <leader>p "+gP<CR>
  375. noremap XX "+x<CR>
  376. if has('macunix')
  377. " pbcopy for OSX copy/paste
  378. vmap <C-x> :!pbcopy<CR>
  379. vmap <C-c> :w !pbcopy<CR><CR>
  380. endif
  381. "" Buffer nav
  382. noremap <leader>z :bp<CR>
  383. noremap <leader>q :bp<CR>
  384. noremap <leader>x :bn<CR>
  385. noremap <leader>w :bn<CR>
  386. "" Close buffer
  387. noremap <leader>c :bd<CR>
  388. "" Clean search (highlight)
  389. nnoremap <silent> <leader><space> :noh<cr>
  390. "" Switching windows
  391. noremap <C-j> <C-w>j
  392. noremap <C-k> <C-w>k
  393. noremap <C-l> <C-w>l
  394. noremap <C-h> <C-w>h
  395. "" Vmap for maintain Visual Mode after shifting > and <
  396. vmap < <gv
  397. vmap > >gv
  398. "" Move visual block
  399. vnoremap J :m '>+1<CR>gv=gv
  400. vnoremap K :m '<-2<CR>gv=gv
  401. "" Open current line on GitHub
  402. nnoremap <Leader>o :.GBrowse<CR>
  403. "*****************************************************************************
  404. "" Custom configs
  405. "*****************************************************************************
  406. " c
  407. autocmd FileType c setlocal tabstop=4 shiftwidth=4 expandtab
  408. autocmd FileType cpp setlocal tabstop=4 shiftwidth=4 expandtab
  409. " html
  410. " for html files, 2 spaces
  411. autocmd Filetype html setlocal ts=2 sw=2 expandtab
  412. " javascript
  413. let g:javascript_enable_domhtmlcss = 1
  414. " vim-javascript
  415. augroup vimrc-javascript
  416. autocmd!
  417. autocmd FileType javascript setl tabstop=4|setl shiftwidth=4|setl expandtab softtabstop=4
  418. augroup END
  419. " php
  420. " Phpactor plugin
  421. " Include use statement
  422. nmap <Leader>u :call phpactor#UseAdd()<CR>
  423. " Invoke the context menu
  424. nmap <Leader>mm :call phpactor#ContextMenu()<CR>
  425. " Invoke the navigation menu
  426. nmap <Leader>nn :call phpactor#Navigate()<CR>
  427. " Goto definition of class or class member under the cursor
  428. nmap <Leader>oo :call phpactor#GotoDefinition()<CR>
  429. nmap <Leader>oh :call phpactor#GotoDefinitionHsplit()<CR>
  430. nmap <Leader>ov :call phpactor#GotoDefinitionVsplit()<CR>
  431. nmap <Leader>ot :call phpactor#GotoDefinitionTab()<CR>
  432. " Show brief information about the symbol under the cursor
  433. nmap <Leader>K :call phpactor#Hover()<CR>
  434. " Transform the classes in the current file
  435. nmap <Leader>tt :call phpactor#Transform()<CR>
  436. " Generate a new class (replacing the current file)
  437. nmap <Leader>cc :call phpactor#ClassNew()<CR>
  438. " Extract expression (normal mode)
  439. nmap <silent><Leader>ee :call phpactor#ExtractExpression(v:false)<CR>
  440. " Extract expression from selection
  441. vmap <silent><Leader>ee :<C-U>call phpactor#ExtractExpression(v:true)<CR>
  442. " Extract method from selection
  443. vmap <silent><Leader>em :<C-U>call phpactor#ExtractMethod()<CR>
  444. " python
  445. " vim-python
  446. augroup vimrc-python
  447. autocmd!
  448. autocmd FileType python setlocal expandtab shiftwidth=4 tabstop=8 colorcolumn=79
  449. \ formatoptions+=croq softtabstop=4
  450. \ cinwords=if,elif,else,for,while,try,except,finally,def,class,with
  451. augroup END
  452. " ale
  453. :call extend(g:ale_linters, {
  454. \'python': ['flake8'], })
  455. " vim-airline
  456. let g:airline#extensions#virtualenv#enabled = 1
  457. " Syntax highlight
  458. let python_highlight_all = 1
  459. "*****************************************************************************
  460. "*****************************************************************************
  461. "" Include user's local vim config
  462. if filereadable(expand("~/.config/nvim/local_init.vim"))
  463. source ~/.config/nvim/local_init.vim
  464. endif
  465. "*****************************************************************************
  466. "" Convenience variables
  467. "*****************************************************************************
  468. " vim-airline
  469. if !exists('g:airline_symbols')
  470. let g:airline_symbols = {}
  471. endif
  472. if !exists('g:airline_powerline_fonts')
  473. let g:airline#extensions#tabline#left_sep = ' '
  474. let g:airline#extensions#tabline#left_alt_sep = '|'
  475. let g:airline_left_sep = '▶'
  476. let g:airline_left_alt_sep = '»'
  477. let g:airline_right_sep = '◀'
  478. let g:airline_right_alt_sep = '«'
  479. let g:airline#extensions#branch#prefix = '⤴' "➔, ➥, ⎇
  480. let g:airline#extensions#readonly#symbol = '⊘'
  481. let g:airline#extensions#linecolumn#prefix = '¶'
  482. let g:airline#extensions#paste#symbol = 'ρ'
  483. let g:airline_symbols.linenr = '␊'
  484. let g:airline_symbols.branch = '⎇'
  485. let g:airline_symbols.paste = 'ρ'
  486. let g:airline_symbols.paste = 'Þ'
  487. let g:airline_symbols.paste = '∥'
  488. let g:airline_symbols.whitespace = 'Ξ'
  489. else
  490. let g:airline#extensions#tabline#left_sep = ''
  491. let g:airline#extensions#tabline#left_alt_sep = ''
  492. " powerline symbols
  493. let g:airline_left_sep = ''
  494. let g:airline_left_alt_sep = ''
  495. let g:airline_right_sep = ''
  496. let g:airline_right_alt_sep = ''
  497. let g:airline_symbols.branch = ''
  498. let g:airline_symbols.readonly = ''
  499. let g:airline_symbols.linenr = ''
  500. endif
  501. "coc-vim
  502. " Set internal encoding of vim, not needed on neovim, since coc.nvim using some
  503. " unicode characters in the file autoload/float.vim
  504. set encoding=utf-8
  505. " TextEdit might fail if hidden is not set.
  506. set hidden
  507. " Some servers have issues with backup files, see #649.
  508. set nobackup
  509. set nowritebackup
  510. " Give more space for displaying messages.
  511. set cmdheight=2
  512. " Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable
  513. " delays and poor user experience.
  514. set updatetime=300
  515. " Don't pass messages to |ins-completion-menu|.
  516. set shortmess+=c
  517. " Always show the signcolumn, otherwise it would shift the text each time
  518. " diagnostics appear/become resolved.
  519. if has("nvim-0.5.0") || has("patch-8.1.1564")
  520. " Recently vim can merge signcolumn and number column into one
  521. set signcolumn=number
  522. else
  523. set signcolumn=yes
  524. endif
  525. " Use tab for trigger completion with characters ahead and navigate.
  526. " NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
  527. " other plugin before putting this into your config.
  528. inoremap <silent><expr> <TAB>
  529. \ pumvisible() ? "\<C-n>" :
  530. \ <SID>check_back_space() ? "\<TAB>" :
  531. \ coc#refresh()
  532. inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
  533. function! s:check_back_space() abort
  534. let col = col('.') - 1
  535. return !col || getline('.')[col - 1] =~# '\s'
  536. endfunction
  537. " Use <c-space> to trigger completion.
  538. if has('nvim')
  539. inoremap <silent><expr> <c-space> coc#refresh()
  540. else
  541. inoremap <silent><expr> <c-@> coc#refresh()
  542. endif
  543. " Make <CR> auto-select the first completion item and notify coc.nvim to
  544. " format on enter, <cr> could be remapped by other vim plugin
  545. inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
  546. \: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
  547. " Use `[g` and `]g` to navigate diagnostics
  548. " Use `:CocDiagnostics` to get all diagnostics of current buffer in location list.
  549. nmap <silent> [g <Plug>(coc-diagnostic-prev)
  550. nmap <silent> ]g <Plug>(coc-diagnostic-next)
  551. " GoTo code navigation.
  552. nmap <silent> gd <Plug>(coc-definition)
  553. nmap <silent> gy <Plug>(coc-type-definition)
  554. nmap <silent> gi <Plug>(coc-implementation)
  555. nmap <silent> gr <Plug>(coc-references)
  556. " Use K to show documentation in preview window.
  557. nnoremap <silent> <C-K> :call <SID>show_documentation()<CR>
  558. function! s:show_documentation()
  559. if (index(['vim','help'], &filetype) >= 0)
  560. execute 'h '.expand('<cword>')
  561. elseif (coc#rpc#ready())
  562. call CocActionAsync('doHover')
  563. else
  564. execute '!' . &keywordprg . " " . expand('<cword>')
  565. endif
  566. endfunction
  567. " Highlight the symbol and its references when holding the cursor.
  568. autocmd CursorHold * silent call CocActionAsync('highlight')
  569. " Symbol renaming.
  570. nmap <leader>rn <Plug>(coc-rename)
  571. " Formatting selected code.
  572. xmap <leader>f <Plug>(coc-format-selected)
  573. nmap <leader>f <Plug>(coc-format-selected)
  574. augroup mygroup
  575. autocmd!
  576. " Setup formatexpr specified filetype(s).
  577. autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
  578. " Update signature help on jump placeholder.
  579. autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
  580. augroup end
  581. " Applying codeAction to the selected region.
  582. " Example: `<leader>aap` for current paragraph
  583. xmap <leader>a <Plug>(coc-codeaction-selected)
  584. nmap <leader>a <Plug>(coc-codeaction-selected)
  585. " Remap keys for applying codeAction to the current buffer.
  586. nmap <leader>ac <Plug>(coc-codeaction)
  587. " Apply AutoFix to problem on the current line.
  588. nmap <leader>qf <Plug>(coc-fix-current)
  589. " Map function and class text objects
  590. " NOTE: Requires 'textDocument.documentSymbol' support from the language server.
  591. xmap if <Plug>(coc-funcobj-i)
  592. omap if <Plug>(coc-funcobj-i)
  593. xmap af <Plug>(coc-funcobj-a)
  594. omap af <Plug>(coc-funcobj-a)
  595. xmap ic <Plug>(coc-classobj-i)
  596. omap ic <Plug>(coc-classobj-i)
  597. xmap ac <Plug>(coc-classobj-a)
  598. omap ac <Plug>(coc-classobj-a)
  599. " Remap <C-f> and <C-b> for scroll float windows/popups.
  600. if has('nvim-0.4.0') || has('patch-8.2.0750')
  601. nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
  602. nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
  603. inoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>"
  604. inoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>"
  605. vnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
  606. vnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
  607. endif
  608. " Use CTRL-S for selections ranges.
  609. " Requires 'textDocument/selectionRange' support of language server.
  610. nmap <silent> <C-s> <Plug>(coc-range-select)
  611. xmap <silent> <C-s> <Plug>(coc-range-select)
  612. " Add `:Format` command to format current buffer.
  613. command! -nargs=0 Format :call CocAction('format')
  614. " Add `:Fold` command to fold current buffer.
  615. command! -nargs=? Fold :call CocAction('fold', <f-args>)
  616. " Add `:OR` command for organize imports of the current buffer.
  617. command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
  618. " Add (Neo)Vim's native statusline support.
  619. " NOTE: Please see `:h coc-status` for integrations with external plugins that
  620. " provide custom statusline: lightline.vim, vim-airline.
  621. set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
  622. " Mappings for CoCList
  623. " Show all diagnostics.
  624. nnoremap <silent><nowait> <space>d :<C-u>CocList diagnostics<cr>
  625. " Manage extensions.
  626. nnoremap <silent><nowait> <space>e :<C-u>CocList extensions<cr>
  627. " Show commands.
  628. nnoremap <silent><nowait> <space>c :<C-u>CocList commands<cr>
  629. " Find symbol of current document.
  630. nnoremap <silent><nowait> <space>o :<C-u>CocList outline<cr>
  631. " Search workspace symbols.
  632. nnoremap <silent><nowait> <space>s :<C-u>CocList -I symbols<cr>
  633. " Do default action for next item.
  634. nnoremap <silent><nowait> <space>j :<C-u>CocNext<CR>
  635. " Do default action for previous item.
  636. nnoremap <silent><nowait> <space>k :<C-u>CocPrev<CR>
  637. " Resume latest coc list.
  638. nnoremap <silent><nowait> <space>p :<C-u>CocListResume<CR>
  639. " CocAction
  640. nnoremap <silent><nowait> <space>a :<C-u>CocAction<cr>
  641. " CocFix
  642. nnoremap <silent><nowait> <space>f :<C-u>CocFix<cr>
  643. " vuejs
  644. " vim vue
  645. let g:vue_disable_pre_processors=1
  646. " vim vue plugin
  647. let g:vim_vue_plugin_load_full_syntax = 1
  648. let g:vim_vue_plugin_config = {
  649. \'syntax': {
  650. \ 'template': ['html'],
  651. \ 'script': ['javascript'],
  652. \ 'style': ['css'],
  653. \},
  654. \'full_syntax': [],
  655. \'initial_indent': [],
  656. \'attribute': 0,
  657. \'keyword': 0,
  658. \'foldexpr': 0,
  659. \'debug': 0,
  660. \}