diff options
author | Jesse Luehrs <doy@tozt.net> | 2017-10-29 17:44:43 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2017-10-29 19:03:53 -0400 |
commit | cf56205e0bb0382595425f077bd272e08b1779f3 (patch) | |
tree | f3e3d2d57978c155bfb97f0f679358fadec62e88 /vim | |
parent | d9fd53a62b8fe7698400610d81456e5e3d9461ef (diff) | |
download | conf-cf56205e0bb0382595425f077bd272e08b1779f3.tar.gz conf-cf56205e0bb0382595425f077bd272e08b1779f3.zip |
split out my settings into a plugin too
Diffstat (limited to 'vim')
-rw-r--r-- | vim/ftplugin/c.vim | 1 | ||||
-rw-r--r-- | vim/ftplugin/cpp.vim | 1 | ||||
-rw-r--r-- | vim/plugin/opinionated-defaults.vim | 154 |
3 files changed, 156 insertions, 0 deletions
diff --git a/vim/ftplugin/c.vim b/vim/ftplugin/c.vim new file mode 100644 index 0000000..13c7d4a --- /dev/null +++ b/vim/ftplugin/c.vim @@ -0,0 +1 @@ +setlocal cinoptions+=:0,l1,g0,(0,W1s diff --git a/vim/ftplugin/cpp.vim b/vim/ftplugin/cpp.vim index 073956b..83d7802 100644 --- a/vim/ftplugin/cpp.vim +++ b/vim/ftplugin/cpp.vim @@ -1 +1,2 @@ let b:load_doxygen_syntax = 1 +setlocal cinoptions+=:0,l1,g0,(0,W1s diff --git a/vim/plugin/opinionated-defaults.vim b/vim/plugin/opinionated-defaults.vim new file mode 100644 index 0000000..54341fc --- /dev/null +++ b/vim/plugin/opinionated-defaults.vim @@ -0,0 +1,154 @@ +""" GENERAL """ +set nocompatible +syntax on +filetype indent plugin on +augroup opinionated_defaults + autocmd! +augroup END + + +""" PERSISTENCE """ + +" remember as many history items as possible (command, search, etc) +set history=10000 +" enable persistent undo (undo even after closing and reopening vim) +if has('persistent_undo') + let s:undocachedir = $HOME . '/.cache/vim/undo' + if !isdirectory(s:undocachedir) + call mkdir(s:undocachedir, 'p') + endif + exe "set undodir=" . s:undocachedir + set undofile +endif + + +""" BUFFERS """ + +" automatically write the buffer before :make, shell commands, etc +set autowrite +" ask to save modified buffers when quitting, instead of throwing an error +set confirm +" allow switching to other buffers when the current one is modified +set hidden +" these two restore the last known cursor position when a buffer is loaded +set nostartofline +autocmd opinionated_defaults BufReadPost * + \ if line("'\"") <= line('$') | + \ exe 'normal! g`"' | + \ endif + + +""" DISPLAY """ + +" show as much of a line as possible if it doesn't all fit on the screen +set display+=truncate +" more useful display of nonprinting characters (<07> instead of ^G) +set display+=uhex +" don't redraw in the middle of noninteractive commands (maps, macros, etc) +set lazyredraw +" always give a message for the number of lines delete/changed +set report=0 +" keep some additional context visible when scrolling +set scrolloff=5 +if has('cmdline_info') + " display the current partial command and size of the visual selection + set showcmd +endif +if has('conceal') + " enable syntax-specific hiding of text + set conceallevel=2 +endif +if has('linebreak') + " display a marker when a line was wrapped + set showbreak=> +endif + + +""" EDITING """ + +" automatically use an indent that matches the previous line +set autoindent +" allow backspacing over everything +set backspace=indent,eol,start +" remove leading comment characters intelligently when joining lines +set formatoptions+=j +" always join with a single space, even between sentences +set nojoinspaces +" try to always keep indentation lined up on shiftwidth boundaries +set shiftround +" keep softtabstop and shiftwidth in sync +set softtabstop=-1 + + +""" COMMAND MODE """ + +" make command mode completion work more like the shell: +" first, complete the longest common sequence, +" then show a list, +" then cycle through completing the full names in the list in order +set wildmode=longest,list,full +if exists('+wildignorecase') + " make command mode completion case insensitive + set wildignorecase +endif + + +""" SEARCH """ + +" make searches case-insensitive +set ignorecase +" unless they include a capital letter +set smartcase +if has('extra_search') + " highlight all matches when searching + set hlsearch +endif + + +""" TERMINAL STUFF """ + +" wait a much shorter amount of time for escape sequences +" (this makes <Esc> much more responsive) +set ttimeoutlen=50 +" send text to the terminal in such a way that line wrapping is done at the +" terminal level, so copying and pasting wrapped lines works correctly +" (assuming you temporarily unset showbreak) +set ttyfast +" entirely disable error bells: +" make all bells visual bells +set visualbell +" and then disable visual bells +set t_vb= + + +""" COLORS """ + +" force vim to use 256 colors +" (it typically can't detect this while in screen/tmux since TERM=screen +" doesn't advertise it, even though ~everything does support it these days) +set t_Co=256 +" globally highlight diff conflict markers +match ErrorMsg '^\(<\||\|=\|>\)\{7\}\([^=].\+\)\?$' +" override some obnoxious default color choices +highlight Folded NONE ctermfg=darkgreen guifg=green +highlight Search NONE ctermfg=red guifg=red + + +""" MAPPINGS """ + +" keep the current selection when indenting +xnoremap < <gv +xnoremap > >gv +" make Y behave analogously to D instead of dd +nnoremap Y y$ +" make arrow keys move visually (since j/k already move linewise) +noremap <up> gk +noremap <down> gj +inoremap <up> <C-o>gk +inoremap <down> <C-o>gj +" use tab for completion +inoremap <expr> <Tab> + \ strpart(getline('.'), 0, col('.') - 1) =~ '\(^\\|\s\+\)$' + \ ? "\<Tab>" + \ : "\<C-n>" +inoremap <S-Tab> <C-p> |