dotfiles/.vimrc

298 lines
9.2 KiB
VimL

set nocompatible
"https://github.com/tpope/vim-pathogen.git
execute pathogen#infect()
syntax enable
filetype plugin on
filetype indent on
colorscheme noctu_adapted
set colorcolumn=80
set mouse=a
set term=screen
set undofile
set shiftwidth=4
set tabstop=4
set softtabstop=4
set backspace=indent,eol,start
set cindent
set history=1000
set showcmd
set incsearch
set nowrap
set nospell
set ruler
set wrap
set breakindent
set showbreak=----->
set linebreak
set listchars=eol,tab:>·,trail:~,extends:>,precedes:<,space:␣
set textwidth=80
set tags=./tags,./TAGS,tags,TAGS
map gn :bn<cr>
map gp :bp<cr>
"map <C-m> <Esc>"zyiw :tjump <C-r>z<cr>
nmap cp :let @" = "in".expand("%")<cr>
nnoremap <LeftMouse> <nop>
map <F5> :!cscope -Rb<CR>:cs reset<CR><CR>
"limit foldtext to 80 characters
fu! FoldText()
return strcharpart(foldtext(), 1, 80)
endf
set foldtext=FoldText()
"check files for changes frequently
set autoread
"set ut=1000
"au CursorHold * checktime
"highlight own types:
au BufRead,BufNewFile *.[ch] let fname = expand('<afile>:p:h') . '/types.vim'
au BufRead,BufNewFile *.[ch] if filereadable(fname)
au BufRead,BufNewFile *.[ch] exe 'so ' . fname
au BufRead,BufNewFile *.[ch] endif
"https://unix.stackexchange.com/questions/60189/how-to-search-the-current-word-in-all-opened-tabs-in-vim
" enables to search in all open buffers with :Search <pattern>
command! -nargs=1 Find call setqflist([]) | silent
\ execute "bufdo grepadd! '<args>' %" | redraw!
nnoremap <left> :cprev<cr>zvzz
nnoremap <right> :cnext<cr>zvzz
"https://stackoverflow.com/questions/9403098/is-it-possible-to-jump-to-the-next-closed-fold-in-vim
nnoremap <silent> <leader>zj :call NextClosedFold('j')<cr>
nnoremap <silent> <leader>zk :call NextClosedFold('k')<cr>
function! NextClosedFold(dir)
let cmd = 'norm!z' . a:dir
let view = winsaveview()
let [l0, l, open] = [0, view.lnum, 1]
while l != l0 && open
exe cmd
let [l0, l] = [l, line('.')]
let open = foldclosed(l) < 0
endwhile
if open
call winrestview(view)
endif
endfunction
"nnoremap <silent> <leader>zj :<c-u>call RepeatCmd('call NextClosedFold("j")')<cr>
"nnoremap <silent> <leader>zk :<c-u>call RepeatCmd('call NextClosedFold("k")')<cr>
"function! RepeatCmd(cmd) range abort
" let n = v:count < 1 ? 1 : v:count
" while n > 0
" exe a:cmd
" let n -= 1
" endwhile
"endfunction
"https://stackoverflow.com/questions/13634826/show-function-name-in-status-line
fun! ShowFuncName()
let lnum = line(".")
let col = col(".")
echohl ModeMsg
echo getline(search("^[^ \t#/]\\{2}.*[^:]\s*$", 'bW'))
echohl None
call search("\\%" . lnum . "l" . "\\%" . col . "c")
endfun
map <C-F> :call ShowFuncName() <CR>
"https://stackoverflow.com/questions/1054701/get-ctags-in-vim-to-go-to-definition-not-declaration
if has("cscope")
set csto=0
set cst
set nocsverb
" add any database in current directory
if filereadable("cscope.out")
cs add cscope.out
" else add database pointed to by environment
elseif $CSCOPE_DB != ""
cs add $CSCOPE_DB
endif
set csverb
endif
" jump to a function declaration
nmap <silent> <C-\> :cs find s <C-R>=expand("<cword>")<CR><CR>1<CR><CR>
" show a list of where function is called
nmap <silent> <C-_> :cs find c <C-R>=expand("<cword>")<CR><CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""" PLUGIN SPECIFIC """""""""""""""""""""""""""""""
runtime ftplugin/man.vim
""""""""""""""""""""""""""""""""""" AUTO-MKDIR """""""""""""""""""""""""""""""""
"https://github.com/arp242/auto_mkdir2.vim.git
"""""""""""""""""""""""""""""""""" VIM-BUFKILL """""""""""""""""""""""""""""""""
"https://github.com/qpkorr/vim-bufkill.git
""""""""""""""""""""""""""""""" MULTIPLE SEARCH """""""""""""""""""""""""""""""
"https://www.vim.org/scripts/script.php?script_id=479
""""""""""""""""""""""""""""""" MULTIPLE CURSORS """""""""""""""""""""""""""""""
"https://github.com/terryma/vim-multiple-cursors.git
""""""""""""""""""""""""""""""""""" SYNTASTIC """"""""""""""""""""""""""""""""""
"https://github.com/vim-syntastic/syntastic.git
let g:syntastic_mode_map = {"mode": "active"}
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 0
let g:syntastic_check_on_open = 0
let g:syntastic_check_on_wq = 0
let g:syntastic_auto_jump = 3
let g:syntastic_aggregate_errors = 1
let g:syntastic_enable_highlighting = 0
let g:syntastic_java_checkers = ['checkstyle', 'javac']
let g:syntastic_java_checkstyle_classpath =
\ '~/.checkstyle/checkstyle-8.16-all.jar'
let g:syntastic_java_checkstyle_conf_file = '~/.checkstyle/checkstyle.xml'
let g:syntastic_tex_chktex_args = "-l ~/.chktexrc"
let g:syntastic_tex_lacheck_quiet_messages = {"regex": ['.*unmatched.*',
\ 'bad character in label.*']}
map <C-j><C-k> :lprev<CR>
map <C-j><C-j> :lnext<CR>
"""""""""""""""""""""""""""""""""""""" VIMUX """""""""""""""""""""""""""""""""""
"https://github.com/preservim/vimux.git
function! REPLsettings(cmd)
call VimuxOpenRunner()
call VimuxSendText(a:cmd."\n")
nmap <Space> "vyy:call VimuxSendText(@v)<CR>j^
endfunction
"autocmd FileType python call REPLsettings("python")
"autocmd FileType R call REPLsettings("R")
nmap <C-c><C-o> :call VimuxOpenRunner()<CR>
nmap <C-c><C-p> :call REPLsettings("")<CR>
"""""""""""""""""""""""""""""""""""" DIFFCHAR """"""""""""""""""""""""""""""""""
"https://github.com/rickhowe/diffchar.vim.git
let g:DiggUnit="Char"
"""""""""""""""""""""""""""""""""" LATEX SUITE """""""""""""""""""""""""""""""""
"https://github.com/vim-latex/vim-latex
set grepprg=grep\ -nH\ $*
set modelineexpr
let g:tex_flavor='latex'
let g:Tex_GotoError=0
let g:Tex_Com_mjax = "\\(<++>\\)<++>"
let g:Tex_Com_eq = "$$<++>$$<++>"
let g:Tex_Com_cal = "\\mathcal{<++>}<++>"
let g:Tex_Com_bb = "\\mathbb{<++>}<++>"
let g:Tex_Com_bf = "\\mathbf{<++>}<++>"
let g:Tex_Com_bm = "\begin{bmatrix}<++>\end{bmatrix}<++>"
let g:Tex_Com_vm = "\begin{vmatrix}<++>\end{vmatrix}<++>"
let g:Tex_Com_std = "\\title{}\n\\author{}\n\\date{}\n\\documentclass[a4paper,"
\ . "notitlepage]{report}\n\\usepackage[pdftex]{graphicx}\n"
\ . "\\usepackage{amssymb}\n\\usepackage{amsmath}\n"
\ . "\\begin{document}\n\\maketitle\n\<++>\n\\end{document}"
autocmd BufNewFile,BufRead *.tex set syntax=plaintex
autocmd BufNewFile,BufRead *.tex syntax match Comment "%.*"
autocmd BufNewFile,BufRead *.tex set textwidth=80
imap <C-l><C-f> :let b:Imap_FreezeImap = 1<CR>
imap <C-l><C-u> :let b:Imap_FreezeImap = 0<CR>
imap <C-l><C-n> <ESC>:w<CR>:!pdflatex %<CR>
nmap <C-l><C-n> :w<CR>:!pdflatex --shell-escape %<CR>
nmap <C-l><C-z> :!zathura $(basename % .tex).pdf &<CR>
imap <C-l><C-m> <ESC>:w<CR>:!biber -E utf8 $(basename % .tex)<CR>
nmap <C-l><C-m> :w<CR>:!biber -E utf8 $(basename % .tex)<CR>
imap <C-l><C-j> <F7>
imap <C-l><C-i> <Plug>Tex_InsertItemOnThisLine
imap <C-l><C-l> <Plug>Tex_LeftRight
imap <C-l><C-x> <Plug>Tex_MathCal
imap <C-l><C-v> <Plug>Tex_MathBF
""""""""""""""""""""""""""""""" RAINBOW BRACKETS """""""""""""""""""""""""""""""
"https://github.com/luochen1990/rainbow.git
let g:rainbow_active = 1
let g:rainbow_conf = {
\ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick'],
\ 'ctermfgs': ['lightblue', 'lightgreen', 'magenta', 'yellow'],
\ 'guis': [''],
\ 'cterms': [''],
\ 'operators': '_,_',
\ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold',
\ 'start=/{/ end=/}/ fold'],
\ 'separately': {
\ '*': {},
\ 'markdown': {
\ 'parentheses_options': 'containedin=markdownCode contained',
\ },
\ 'lisp': {
\ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick',
\ 'darkorchid3'],
\ },
\ 'haskell': {
\ 'parentheses': ['start=/(/ end=/)/ fold',
\ 'start=/\[/ end=/\]/ fold', 'start=/\v\{\ze[^-]/ end=/}/ fold'],
\ },
\ 'vim': {
\ 'parentheses_options': 'containedin=vimFuncBody',
\ },
\ 'perl': {
\ 'syn_name_prefix': 'perlBlockFoldRainbow',
\ },
\ 'stylus': {
\ 'parentheses': ['start=/{/ end=/}/ fold contains=@colorableGroup'],
\ },
\ 'css': 0,
\ }
\}
""""""""""""""""""""""""""""""""""" TINY MODE """"""""""""""""""""""""""""""""""
"https://www.vim.org/scripts/script.php?script_id=2223
nmap <C-W>+ <C-W>+<SID>ws
nmap <C-W>- <C-W>-<SID>ws
nmap <C-W>> <C-W>><SID>ws
nmap <C-W>< <C-W><<SID>ws
nn <script> <SID>ws+ <C-W>+<SID>ws
nn <script> <SID>ws- <C-W>-<SID>ws
nn <script> <SID>ws> <C-W>><SID>ws
nn <script> <SID>ws< <C-W><<SID>ws
nmap <SID>ws <Nop>
"""""""""""""""""""""""""""""""" DOXYGEN TOOLKIT """""""""""""""""""""""""""""""
"https://www.vim.org/scripts/script.php?script_id=987
"fu! DoxyFoldText()
" if match(getline(v:foldstart+1), "\^/\[*]\[*]") == 0
" return strcharpart("++ " . (v:foldend-v:foldstart) . " lines: " .
" \matchstr(getline(v:foldstart+1, v:foldend),
" \"\^\[^ ]\[^\*]\.\*"), 0, 80)
" else
" return FoldText()
" endif
"endf
"map <C-D> ][a/*}}}*/<ESC>^%:call search("(", 'b')<cr>O/*{{{*/<ESC>j:Dox<cr>
map <C-D> <ESC>][%:call search("(", 'b')<cr>:Dox<cr>
autocmd FileType c set foldenable
autocmd FileType c set foldmethod=syntax
autocmd FileType c set foldnestmax=2
"autocmd FileType c set foldtext=DoxyFoldText()
"autocmd FileType c set syntax=c.doxygen