257 lines
7.8 KiB
VimL
257 lines
7.8 KiB
VimL
execute pathogen#infect()
|
|
|
|
" Setup {{
|
|
filetype plugin on
|
|
set nocompatible
|
|
set shortmess+=filmnrxoOtT
|
|
" }}
|
|
|
|
" Plugins {{
|
|
" }}
|
|
|
|
" General Settings {{
|
|
scriptencoding utf-8
|
|
|
|
" 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 foldmethod=syntax " Fold based on syntax
|
|
|
|
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
|
|
" }}
|
|
|
|
" 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"
|
|
" }}
|
|
|
|
" Java {{
|
|
" let java_highlight_all=1
|
|
" let java_highlight_functions="style"
|
|
" let java_allow_cpp_keywords=1
|
|
" }}
|
|
|
|
" JSON {{
|
|
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>
|
|
let g:vim_json_syntax_conceal = 0
|
|
" }}
|
|
|
|
" Misc Things {{
|
|
" Vimwiki {{
|
|
let g:vimwiki_list = [{'path': '~/Dropbox/Documents/vimwiki/vimwiki', 'path_html': '~/Dropbox/Documents/vimwiki/vimwiki_html/', 'auto_export':'1'}]
|
|
nnoremap <leader>wb :Vimwiki2HTMLBrowse<CR><CR>
|
|
let g:vimwiki_auto_checkbox = 1
|
|
" }}
|
|
|
|
" Gist {{
|
|
let g:gist_detect_filetype = 1
|
|
let g:gist_open_browser_after_post = 1
|
|
let g:gist_post_private = 1
|
|
" }}
|
|
|
|
" Scratch File {{
|
|
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
|
|
" }}
|
|
" }}
|
|
|
|
" Mappings and Macros {{
|
|
" expand_region {{
|
|
vmap v <Plug>(expand_region_expand)
|
|
vmap <C-v> <Plug>(expand_region_shrink)
|
|
" }}
|
|
|
|
" 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>
|
|
" }}
|
|
|
|
" Find merge-conflict markers {{
|
|
map <leader>fc /\v^[<\|=>]{7}( .*\|$)<CR>
|
|
" }}
|
|
|
|
" 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
|
|
" }}
|
|
|