diff --git a/.vimrc b/.vimrc index a1daa5c..fbdc74c 100644 --- a/.vimrc +++ b/.vimrc @@ -1,28 +1,52 @@ +" " General config " ______________________________ -" + 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 smarttab -set backspace=indent,eol,start -set ttyfast -set timeout timeoutlen=1000 ttimeoutlen=50 +set signcolumn=yes 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 nowritebackup set noswapfile 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' edit! + +" +" Filetypes +" ______________________________ + +filetype plugin indent on + +" " Keybindings " ______________________________ -" -" no arrow keys + map map map @@ -38,26 +62,113 @@ inoremap jk " quick help :ca htab :tab h -" 2x scrolling -nnoremap 2 -nnoremap 2 +" coc +inoremap + \ pumvisible() ? "\" : + \ check_back_space() ? "\" : + \ coc#refresh() +inoremap pumvisible() ? "\" : "\" +function! s:check_back_space() abort + let col = col('.') - 1 + return !col || getline('.')[col - 1] =~# '\s' +endfunction + +inoremap coc#refresh() + +if has('patch8.1.1068') + inoremap complete_info()["selected"] != "-1" ? "\" : "\u\" +else + imap pumvisible() ? "\" : "\u\" +endif + +nmap [g (coc-diagnostic-prev) +nmap ]g (coc-diagnostic-next) + +nmap gd (coc-definition) +nmap gy (coc-type-definition) +nmap gi (coc-implementation) +nmap gr (coc-references) + +nnoremap K :call show_documentation() + +function! s:show_documentation() + if (index(['vim','help'], &filetype) >= 0) + execute 'h '.expand('') + else + call CocAction('doHover') + endif +endfunction + +autocmd CursorHold * silent call CocActionAsync('highlight') + +nmap rn (coc-rename) + +xmap f (coc-format-selected) +nmap f (coc-format-selected) + +augroup mygroup + autocmd! + autocmd FileType typescript, json setl formatexpr=CocAction('formatSelected') + autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') +augroup end + +xmap a (coc-codeaction-selected) +nmap a (coc-codeaction-selected) + +nmap ac (coc-codeaction) +nmap qf (coc-fix-current) + +xmap if (coc-funcobj-i) +xmap af (coc-funcobj-a) +omap if (coc-funcobj-i) +omap af (coc-funcobj-a) + +nmap (coc-range-select) +xmap (coc-range-select) + +command! -nargs=0 Format :call CocAction('format') +command! -nargs=? Fold :call CocAction('fold', ) +command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport') + +set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} + +nnoremap a :CocList diagnostics +nnoremap e :CocList extensions +nnoremap c :CocList commands +nnoremap o :CocList outline +nnoremap s :CocList -I symbols +nnoremap j :CocNext +nnoremap k :CocPrev +nnoremap p :CocListResume + +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 " ______________________________ call plug#begin() +Plug 'neoclide/coc.nvim', {'branch': 'release'} Plug 'arcticicestudio/nord-vim' Plug 'scrooloose/nerdtree' +Plug 'yuezk/vim-js' Plug 'maxmellon/vim-jsx-pretty' Plug 'ryanoasis/vim-devicons' Plug 'junegunn/fzf', { 'do': './install --bin' } Plug 'junegunn/fzf.vim' -Plug 'neoclide/coc.nvim', {'branch': 'release'} Plug 'leafgarland/typescript-vim' 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() " NERDTree @@ -66,12 +177,9 @@ let g:NERDTreeMinimalUI = 1 let g:NERDTreeIgnore = [] let g:NERDTreeStatusline = '' -" fzf - use silversearcher-ag to respect .gitignore +" FZF - use silversearcher-ag to respect .gitignore let $FZF_DEFAULT_COMMAND = 'ag -g ""' - -" 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 +let g:vim_jsx_pretty_colorful_config = 1 " plugin keybindings nnoremap :NERDTreeToggle @@ -82,8 +190,10 @@ let g:fzf_action = { \ 'ctrl-v': 'vsplit' \} +" " Theme " ______________________________ colorscheme nord +set t_Co=256