Created
August 18, 2017 21:26
-
-
Save dialtone/e6943debc781d11315b5d294a70ce51d to your computer and use it in GitHub Desktop.
.vimrc
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
"" install pathogen | |
call pathogen#infect() | |
set nocompatible " choose no compatibility with legacy vi | |
syntax enable | |
set encoding=utf-8 | |
set showcmd " display incomplete commands | |
"" Whitespace | |
set nowrap " don't wrap lines | |
set tabstop=4 | |
set shiftwidth=4 " a tab is two spaces (or set this to 4) | |
set expandtab " use spaces, not tabs (optional) | |
set backspace=indent,eol,start " backspace through everything in insert mode | |
set textwidth=9999 | |
"" Various | |
set ruler " show position in status line | |
if has("gui_running") | |
set cursorline " highlight current line | |
end | |
set number " line numbers | |
set list " show invisible chars | |
set listchars=tab:▸\ ,eol:¬,trail:·,extends:»,precedes:«,nbsp:· | |
set scrolloff=10 " unless not possible, don't reach the last line before scrolling | |
set sidescrolloff=10 | |
set visualbell " no sound | |
set t_vb= " and no sound | |
set antialias " better font | |
set clipboard=unnamed " Use the system clipboard | |
set laststatus=2 " basically enable vim status line | |
set autoread " autoreload files when there are no unsaved changes | |
set hidden | |
"" Searching | |
set hlsearch " highlight matches | |
set incsearch " incremental searching | |
set ignorecase " searches are case insensitive... | |
set smartcase " ... unless they contain at least one capital letter | |
set wildmenu " help with autocomplete commands | |
set wildmode=list:longest,full | |
set showmatch " show paren matching | |
set mat=5 " change duration of show | |
"" no backups | |
set nobackup | |
set nowritebackup | |
set noswapfile | |
"set backupdir=~/.vim/_backup " where to put backup files. | |
set directory=~/.vim/_temp " where to put swap files. | |
"" use comma as <Leader> key instead of backslash | |
let mapleader="," | |
"" double percentage sign in command mode is expanded | |
"" to directory of current file - http://vimcasts.org/e/14 | |
cnoremap %% <C-R>=expand('%:h').'/'<cr> | |
" Go back to previous buffer | |
nnoremap <leader><leader> <c-^> | |
" Change buffer in the current split | |
map <m-d-left> :bp<cr> | |
map <m-d-right> :bn<cr> | |
" Remap convenient vertical/horizontal split | |
map <leader>s :split<cr> | |
map <leader>v :vsplit<cr> | |
map <leader>u <c-w>q | |
map <leader>U <c-w><c-o> | |
" Remap buffer delete | |
map `` :bd<cr> | |
map `! :bd!<cr> | |
map <leader>` :bd!<cr> | |
" Remap autocomplete | |
inoremap <D-]> <c-n> | |
inoremap <D-[> <c-p> | |
" Remap moving between splits | |
nnoremap <c-j> <c-w>j | |
nnoremap <c-k> <c-w>k | |
nnoremap <c-h> <c-w>h | |
nnoremap <c-l> <c-w>l | |
colorscheme molokai | |
" take out the toolbar | |
set guioptions-=T | |
" Buffer history tree | |
nnoremap t :GundoToggle<CR> | |
" Wrap in certain cases. | |
function! s:setupWrapping() | |
set wrap | |
set wrapmargin=2 | |
set textwidth=72 | |
endfunction | |
""" | |
""" | |
""" Given path to a directory find the project root for it | |
""" defined as the first directory to have a given marker | |
""" such as .git/.hg/_darcs/.bzr and so on. | |
function! s:findroot(curr, markers, depth) | |
" Search all markers in the current directory | |
for marker in a:markers | |
let found = !empty(globpath(a:curr, marker)) | |
if !found && a:depth > 40 | |
return '' | |
endif | |
if found | |
return a:curr | |
endif | |
endfor | |
" Increase depth | |
let depth = a:depth + 1 | |
" get the parent and recurse | |
let parent = s:getparent(a:curr) | |
if parent != a:curr | |
return s:findroot(parent, a:markers, depth) | |
endif | |
endfunction | |
function! s:getparent(item) | |
let parent = substitute(a:item, '[\/][^\/]\+[\/:]\?$', '', '') | |
if parent == '' || match(parent, '[\/]') < 0 | |
let parent .= '/' | |
endif | |
return parent | |
endf | |
function! ProjectRoot(path) | |
let markers = ['root.dir','.git/','.hg/','_darcs/','.bzr/'] | |
let root = s:findroot(a:path, markers, 0) | |
if root == '' | |
return path | |
endif | |
return fnameescape(root) | |
endf | |
"""" | |
"""" | |
"" Some variants | |
if has("autocmd") | |
" In Makefiles, use real tabs, not tabs expanded to spaces | |
au FileType make set noexpandtab | |
" au FileType javascript set indentkeys="0{,0},:,0#,!^F,o,O,e,!^L" | |
au FileType rust set expandtab | |
au FileType rust set tabstop=4 | |
au FileType rust set shiftwidth=4 | |
" Make sure all markdown files have the correct filetype set and setup wrapping | |
au BufRead,BufNewFile *.{md,markdown,mdown,mkd,mkdn,txt} set filetype=markdown | call s:setupWrapping() | |
" Treat JSON files like JavaScript | |
au BufNewFile,BufRead *.json set ft=javascript | |
" Remember last location in file, but not for commit messages. | |
" see :help last-position-jump | |
au BufReadPost * if &filetype !~ '^git\c' && line("'\"") > 0 && line("'\"") <= line("$") | |
\| exe "normal! g`\"" | endif | |
" This calls projectRoot and sets it to the root of the file currently open | |
au BufEnter * silent! exec "lcd ".ProjectRoot(expand("%:p:h")) | |
endif | |
" don't use Ex mode, use Q for formatting | |
map Q gq | |
" clear the search buffer when hitting return | |
nnoremap <CR> :nohlsearch<cr> | |
" turn on tagbar | |
nmap m :TagbarToggle<CR> | |
" No idea what this does but nobody should care about .pyc files | |
set wildignore+=*.pyc | |
" Get rid of extra white space | |
command! KillWhitespace :normal :%s/ *$//g<cr><c-o><cr> | |
" ^F is an awful combination for this strict indent... Better to use ^L | |
set indentkeys+=:!^L | |
" vim-python-combined with all highlights | |
let python_highlight_all=1 | |
" w!! if you forget to sudo before saving | |
cmap w!! w !sudo tee % >/dev/null | |
" Turn on immediate autocomplete | |
let g:neocomplete#enable_at_startup = 1 | |
" Use goimports instead of gfmt | |
let g:go_fmt_command = "goimports" | |
" golang tagbar config | |
let g:tagbar_type_go = {'ctagstype': 'go', 'kinds': ['p:package', 'i:imports:1', 'c:constants', 'v:variables', 't:types', 'n:interfaces', 'w:fields', 'e:embedded', 'm:methods', 'r:constructor', 'f:functions'], 'sro' : '.', 'kind2scope' : {'t' : 'ctype', 'n' : 'ntype'}, 'scope2kind' : {'ctype' : 't', 'ntype' : 'n'}, 'ctagsbin': 'gotags', 'ctagsargs' : '-sort -silent'} | |
" map the buffer list | |
map ; :ls<CR> | |
" bernie: search for highlighted text | |
:vmap // y/<C-R>"<CR> | |
let g:ctrlp_custom_ignore = { | |
\ 'dir': '\v(\.git|\.hg|\.svn|\.eunit|\.sass-cache|build|tmp|log|deps|ebin|rails|gems|node_modules|build)', | |
\ 'file': '\v(\.#.+|\.DS_Store|\.svn|\.png|\.jpe?g|\.gif|\.elc|\.rbc|\.html\.py|\.pyc|\.swp|\.psd|\.ai|\.pdf|\.mov|\.aep|\.dmg|\.zip|\.gz|\.beam|rebar)$', | |
\ } | |
let g:ctrlp_working_path_mode = 'wa' | |
let g:ctrlp_map = '<leader>p' | |
" change directory | |
command! Adroll :lcd ~/dev/Adroll/adroll | |
command! Dyno :lcd ~/dev/Adroll/dyno | |
command! S3cripts :lcd ~/dev/Adroll/s3scripts | |
command! Kinetic :lcd ~/dev/Adroll/kinetic | |
" piro: fix broken Page Up/Down | |
" http://vimrc-dissection.blogspot.com/2009/02/fixing-pageup-and-pagedown.html | |
map <silent> <PageUp> 1000<C-U> | |
map <silent> <PageDown> 1000<C-D> | |
imap <silent> <PageUp> <C-O>1000<C-U> | |
imap <silent> <PageDown> <C-O>1000<C-D> | |
set nostartofline | |
filetype plugin indent on " load file type plugins + indentation | |
if has('gui_running') | |
set guifont=Inconsolata\ for\ Powerline:h15 | |
"set guifont=Sauce\ Code\ Powerline\ Light:h11 | |
python from powerline.vim import setup as powerline_setup | |
python powerline_setup() | |
python del powerline_setup | |
endif | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment