Permalink
Fetching contributors…
Cannot retrieve contributors at this time
214 lines (187 sloc) 6.26 KB
let mapleader = " " " Spacebar
set autoindent
set autowrite " Automatically :write before running commands
set backspace=2 " Backspace deletes like most programs in insert mode
set colorcolumn=+1
set complete+=kspell " Include spellfile in completion results
set diffopt+=vertical " Always use vertical diffs
set expandtab
set exrc " http://andrew.stwrt.ca/posts/project-specific-vimrc/
set history=50
set incsearch
set laststatus=2 " Always display status line
set list listchars=tab:»·,trail:·,nbsp:·
set nobackup
set nojoinspaces " Use one space, not two, after punctuation
set noswapfile
set nowritebackup
set number
set numberwidth=5
set ruler " Ahow cursor position all the time
set shiftround
set shiftwidth=2
set showcmd " Display incomplete commands
set splitbelow
set splitright
set tabstop=2
set textwidth=80
if &compatible
set nocompatible
end
" Open vim-plug without a vertical split
let g:plug_window='enew'
call plug#begin('~/.vim/plugged')
Plug '/usr/local/opt/fzf'
Plug 'AndrewRadev/splitjoin.vim'
Plug 'fatih/vim-go', { 'do': ':GoInstallBinaries' }
Plug 'hashivim/vim-terraform'
Plug 'janko-m/vim-test'
Plug 'junegunn/fzf.vim'
Plug 'junegunn/vim-easy-align'
Plug 'leafgarland/typescript-vim'
Plug 'mxw/vim-jsx'
Plug 'nicholaides/words-to-avoid.vim'
Plug 'pangloss/vim-javascript'
Plug 'pbrisbin/vim-mkdir'
Plug 'tpope/vim-endwise'
Plug 'tpope/vim-eunuch'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-projectionist'
Plug 'tpope/vim-rails'
Plug 'vim-ruby/vim-ruby'
Plug 'vim-scripts/tComment'
Plug 'w0rp/ale'
call plug#end()
augroup vimrcEx
autocmd!
" When editing a file, always jump to the last known cursor position.
" Don't do it for commit messages, when the position is invalid, or when
" inside an event handler (happens when dropping a file on gvim).
autocmd BufReadPost *
\ if &ft != 'gitcommit' && line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
" ALE linting events
set updatetime=1000
let g:ale_lint_on_enter = 1
let g:ale_lint_on_text_changed = 0
augroup END
" Use fzf for finding files
nmap <C-p> :Files<CR>
" Use ag for searching files
nmap \ :Ag<SPACE>
set grepprg=ag\ --nogroup\ --nocolor
" Search word under cursor
nmap <Leader>k :grep! "\b<C-R><C-W>\b"<CR>:cw<CR>
" Tab completion
" will insert tab at beginning of line,
" will use completion if not at beginning
set wildmode=list:longest,list:full
function! InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<Tab>"
else
return "\<C-p>"
endif
endfunction
inoremap <Tab> <C-r>=InsertTabWrapper()<CR>
inoremap <S-Tab> <C-n>
" Switch between the last two files
nnoremap <leader><leader> <C-^>
" vim-test mappings
nnoremap <silent> <Leader>t :TestFile<CR>
nnoremap <silent> <Leader>s :TestNearest<CR>
nnoremap <silent> <Leader>l :TestLast<CR>
" Test && Commit || Revert
nnoremap <silent> <Leader>c :!clear && tcr<CR>
" Treat <li> and <p> tags like the block tags they are
let g:html_indent_tags = 'li\|p'
" Quicker window movement
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-h> <C-w>h
nnoremap <C-l> <C-w>l
" Exclude JavaScript files in :Rtags via rails.vim due to warnings when parsing
let g:Tlist_Ctags_Cmd="ctags --exclude='*.js'"
" Index ctags from any project, including those outside Rails
function! ReindexCtags()
let l:ctags_hook = '$(git rev-parse --show-toplevel)/.git/hooks/ctags'
if exists(l:ctags_hook)
exec '!'. l:ctags_hook
else
exec "!ctags -R ."
endif
endfunction
nmap <Leader>ct :call ReindexCtags()<CR>
" Colors
hi clear
if version > 580
if exists("syntax_on")
syntax reset
endif
endif
" Black
hi IncSearch ctermfg=16 ctermbg=189 cterm=NONE
hi Label ctermfg=16
hi MatchParen ctermfg=16 ctermbg=189 cterm=NONE
hi Normal ctermfg=16 ctermbg=231 cterm=NONE
hi PmenuSel ctermfg=16 ctermbg=189 cterm=NONE
hi Search ctermfg=16 ctermbg=189 cterm=NONE
hi Statement ctermfg=16
hi StorageClass ctermfg=16
hi Structure ctermfg=16
hi TypeDef ctermfg=16
hi Underlined ctermfg=16 cterm=UNDERLINE
hi rubyDefine ctermfg=16
hi rubyMacro ctermfg=16
hi rubyValidation ctermfg=16
" Light gray
hi ColorColumn ctermbg=250 cterm=NONE
hi Comment ctermfg=250 cterm=NONE
hi Cursor ctermfg=250 ctermbg=238 cterm=NONE
hi CursorColumn ctermbg=250 cterm=NONE
hi CursorLine ctermbg=250 cterm=NONE
hi CursorLineNr ctermfg=250 ctermbg=253 cterm=NONE
hi Error ctermfg=250 ctermbg=196 cterm=NONE
hi Folded ctermfg=250 ctermbg=255 cterm=NONE
hi Ignore ctermfg=250 cterm=NONE
hi LineNr ctermfg=250 ctermbg=255 cterm=NONE
hi NonText ctermfg=250 ctermbg=255 cterm=NONE
hi Pmenu ctermfg=250 ctermbg=244
hi PmenuSbar ctermfg=250 ctermbg=16 cterm=NONE
hi PmenuThumb ctermfg=250 ctermbg=248 cterm=NONE
hi PreProc ctermfg=250
hi SpecialKey ctermfg=250 ctermbg=196 cterm=NONE
hi StatusLine ctermfg=250 ctermbg=255
hi StatusLineNC ctermfg=250 ctermbg=255 cterm=NONE
hi TabLine ctermfg=250 ctermbg=253 cterm=NONE
hi TabLineFill ctermfg=250 ctermbg=253 cterm=NONE
hi TabLineSel ctermfg=250
hi Todo ctermfg=250 ctermbg=88
hi VertSplit ctermfg=250 ctermbg=250 cterm=NONE
hi Visual ctermfg=250 ctermbg=61 cterm=NONE
hi VisualNOS ctermfg=250 ctermbg=24 cterm=NONE
hi gitCommitDiff ctermfg=250 cterm=NONE
" Pink
hi DiffDelete ctermfg=161 cterm=NONE
hi Directory ctermfg=161 cterm=NONE
hi Function ctermfg=161
hi ModeMsg ctermfg=161 cterm=NONE
hi MoreMsg ctermfg=161 cterm=NONE
hi String ctermfg=161 cterm=NONE
hi Title ctermfg=161 cterm=NONE
hi WarningMsg ctermfg=161 cterm=NONE
hi diffRemoved ctermfg=161 cterm=NONE
hi rubySymbol ctermfg=161 cterm=NONE
" Turquoise
hi Constant ctermfg=30 cterm=NONE
hi DiffAdd ctermfg=30 ctermbg=194 cterm=NONE
hi Identifier ctermfg=30 cterm=NONE
hi Number ctermfg=30 cterm=NONE
hi Special ctermfg=30
hi Type ctermfg=30
hi WildMenu ctermfg=30 ctermbg=60 cterm=NONE
hi diffAdded ctermfg=30 cterm=NONE
" Disable spelling by default, enable per-filetype
autocmd BufRead setlocal nospell