Skip to content

Instantly share code, notes, and snippets.

@allexcd
Forked from termosa/.vimrc
Last active June 21, 2017 14:53
Show Gist options
  • Save allexcd/80ee3ff511b0ee58e050031c015e3591 to your computer and use it in GitHub Desktop.
Save allexcd/80ee3ff511b0ee58e050031c015e3591 to your computer and use it in GitHub Desktop.
" Before using this configuration follow the instruction below
"
" Check the requirements for plugins:
" * npm required for marijnh/tern_for_vim
" * tidy5 required for html validation (http://www.html-tidy.org/)
"
" Create folders for storing temporary files
" $ mkdir ~/.vim/backup && mkdir ~/.vim/tmp
"
" Download Vim-Plug:
" $ curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
" https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
"
" Install Vim plugins with the command:
" :PlugInstall
"
call plug#begin('~/.vim/plugged')
Plug 'tpope/vim-repeat' | Plug 'tpope/vim-surround' " Commands for modifying surround quotes, brackets and etc
Plug 'junegunn/vim-easy-align' " Aligning bunch of lines
Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets' " Generating code with snippets
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } " Dependency of fzf.vim
Plug 'junegunn/fzf.vim' " Searching through files
Plug 'jelera/vim-javascript-syntax' " Javascript syntax
Plug 'nathanaelkane/vim-indent-guides' " Tabs highlighting
Plug 'scrooloose/syntastic' " Check syntax with linters (for example: npm i -g eslint)
Plug 'stephpy/vim-yaml' " Yaml syntax
Plug 'ekalinin/Dockerfile.vim' " Syntax for Dockerfile
Plug 'markcornick/vim-vagrant' " Vafrantfile syntax
Plug 'itchyny/lightline.vim' " Sexy status bar
Plug 'tpope/vim-fugitive' " Working with Git
Plug 'ConradIrwin/vim-bracketed-paste' " Normalize text pasted with OS hotkeys
Plug 'easymotion/vim-easymotion' " Improved motions
Plug 'posva/vim-vue' " Syntax for VueJS
Plug 'junegunn/goyo.vim' " Distraction free editing
Plug 'junegunn/limelight.vim' " Light focused scope
Plug 'gagoar/StripWhiteSpaces' " Strips whitespaces buy running :StripWhiteSpaces
Plug 'Shougo/vimproc.vim', {'do' : 'make'} | Plug 'Shougo/vimshell.vim' " Shell in Vim editor
Plug 'timakro/vim-searchant' " Highlight search match under cursor
Plug 'gavinbeatty/dragvisuals.vim' " Drag and duplicate visual blocks
Plug 'dhruvasagar/vim-table-mode' " Managing ASCII tables
Plug 'mhinz/vim-startify' " Fancy start screen
Plug 'fatih/vim-go' " Support for Go lang
Plug 'xolox/vim-misc' | Plug 'xolox/vim-notes' " Fancy notes via Vim
Plug 'omaraboumrad/vim-life' " Life game
Plug 'tmhedberg/matchit' " Jump to the end or beginning of xml tag
Plug 'scrooloose/nerdcommenter' " Fast commenting
Plug 'scrooloose/vim-slumlord' " Write UML's and render them
Plug 'aklt/plantuml-syntax' " Syntax for plantuml
Plug 'stephenway/postcss.vim' " Syntax for PostCSS
Plug 'https://github.com/chriskempson/vim-tomorrow-theme.git' " Default color scheme
call plug#end()
" Hack to fix reloading .vimrc
augroup reload_vimrc " {
autocmd!
autocmd BufWritePost $MYVIMRC nested source $MYVIMRC
augroup END " }
" Enable using local .vimrc files
set exrc
set secure " disable using dangerous commands in local .vimrc files
" Custom directories
set backupdir=~/.vim/backup
set directory=~/.vim/tmp
" Enable pretty colorscheme
syntax on
set background=dark
colorscheme Tomorrow-Night
syntax enable
au BufRead,BufNewFile *.es6 set filetype=javaScript
" Map Leader key
let mapleader=","
" Improve vim file completion
set path+=**
set wildmenu
" Display whitespaces
set list
exec "set listchars=tab:\u2023\uB7,trail:\uB0,nbsp:\uB0"
" Print typed command
set showcmd
" Using digraphs
"inoremap <expr> <C-k> ShowDigraphs()
function! ShowDigraphs ()
call digraphs
call getchar()
return "\<C-k>"
endfunction
" Custom digraphs
silent! dig -. 8230 "U+2026=… HORIZONTAL ELLIPSIS
"# Setup UltiSnips
let g:UltiSnipsSnippetDirectories = ['~/.vim/UltiSnips', 'UltiSnips']
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<c-f>"
let g:UltiSnipsJumpBackwardTrigger="<c-b>"
"# Managing windows and tabs
" Close window with Alt-w
nnoremap <A-w> :q<CR>
" Split window with Alt-s
nnoremap <A-s> :split<CR>
" Split window vertically with Alt-d
nnoremap <A-d> :vsplit<CR>
" Horizontal split add new window to below
set splitbelow
" Vertical split add new window to right
set splitright
" Resize windows with Alt-{h,j,k,l}
nnoremap <A-h> :vertical resize -1<CR>
nnoremap <A-j> :resize +1<CR>
nnoremap <A-k> :resize -1<CR>
nnoremap <A-l> :vertical resize +1<CR>
" Navigation through panes with Ctrl-{h,j,k,l}
nnoremap <C-h> <C-w>h " Left pane
nnoremap <C-j> <C-w>j " Down pane
nnoremap <C-k> <C-w>k " Up pane
nnoremap <C-l> <C-w>l " Right pane
" Navigation through tabs
nnoremap th :tabprev<CR>
nnoremap tl :tabnext<CR>
nnoremap tn :tabnew<CR>
nnoremap td :tabclose<CR>
nnoremap tm :tabmove
for i in [1, 2, 3, 4, 5, 6, 7, 8, 9]
execute 'nnoremap t' . i . ' ' . i . 'gt'
endfor
" File browsing
" :help netrw-browse-maps
set modifiable
autocmd FileType netrw nmap <silent> <buffer> <C><CR> :bd<CR>
let g:netrw_banner=0 " disable annoying banner
"let g:netrw_browse_split=4 " open in prior window
let g:netrw_altv=1 " open splits to the right
let g:netrw_liststyle=3 " tree view
let g:netrw_list_hide=netrw_gitignore#Hide()
let g:netrw_list_hide.=',\(^|\s\s\)\zs\.\S\+'
nnoremap ty :<Plug>NetrwHideEdit
" Folding
set foldmethod=indent
set foldnestmax=5
set foldlevel=99
highlight Folded cterm=none ctermbg=59 ctermfg=15
" Show line numbers
set number
set relativenumber
" Prevent poll when opening a file with existing swap
augroup NoSimultaneousEdits
let ErrorMsg = 'Duplicate edit session (readonly)'
autocmd!
autocmd SwapExists * let v:swapchoice = 'o'
autocmd SwapExists * echoerr ErrorMsg
autocmd SwapExists * echo ErrorMsg
autocmd SwapExists * echohl None
augroup END
" Toggle ruller warning with [t][e]
highlight OverLength ctermbg=7 ctermfg=0
function! HighlightOverLength()
if g:highlight_overlength_match
call matchdelete(g:highlight_overlength_match)
let g:highlight_overlength_match = 0
else
let g:highlight_overlength_match = matchadd('OverLength', '\%120v.\+', 100)
endif
endfunction
if !exists("g:highlight_overlength_match")
let g:highlight_overlength_match = 0
call HighlightOverLength()
endif
nnoremap te :call HighlightOverLength()<CR>
" Padding settings
set tabstop=2
set shiftwidth=2
set softtabstop=2
set smarttab
set expandtab
set smartindent
set autoindent
set pastetoggle=<f5> " to stop indenting when pasting from GUI
set linebreak
set showbreak=··>
" Search settings
set incsearch
set hlsearch
" Screen follows cursor
set scrolloff=12
" Expand history
set history=200
" Add options to build tags file
command! MTags !ctags -R .
"# Setup Lightline (itchyny/lightline.vim)
set laststatus=2
set noshowmode
let g:lightline = {
\ 'colorscheme': 'wombat',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'fugitive', 'readonly', 'filename', 'modified' ] ]
\ },
\ 'component': {
\ 'readonly': '%{&filetype=="help"?"":&readonly?"☓":""}',
\ 'modified': '%{&filetype=="help"?"":&modified?"∗":&modifiable?"":"ø"}',
\ 'fugitive': '%{exists("*fugitive#head")?fugitive#head():""}'
\ },
\ 'component_visible_condition': {
\ 'readonly': '(&filetype!="help"&& &readonly)',
\ 'modified': '(&filetype!="help"&&(&modified||!&modifiable))',
\ 'fugitive': '(exists("*fugitive#head") && ""!=fugitive#head())'
\ }
\ }
if !has('gui_running')
set t_Co=256
endif
"# Setup Syntatic (scrooloose/syntastic)
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
function! s:syntastic()
SyntasticCheck
call lightline#update()
endfunction
" Configure behavior
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 0
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_aggregate_errors = 1
let g:syntastic_echo_current_error = 1 " Show error message in the command line when cursor hovers on the error
let g:syntastic_enable_signs = 1 " Show errors on the side
let g:syntastic_error_symbol = "#" " For syntax errors, defaults to '>>'
let g:syntastic_warning_symbol = "*" " For syntax warnings, defaults to '>>'
let g:syntastic_style_error_symbol = ">" " For style errors, defaults to 'S>'
let g:syntastic_style_warning_symbol = "-" " For style warnings, defaults to 'S>'
let g:syntastic_enable_balloons = 0 " Turn off tooltips
let g:syntastic_auto_loc_list = 2 " Close list automatically
let g:syntastic_loc_list_height = 5
" Setup linters
let g:syntastic_javascript_checkers = ['eslint']
let g:syntastic_html_checkers = ['tidy']
" Setup bindings
nnoremap tj :lnext<CR> " Go to next error
nnoremap tk :lprevious<CR> " Go to previous error
nnoremap to :Error<CR> " Go to location list
" Toggle location list by Ctrl-e
function! ToggleErrors()
if empty(filter(tabpagebuflist(), 'getbufvar(v:val, "&buftype") is# "quickfix"'))
" No location/quickfix list shown, open syntastic error location panel
Errors
else
lclose
endif
endfunction
nnoremap <silent> <C-e> :<C-u>call ToggleErrors()<CR><Paste><C-w><C-j>
"# Setup DragVisuals (gavinbeatty/dragvisuals.vim)
vmap <expr> <LEFT> DVB_Drag('left')
vmap <expr> <RIGHT> DVB_Drag('right')
vmap <expr> <DOWN> DVB_Drag('down')
vmap <expr> <UP> DVB_Drag('up')
vmap <expr> D DVB_Duplicate()
"# Setup EasyAlign (junegunn/vim-easy-align)
vmap <Enter> <Plug>(EasyAlign)
"# Setup FZF (junegunn/fzf.vim)
" plain files list in current directory
nnoremap <C-f>f :Files<CR>
" look through all system
nnoremap <C-f>l :Locate
" search inside of files
nnoremap <C-f><S-a> :Ag
" list of opened buffers
nnoremap <C-f>b :Buffers<CR>
nnoremap <C-f>m :Marks<CR>
" recent files
nnoremap <C-f>h :History<CR>
nnoremap <C-f>s :Snippets<CR>
nnoremap <C-f>t :Tags<CR>
nnoremap <C-f>C :Commits<CR>
nnoremap <C-f>c :Commands<CR>
nnoremap <C-f>e :BCommits<CR>
nnoremap <C-f><S-m> :Maps<CR>
nnoremap <C-f>? :Helptags<CR>
nnoremap <C-f><S-s> :Filetypes<CR>
" GitFiles with preview
nnoremap <C-f>g :call fzf#vim#gitfiles('--exclude-standard -cmo', fzf#vim#with_preview('right'))<CR>
" Ag with preview
nnoremap <C-f>a :call fzf#vim#ag('', fzf#vim#with_preview('right'))<CR>
" FZF with preview
let g:fzf_files_options =
\ "--preview 'highlight --force -qO ansi {}' --bind alt-n:preview-down,alt-m:preview-up"
"# Setup StripWhiteSpaces (gagoar/StripWhiteSpaces)
let g:loaded_StripWhiteSpaces = 1
"# Setup Goyo (junegunn/goyo.vim)
nnoremap zf :Goyo<CR>
"# Setup Limelight (junegunn/limelight.vim)
nnoremap zl :Limelight<CR>
" Goyo.vim integration
autocmd! User GoyoEnter Limelight
autocmd! User GoyoLeave Limelight!
" Color name (:help cterm-colors) or ANSI code
let g:limelight_conceal_ctermfg = 242
" Color name (:help gui-colors) or RGB color
let g:limelight_conceal_guifg = 242
" Default: 0.5
let g:limelight_default_coefficient = 0.5
" Number of preceding/following paragraphs to include (default: 0)
let g:limelight_paragraph_span = 0
" Highlighting priority (default: 10)
" Set it to -1 not to overrule hlsearch
let g:limelight_priority = -1
"# Setup VimShell (Shougo/vimshell.vim)
nnoremap ts :VimShellTab<CR>
nnoremap tp :VimShellPop<CR>
let g:vimshell_prompt = "# "
"let g:vimshell_user_prompt = '"@>> " . fnamemodify(getcwd(), ":~")'
let g:vimshell_force_overwrite_statusline = 1
let g:vimshell_vimshrc_path = "expand('~/.vimshrc')"
"# NeoVim configuration
if has("nvim")
" Python support
let g:python2_host_prog = '/usr/local/bin/python'
let g:python3_host_prog = '/usr/local/bin/python3'
nnoremap tt :tabnew term://zsh<CR>:startinsert<CR>
nnoremap ti :terminal<CR>
tnoremap <Esc> <C-\><C-n>
" Navigation through panes with Alt {h,j,k,l}
tnoremap <A-h> <C-\><C-n><C-w>h
tnoremap <A-j> <C-\><C-n><C-w>j
tnoremap <A-k> <C-\><C-n><C-w>k
tnoremap <A-l> <C-\><C-n><C-w>l
endif
" Before using this configuration follow the instruction below
"
" Create folders for storing temporary files
" $ mkdir ~/.vim/backup && mkdir ~/.vim/tmp && mkdir ~/.vim/undo
"
" Download Vim-Plug:
" $ curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
" https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
"
" Download Solarized colorscheme
" $ curl -fLo ~/.vim/colors/solarized.vim --create-dirs \
" https://raw.githubusercontent.com/altercation/vim-colors-solarized/master/colors/solarized.vim
"
" Install Vim plugins with the command:
" :PlugInstall
call plug#begin('~/.vim/plugged')
Plug 'tpope/vim-repeat' | Plug 'tpope/vim-surround' " Commands for modifying surround quotes, brackets and etc
Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets' " Generating code with snippets
Plug 'junegunn/vim-github-dashboard' " See activity on GH
Plug 'jelera/vim-javascript-syntax' " Javascript syntax
Plug 'nathanaelkane/vim-indent-guides' " Tabs highlighting
Plug 'scrooloose/syntastic' " Check syntax with linters (for example: npm i -g eslint)
Plug 'stephpy/vim-yaml' " Yaml syntax
Plug 'itchyny/lightline.vim' " Sexy status bar
Plug 'tpope/vim-fugitive' " Working with Git
Plug 'ConradIrwin/vim-bracketed-paste' " Normalize text pasted with OS hotkeys
Plug 'posva/vim-vue' " Syntax for VueJS
call plug#end()
" Hack to fix reloading .vimrc
augroup reload_vimrc " {
autocmd!
autocmd BufWritePost $MYVIMRC nested source $MYVIMRC
augroup END " }
" Enable using local .vimrc files
set exrc
set secure " disable using dangerous commands in local .vimrc files
" Custom directories
set backupdir=~/.vim/backup
set directory=~/.vim/tmp
set undodir=~/.vim/undo
" Backups
set backup
set undofile
set undolevels=100
set undoreload=200
" Enable pretty colorscheme
syntax on
set background=dark
colorscheme solarized
syntax enable
au BufRead,BufNewFile *.es6 set filetype=javaScript
" Better navigation
map <C-h> <C-w>h " Left pane
map <C-j> <C-w>j " Down pane
map <C-k> <C-w>k " Up pane
map <C-l> <C-w>l " Right pane
nnoremap th :tabprev<CR>
nnoremap tl :tabnext<CR>
nnoremap tn :tabnew<CR>
nnoremap td :tabclose<CR>
nnoremap tm :tabmove
for i in [1, 2, 3, 4, 5, 6, 7, 8, 9]
execute 'nnoremap t' . i . ' ' . i . 'gt'
endfor
" Folding
set foldmethod=indent
set foldnestmax=5
highlight Folded cterm=none ctermbg=59 ctermfg=15 gui=none guibg=#3B3B3B guifg=#90AB41
" Show line numbers
set number
set relativenumber
" Padding settings
set tabstop=2
set shiftwidth=2
set softtabstop=2
set smarttab
set expandtab
set smartindent
set autoindent
set linebreak
set showbreak=+++\
" Search settings
set incsearch
set hlsearch
" Screen follows cursor
set scrolloff=3
" Expand history
set history=100
" Setup Lightline (itchyny/lightline.vim)
set laststatus=2
set noshowmode
let g:lightline = {
\ 'colorscheme': 'wombat',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'fugitive', 'readonly', 'filename', 'modified' ] ]
\ },
\ 'component': {
\ 'readonly': '%{&filetype=="help"?"":&readonly?"☓":""}',
\ 'modified': '%{&filetype=="help"?"":&modified?"∗":&modifiable?"":"ø"}',
\ 'fugitive': '%{exists("*fugitive#head")?fugitive#head():""}'
\ },
\ 'component_visible_condition': {
\ 'readonly': '(&filetype!="help"&& &readonly)',
\ 'modified': '(&filetype!="help"&&(&modified||!&modifiable))',
\ 'fugitive': '(exists("*fugitive#head") && ""!=fugitive#head())'
\ }
\ }
if !has('gui_running')
set t_Co=256
endif
" Setup Syntatic (scrooloose/syntastic)
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment