dotfiles/.vim/vimrc

197 lines
5.3 KiB
VimL
Raw Normal View History

if filereadable("/usr/local/bin/task")
packadd vim-taskwarrior
endif
" ###########################################
" # CORE BEHAVIOR
" ###########################################
set nocompatible
set mouse=
set backspace=indent,eol,start
" ###########################################
" # TEMPORARY FILES
" ###########################################
set undofile
set undodir=~/.local/vim/undo//
set backup
set backupcopy=yes
set backupdir=~/.local/vim/backup//
set directory=~/.local/vim/swapfiles//
silent execute '!mkdir -p ~/.local/vim/backup ~/.local/vim/undo ~/.local/vim/swapfiles'
" ###########################################
" # VISUAL CHANGES
" ###########################################
set shm+=I
set noshowcmd
set noshowmode
syntax on
filetype plugin on
set t_Co=256
set background=dark
colorscheme candle-grey-transparent
hi CursorLineNr ctermbg=NONE ctermfg=30 cterm=NONE
hi CursorLine ctermbg=NONE ctermfg=NONE cterm=NONE
hi SpellBad ctermbg=NONE ctermfg=124
match ErrorMsg '\(TODO:\|FIXME\|XXX\|workaround\|WTF\|: error:.*\|\s\+$\| \+\ze\t\)'
" ###########################################
" # VIMDIFF
" ###########################################
set formatoptions=crolj
hi DiffAdd ctermbg=22 ctermfg=NONE cterm=NONE
hi DiffDelete ctermbg=234 ctermfg=NONE cterm=NONE
hi DiffChange ctermbg=236 ctermfg=NONE cterm=NONE
hi DiffText ctermbg=red ctermfg=NONE cterm=NONE
hi VertSplit ctermbg=NONE ctermfg=246 cterm=NONE
hi FoldColumn ctermbg=NONE ctermfg=251 cterm=NONE
hi Folded ctermbg=233 ctermfg=251 cterm=NONE
hi ErrorMsg ctermbg=NONE ctermfg=160 cterm=NONE
" ###########################################
" # TOGGLES / SETTINGS
" ###########################################
let g:is_posix=1
let g:mapleader = ","
set scrolloff=3
set spelllang=de,en
set hlsearch
set ignorecase
set smartcase
set tabstop=8
set shiftwidth=4
let &softtabstop=&shiftwidth
set expandtab
set smarttab
set textwidth=72
set formatprg=par\ -w72q
set list
set number
set listchars=tab:›,trail:
set fillchars=vert:\|,eob:\
" ###########################################
" # STATUS BAR
" ###########################################
function BufInfo()
endfunction
set laststatus=2
set statusline=%#Comment#
set statusline+=[%{toupper(mode())}]
set statusline+=\ <%n/%{g:bufno}>
set statusline+=%=
set statusline+=\ %f:%l:%c
set statusline+=\ %{&fileencoding?&fileencoding:&encoding}\ %{&fileformat}
set statusline+=\ 0x%B
set statusline+=\ %p%%
" ###########################################
" # OMNI COMPLETE
" ###########################################
set omnifunc=syntaxcomplete#Complete
set wildmenu
set wildmode=longest:full,full
function! CleverTab()
if strpart( getline('.'), 0, col('.')-1 ) =~ '^\s*$'
return "\<Tab>"
else
return "\<C-N>"
endif
endfunction
inoremap <tab> <C-R>=CleverTab()<CR>
" ###########################################
" # TERMINAL DEBUGGER
" ###########################################
"packadd termdebug
"let g:termdebugger = "egdb"
" ###########################################
" # VIM FZF
" ###########################################
let g:fzf_layout = { 'down': '60%' }
let g:fzf_action = { 'ctrl-t': 'tab split', 'ctrl-x': 'vsplit' }
noreabbrev <expr> ts getcmdtype() == ":" && getcmdline() == 'ts' ? 'FZFTselect' : 'ts'
nmap gt <Plug>(fzf_tags)
nnoremap <leader>g :RG <C-R>=expand("<cword>")<CR><CR>
nnoremap <leader>f :Files<CR>
nnoremap <leader>b :Buffers<CR>
nnoremap <leader>t :Tags<CR>
nnoremap <leader>h :History<CR>
" ###########################################
" # TAGBAR
" ###########################################
let g:tagbar_ctags_bin = "ectags"
noremap <F12> :TagbarToggle<CR>
noremap mm :silent make \| redraw! <CR>
nnoremap <Up> gk
nnoremap <Down> gj
xnoremap <Up> gk
xnoremap <Down> gj
inoremap <Up> <C-O>gk
inoremap <Down> <C-O>gj
" ###########################################
" # TAGS FILE
" ###########################################
set tags=./tags;/
nnoremap gb <c-o>
nnoremap gs :call Cscope('0', expand('<cword>'), 0)<CR>
nnoremap gc :call Cscope('3', expand('<cword>'), 0)<CR>
nnoremap ge :call Cscope('6', expand('<cword>'), 0)<CR>
" ###########################################
" # CSCOPE
" ###########################################
function! LoadCscope()
let db = findfile("cscope.out", ".;")
if (!empty(db))
let path = strpart(db, 0, match(db, "/cscope.out$"))
set nocscopeverbose " suppress 'duplicate connection' error
exe "cs add " . db . " " . path
set cscopeverbose
" else add the database pointed to by environment variable
elseif $CSCOPE_DB != ""
cs add $CSCOPE_DB
endif
endfunction
" ###########################################
" # EASY ALIGN
" ###########################################
xmap ga <Plug>(EasyAlign)
nmap ga <Plug>(EasyAlign)
" ###########################################
" # AUTORUN
" ###########################################
augroup mystuff
au!
au VimResized * wincmd =
au BufEnter * let g:bufno=len(getbufinfo({'buflisted':1}))
au BufEnter * call LoadCscope()
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
au BufRead,BufNewFile *.h,*.c set filetype=c.doxygen
au BufRead,BufNewFile Makefile,/usr/src/*.c,/usr/src/*.h,*.gmk setl sw=8 sts=8 noet
au BufWritePost vimrc so ~/.vim/vimrc
augroup end