" ================================================================== " ~/.vimrc " Author: Dongsu Park " ================================================================== version 7.0 " ============================ " Loading general setup files " ============================ if has("unix") " Source the setup file for all users: let FILE=expand("~/.vimrc.foralls") if filereadable(FILE) exe "source " . FILE endif endif " ============== " General settings " ============== colorscheme desert filetype on filetype plugin on filetype indent on syntax on :if &term == "xterm" : set t_kb= : fixdel :endif " =================== " Setting of Options " =================== set noautoindent set background=dark set backspace=indent,eol,start set nocindent set nocp set cinoptions=:0,#0 set expandtab set fileencodings=utf-8,iso-8859-1 set hlsearch set indentkeys=0{,0},0),:,!^F,o,O,e set nojoinspaces set linebreak set magic set ruler set shiftwidth=4 set nosmartindent set smarttab set noshowcmd set noshowmatch set tabstop=4 set wildmenu set wrap " this mapping is very very crucial. otherwise, the buffer and file " explorer area will keep jumping all over the place. very very annoying " if that happens. if has(":vsplit") set ea set eadirection=ver end " ============== " Autocommands " ============== autocmd FileType sh set noexpandtab|set tabstop=8|set shiftwidth=8|set autoindent|set smartindent augroup dotconfig autocmd BufRead,BufNewFile .* set noexpandtab|set tabstop=8|set shiftwidth=8|set autoindent|set smartindent augroup END augroup cfile " default settings autocmd BufRead,BufNewFile *.{c,h,cpp,hx} set expandtab|set tabstop=4|set shiftwidth=4|set textwidth=78|set cindent " kernel source files autocmd BufRead,BufNewFile */linux*/*.{c,h,cpp,hx} set noexpandtab|set tabstop=8|set shiftwidth=8 " systemd source files autocmd BufRead,BufNewFile */systemd*/*.{c,h,cpp,hx} set tabstop=8|set shiftwidth=8 autocmd BufRead,BufNewFile */casync*/*.{c,h,cpp,hx} set tabstop=8|set shiftwidth=8 " qemu source files autocmd BufRead,BufNewFile */qemu*/*.{c,h,cpp,hx} set tabstop=4|set shiftwidth=4 augroup END autocmd FileType diff set noexpandtab|set tabstop=8|set shiftwidth=8|set autoindent|set smartindent autocmd FileType html set isk+=:,/,~ autocmd FileType java set expandtab|set autoindent|set smartindent autocmd FileType json set expandtab|set tabstop=2|set shiftwidth=2|set autoindent|set smartindent autocmd FileType make set noexpandtab|set tabstop=8|set shiftwidth=8|set autoindent|set smartindent autocmd FileType perl set expandtab|set autoindent|set nosmartindent autocmd FileType python set expandtab|set autoindent|set nosmartindent autocmd FileType ruby set expandtab|set autoindent|set nosmartindent autocmd FileType toml set expandtab|set tabstop=2|set shiftwidth=2|set autoindent|set smartindent autocmd FileType yaml set expandtab|set tabstop=2|set shiftwidth=2|set autoindent|set smartindent " ============== " Autocommands Group " ============== augroup Binary au! au BufReadPre *.bin let &bin=1 au BufReadPost *.bin if &bin | %!xxd au BufReadPost *.bin set ft=xxd | endif au BufWritePre *.bin if &bin | %!xxd -r au BufWritePre *.bin endif au BufWritePost *.bin if &bin | %!xxd au BufWritePost *.bin set nomod | endif augroup END " =================== " Functions " =================== function s:FindFile(file) let curdir = getcwd() let found = curdir while !filereadable(a:file) && found != "/" cd .. let found = getcwd() endwhile execute "cd " . fnameescape(curdir) return found endfunction " =================== " Cscope " =================== map g :cs find 0 =expand("") map s :cs find 0 =expand("") map :GotoBufExplorerWindow map :GotoFileExplorerWindow "I've installed the Enhanced Commentify Plugin of vim! let g:EnhCommentifyUseAltKeys = 'Yes' " =================== " Ctags " =================== let $CTAGS_DIR = s:FindFile("tags") let $CTAGS_DB = $CTAGS_DIR."/tags" if filereadable($CTAGS_DB) set tags+=$CTAGS_DB endif command -nargs=0 Ctags !ctags -R & " =================== " EnhancedCommentify " =================== let ECFILE="~/.vim/plugin/EnhancedCommentify.vim" if filereadable(ECFILE) source ECFILE endif nmap Traditionalj imap Traditionalji vmap Traditional nmap Traditionalj imap Traditionalji vmap Traditional map a/**/ imap a/**/i map i imap i nmap :TagBarToggle inoremap :set imdisable nnoremap i :set noimdi nnoremap I :set noimdI nnoremap a :set noimda nnoremap A :set noimdA nnoremap o :set noimdo nnoremap O :set noimdO " pathogen source ~/.vim/autoload/pathogen.vim execute pathogen#infect() " =================== " Fugitive " =================== let FTFILE="~/.vim/plugin/fugitive.vim" if filereadable(FTFILE) source FTFILE endif " ====================== " Vim plug " ====================== call plug#begin('~/.vim/plugged') " plug vim-go Plug 'ctrlpvim/ctrlp.vim' Plug 'fatih/vim-go' Plug 'jodosha/vim-godebug' call plug#end() " ====================== " vim-go mappings " ====================== au FileType go nmap r (go-run) au FileType go nmap b (go-build) au FileType go nmap t (go-test) au FileType go nmap c (go-coverage) au FileType go nmap ds (go-def-split) au FileType go nmap dv (go-def-vertical) au FileType go nmap dt (go-def-tab) au FileType go nmap gd (go-doc) au FileType go nmap gv (go-doc-vertical) au FileType go nmap gb (go-doc-browser) au FileType go nmap s (go-implements) au FileType go nmap i (go-info) au FileType go nmap e (go-rename) au FileType go nmap (go-def) au FileType go nmap s (go-callers) au FileType qf call AdjustWindowHeight(5, 10) function! AdjustWindowHeight(minheight, maxheight) exe max([min([line("$"), a:maxheight]), a:minheight]) . "wincmd _" endfunction let g:mapleader="," let g:go_fmt_autosave = 1 let g:go_def_mode = 'godef' let g:go_list_type = 'quickfix' let g:syntastic_go_checkers = 1 " ====================== " rust " ====================== let g:rustfmt_autosave = 1 set hidden let g:racer_cmd = '~/.cargo/bin/racer' au FileType rust nmap r (RustRun) au FileType rust nmap b (RustBuild) au FileType rust nmap gd (rust-def) au FileType rust nmap gs (rust-def-split) au FileType rust nmap gx (rust-def-vertical) au FileType rust nmap gd (rust-doc) au FileType rust nmap (rust-def) " ====================== " typescript " ====================== let g:typescript_compiler_binary = 'tsc' let g:typescript_compiler_options = '' au FileType typescript :set makeprg=tsc " ====================== " terraform " ====================== let g:terraform_align=1 au FileType terraform setlocal commentstring=#%s