dotfiles/.vim/vimrc

169 lines
3.7 KiB
VimL

packadd termdebug
set nocompatible
" mouse support
set mouse=
" real backspace, please
set backspace=indent,eol,start
" disable welcome screen
set shm+=I
" don't complain about $( )
let g:is_posix=1
set number
set cursorline
"set cursorline
set scrolloff=3
set spelllang=de,en
syntax on
filetype plugin on
set omnifunc=syntaxcomplete#Complete
" colors
set t_Co=257
set background=dark
colorscheme candle-grey-transparent
hi CursorLineNr ctermbg=NONE ctermfg=30 cterm=NONE
hi CursorLine ctermbg=NONE ctermfg=NONE cterm=NONE
" SEARCH
set hlsearch
set ignorecase
set smartcase
" SPACES (TABS)
set tabstop=8
set shiftwidth=4
let &softtabstop=&shiftwidth
set expandtab
set smarttab
set textwidth=72
" set colorcolumn=72
set formatprg=par\ -w72q
set list
set listchars=tab:>_,trail:>
set fillchars=vert:\|,eob:\
" " autocomplete
" 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>
function! s:build_quickfix_list(lines)
call setqflist(map(copy(a:lines), '{ "filename": v:val, "lnum": 1 }'))
copen
cc
endfunction
let g:fzf_layout = { 'down': '60%' }
nnoremap <c-o> :Files<CR>
nnoremap <c-b> :Buffers<CR>
let g:fzf_action = {
\ 'ctrl-t': 'tab split',
\ 'ctrl-x': 'vsplit' }
let g:fzf_vim = {}
let g:fzf_vim.tags_command = 'ksh -ic mktags'
command! MyFiles call fzf#run(fzf#wrap({
\ 'source': 'list-myfiles',
\ 'sink': 'edit',
\ 'options': ['--multi', '--pointer', '→', '--marker', '♡', '--preview', 'cat {}']
\ }))
let g:mapleader = ","
nnoremap <leader>f :Files<CR>
nnoremap <leader>b :Buffers<CR>
nnoremap <leader>l :Lines<CR>
nnoremap <leader>t :Tags<CR>
nnoremap <leader>m :MyFiles<CR>
nnoremap <leader>h :History<CR>
let g:tagbar_ctags_bin = "ectags"
noremap <leader>tt :TagbarToggle<CR>
" TAGS FILE
set tags=./tags;/
"nnoremap gt :cs find 1 <C-R>=expand("<cword>")<CR><CR>
"nnoremap gs :cs find 4 <C-R>=expand("<cword>")<CR><CR>
nnoremap gb <c-o>
"nnoremap gh :FSHere<CR>
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>
let g:fzf_tags_prompt = "Gd "
noreabbrev <expr> ts getcmdtype() == ":" && getcmdline() == 'ts' ? 'FZFTselect' : 'ts'
nmap gt <Plug>(fzf_tags)
let g:autotagTagsFile = ".tags"
let g:autotagCtagsCmd = "ectags"
let g:termdebugger = "egdb"
" HIGHLIGHT SPECIAL WORDS
match ErrorMsg '\(TODO:\|FIXME\|XXX\|workaround\|WTF\|: error:.*\|\s\+$\| \+\ze\t\)'
" DIFF
set formatoptions=crolj
" 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'
" PLUGIN: EASY ALIGN
xmap ga <Plug>(EasyAlign)
nmap ga <Plug>(EasyAlign)
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
augroup mystuff
au!
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