Update vim config

master
Hektor Misplon 2020-02-17 16:05:51 +00:00
parent 2000dcea1c
commit fc48847ecb
1 changed files with 134 additions and 24 deletions

158
.vimrc
View File

@ -1,28 +1,52 @@
"
" General config " General config
" ______________________________ " ______________________________
"
set encoding=utf-8 set encoding=utf-8
set laststatus=2 set hidden
set ttyfast
set updatetime=300
set timeout timeoutlen=1000 ttimeoutlen=50
set undolevels=500
set history=500
set shortmess+=c
set signcolumn=yes
set nowrap set nowrap
set smarttab set smarttab
set backspace=indent,eol,start set signcolumn=yes
set ttyfast
set timeout timeoutlen=1000 ttimeoutlen=50
set clipboard=unnamed "use p to paste clipboard set clipboard=unnamed "use p to paste clipboard
set history=1000
set undolevels=1000 set backspace=indent,eol,start
set tabstop=2 softtabstop=2 shiftwidth=2 expandtab smarttab autoindent
set ignorecase smartcase incsearch hlsearch
set emoji
" no backups
set nocursorcolumn
set nocursorline
set scrolljump=5
set lazyredraw
set synmaxcol=180
set nobackup set nobackup
set nowritebackup set nowritebackup
set noswapfile set noswapfile
set viminfo='20,\"100 "max 100 lines in registers set viminfo='20,\"100 "max 100 lines in registers
set visualbell
set noerrorbells
set nomodeline
set cmdheight=2
" sudo save
command! W execute 'w !sudo tee % > /dev/null' <bar> edit!
"
" Filetypes
" ______________________________
filetype plugin indent on
"
" Keybindings " Keybindings
" ______________________________ " ______________________________
"
" no arrow keys
map <Up> <NOP> map <Up> <NOP>
map <Down> <NOP> map <Down> <NOP>
map <Left> <NOP> map <Left> <NOP>
@ -38,26 +62,113 @@ inoremap jk <Esc>
" quick help " quick help
:ca htab :tab h :ca htab :tab h
" 2x scrolling " coc
nnoremap <C-e> 2<C-e> inoremap <silent><expr> <TAB>
nnoremap <C-y> 2<C-y> \ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
inoremap <silent><expr> <c-space> coc#refresh()
if has('patch8.1.1068')
inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>"
else
imap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
endif
nmap <silent> [g <Plug>(coc-diagnostic-prev)
nmap <silent> ]g <Plug>(coc-diagnostic-next)
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
nnoremap <silent> K :call <SID>show_documentation()<CR>
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
else
call CocAction('doHover')
endif
endfunction
autocmd CursorHold * silent call CocActionAsync('highlight')
nmap <leader>rn <Plug>(coc-rename)
xmap <leader>f <Plug>(coc-format-selected)
nmap <leader>f <Plug>(coc-format-selected)
augroup mygroup
autocmd!
autocmd FileType typescript, json setl formatexpr=CocAction('formatSelected')
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
augroup end
xmap <leader>a <Plug>(coc-codeaction-selected)
nmap <leader>a <Plug>(coc-codeaction-selected)
nmap <leader>ac <Plug>(coc-codeaction)
nmap <leader>qf <Plug>(coc-fix-current)
xmap if <Plug>(coc-funcobj-i)
xmap af <Plug>(coc-funcobj-a)
omap if <Plug>(coc-funcobj-i)
omap af <Plug>(coc-funcobj-a)
nmap <silent> <TAB> <Plug>(coc-range-select)
xmap <silent> <TAB> <Plug>(coc-range-select)
command! -nargs=0 Format :call CocAction('format')
command! -nargs=? Fold :call CocAction('fold', <f-args>)
command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
nnoremap <silent> <space>a :<C-u>CocList diagnostics<cr>
nnoremap <silent> <space>e :<C-u>CocList extensions<cr>
nnoremap <silent> <space>c :<C-u>CocList commands<cr>
nnoremap <silent> <space>o :<C-u>CocList outline<cr>
nnoremap <silent> <space>s :<C-u>CocList -I symbols<cr>
nnoremap <silent> <space>j :<C-u>CocNext<CR>
nnoremap <silent> <space>k :<C-u>CocPrev<CR>
nnoremap <silent> <space>p :<C-u>CocListResume<CR>
let g:coc_global_extensions = [
\'coc-css',
\'coc-eslint',
\'coc-html',
\'coc-json',
\'coc-prettier',
\'coc-svelte',
\'coc-tsserver'
\]
command! -nargs=0 Prettier :CocCommand prettier.formatFile
"
" Plugins " Plugins
" ______________________________ " ______________________________
call plug#begin() call plug#begin()
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'arcticicestudio/nord-vim' Plug 'arcticicestudio/nord-vim'
Plug 'scrooloose/nerdtree' Plug 'scrooloose/nerdtree'
Plug 'yuezk/vim-js'
Plug 'maxmellon/vim-jsx-pretty' Plug 'maxmellon/vim-jsx-pretty'
Plug 'ryanoasis/vim-devicons' Plug 'ryanoasis/vim-devicons'
Plug 'junegunn/fzf', { 'do': './install --bin' } Plug 'junegunn/fzf', { 'do': './install --bin' }
Plug 'junegunn/fzf.vim' Plug 'junegunn/fzf.vim'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'leafgarland/typescript-vim' Plug 'leafgarland/typescript-vim'
Plug 'peitalin/vim-jsx-typescript' Plug 'peitalin/vim-jsx-typescript'
Plug 'prettier/vim-prettier', {
\ 'do': 'yarn install',
\ 'for': ['javascript', 'typescript', 'css', 'less', 'scss', 'json', 'graphql', 'markdown', 'vue', 'yaml', 'html'] }
call plug#end() call plug#end()
" NERDTree " NERDTree
@ -66,12 +177,9 @@ let g:NERDTreeMinimalUI = 1
let g:NERDTreeIgnore = [] let g:NERDTreeIgnore = []
let g:NERDTreeStatusline = '' let g:NERDTreeStatusline = ''
" fzf - use silversearcher-ag to respect .gitignore " FZF - use silversearcher-ag to respect .gitignore
let $FZF_DEFAULT_COMMAND = 'ag -g ""' let $FZF_DEFAULT_COMMAND = 'ag -g ""'
let g:vim_jsx_pretty_colorful_config = 1
" prettier
let g:prettier#quickfix_enabled = 0
autocmd TextChanged,InsertLeave *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.md,*.vue,*.yaml,*.html PrettierAsync
" plugin keybindings " plugin keybindings
nnoremap <silent> <C-b> :NERDTreeToggle<CR> nnoremap <silent> <C-b> :NERDTreeToggle<CR>
@ -82,8 +190,10 @@ let g:fzf_action = {
\ 'ctrl-v': 'vsplit' \ 'ctrl-v': 'vsplit'
\} \}
"
" Theme " Theme
" ______________________________ " ______________________________
colorscheme nord colorscheme nord
set t_Co=256