Last active
December 22, 2020 08:42
-
-
Save dvvtms/41fd7bcd9a408d6e670a64d4b158bac7 to your computer and use it in GitHub Desktop.
vimrc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" https://stackoverflow.com/questions/13239464/create-a-new-file-in-the-directory-of-the-open-file-in-vim | |
set autochdir | |
call plug#begin('~/.vim/plugged') | |
Plug 'neoclide/coc.nvim', {'branch': 'release'} | |
" {{{ | |
" CoC extensions | |
let g:coc_global_extensions = ['coc-tsserver'] | |
" Remap keys for applying codeAction to the current line. | |
nmap <leader>ac <Plug>(coc-codeaction) | |
" Apply AutoFix to problem on the current line. | |
nmap <leader>qf <Plug>(coc-fix-current) | |
" https://pragmaticpineapple.com/e676eb63e002a93c834fed2c375934b3/code-jumping.gif | |
" GoTo code navigation. | |
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) | |
" Highlight the symbol and its references when holding the cursor. | |
autocmd CursorHold * silent call CocActionAsync('highlight') | |
" Formatting selected code. | |
nmap <leader>fo <Plug>(coc-format-selected) | |
" Some servers have issues with backup files, see #649. | |
set nobackup | |
set nowritebackup | |
" Add `:Format` command to format current buffer. | |
command! -nargs=0 Format :call CocAction('format') | |
" Add `:OR` command for organize imports of the current buffer. | |
command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport') | |
" Show all diagnostics. | |
nnoremap <silent><nowait> <space>a :<C-u>CocList diagnostics<cr> | |
nmap <leader>foa :Format<CR> | |
" }}} | |
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } | |
Plug 'junegunn/fzf.vim' | |
" {{{ | |
" mapped to search for open buffers, and to search buffer history. | |
nmap <Leader>b :Buffers<CR> | |
nmap <Leader>h :History<CR> | |
" mapped to search for tags in current buffer, and to search for tags across project. | |
nmap <Leader>t :BTags<CR> | |
nmap <Leader>T :Tags<CR> | |
" search for git tracked files, and <Leader>F to search all files*. | |
nmap <Leader>f :GFiles<CR> | |
nmap <Leader>F :Files<CR> | |
" Project finder | |
" nnoremap <silent> <leader>/ :execute 'Ag ' . input('Ag/')<CR> | |
" nmap <Leader>/ :Ag<Space> | |
nmap <Leader>/ :Rg<Space> | |
" }}} | |
Plug 'junegunn/vim-easy-align' | |
" {{{ | |
let g:easy_align_ignore_comment = 0 " align comments | |
vnoremap <silent> <Enter> :EasyAlign<cr> | |
" }}} | |
Plug 'preservim/nerdtree' | |
" {{{ | |
" Open NERD Tree when directory is specified. | |
autocmd StdinReadPre * let s:std_in=1 | |
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | endif | |
" map Ctrl+n to toggling the NERD Tree | |
map <C-n> :NERDTreeToggle<CR> | |
" Close NERD Tree when everything else is closed. | |
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif | |
" Keep NERD Tree open in new tabs | |
autocmd BufWinEnter * NERDTreeMirror | |
" }}} | |
Plug 'pangloss/vim-javascript' " JavaScript support | |
Plug 'leafgarland/typescript-vim' " TypeScript syntax | |
Plug 'maxmellon/vim-jsx-pretty' " JS and JSX syntax | |
Plug 'styled-components/vim-styled-components' | |
Plug 'airblade/vim-gitgutter' " Show git diff of lines edited | |
" {{{ | |
nmap gph <Plug>(GitGutterPreviewHunk) | |
" set signcolumn=yes | |
nmap ]h <Plug>(GitGutterNextHunk) | |
nmap [h <Plug>(GitGutterPrevHunk) | |
nmap <Leader>gsh <Plug>(GitGutterStageHunk) | |
nmap <Leader>guh <Plug>(GitGutterUndoHunk) | |
" Cycle through hunks in all buffers | |
nmap <silent> ]c :call NextHunkAllBuffers()<CR> | |
nmap <silent> [c :call PrevHunkAllBuffers()<CR> | |
" let g:gitgutter_highlight_lines = 1 | |
let g:gitgutter_highlight_linenrs= 1 | |
let g:gitgutter_sign_column_always = 1 | |
" }}} | |
Plug 'editorconfig/editorconfig-vim' | |
" themes | |
Plug 'lifepillar/vim-solarized8' | |
Plug 'NLKNguyen/papercolor-theme' | |
Plug 'morhetz/gruvbox' | |
Plug 'chriskempson/base16-vim' | |
Plug 'owickstrom/vim-colors-paramount' | |
Plug 'tpope/vim-fugitive' | |
Plug 'vim-airline/vim-airline' | |
call plug#end() | |
let base16colorspace=256 | |
set number " show line numbers on the sidebar. | |
set numberwidth=4 | |
set title " Set the window’s title, reflecting the file currently being edited. | |
set background=dark | |
set spell " Enable spellchecking | |
set termguicolors | |
" Disable all bells and whistles | |
set noerrorbells visualbell t_vb= | |
set ignorecase " Ignore case when searching | |
set smartcase " When searching try to be smart about cases | |
set incsearch " Jumping search | |
" Allow copy and paste from system clipboard | |
set clipboard=unnamed | |
" Delete characters outside of insert area | |
set backspace=indent,eol,start | |
set hidden " hide buffers instead of closing | |
set updatetime=100 | |
syntax on | |
"colorscheme anderson | |
colorscheme gruvbox | |
autocmd BufNewFile,BufRead *.tsx,*.jsx set filetype=typescript.tsx | |
" nmap <C-F8> :LspDocumentDiagnostics <CR> | |
" autocmd FileType qf nnoremap <silent> <buffer> <CR> <CR> :cclose<CR>:lclose<CR> | |
" Source Vim configuration file and install plugins | |
nnoremap <silent><leader>1 :source ~/.vimrc \| :PlugInstall<CR> | |
nnoremap <silent><leader>l :ls<CR> | |
function! NextHunkAllBuffers() | |
let line = line('.') | |
GitGutterNextHunk | |
if line('.') != line | |
return | |
endif | |
let bufnr = bufnr('') | |
while 1 | |
bnext | |
if bufnr('') == bufnr | |
return | |
endif | |
if !empty(GitGutterGetHunks()) | |
1 | |
GitGutterNextHunk | |
return | |
endif | |
endwhile | |
endfunction | |
function! PrevHunkAllBuffers() | |
let line = line('.') | |
GitGutterPrevHunk | |
if line('.') != line | |
return | |
endif | |
let bufnr = bufnr('') | |
while 1 | |
bprevious | |
if bufnr('') == bufnr | |
return | |
endif | |
if !empty(GitGutterGetHunks()) | |
normal! G | |
GitGutterPrevHunk | |
return | |
endif | |
endwhile | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment