vim-castle/home/.vimrc

315 lines
9.6 KiB
VimL
Raw Normal View History

execute pathogen#infect()
" Setup {{
filetype plugin on
set nocompatible
set shortmess+=filmnrxoOtT
" }}
" General Settings {{
scriptencoding utf-8
set foldmethod=manual
2017-03-01 13:55:06 +00:00
set ai
2017-02-06 15:42:39 +00:00
" Disable Ex Mode
map Q <nop>
" VimCrypt encryption method
set cm=blowfish2
" Views, Backups, Swap, Info, and Undo files {{
set viminfo+=n~/.vim/viminfo
set history=1000
set backup
set undofile
set undolevels=1000
set undoreload=10000
" Make directories for backups, swap, views, and undo
" Also set appropriate settings to use those dirs
function! InitializeDirectories()
let base_dir = $HOME . '/.vim'
let dir_list = {
\ 'backups': 'backupdir',
\ 'views': 'viewdir',
\ 'swaps': 'directory',
\ 'undos': 'undodir' }
for [dirname, settingname] in items(dir_list)
let directory = base_dir . '/' . dirname . '/'
if exists("*mkdir")
if !isdirectory(directory)
call mkdir(directory)
endif
endif
if !isdirectory(directory)
echo "Warning: Unable to create directory: " . directory
echo "Try: mkdir -p " . directory
else
let directory = substitute(directory, " ", "\\\\ ", "g")
exec "set " . settingname . "=" . directory
endif
endfor
endfunction
call InitializeDirectories()
" }}
" }}
" Text Formatting {{
function! SetTabWidth(width)
exec "set shiftwidth=" . a:width
exec "set tabstop=" . a:width
exec "set softtabstop=" . a:width
endfunction
set expandtab " Tabs are spaces
call SetTabWidth(2) " I use columns of 2 spaces
set list
set listchars=tab:\ \ ,trail:•,extends:#,nbsp:.
" }}
" Search {{
set incsearch " Find as you type
set hlsearch " Highlight search terms
set ignorecase " Case insensitive
set smartcase " Case sensitive when uppercase chars are present
" Hit backspace in normal mode to clear hlsearch
nmap <silent> <BS> :nohlsearch<CR>
" }}
set number
set norelativenumber
set timeout ttimeoutlen=50
set mouse= " No mouse support
set pastetoggle=<F12> " F12 to enable pastetoggle (sane indentation on pastes)
set nospell " No spell checking
" Disable bells
set noerrorbells visualbell t_vb=
if has('autocmd')
autocmd GUIEnter * set visualbell t_vb=
endif
" Tabs and Buffers {{
set tabpagemax=15 " Only show 15 tabs
set hidden " Allow buffer switching without saving
" }}
set cursorline " Highlight current line
set backspace=indent,eol,start " Backspace for dummies
set linespace=0 " No extra spaces between rows
set winminheight=0 " Windows can be 0 lines high
set wildmenu " Show list instead of just completing
set wildmode=list:longest,full " Command <Tab> completion, list matches,
" then longest common part, then all
set whichwrap= " Don't go to previous lines when going left/right
set scrolljump=5 " Lines to scroll when cursor leaves screen
set scrolloff=2 " Minimum lines to keep above/below cursor
set nofoldenable " Don't auto-fold code
set nowrap " Don't wrap long lines
set nojoinspaces " Prevents inserting two spaces after punctiuation on
" a join (J)
set splitright " Puts new vsplit windows to the right of current
set splitbelow " Puts new split windows to the bottom of current
set showmatch " Show matchign brackets/parens
set matchpairs+=<:> " Match < and > with %
set formatoptions+=j " Remove comment leaders when joining lines in comments
autocmd BufNewFile,BufRead * setlocal formatoptions-=cro " Do not add comment leaders on new lines
" }}
" Colors and UI {{
syntax on
set colorcolumn=120 " Visual indicator on column 120
" Status line {{
set laststatus=2 " Always show status line
set statusline=%f " Path to the file
set statusline+=%< " If status line is too long, truncate here
set statusline+=\ %y " File type, e.g. [go]
set statusline+=%r " [RO] if read-only
set statusline+=%m " [+] if modified
set statusline+=%= " Switch to right side
set statusline+=%p%% " % through file in lines
set statusline+=\ %l,%c " Line, Col numbers
set showmode " Show current mode below the status line on left side
" (when not in normal mode)
set showcmd " Show partial commands below the status line on the
" right (and selected chars/lines in visual mode)
" }}
" Colorscheme {{
let g:nofrils_heavycomments=1
let g:nofrils_heavylinenumbers=1
set background=dark
colorscheme nofrils-dark
" }}
" }}
" Utility {{
" Vim REST Console {{
let g:vrc_trigger = '<leader>r'
" }}
" Tagbar {{
nnoremap <silent> <leader>tt :TagbarToggle<CR>
let g:tagbar_autofocus = 1
let g:tagbar_autoclose = 1
" }}
" }}
" Go {{
" Convenient mappings for all Go things
au FileType go nmap <leader>r :GoRun!<CR>
au FileType go nmap <leader>e <Plug>(go-rename)
au FileType go nmap <leader>s <Plug>(go-implements)
au FileType go nmap <leader>t :GoTest!<CR>
au FileType go nmap <leader>c <Plug>(go-coverage)
au FileType go nmap <leader>v <Plug>(go-vet)
au FileType go nmap <leader>gd <Plug>(go-doc)
au FileType go nmap <leader>d :GoDef<CR>
au FileType go nmap <leader>D :GoDescribe<CR>
" Use `goimports` instead of `gofmt`
let g:go_fmt_command = "goimports"
2015-01-14 23:28:12 +00:00
" }}
" Java {{
" let java_highlight_all=1
" let java_highlight_functions="style"
" let java_allow_cpp_keywords=1
2015-01-14 23:28:12 +00:00
" }}
2015-01-22 15:07:51 +00:00
" JSON {{
2015-01-22 15:07:51 +00:00
nmap <leader>jt <Esc>:%!python -m json.tool<CR><Esc>:set filetype=json<CR>
nmap <leader>jT <Esc>:.!python -m json.tool<CR><Esc>:set filetype=json<CR>
2015-01-22 15:07:51 +00:00
let g:vim_json_syntax_conceal = 0
" }}
2015-02-05 00:03:08 +00:00
" Misc Things {{
" Vimwiki {{
2017-02-01 20:43:30 +00:00
let g:vimwiki_list = [
\{'path': '~/Dropbox/Documents/vimwiki/vimwiki', 'path_html': '~/Dropbox/Documents/vimwiki/vimwiki_html/', 'auto_export':'1'},
\{'path': '~/Dropbox/Documents/vimwiki/work', 'path_html': '~/Dropbox/Documents/vimwiki/work_html/', 'auto_export':'1'},
\{'path': '~/Dropbox/Documents/vimwiki/redemption', 'path_html': '~/Dropbox/Documents/vimwiki/redemption_html/', 'auto_export':'1'}
2017-02-01 20:43:30 +00:00
\]
nnoremap <leader>wb :Vimwiki2HTMLBrowse<CR><CR>
let g:vimwiki_auto_checkbox = 1
2017-01-02 18:10:47 +00:00
function! VimwikiLinkHandler(link)
let link = a:link
if link =~# '^vfile:'
let link = link[1:]
else
return 0
endif
let link_infos = vimwiki#base#resolve_link(link)
if link_infos.filename == ''
echomsg 'Vimwiki Error: Unable to resolve link!'
return 0
else
exe 'e ' . fnameescape(link_infos.filename)
return 1
endif
endfunction
nmap <C-k> <Plug>VimwikiDiaryPrevDay
nmap <C-j> <Plug>VimwikiDiaryNextDay
" }}
" Gist {{
let g:gist_detect_filetype = 1
let g:gist_open_browser_after_post = 1
let g:gist_post_private = 1
" }}
" Scratch File {{
2017-02-01 20:43:30 +00:00
" nmap <leader>sc :Scratch<CR>
" nmap <leader>cc :Sscratch<CR>
" }}
" Show syntax highlighting groups for word under cursor {{
" From http://stackoverflow.com/a/7893500/859353
nmap <leader>sn :call <SID>SynStack()<CR>
function! <SID>SynStack()
if !exists("*synstack")
return
endif
echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
endfunc
" }}
" Syntastic Settings {{
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
let g:syntastic_javascript_checkers = ['eslint']
let g:syntastic_go_checkers = ['golint', 'govet', 'errcheck']
let g:syntastic_mode_map = { 'mode': 'active', 'passive_filetypes': ['go'] }
2017-02-01 20:43:30 +00:00
nmap <leader>st :SyntasticToggleMode<CR>
nmap <leader>sc :SyntasticCheck<CR>
" }}
2017-05-03 12:50:52 +00:00
" Vimux {{
map <Leader>vp :VimuxPromptCommand<CR>
map <Leader>vl :VimuxRunLastCommand<CR>
map <Leader>vi :VimuxInspectRunner<CR>
map <Leader>vz :VimuxZoomRunner<CR>
" }}
2015-02-05 00:03:08 +00:00
" }}
2015-06-04 15:13:29 +00:00
" Mappings and Macros {{
" expand_region {{
vmap v <Plug>(expand_region_expand)
vmap <C-v> <Plug>(expand_region_shrink)
" }}
2015-06-04 15:13:29 +00:00
" Code Folding Options {{
nmap <leader>f0 :set foldlevel=0<CR>
nmap <leader>f1 :set foldlevel=1<CR>
nmap <leader>f2 :set foldlevel=2<CR>
nmap <leader>f3 :set foldlevel=3<CR>
nmap <leader>f4 :set foldlevel=4<CR>
nmap <leader>f5 :set foldlevel=5<CR>
nmap <leader>f6 :set foldlevel=6<CR>
nmap <leader>f7 :set foldlevel=7<CR>
nmap <leader>f8 :set foldlevel=8<CR>
nmap <leader>f9 :set foldlevel=9<CR>
" }}
2015-06-04 15:13:29 +00:00
" Find merge-conflict markers {{
map <leader>fc /\v^[<\|=>]{7}( .*\|$)<CR>
" }}
2015-06-04 15:13:29 +00:00
" Allow the repeat operator on visual selsections {{
vnoremap . :normal .<CR>
" }}
" }}
" Overrides {{
" Hook for local (user) changes
"if filereadable(expand("~/.vimrc.local"))
" source ~/.vimrc.local
"endif
" Hook for local (directory) changes
if filereadable(glob("./.vimrc.local"))
source ./.vimrc.local
endif
" }}
2016-06-07 15:43:27 +00:00
" Date/Time Shortcuts {{
nnoremap <F5> "=strftime("%Y-%m-%d")<CR>P"
inoremap <F5> <C-R>=strftime("%Y-%m-%d")<CR>
nnoremap <F6> "=strftime("%H:%M:%S")<CR>P"
inoremap <F6> <C-R>strftime("%H:%M:%S")<CR>
" }}