dotfiles

Obligatory dotfiles repo
git clone git://git.danielmoch.com/dotfiles.git
Log | Files | Refs

commit fa2fa9da2439bc1dcae90ab011b6c049c2327613
parent eb302474a2a4d6c916043fe525212bba4ee2de4a
Author: Daniel Moch <daniel@danielmoch.com>
Date:   Sun, 24 Nov 2019 16:14:51 -0500

Vim: Open in compatible mode for tiny and small builds

Diffstat:
M.vim/vimrc | 372++-----------------------------------------------------------------------------
A.vim/vimrc.normal | 362+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 371 insertions(+), 363 deletions(-)

diff --git a/.vim/vimrc b/.vim/vimrc @@ -1,363 +1,9 @@ -set nocompatible - -" Vim starting {{{ -if has('vim_starting') - if (has('win32') || has('win64')) - set undodir=$HOME/vimfiles/undo - if v:servername !~ '.*[0-9]$' - silent! execute '!rmdir /S /Q "'.$HOME.'/vimfiles/vimtemp" &&' - \ ' mkdir "'.$HOME.'/vimfiles/vimtemp"' - endif - set backupdir=$HOME/vimfiles/vimtemp// - set directory=$HOME/vimfiles/vimtemp// - set spellfile=$HOME/vimfiles/en.utf-8.add - if exists('$HOME') && has('gui_running') && (argc() == 0) - cd $HOME - endif - else - set undodir=$HOME/.vim/undo - if v:servername !~ '.*[0-9]$' - silent! execute '!rm -rf "'.$HOME.'/.vim/vimtemp"' - silent! execute '!mkdir "'.$HOME.'/.vim/vimtemp"' - endif - set backupdir=$HOME/.vim/vimtemp// - set directory=$HOME/.vim/vimtemp// - set spellfile=$HOME/.vim/en.utf-8.add - endif - if has('win32') || has('win64') || $PATH =~ 'cygdrive' - set fileformats=dos,unix - endif - set undofile - if has('packages') - if isdirectory(expand('~/Documents/src/vim_plugins')) - set packpath+=~/Documents/src/vim_plugins - endif - elseif filereadable(expand('~/.vim/pack/bundle/start/vim-pathogen/autoload/pathogen.vim')) - runtime pack/bundle/start/vim-pathogen/autoload/pathogen.vim - if isdirectory(expand('~/Documents/src/vim_plugins')) - execute pathogen#infect('pack/bundle/start/{}', '~Documents/src/vim_plugins/pack/bundle/start{}') - else - execute pathogen#infect() - endif - execute pathogen#helptags() - endif - syntax off - filetype plugin indent on -endif -" }}} - -" Globals {{{ -let readline_has_bash = 1 -if exists('$TMUX') - if has('packages') - packadd vim-slime - endif - let g:slime_no_mappings = 1 - let g:slime_target = 'tmux' - let g:slime_paste_file = tempname() - let g:slime_default_config = {"socket_name": split($TMUX, ",")[0], "target_pane": ":.2"} -endif -" }}} - -" Helper functions {{{ -function! MyTmuxStatusLine(action) - if exists('$TMUX') - if a:action == 'off' - execute 'silent !tmux set -s status off' | redraw! - else - execute 'silent !tmux set -s status on' | redraw! - endif - endif -endfunction - -function! MyFileEncoding() - if &fileencoding != '' - return '['.&fileencoding.']' - else - return '' - endif -endfunction - -function! MyHexToggle() - if !&binary - setlocal binary - setlocal nonumber - let l:modified = &modified - %!xxd - if &ft - let b:filetype = &ft - endif - setlocal ft=xxd - let &modified = l:modified - else - setlocal nobinary - setlocal number - let l:modified = &modified - %!xxd -r - if exists('b:filetype') - let &ft=b:filetype - else - setlocal ft= - endif - let &modified = l:modified - endif -endfunction - -function! MySkeleton() - let l:skelfiles = glob('~/.vim/skel/*.skel', v:false, v:true) - let l:idx = 1 - let l:msg = 'Available licenses:' - for l:skelfile in l:skelfiles - let l:msg .= "\n\t".l:idx."\t".l:skelfile - let l:idx += 1 - endfor - let l:msg .= "\n\t".l:idx."\tNone" - echo l:msg - let l:selection = 0 - while l:selection < 1 || l:selection > l:idx - let l:selection = input("Use license: ") - endwhile - if l:selection == l:idx - return - endif - let l:skel = readfile(l:skelfiles[l:selection - 1]) - let l:comments = split(&comments, ',') - let l:idx = 0 - let l:firstcomment = '' - let l:comment = '' - let l:endspace = '' - let l:lastcomment = '' - let l:space = '' - for l:token in l:comments - if l:token =~ '^s[^O]' - let l:firstcomment = substitute(l:token, '^s.*:', '', '') - let l:comment = substitute(l:comments[l:idx + 1], '^m.*:', '', '') - if l:token =~ '^sr' - let l:offset = len(l:firstcomment) - len(l:comment) - let l:comment = repeat(' ', l:offset) . l:comment - let l:endspace = repeat(' ', l:offset) - endif - let l:lastcomment = substitute(l:comments[l:idx + 2], '^e.*:', '', '') - let l:space = (l:comments[l:idx + 1] =~ '^mb') ? ' ' : '' - break - elseif l:token =~ '^b\?:' - let l:comment = substitute(l:token, '^b\?:', '', '') - let l:firstcomment = l:comment - let l:lastcomment = l:comment - let l:rightalign = v:false - let l:space = (l:token =~ '^b') ? ' ' : '' - break - endif - let l:idx += 1 - endfor - let l:idx = 0 - for l:line in l:skel - if l:line =~ "^$" - let l:line = l:comment - else - let l:line = l:comment . l:space . l:line - endif - let l:line = substitute(l:line, '{{ year }}', "\\=strftime('%Y')", '') - let l:skel[l:idx] = l:line - let l:idx += 1 - endfor - let l:skel = [l:firstcomment] + l:skel + [l:endspace . l:lastcomment] - - let l:lines = join(l:skel, "\n") - silent execute '0put =printf(\"%s\", l:lines)' - set modified - normal G -endfunction - -function! MyPasteStatus() - if &paste && get(w:,'active_window',0) - return '[p]' - else - return '' - endif -endfunction - -function! MySpellStatus() - if &spell - return '[s]' - else - return '' - endif -endfunction - -function! MyItalicize() - if exists('*execute') - let l:higroups = split(execute(':highlight'), '\n') - for l:group in l:higroups - if l:group =~# 'gui=[\w,]*italic' - let l:groupname = split(l:group)[0] - let l:ctermcmd = '' - for l:token in split(l:group) - if l:token =~# '^cterm=' - let l:ctermcmd = l:token - endif - endfor - if l:ctermcmd == '' - let l:ctermcmd = 'cterm=italic' - else - if l:ctermcmd !~# 'italic' - let l:ctermcmd = l:ctermcmd.',italic' - endif - endif - execute 'highlight '.l:groupname.' '.l:ctermcmd - endif - endfor - endif -endfunction - -function! MyShowMode() - if get(w:, 'active_window', 0) - return '['.mode().']' - else - return '' - endif -endfunction - -function! OptStatus(function) - if exists('*'.a:function) - return call(a:function, []) - else - return '' - endif -endfunction - -function! InitializeClasspath() - if(filereadable('.vim_java_classpath')) - so .vim_java_classpath - endif -endfunction - -function! BuildJavaMakeprg() - if exists('b:vim_java_classpath') - let &makeprg = &makeprg.' -cp '.b:vim_java_classpath - endif -endfunction -" }}} - -" Commands {{{ -if !has('win32') && !has('win64') - command! -range=% IX silent execute <line1>.','.<line2>."w !curl -n -F" - \ ."'f:1=<-' ix.io | tr -d '\\n' | " - \."my copy" -endif -" }}} - -" Auto-commands {{{ -augroup myvimrc - autocmd! - if has('win32') || has('win64') - autocmd BufWritePost _*imrc silent! execute '!attrib +H' - \.bufname('%') | so % | call MyItalicize() - else - autocmd BufWritePost *imrc so % | call MyItalicize() - endif - autocmd VimResized * wincmd = - autocmd User GoyoEnter Limelight | execute MyTmuxStatusLine('off') - autocmd User GoyoLeave Limelight! | execute MyTmuxStatusLine('') - autocmd QuickFixCmdPost [^l]* nested cwindow - autocmd QuickFixCmdPost l* nested lwindow - autocmd QuickFixCmdPre [^l]* nested silent! cclose - autocmd QuickFixCmdPre l* nested silent! lclose - autocmd BufNewFile Makefile,*.py,*.cpp,*.java,LICENSE call MySkeleton() - autocmd VimEnter * let w:active_window = 1 | call MyItalicize() - autocmd WinEnter * let w:active_window = 1 - autocmd WinLeave * unlet! w:active_window - if has('win32') || has('win64') - autocmd GuiEnter * simalt ~x - elseif has('gui_macvim') - autocmd GuiEnter * set fullscreen - endif - autocmd ColorScheme * call MyItalicize() - autocmd BufWritePre /tmp/* setlocal noundofile -augroup END -" }}} - -" Key mappings {{{ -let mapleader=";" -nnoremap rc :New $MYVIMRC<CR> -nnoremap <Leader>g :GrepJob!<Space> -nnoremap <Leader>' :vnew<CR> -nnoremap <Leader>- :new<CR> -nnoremap <Leader>e :e **/ -nnoremap <Leader>s :ScratchBuffer<CR> -nnoremap <Leader>n :New<Space> -nnoremap <Leader>h :Help<Space> -nnoremap <Leader>l :ls<CR>:b -nnoremap <Leader>L :ls<CR>:Buffer -nnoremap <leader>b :Buffer<Space> -nnoremap <leader>x :call MyHexToggle()<CR> -if exists('$TMUX') - xmap <leader>r <Plug>SlimeRegionSend - nmap <leader>r <Plug>SlimeMotionSend - nmap <leader>rr <Plug>SlimeLineSend -endif -if has('win32') || has('win64') - nnoremap <Leader>o :execute 'silent ! start '.expand('<cWORD>')<CR> -else - nnoremap <Leader>o :execute 'silent !my-open ' - \ .expand(shellescape('<cWORD>')) \| redraw!<CR> -endif -nnoremap <Leader>c :silent! execute 'cclose' \| - \ silent! execute 'lclose'<CR> -nnoremap <F4> :setlocal spell spelllang=en_us<CR> -nnoremap <F5> :nohl<CR> -nnoremap <F6> :call MySkeleton()<CR> -nnoremap <F8> :Goyo<CR> -if has('win32') || has('win64') - nnoremap <F9> :MakeJob!<CR> -else - nnoremap <F9> :MakeJob!<CR> -endif -" }}} - -" General options {{{ -set statusline=%{MyShowMode()}%{MySpellStatus()}%{MyPasteStatus()}%<%f%m -set statusline+=%r%h%q%w%{OptStatus('fugitive#statusline')}%=[%{&ff}] -set statusline+=%{MyFileEncoding()}%y%{OptStatus('ObsessionStatus')} -set statusline+=[%p%%][Ln:%l/%L,Col:%v] -colorscheme djmoch -set ttyfast -set nowrap -set noshowmode -set showcmd -set textwidth=72 -set autoindent -set visualbell -set smartcase -set number -set foldmethod=marker -set ttimeoutlen=0 -if !exists('$TMUX') - set clipboard+=unnamed -endif -set laststatus=2 -set wildmenu -set wildmode=longest:full,full -set nofileignorecase -set history=10000 -set hlsearch -set incsearch -set mouse=a -set backspace=indent,eol,start -set backup -set wildignore+=tags,*.class,*.pyc,*.pyo,__pycache__,*.o -if has('win32') || has('win64') - set grepprg=findstr\ /n\ /S - set viminfo+=n$HOME/vimfiles/viminfo -else - set grepprg=ag\ --vimgrep\ -p\ ~/.cvsignore\ $* - set grepformat=%f:%l:%c:%m - set viminfo+=n$HOME/.vim/viminfo -endif -set autowrite -set pastetoggle=<F2> -if $SHELL =~ 'zsh' || $SHELL =~ 'bash' - set title -endif -let &titlestring=hostname() . ':%t%h' -" }}} +if !&compatible && !exists('$POSIXLY_CORRECT') && v:version >= 700 + source ~/.vim/vimrc.normal + finish +end + +set runtimepath-=~/.vim +set runtimepath-=~/.vim/after +set compatible shortmess+=I t_Co=0 +silent! source ~/.exrc diff --git a/.vim/vimrc.normal b/.vim/vimrc.normal @@ -0,0 +1,362 @@ +" Vim starting {{{ +if has('vim_starting') + if (has('win32') || has('win64')) + set undodir=$HOME/vimfiles/undo + if v:servername !~ '.*[0-9]$' + silent! execute '!rmdir /S /Q "'.$HOME.'/vimfiles/vimtemp" &&' + \ ' mkdir "'.$HOME.'/vimfiles/vimtemp"' + endif + set backupdir=$HOME/vimfiles/vimtemp// + set directory=$HOME/vimfiles/vimtemp// + set spellfile=$HOME/vimfiles/en.utf-8.add + if exists('$HOME') && has('gui_running') && (argc() == 0) + cd $HOME + endif + else + set undodir=$HOME/.vim/undo + if v:servername !~ '.*[0-9]$' + silent! execute '!rm -rf "'.$HOME.'/.vim/vimtemp"' + silent! execute '!mkdir "'.$HOME.'/.vim/vimtemp"' + endif + set backupdir=$HOME/.vim/vimtemp// + set directory=$HOME/.vim/vimtemp// + set spellfile=$HOME/.vim/en.utf-8.add + endif + if has('win32') || has('win64') || $PATH =~ 'cygdrive' + set fileformats=dos,unix + endif + set undofile + if has('packages') + if isdirectory(expand('~/Documents/src/vim_plugins')) + set packpath+=~/Documents/src/vim_plugins + endif + elseif filereadable(expand('~/.vim/pack/bundle/start/vim-pathogen/autoload/pathogen.vim')) + runtime pack/bundle/start/vim-pathogen/autoload/pathogen.vim + if isdirectory(expand('~/Documents/src/vim_plugins')) + execute pathogen#infect('pack/bundle/start/{}', '~Documents/src/vim_plugins/pack/bundle/start{}') + else + execute pathogen#infect() + endif + execute pathogen#helptags() + endif + syntax off + filetype plugin indent on +endif +" }}} + +" Globals {{{ +let readline_has_bash = 1 +if exists('$TMUX') + if has('packages') + packadd vim-slime + endif + let g:slime_no_mappings = 1 + let g:slime_target = 'tmux' + let g:slime_paste_file = tempname() + let g:slime_default_config = {"socket_name": split($TMUX, ",")[0], "target_pane": ":.2"} +endif +" }}} + +" Helper functions {{{ +function! MyTmuxStatusLine(action) + if exists('$TMUX') + if a:action == 'off' + execute 'silent !tmux set -s status off' | redraw! + else + execute 'silent !tmux set -s status on' | redraw! + endif + endif +endfunction + +function! MyFileEncoding() + if &fileencoding != '' + return '['.&fileencoding.']' + else + return '' + endif +endfunction + +function! MyHexToggle() + if !&binary + setlocal binary + setlocal nonumber + let l:modified = &modified + %!xxd + if &ft + let b:filetype = &ft + endif + setlocal ft=xxd + let &modified = l:modified + else + setlocal nobinary + setlocal number + let l:modified = &modified + %!xxd -r + if exists('b:filetype') + let &ft=b:filetype + else + setlocal ft= + endif + let &modified = l:modified + endif +endfunction + +function! MySkeleton() + let l:skelfiles = glob('~/.vim/skel/*.skel', v:false, v:true) + let l:idx = 1 + let l:msg = 'Available licenses:' + for l:skelfile in l:skelfiles + let l:msg .= "\n\t".l:idx."\t".l:skelfile + let l:idx += 1 + endfor + let l:msg .= "\n\t".l:idx."\tNone" + echo l:msg + let l:selection = 0 + while l:selection < 1 || l:selection > l:idx + let l:selection = input("Use license: ") + endwhile + if l:selection == l:idx + return + endif + let l:skel = readfile(l:skelfiles[l:selection - 1]) + let l:comments = split(&comments, ',') + let l:idx = 0 + let l:firstcomment = '' + let l:comment = '' + let l:endspace = '' + let l:lastcomment = '' + let l:space = '' + for l:token in l:comments + if l:token =~ '^s[^O]' + let l:firstcomment = substitute(l:token, '^s.*:', '', '') + let l:comment = substitute(l:comments[l:idx + 1], '^m.*:', '', '') + if l:token =~ '^sr' + let l:offset = len(l:firstcomment) - len(l:comment) + let l:comment = repeat(' ', l:offset) . l:comment + let l:endspace = repeat(' ', l:offset) + endif + let l:lastcomment = substitute(l:comments[l:idx + 2], '^e.*:', '', '') + let l:space = (l:comments[l:idx + 1] =~ '^mb') ? ' ' : '' + break + elseif l:token =~ '^b\?:' + let l:comment = substitute(l:token, '^b\?:', '', '') + let l:firstcomment = l:comment + let l:lastcomment = l:comment + let l:rightalign = v:false + let l:space = (l:token =~ '^b') ? ' ' : '' + break + endif + let l:idx += 1 + endfor + let l:idx = 0 + for l:line in l:skel + if l:line =~ "^$" + let l:line = l:comment + else + let l:line = l:comment . l:space . l:line + endif + let l:line = substitute(l:line, '{{ year }}', "\\=strftime('%Y')", '') + let l:skel[l:idx] = l:line + let l:idx += 1 + endfor + let l:skel = [l:firstcomment] + l:skel + [l:endspace . l:lastcomment] + + let l:lines = join(l:skel, "\n") + silent execute '0put =printf(\"%s\", l:lines)' + set modified + normal G +endfunction + +function! MyPasteStatus() + if &paste && get(w:,'active_window',0) + return '[p]' + else + return '' + endif +endfunction + +function! MySpellStatus() + if &spell + return '[s]' + else + return '' + endif +endfunction + +function! MyItalicize() + if exists('*execute') + let l:higroups = split(execute(':highlight'), '\n') + for l:group in l:higroups + if l:group =~# 'gui=[\w,]*italic' + let l:groupname = split(l:group)[0] + let l:ctermcmd = '' + for l:token in split(l:group) + if l:token =~# '^cterm=' + let l:ctermcmd = l:token + endif + endfor + if l:ctermcmd == '' + let l:ctermcmd = 'cterm=italic' + else + if l:ctermcmd !~# 'italic' + let l:ctermcmd = l:ctermcmd.',italic' + endif + endif + execute 'highlight '.l:groupname.' '.l:ctermcmd + endif + endfor + endif +endfunction + +function! MyShowMode() + if get(w:, 'active_window', 0) + return '['.mode().']' + else + return '' + endif +endfunction + +function! OptStatus(function) + if exists('*'.a:function) + return call(a:function, []) + else + return '' + endif +endfunction + +function! InitializeClasspath() + if(filereadable('.vim_java_classpath')) + so .vim_java_classpath + endif +endfunction + +function! BuildJavaMakeprg() + if exists('b:vim_java_classpath') + let &makeprg = &makeprg.' -cp '.b:vim_java_classpath + endif +endfunction +" }}} + +" Commands {{{ +if !has('win32') && !has('win64') + command! -range=% IX silent execute <line1>.','.<line2>."w !curl -n -F" + \ ."'f:1=<-' ix.io | tr -d '\\n' | " + \."my copy" +endif +" }}} + +" Auto-commands {{{ +augroup myvimrc + autocmd! + if has('win32') || has('win64') + autocmd BufWritePost _*imrc silent! execute '!attrib +H' + \.bufname('%') | so % | call MyItalicize() + else + autocmd BufWritePost *imrc so % | call MyItalicize() + endif + autocmd VimResized * wincmd = + autocmd User GoyoEnter Limelight | execute MyTmuxStatusLine('off') + autocmd User GoyoLeave Limelight! | execute MyTmuxStatusLine('') + autocmd QuickFixCmdPost [^l]* nested cwindow + autocmd QuickFixCmdPost l* nested lwindow + autocmd QuickFixCmdPre [^l]* nested silent! cclose + autocmd QuickFixCmdPre l* nested silent! lclose + autocmd BufNewFile Makefile,*.py,*.cpp,*.java,LICENSE call MySkeleton() + autocmd VimEnter * let w:active_window = 1 | call MyItalicize() + autocmd WinEnter * let w:active_window = 1 + autocmd WinLeave * unlet! w:active_window + if has('win32') || has('win64') + autocmd GuiEnter * simalt ~x + elseif has('gui_macvim') + autocmd GuiEnter * set fullscreen + endif + autocmd ColorScheme * call MyItalicize() + autocmd BufWritePre /tmp/* setlocal noundofile +augroup END +" }}} + +" Key mappings {{{ +let mapleader=";" +nnoremap rc :New $MYVIMRC<CR> +nnoremap <Leader>g :GrepJob!<Space> +nnoremap <Leader>' :vnew<CR> +nnoremap <Leader>- :new<CR> +nnoremap <Leader>e :e **/ +nnoremap <Leader>s :ScratchBuffer<CR> +nnoremap <Leader>n :New<Space> +nnoremap <Leader>h :Help<Space> +nnoremap <Leader>l :ls<CR>:b +nnoremap <Leader>L :ls<CR>:Buffer +nnoremap <leader>b :Buffer<Space> +nnoremap <leader>x :call MyHexToggle()<CR> +if exists('$TMUX') + xmap <leader>r <Plug>SlimeRegionSend + nmap <leader>r <Plug>SlimeMotionSend + nmap <leader>rr <Plug>SlimeLineSend +endif +if has('win32') || has('win64') + nnoremap <Leader>o :execute 'silent ! start '.expand('<cWORD>')<CR> +else + nnoremap <Leader>o :execute 'silent !my-open ' + \ .expand(shellescape('<cWORD>')) \| redraw!<CR> +endif +nnoremap <Leader>c :silent! execute 'cclose' \| + \ silent! execute 'lclose'<CR> +nnoremap <F4> :setlocal spell spelllang=en_us<CR> +nnoremap <F5> :nohl<CR> +nnoremap <F6> :call MySkeleton()<CR> +nnoremap <F8> :Goyo<CR> +if has('win32') || has('win64') + nnoremap <F9> :MakeJob!<CR> +else + nnoremap <F9> :MakeJob!<CR> +endif +" }}} + +" General options {{{ +set statusline=%{MyShowMode()}%{MySpellStatus()}%{MyPasteStatus()}%<%f%m +set statusline+=%r%h%q%w%{OptStatus('fugitive#statusline')}%=[%{&ff}] +set statusline+=%{MyFileEncoding()}%y%{OptStatus('ObsessionStatus')} +set statusline+=[%p%%][Ln:%l/%L,Col:%v] +colorscheme djmoch +set ttyfast +set nowrap +set noshowmode +set showcmd +set textwidth=72 +set autoindent +set visualbell +set smartcase +set number +set foldmethod=marker +set ttimeoutlen=0 +if !exists('$TMUX') + set clipboard+=unnamed +endif +set laststatus=2 +set wildmenu +set wildmode=longest:full,full +set nofileignorecase +set history=10000 +set hlsearch +set incsearch +set mouse=a +set backspace=indent,eol,start +set backup +set wildignore+=tags,*.class,*.pyc,*.pyo,__pycache__,*.o +if has('win32') || has('win64') + set grepprg=findstr\ /n\ /S + set viminfo+=n$HOME/vimfiles/viminfo +else + set grepprg=ag\ --vimgrep\ -p\ ~/.cvsignore\ $* + set grepformat=%f:%l:%c:%m + set viminfo+=n$HOME/.vim/viminfo +endif +set autowrite +set pastetoggle=<F2> +if $SHELL =~ 'zsh' || $SHELL =~ 'bash' + set title +endif +let &titlestring=hostname() . ':%t%h' +set tags^=.git/tags +" }}}