Skip to content

Instantly share code, notes, and snippets.

@svnlto
Created April 5, 2017 16:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save svnlto/e9879eb700a5c32f9eb76965393ebad8 to your computer and use it in GitHub Desktop.
Save svnlto/e9879eb700a5c32f9eb76965393ebad8 to your computer and use it in GitHub Desktop.
vim config
set nocompatible " be iMproved
filetype off " required!
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" let Vundle manage Vundle
" required!
Plugin 'gmarik/vundle'
Plugin 'benekastah/neomake'
" Editing
Plugin 'matchit.zip'
Plugin 'repeat.vim'
Plugin 'surround.vim'
Plugin 'remko/detectindent'
" File explore
Plugin 'The-NERD-Commenter'
Plugin 'The-NERD-tree'
Plugin 'kien/ctrlp.vim'
Plugin 'bling/vim-airline'
" Auto complete
Plugin 'ervandew/supertab'
Plugin 'garbas/vim-snipmate'
Plugin 'honza/vim-snippets'
" Syntax Highlight
Plugin 'colorizer'
Plugin 'sheerun/vim-polyglot'
" Programming
Plugin 'isRuslan/vim-es6'
Plugin 'othree/yajs.vim'
Plugin 'othree/es.next.syntax.vim'
Plugin 'mxw/vim-jsx'
Plugin 'moll/vim-node'
" Others
Plugin 'airblade/vim-gitgutter'
Plugin 'jordwalke/VimSplitBalancer'
Plugin 'editorconfig-vim'
Plugin 'mattn/gist-vim'
Plugin 'mattn/webapi-vim'
Plugin 'ack.vim'
Plugin 'matchparenpp'
Plugin 'tpope/vim-surround'
Plugin 'Townk/vim-autoclose'
Plugin 'MarcWeber/vim-addon-mw-utils'
Plugin 'tomtom/tlib_vim'
Plugin 'djoshea/vim-autoread'
Plugin 'mhinz/vim-startify'
Plugin 'fholgado/minibufexpl.vim'
Plugin 'sjl/vitality.vim'
Plugin 'tmux-plugins/vim-tmux-focus-events'
" Colorscheme
Plugin 'svnlto/vim-svnlto'
Plugin 'joshdick/onedark.vim'
"Use 24-bit (true-color) mode in Vim/Neovim when outside tmux.
if (has("nvim"))
"For Neovim 0.1.3 and 0.1.4 < https://github.com/neovim/neovim/pull/2198 >
let $NVIM_TUI_ENABLE_TRUE_COLOR=1
endif
"For Neovim > 0.1.5 and Vim > patch 7.4.1799 < https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162 >
"Based on Vim patch 7.4.1770 (`guicolors` option) < https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd >
" < https://github.com/neovim/neovim/wiki/Following-HEAD#20160511 >
if (has("termguicolors"))
set termguicolors
endif
filetype plugin indent on " required!
"
" Brief help
" :PluginList - list configured bundles
" :PluginInstall(!) - install (update) bundles
" :PluginSearch(!) foo - search (or refresh cache first) for foo
" :PluginClean(!) - confirm (or auto-approve) removal of unused bundles
"
" see :h vundle for more details or wiki for FAQ
" NOTE: comments after Plugin commands are not allowed.
syntax on
set so=10
set ruler
set number
set hidden
set nowrap
set autoread
set showmatch
set clipboard=unnamed
set wildignore=*.o,*~,*.pyc
set backspace=eol,start,indent
set iskeyword+=-
set ffs=unix,dos,mac
set laststatus=2
set colorcolumn=80
behave mswin
" Turn backup off, since most stuff is in SVN, git etc.
set nowb
set nobackup
set noswapfile
" No annoying sound on errors
set noerrorbells
set visualbell
set t_vb=
set tm=500
set ignorecase
set smartcase
set hlsearch
set incsearch
set expandtab
set smarttab
set smartindent
set shiftwidth=2
set tabstop=2
set autoread
set guifont=Hack:h12
set t_Co=256
set background=dark
colorscheme onedark
noremap ; :
noremap 0 ^
noremap <space> $
noremap Y y$
" Treat long lines as break lines (useful when moving around in them)
noremap j gj
noremap k gk
" Smart way to move between windows
noremap <C-j> <C-W>j
noremap <C-k> <C-W>k
noremap <C-h> <C-W>h
noremap <C-l> <C-W>l
let mapleader = ","
nmap <leader>l :set list!<CR>
nnoremap <leader>hs :noh<CR>
" edit and reload vimrc
nnoremap <leader>ev :e $MYVIMRC<CR>
nnoremap <leader>sv :source $MYVIMRC<CR>
autocmd! bufwritepost vimrc source %
map <leader>pp :setlocal paste!<cr>
map <Leader>bn :MBEbn <cr>
map <Leader>bp :MBEbp <cr>
map <Leader>bt :MBEToggle <cr>
" plugin settings
let g:airline_powerline_fonts = 1
let g:polyglot_disabled = ['jsx']
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let g:airline_symbols.space = "\ua0"
let g:jsx_ext_required = 0
let g:nerdtreechdirmode=2
map nt :NERDTreeToggle<cr>
map nf :NERDTreeFind<cr>
let NERDSpaceDelims=1
autocmd VimEnter * call StartUp()
autocmd VimEnter * wincmd p
let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlP'
let g:ctrlp_custom_ignore = 'tmp$\|\.git$\|\.hg$\|\.svn$\|\.rvm$\|vendor$'
let g:ctrlp_tabpage_position = 'a'
let g:ctrlp_working_path_mode = 'ra'
let g:ctrlp_max_files = 0
let g:SuperTabCrMapping = 1
" vim mapping to search for the current word under the cursor.
nnoremap <leader>S :Ack <C-R><C-W><CR>
" The Silver Searcher
if executable('ag')
" Use ag over grep
set grepprg=ag\ --nogroup\ --nocolor
" Use ag in CtrlP for listing files. Lightning fast and respects .gitignore
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""'
" ag is fast enough that CtrlP doesn't need to cache
let g:ctrlp_use_caching = 0
endif
let g:neomake_javascript_enabled_makers = ['eslint']
let g:neomake_open_list = 2
let g:neomake_list_height = 3
" load local eslint in the project root
let s:eslint_path = system('PATH=$(npm bin --silent):$PATH && which eslint')
let g:neomake_javascript_eslint_exe = substitute(s:eslint_path, '^\n*\s*\(.\{-}\)\n*\s*$', '\1', '')
nmap <Leader><Space>o :lopen<CR> " open location window
nmap <Leader><Space>c :lclose<CR> " close location window
nmap <Leader><Space>, :ll<CR> " go to current error/warning
nmap <Leader><Space>n :lnext<CR> " next error/warning
nmap <Leader><Space>p :lprev<CR> " previous error/warning
autocmd! BufWritePost * Neomake
" remove trailing whitespace on save
autocmd BufWritePre * :%s/\s\+$//e
function! CmdLine(str)
exe "menu Foo.Bar :" . a:str
emenu Foo.Bar
unmenu Foo
endfunction
function! VisualSelection(direction, extra_filter) range
let l:saved_reg = @"
execute "normal! vgvy"
let l:pattern = escape(@", '\\/.*$^~[]')
let l:pattern = substitute(l:pattern, "\n$", "", "")
if a:direction == 'b'
execute "normal ?" . l:pattern . "^M"
elseif a:direction == 'gv'
call CmdLine("vimgrep " . '/'. l:pattern . '/' . ' **/*.' . a:extra_filter)
elseif a:direction == 'replace'
call CmdLine("%s" . '/'. l:pattern . '/')
elseif a:direction == 'f'
execute "normal /" . l:pattern . "^M"
endif
let @/ = l:pattern
let @" = l:saved_reg
endfunction
function! StartUp()
execute 'NERDTree' getcwd()
endfunction
" change cursor depending on mode
if empty($TMUX)
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
let &t_SR = "\<Esc>]50;CursorShape=2\x7"
else
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
let &t_SR = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=2\x7\<Esc>\\"
endif
" Visual mode pressing * or # rearches for the current selection
" Super useful! From an idea by Michael Naumann
vnoremap <silent> * :call VisualSelection('f', '')<CR>
vnoremap <silent> # :call VisualSelection('b', '')<CR>
" When you press <leader>r you can search and replace the selected text
vnoremap <silent> <leader>r :call VisualSelection('replace', '')<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment