Last active
February 25, 2020 10:52
-
-
Save neanias/467a3912d3b3196de995 to your computer and use it in GitHub Desktop.
Super basic (not so much anymore) vimrc, some shamelessly stolen from http://amix.dk/vim/vimrc.html
This file contains 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
set nocompatible " be iMproved, required | |
" Load vim-plug | |
if empty(glob("~/.vim/autoload/plug.vim")) | |
execute '!curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.github.com/junegunn/vim-plug/master/plug.vim' | |
endif | |
call plug#begin('~/.vim/plugged') | |
" Dependencies | |
Plug 'marcweber/vim-addon-mw-utils' | |
Plug 'tomtom/tlib_vim' | |
Plug 'mattn/webapi-vim' | |
" Auto-closing brackets :D | |
Plug 'Raimondi/delimitMate' | |
" TPope time | |
Plug 'tpope/vim-fugitive' | |
Plug 'tpope/vim-surround' | |
Plug 'tpope/vim-unimpaired' | |
Plug 'tpope/vim-rails', { 'for': ['ruby', 'eruby', 'haml', 'slim', 'coffee'] } | |
Plug 'tpope/vim-rake', { 'for': 'ruby' } | |
Plug 'tpope/vim-endwise' | |
Plug 'tpope/vim-abolish' | |
Plug 'tpope/vim-repeat' | |
" Better commenting | |
Plug 'scrooloose/nerdcommenter' | |
" Nice file browsing | |
Plug 'scrooloose/nerdtree' | |
Plug 'Xuyuanp/nerdtree-git-plugin' | |
Plug 'ctrlpvim/ctrlp.vim' | |
Plug 'mbbill/undotree' | |
" Check that it actually has ctags before kick-off | |
if executable('ctags') | |
Plug 'majutsushi/tagbar' | |
endif | |
" Snippets | |
Plug 'garbas/vim-snipmate' | |
Plug 'honza/vim-snippets' | |
Plug 'SirVer/ultisnips' | |
Plug 'ervandew/supertab' | |
" Syntax & languages | |
Plug 'dense-analysis/ale' | |
Plug 'sheerun/vim-polyglot' | |
Plug 'jmcantrell/vim-virtualenv' | |
" Pretty colours | |
Plug 'icymind/NeoSolarized' | |
Plug 'vim-scripts/TagHighlight' | |
Plug 'vim-airline/vim-airline' | Plug 'vim-airline/vim-airline-themes' | |
Plug 'gregsexton/gitv' | |
Plug 'junegunn/rainbow_parentheses.vim' | |
" Other stuff | |
Plug 'junegunn/vim-easy-align' | |
Plug 'AndrewRadev/splitjoin.vim' | |
Plug 'ck3g/vim-change-hash-syntax' | |
Plug 'mattn/gist-vim' | |
Plug 'nathanaelkane/vim-indent-guides' | |
Plug 'lucapette/vim-textobj-underscore' | Plug 'kana/vim-textobj-user' | |
Plug 'bogado/file-line' | |
Plug 'airblade/vim-gitgutter' | |
" Indexed search | |
Plug 'henrik/vim-indexed-search' | |
" Vim motions on speed | |
Plug 'easymotion/vim-easymotion' | |
Plug 'justinmk/vim-sneak' | |
" All of your Plugs must be added before the following line | |
call plug#end() " required | |
filetype plugin indent on " required | |
set number | |
set ruler | |
set autoindent | |
set smartindent | |
set expandtab | |
set smarttab | |
set showmode | |
set showcmd | |
set tabstop=4 | |
set shiftwidth=2 | |
set autoread | |
" Needed for solarized | |
set termguicolors | |
syntax enable | |
set hlsearch | |
set incsearch | |
set ignorecase | |
set smartcase | |
set lazyredraw | |
set magic | |
set showmatch | |
set mat=2 | |
set noswapfile | |
let mapleader="," | |
set so=8 | |
set wildignore=*.o,*~,*.pyc | |
set cmdheight=1 | |
set encoding=utf8 | |
set ffs=unix,dos,mac | |
" Fix backspace not working | |
set backspace=indent,eol,start | |
" Strip trailing whitespace in Python and Ruby files | |
autocmd BufWritePre *.py,*.rb :StripTrailingWhitespaces | |
set nowrap | |
vnoremap <silent> * :call VisualSelection('f')<CR> | |
vnoremap <silent> # :call VisualSelection('b')<CR> | |
" ==== NERD tree | |
" Cmd-Shift-N for nerd tree | |
nmap <D-N> :NERDTreeToggle<CR> | |
" Open the project tree and expose current file in the nerdtree with Ctrl-\ | |
nnoremap <silent> <C-\> :NERDTreeFind<CR>:vertical res 30<CR> | |
" Use Q to intelligently close a window | |
" (if there are multiple windows into the same buffer) | |
" or kill the buffer entirely if it's the last window looking into that buffer | |
function! CloseWindowOrKillBuffer() | |
let number_of_windows_to_this_buffer = len(filter(range(1, winnr('$')), "winbufnr(v:val) == bufnr('%')")) | |
" We should never bdelete a nerd tree | |
if matchstr(expand("%"), 'NERD') == 'NERD' | |
wincmd c | |
return | |
endif | |
if number_of_windows_to_this_buffer > 1 | |
wincmd c | |
else | |
bdelete | |
endif | |
endfunction | |
nnoremap <silent> Q :call CloseWindowOrKillBuffer()<CR> | |
" Rainbow brackets | |
au VimEnter * RainbowParantheses | |
" Tagbar | |
" open the taglist (method browser) using ,t | |
nnoremap <silent> ,T :TagbarToggle<CR> | |
let g:tagbar_type_ruby = { | |
\ 'kinds' : [ | |
\ 'm:modules', | |
\ 'c:classes', | |
\ 'd:describes', | |
\ 'C:contexts', | |
\ 'f:methods', | |
\ 'F:singleton methods' | |
\ ] | |
\ } | |
let g:tagbar_type_snippets = { | |
\ 'ctagstype' : 'snippets', | |
\ 'kinds' : [ | |
\ 's:snippets', | |
\ ] | |
\ } | |
let g:tagbar_type_haskell = { | |
\ 'ctagsbin' : 'hasktags', | |
\ 'ctagsargs' : '-x -c -o-', | |
\ 'kinds' : [ | |
\ 'm:modules:0:1', | |
\ 'd:data: 0:1', | |
\ 'd_gadt: data gadt:0:1', | |
\ 't:type names:0:1', | |
\ 'nt:new types:0:1', | |
\ 'c:classes:0:1', | |
\ 'cons:constructors:1:1', | |
\ 'c_gadt:constructor gadt:1:1', | |
\ 'c_a:constructor accessors:1:1', | |
\ 'ft:function types:1:1', | |
\ 'fi:function implementations:0:1', | |
\ 'o:others:0:1' | |
\ ], | |
\ 'sro' : '.', | |
\ 'kind2scope' : { | |
\ 'm' : 'module', | |
\ 'c' : 'class', | |
\ 'd' : 'data', | |
\ 't' : 'type' | |
\ }, | |
\ 'scope2kind' : { | |
\ 'module' : 'm', | |
\ 'class' : 'c', | |
\ 'data' : 'd', | |
\ 'type' : 't' | |
\ } | |
\ } | |
" Gist.vim | |
let g:gist_detect_filetype = 1 | |
" Open browser after gisting | |
let g:gist_open_browser_after_post = 1 | |
" Indent guides | |
let g:indent_guides_auto_colors = 1 | |
let g:indent_guides_start_level = 2 | |
let g:indent_guides_guide_size = 1 | |
" Handy key bindings for surrounding things | |
" ,# Surround a word with #{ruby interpolation} | |
map ,# ysiw# | |
vmap ,# c#{<C-R>"}<ESC> | |
" ," Surround a word with "quotes" | |
map ," ysiw" | |
vmap ," c"<C-R>""<ESC> | |
" ,' Surround a word with 'single quotes' | |
map ,' ysiw' | |
vmap ,' c'<C-R>"'<ESC> | |
" ,) or ,( Surround a word with (parens) | |
" The difference is in whether a space is put in | |
map ,( ysiw( | |
map ,) ysiw) | |
vmap ,( c( <C-R>" )<ESC> | |
vmap ,) c(<C-R>")<ESC> | |
" ,[ Surround a word with [brackets] | |
map ,] ysiw] | |
map ,[ ysiw[ | |
vmap ,[ c[ <C-R>" ]<ESC> | |
vmap ,] c[<C-R>"]<ESC> | |
" ,{ Surround a word with {braces} | |
map ,} ysiw} | |
map ,{ ysiw{ | |
vmap ,} c{ <C-R>" }<ESC> | |
vmap ,{ c{<C-R>"}<ESC> | |
map ,` ysiw` | |
" Sneak | |
nmap <Space> <Plug>SneakForward | |
" Easymotion | |
" This remaps easymotion to show us only the left | |
" hand home row keys as navigation options which | |
" may mean more typing to get to a particular spot | |
" but it'll all be isolated to one area of the keyboard | |
" Doesn't seem to work any longer... | |
"call EasyMotion#InitOptions({ | |
"\ 'leader_key' : '<Leader><Leader>' | |
"\ , 'keys' : 'fjdksewoavn' | |
"\ , 'do_shade' : 1 | |
"\ , 'do_mapping' : 1 | |
"\ , 'grouping' : 1 | |
"\ | |
"\ , 'hl_group_target' : 'Type' | |
"\ , 'hl_group_shade' : 'Comment' | |
"\ }) | |
nmap ,<ESC> ,,w | |
nmap ,<S-ESC> ,,b | |
" ================ Persistent Undo ================== | |
" Keep undo history across sessions, by storing in file. | |
" Only works all the time. | |
if has('persistent_undo') | |
silent !mkdir ~/.vim/backups > /dev/null 2>&1 | |
set undodir=~/.vim/backups | |
set undofile | |
endif | |
" Ctrl-P | |
if executable('ag') | |
" Use ag in CtrlP for listing files. Lightning fast and respects .gitignore | |
let g:ctrlp_user_command = 'ag %s --files-with-matches -g "" --ignore "\.git$\|\.hg$\|\.svn$"' | |
" ag is fast enough that CtrlP doesn't need to cache | |
let g:ctrlp_use_caching = 0 | |
else | |
" Fall back to using git ls-files if Ag is not available | |
let g:ctrlp_custom_ignore = '\.git$\|\.hg$\|\.svn$' | |
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files . --cached --exclude-standard --others'] | |
endif | |
" Default to filename searches - so that appctrl will find application | |
" controller | |
let g:ctrlp_by_filename = 1 | |
" Don't jump to already open window. This is annoying if you are maintaining | |
" several Tab workspaces and want to open two windows into the same file. | |
let g:ctrlp_switch_buffer = 0 | |
" We don't want to use Ctrl-p as the mapping because | |
" it interferes with YankRing (paste, then hit ctrl-p) | |
let g:ctrlp_map = ',t' | |
nnoremap <silent> ,t :CtrlP<CR> | |
" Syntastic settings | |
" mark syntax errors with :signs | |
let g:syntastic_enable_signs=1 | |
" automatically jump to the error when saving the file | |
let g:syntastic_auto_jump=0 | |
" show the error list automatically | |
let g:syntastic_auto_loc_list=1 | |
" don't care about warnings | |
let g:syntastic_quiet_messages = {'level': 'warnings'} | |
" UltiSnips | |
" ---- Differing split for UltiSnips ---- | |
let g:UltiSnipsEditSplit="vertical" | |
" ---- Changing keymaps for UltiSnips jumping ---- | |
let g:UltiSnipsExpandTrigger="<tab>" | |
let g:UltiSnipsJumpForwardTrigger="<tab>" | |
let g:UltiSnipsJumpBackwardTrigger="<s-tab>" | |
" Undotree | |
nnoremap <leader>u :UndotreeToggle<CR> | |
let g:undotree_WindowLayout = 3 | |
" Create window splits easier. The default | |
" way is Ctrl-w,v and Ctrl-w,s. I remap | |
" this to vv and ss | |
nnoremap <silent> vv <C-w>v | |
nnoremap <silent> ss <C-w>s | |
" Smart way to move between windows | |
map <C-j> <C-W>j | |
map <C-k> <C-W>k | |
map <C-h> <C-W>h | |
map <C-l> <C-W>l | |
" SplitJoin plugin | |
nmap sj :SplitjoinSplit<cr> | |
nmap sk :SplitjoinJoin<cr> | |
" Disable highlight when // is pressed | |
map <silent> // :noh<CR> | |
" Always show the status line | |
set laststatus=2 | |
" Format the status line | |
set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l\ Col:\ %c | |
" Remap VIM 0 to first non-blank character | |
map 0 ^ | |
" Move a line of text using ALT+[jk] or Comamnd+[jk] on mac | |
nmap <M-j> mz:m+<cr>`z | |
nmap <M-k> mz:m-2<cr>`z | |
vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z | |
vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z | |
" Unimpaired configuration | |
" Bubble single lines | |
nmap <C-Up> [e | |
nmap <C-Down> ]e | |
" Bubble multiple lines | |
vmap <C-Up> [egv | |
vmap <C-Down> ]egv | |
if has("mac") || has("macunix") | |
nmap <D-j> <M-j> | |
nmap <D-k> <M-k> | |
vmap <D-j> <M-j> | |
vmap <D-k> <M-k> | |
endif | |
" Pressing ,ss will toggle and untoggle spell checking | |
map <leader>ss :setlocal spell!<cr> | |
" --- Easy Align --- | |
" Start interactive EasyAlign in visual mode (e.g. vipga) | |
xmap ga <Plug>(EasyAlign) | |
" Start interactive EasyAlign for a motion/text object (e.g. gaip) | |
nmap ga <Plug>(EasyAlign) | |
" Remove the Windows ^M - when the encodings gets messed up | |
noremap <Leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm | |
" Pretty self-explanatory (function def further down) | |
command! StripTrailingWhitespaces call <SID>StripTrailingWhitespaces() | |
nmap ,w :StripTrailingWhitespaces<CR> | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" => Helper functions | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
function! CmdLine(str) | |
exe "menu Foo.Bar :" . a:str | |
emenu Foo.Bar | |
unmenu Foo | |
endfunction | |
function! VisualSelection(direction) 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 . '/' . ' **/*.') | |
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 | |
" Returns true if paste mode is enabled | |
function! HasPaste() | |
if &paste | |
return 'PASTE MODE ' | |
endif | |
return '' | |
endfunction | |
" via: http://rails-bestpractices.com/posts/60-remove-trailing-whitespace | |
" Strip trailing whitespace | |
function! <SID>StripTrailingWhitespaces() | |
" Preparation: save last search, and cursor position. | |
let _s=@/ | |
let l = line(".") | |
let c = col(".") | |
" Do the business: | |
%s/\s\+$//e | |
" Clean up: restore previous search history, and cursor position | |
let @/=_s | |
call cursor(l, c) | |
endfunction | |
" Colourful | |
set background=dark | |
colorscheme NeoSolarized |
This file contains 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
#!/bin/bash | |
cd ~ | |
echo "Linking .vimrc into home directory (~)" | |
ln -Fis ~/vimrc/.vimrc . | |
echo "Linking update_vimrc into home directory (~)" | |
ln -Fis ~/vimrc/update_vimrc . | |
echo | |
echo "Installing plugins" | |
exec vim +PlugInstall +qall | |
echo |
This file contains 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
#!/bin/bash | |
cd ~/vimrc | |
exec git stash -q | |
exec git pull --quiet | |
exec git stash pop -q | |
cd ~ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment