Skip to content

Instantly share code, notes, and snippets.

@elhenro elhenro/.vimrc

Last active Jun 4, 2020
Embed
What would you like to do?
elhenro vimrc
set encoding=utf-8
set expandtab
set shiftwidth=2
set tabstop=2
set mouse=a
set number
set autoread
set diffopt+=iwhite
set nocompatible
set hidden
set ignorecase
set smartcase
set splitbelow
set splitright
set noshowmode
set hlsearch
set grepprg=ag\ --vimgrep\ $*
set grepformat=%f:%l:%c:%m
set cpoptions=ces$
set cursorline
set ruler
" move cursor freely
set virtualedit=all
" if $TERM == "xterm-256color"
" set t_Co=256
" endif
set showtabline=0
set noswapfile
let mapleader = ","
imap jj <Esc>
cabb W w
cabb Q q
cabb Wq wq
cabb WQ wq
" easier split navigation
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
" toggle numbers
nmap <leader>nu :set nu!<cr>
" block arrow keys
noremap <Up> <NOP>
noremap <Down> <NOP>
noremap <Left> <NOP>
noremap <Right> <NOP>
map <Esc><Esc> :w<CR>
nmap <leader>nw :set wrap!<cr>
call plug#begin('~/.vim/plugged')
" Plug 'airblade/vim-gitgutter'
Plug 'eslint/eslint'
Plug 'isruslan/vim-es6'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'junegunn/goyo.vim'
Plug 'maxmellon/vim-jsx-pretty'
Plug 'pangloss/vim-javascript'
Plug 'scrooloose/nerdcommenter'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-unimpaired'
Plug 'dense-analysis/ale'
Plug 'vimwiki/vimwiki'
Plug 'tpope/vim-repeat'
Plug 'jamessan/vim-gnupg'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
if has('nvim') || has('patch-8.0.902')
Plug 'mhinz/vim-signify'
else
Plug 'mhinz/vim-signify', { 'branch': 'legacy' }
endif
call plug#end()
" ale
let g:ale_sign_error = '🔴'
let g:ale_sign_warning = '🟡'
highlight ALEErrorSign ctermbg=NONE ctermfg=red
highlight ALEWarningSign ctermbg=NONE ctermfg=yellow
let g:ale_fix_on_save = 1
let g:airline#extensions#ale#enabled = 0
let g:ale_sign_column_always = 1
let g:ale_linters = {'javascript': ['eslint'],}
let g:ale_fixers = {'javascript': ['eslint'],}
let b:ale_linters = {'javascript': ['prettier', 'eslint']}
" ale navigate between erorrs quickly
nmap <silent> <Leader>en <Plug>(ale_previous_wrap)
nmap <silent> <Leader>ep <Plug>(ale_next_wrap)
" git gutter colors
highlight GitGutterAdd ctermfg=green
highlight GitGutterChange ctermfg=yellow
highlight GitGutterDelete ctermfg=red
highlight GitGutterChangeDelete ctermfg=yellow
nmap <leader>+ :GitGutterLineHighlightsToggle<CR>
nmap <leader>_ :GitGutterFold<CR>
nmap ]h :GitGutterNextHunk<CR>
nmap [h :GitGutterPrevHunk<CR>
nmap ,gn :GitGutterNextHunk<CR>
nmap ,gp :GitGutterPrevHunk<CR>
nmap ,gs :GitGutterStageHunk<CR>
nmap ,gu :GitGutterUndoHunk<CR>
function! s:ToggleBlame()
if &l:filetype ==# 'fugitiveblame'
close
else
Gblame
endif
endfunction
nnoremap gb :call <SID>ToggleBlame()<CR>
" js beautify shortcut
" nmap <leader>jb :call JsBeautify()<cr>
" goyo
nmap <leader>gy :Goyo 120x100%<cr>
nmap <leader>gyy :Goyo<cr>
" autocmd VimEnter * Goyo " autostart goyo
" ensure to leave, even with Goyo open
function! s:goyo_enter()
let b:quitting = 0
let b:quitting_bang = 0
autocmd QuitPre <buffer> let b:quitting = 1
cabbrev <buffer> q! let b:quitting_bang = 1 <bar> q!
endfunction
let g:goyo_margin_top = 0
let g:goyo_margin_bottom = 0
function! s:goyo_leave()
" quit if only remaining buffer
" if b:quitting && len(filter(range(1, bufnr('$')), 'buflisted(v:val)')) == 1
if b:quitting
if b:quitting_bang
qa!
else
qa
endif
endif
endfunction
autocmd! User GoyoEnter call <SID>goyo_enter()
autocmd! User GoyoLeave call <SID>goyo_leave()
" resize window
autocmd VimResized * if exists('#goyo') | exe "normal \<c-w>=" | endif
" insert space in normal mode
nnoremap <space> i<space><esc>
let s:hidden_all = 0
function! ToggleHiddenAll()
if s:hidden_all == 0
let s:hidden_all = 1
set noshowmode
set noruler
set laststatus=0
set noshowcmd
else
let s:hidden_all = 0
set showmode
set ruler
set laststatus=2
set showcmd
endif
endfunction
" hide statusline
autocmd VimEnter * call ToggleHiddenAll()
nmap <Leader>ha :call ToggleHiddenAll()<CR>
" ** fzf shortcuts
"" fzf search files
" nmap <Leader>f :Files<CR>
nmap <Leader>F :Files<CR>
nmap <leader>z :Rg<cr>
" fzf search buffers
nmap <Leader>b :Buffers<CR>
" " fzf search file history
nmap <Leader>h :History<CR>
" " fzf search help pages
nmap <Leader>H :Helptags!<CR>
" " fzf search commands
nmap <Leader>C :Commands<CR>
" " fzf search history
nmap <Leader>: :History:<CR>
" fzf search keymappings
nmap <Leader>M :Maps<CR>
" fzf search gitfiles
nmap <leader>p :call fzf#vim#gitfiles('', fzf#vim#with_preview('right'))<CR>
" ctrl+g ripgrep
nnoremap <C-g> :Rg<Cr>
nnoremap <C-f> :Ag<Cr>
" format json files
" com! FormatJSON %!python -m json.tool
" nmap <Leader>fj :FormatJSON<CR>
" hide cursorline
hi clear CursorLine
augroup CLClear
autocmd! ColorScheme * hi clear CursorLine
augroup END
hi CursorLineNR cterm=bold
augroup CLNRSet
autocmd! ColorScheme * hi CursorLineNR cterm=bold
augroup END
" nerdCommenter space delimit
let NERDSpaceDelims=1
" hightlight open brackets
hi link MatchOpen Error
" automatically strip trailing spaces
autocmd BufWritePre *.js :%s/\s\+$//e
autocmd BufWritePre *.sh :%s/\s\+$//e
" hide empty line ~s
"highlight EndOfBuffer ctermfg=black ctermbg=black
" remove black lines bug in kitty
" let &t_ut=''
" let g:ycm_path_to_python_interpreter = '/usr/bin/python'
" vimwiki
" let g:vimwiki_list = ..
nmap <Leader>id :IndentGuidesToggle<CR>
" hide ~ on blank lines
nmap <F7> :hi EndOfBuffer ctermfg=black ctermbg=black<CR>
" switch buffer from terminal split
tnoremap <leader>b <C-w>:Buffers<CR>
" ,tt to open terminal pane
nmap <Leader>tt :ter ++curwin<CR>
" hide split-bar
autocmd VimEnter highlight StatusLine ctermfg=bg ctermbg=bg guibg=bg guifg=bg
autocmd VimEnter highlight StatusLineNC ctermfg=bg ctermbg=bg guibg=bg guifg=bg
" also hide '|' char in vertical split-bar
set fillchars+=vert:\
" autosave buffer on focus loss
augroup AutoWrite
autocmd! BufLeave * :update
augroup END
" quicksave stroke
noremap <Leader><Leader> :update<CR>
" insert date
nmap <Leader>da i<C-R>=strftime("%Y-%m-%d %a %I:%M %p")<CR><Esc>
highlight clear LineNr
"
" gpg encr
let g:GPGPreferArmor=1
" ...
let r_indent_align_args = 0
colo gruvbox
" coc
set hidden
set nobackup
set nowritebackup
set cmdheight=2
set updatetime=300
set shortmess+=c
set signcolumn=yes
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
syntax sync minlines=10000
" signify
" default updatetime 4000ms is not good for async update
set updatetime=100
highlight SignColumn ctermbg=black
" Center screen on search next/prev
nnoremap n nzz
nnoremap N Nzz
nnoremap { {zz
nnoremap } }zz
" less padding
set noshowmode
set noruler
set laststatus=0
set noshowcmd
set cmdheight=1
let g:netrw_banner = 0
let g:netrw_liststyle = 3
let g:netrw_browse_split = 4
let g:netrw_altv = 1
let g:netrw_winsize = 25
let g:netrw_banner = 0
" newtr
augroup ProjectDrawer
autocmd!
autocmd VimEnter * :Vexplore
augroup END
" open newtr as project drawer
nmap <Leader>mm :Vexplore<cr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.