dotfiles/.vimrc

354 lines
11 KiB
VimL
Raw Permalink Normal View History

2021-03-06 17:33:52 +01:00
set nocompatible
2021-03-06 18:21:47 +01:00
"https://github.com/tpope/vim-pathogen.git
2021-03-06 17:33:52 +01:00
execute pathogen#infect()
syntax enable
2021-08-04 16:54:15 +02:00
syntax sync fromstart
2021-03-06 17:33:52 +01:00
filetype plugin on
filetype indent on
2021-03-06 18:21:47 +01:00
colorscheme noctu_adapted
2021-03-06 17:33:52 +01:00
2021-03-11 10:40:38 +01:00
set encoding=utf-8
2021-08-09 17:46:38 +02:00
set colorcolumn=81
2021-03-06 17:33:52 +01:00
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
2021-08-09 17:46:38 +02:00
set spell
2021-03-06 17:33:52 +01:00
set ruler
set wrap
set breakindent
set showbreak=----->
set listchars=eol,tab:>·,trail:~,extends:>,precedes:<,space:␣
set tags=./tags,./TAGS,tags,TAGS
2022-06-01 07:27:05 +02:00
"set textwidth=80
"set linebreak
2021-06-29 01:21:14 +02:00
set nojoinspaces
2022-06-01 07:27:05 +02:00
set nrformats+=alpha
autocmd BufNewFile,BufRead *.sage set syntax=python
2022-01-29 00:46:19 +01:00
2022-01-16 14:23:31 +01:00
autocmd FileType haskell set expandtab
autocmd FileType haskell set nospell
"autocmd FileType haskell set formatprg=brittany
2021-08-04 16:54:15 +02:00
"escape codes for italics
set t_ZH=
set t_ZR=
2021-08-26 09:16:35 +02:00
map cc :cc<cr>
2021-03-06 17:33:52 +01:00
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()
2021-09-01 13:07:00 +02:00
set fillchars=fold:\
2021-03-06 17:33:52 +01:00
"check files for changes frequently
2022-06-01 07:27:05 +02:00
set autoread
set ut=1000
au CursorHold * checktime
2021-03-06 17:33:52 +01:00
"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")
2021-07-27 22:56:39 +02:00
set csto=0
set cst
2021-03-06 17:33:52 +01:00
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
2021-04-09 23:09:11 +02:00
nmap <silent> <C-_> :lcs find c <C-R>=expand("<cword>")<CR><CR>
set cscopequickfix=c+
2021-03-06 17:33:52 +01:00
2022-06-01 07:27:05 +02:00
"nmap <F6> :let @+=system("sage -c \"t=var('t');s=var('s');u=var('u');v=var('v');w=var('w');x=var('x');y=var('y');z=var('z');print(latex(".getline('.')."))\"")<CR>j
nmap <F6> :let @+=system("sage -c \"R.<t,z> = PowerSeriesRing(ZZ);print(latex(".getline('.')."))\"")<CR>j
2021-03-06 17:33:52 +01:00
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""" PLUGIN SPECIFIC """""""""""""""""""""""""""""""
runtime ftplugin/man.vim
2021-03-06 18:21:47 +01:00
""""""""""""""""""""""""""""""""""" 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
2021-03-06 17:33:52 +01:00
""""""""""""""""""""""""""""""""""" SYNTASTIC """"""""""""""""""""""""""""""""""
2021-03-06 18:21:47 +01:00
"https://github.com/vim-syntastic/syntastic.git
2021-03-06 17:33:52 +01:00
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
2021-09-01 13:07:00 +02:00
let g:syntastic_c_include_dirs = ["/usr/include/gtk-3.0"]
2021-03-06 17:33:52 +01:00
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.*',
2022-01-29 00:46:19 +01:00
\ 'bad character in label.*', 'Do not use @ in LaTeX macro names.']}
2022-01-16 14:23:31 +01:00
let g:syntastic_tex_chktex_quiet_messages =
\ {"regex": ["`)' expected, found `}'",
\ "`}' expected, found `)'"]}
2021-03-06 17:33:52 +01:00
2022-06-01 07:27:05 +02:00
let g:syntastic_java_checkstyle_quiet_messages = {"regex": ['Missing a Javadoc comment.']}
2021-04-05 22:01:49 +02:00
map <C-h><C-h> :lprev<CR>
2021-03-06 17:33:52 +01:00
map <C-j><C-j> :lnext<CR>
2021-06-29 01:21:14 +02:00
autocmd FileType c set formatprg=uncrustify\ -l\ c\ --frag\ -q
2021-08-25 16:21:18 +02:00
"https://vim.fandom.com/wiki/Highlight_current_line#Highlighting_that_stays_after_cursor_moves
nnoremap <silent> <Leader>h ml:execute 'match Search /\%'.line('.').'l/'<CR>
2021-03-06 17:33:52 +01:00
"""""""""""""""""""""""""""""""""""""" VIMUX """""""""""""""""""""""""""""""""""
2021-03-06 18:21:47 +01:00
"https://github.com/preservim/vimux.git
2021-03-06 17:33:52 +01:00
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 """"""""""""""""""""""""""""""""""
2021-03-06 18:21:47 +01:00
"https://github.com/rickhowe/diffchar.vim.git
2021-03-06 17:33:52 +01:00
2022-06-01 07:27:05 +02:00
let g:DiffUnit="Char"
2021-03-06 17:33:52 +01:00
"""""""""""""""""""""""""""""""""" LATEX SUITE """""""""""""""""""""""""""""""""
2021-03-06 18:21:47 +01:00
"https://github.com/vim-latex/vim-latex
2021-03-06 17:33:52 +01:00
set grepprg=grep\ -nH\ $*
set modelineexpr
2022-06-01 07:27:05 +02:00
"let g:Tex_DefaultTargetFormat = "pdf"
"let g:Tex_ViewRule_pdf = "qpdfview"
"let g:Tex_CompileRule_pdf = "latexmk -pdf -shell-escape -synctex=1 $*"
""let g:Tex_ViewRule_pdf = "zathura"
"
"let g:tex_flavor='latex'
"let g:Tex_GotoError=0
"let g:tex_comment_nospell=1
2021-03-06 17:33:52 +01:00
2022-01-29 00:46:19 +01:00
"autocmd BufNewFile,BufRead *.tex syntax sync fromstart
2021-07-29 23:10:00 +02:00
autocmd BufNewFile,BufRead *.tex set spelllang=en_gb spell
2021-03-06 17:33:52 +01:00
autocmd BufNewFile,BufRead *.tex syntax match Comment "%.*"
2021-08-04 16:54:15 +02:00
autocmd BufNewFile,BufRead *.tex call TexNewMathZone("M", "align", 1)
autocmd BufNewFile,BufRead *.tex set foldtext=FoldText()
2021-03-06 17:33:52 +01:00
autocmd BufNewFile,BufRead *.tex set textwidth=80
2021-06-29 01:21:14 +02:00
autocmd BufNewFile,BufRead *.tex let g:syntastic_auto_jump = 0
2022-01-16 14:23:31 +01:00
autocmd BufNewFile,BufRead *.tex set expandtab
2021-03-06 17:33:52 +01:00
2022-06-01 07:27:05 +02:00
"imap <C-l><C-o> :let b:Imap_FreezeImap = 1<CR>
"imap <C-l><C-u> :let b:Imap_FreezeImap = 0<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
2021-03-06 17:33:52 +01:00
2022-06-01 07:27:05 +02:00
"map <C-l><C-f> :execute escape(":!qpdfview --quiet --unique $(basename % .tex).pdf $(basename % .tex).pdf#src:%:" . line('.') . ":" . col('.') . " &", '#')<CR><CR>
map <C-l><C-f> :execute escape(":!okular --unique \"$(basename % .tex).pdf#src:" . line('.') . " %\" &> /dev/null &", '#')<CR><CR>
nnoremap <silent> <Leader>ll :!latexmk -pdf -shell-escape -synctex=1 %<CR>
2021-07-27 22:56:39 +02:00
2022-06-01 07:27:05 +02:00
""""""""""""""""""""""""""""""""""""" JAVA """""""""""""""""""""""""""""""""""""
autocmd BufNewFile,BufRead *.java set expandtab
autocmd BufNewFile,BufRead *.g4 set expandtab
2021-03-06 17:33:52 +01:00
""""""""""""""""""""""""""""""" RAINBOW BRACKETS """""""""""""""""""""""""""""""
2021-03-06 18:21:47 +01:00
"https://github.com/luochen1990/rainbow.git
2021-09-01 13:07:00 +02:00
"
"\ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold',
"\ 'start=/{/ end=/}/ fold'],
2021-03-06 17:33:52 +01:00
let g:rainbow_active = 1
let g:rainbow_conf = {
\ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick'],
\ 'ctermfgs': ['lightblue', 'lightgreen', 'magenta', 'yellow'],
\ 'guis': [''],
\ 'cterms': [''],
\ 'operators': '_,_',
2021-09-01 13:07:00 +02:00
\ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/ fold',
2021-03-06 17:33:52 +01:00
\ '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 """"""""""""""""""""""""""""""""""
2021-03-06 18:21:47 +01:00
"https://www.vim.org/scripts/script.php?script_id=2223
2021-03-06 17:33:52 +01:00
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
2021-09-11 19:59:04 +02:00
"nmap <SID>ws <Nop>
2021-03-06 17:33:52 +01:00
"""""""""""""""""""""""""""""""" DOXYGEN TOOLKIT """""""""""""""""""""""""""""""
2021-03-06 18:21:47 +01:00
"https://www.vim.org/scripts/script.php?script_id=987
2021-03-06 17:33:52 +01:00
"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()
2021-04-05 22:01:49 +02:00
autocmd FileType c set syntax=c.doxygen
2021-07-09 20:09:48 +02:00
autocmd FileType dart set shiftwidth=2
autocmd FileType dart set tabstop=2
autocmd FileType dart set softtabstop=2
autocmd FileType dart set expandtab
2022-01-16 14:23:31 +01:00
"""""""""""""""""""""""""""""""""""" VIM2HS """"""""""""""""""""""""""""""""""""
"https://github.com/dag/vim2hs
let g:haskell_conceal = 1
2022-06-01 07:27:05 +02:00
"""""""""""""""""""""""""""""""""" NERDTREE """"""""""""""""""""""""""""""""""""
"https://github.com/preservim/nerdtree
map tn :NERDTreeMirror<CR>:NERDTreeFocus<CR>