Files
dotfiles/.vimrc

252 lines
8.5 KiB
VimL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

" Start: Manage plugins
set nocompatible
filetype off
set runtimepath+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" Plugin-Manager
Plugin 'git@github.com:VundleVim/Vundle.vim'
" A wiki within vim
Plugin 'git@github.com:vimwiki/vimwiki'
" A navigable visualization of vim's file-history
Plugin 'git@github.com:mbbill/undotree'
" A handy file-browser for vim
Plugin 'git@github.com:scrooloose/nerdtree'
" Utilities which are required by vim-snipmate
Plugin 'git@github.com:MarcWeber/vim-addon-mw-utils'
" Utilities which are required by vim-snipmate
Plugin 'git@github.com:tomtom/tlib_vim'
" Manage snippets as short cuts for vim
Plugin 'git@github.com:garbas/vim-snipmate'
" Add support for typecript-syntax
Plugin 'git@github.com:leafgarland/typescript-vim'
" Improve foldings on yaml-files (These are otherwise really unconvenient in vim)
Plugin 'git@github.com:pedrohdz/vim-yaml-folds'
" Add git-support, especially the command :Git
Plugin 'git@github.com:tpope/vim-fugitive'
" Autoformat tables in vim
Plugin 'git@github.com:godlygeek/tabular'
" Add git-status-marker in nerdtree
Plugin 'git@github.com:Xuyuanp/nerdtree-git-plugin'
" Enable syntax-checks
Plugin 'git@github.com:vim-syntastic/syntastic'
" Add markers for changed lines
Plugin 'git@github.com:airblade/vim-gitgutter'
" A magigical search-term for pretty much everything within vim
Plugin 'git@github.com:ctrlpvim/ctrlp.vim'
" Add a bunch of support for csv-files
Plugin 'git@github.com:chrisbra/csv.vim'
" A navigable view of the tags/marks within a file
Plugin 'git@github.com:preservim/tagbar'
" Add support for js-syntax
Plugin 'git@github.com:jelera/vim-javascript-syntax'
" A 'surround' command similiar to the 'inner' commands (cs'" to change quotes)
Plugin 'git@github.com:tpope/vim-surround'
" A cool theme with good readability
Plugin 'git@github.com:lifepillar/vim-gruvbox8'
" A tool to remove every noisy output to concentrate on writing!
Plugin 'git@github.com:junegunn/goyo.vim'
" Add support for hcl (terraform, packer, etc.)
Plugin 'git@github.com:hashivim/vim-terraform'
Plugin 'git@github.com:hashivim/vim-packer'
" Add closing-tags in HTML/XML
Plugin 'git@github.com:alvan/vim-closetag.git'
" A tool to build HTML with a simplified selector-language
Plugin 'git@github.com:mattn/emmet-vim.git'
" Add a status/tabline at the bottom
Plugin 'git@github.com:vim-airline/vim-airline.git'
" A calendar-integration
Plugin 'git@github.com:mattn/calendar-vim.git'
" Papercolor
Plugin 'git@github.com:NLKNguyen/papercolor-theme.git'
call vundle#end()
" End: Manage plugins
filetype plugin on
syntax on
let mapleader = ","
let g:gruvbox_contrast_dark = 'hard'
let g:vimwiki_table_mappings = 0
let g:vimwiki_folding = 'expr'
let g:vimwiki_list = [{'path': '~/Development/nemoinho/gitea.nehrke.info/nemoinho/vimwiki/', 'auto_export': 1}]
let g:vimwiki_autowriteall = 0
let g:vimwiki_url_maxsave = 0
let g:NERDTreeGitStatusShowIgnored = 1
let NERDTreeMinimalUI = 1
let NERDTreeDirArrows = 1
let g:snipMate = { 'snippet_version' : 1 }
let g:tagbar_ctags_bin = '~/.local/opt/ctags/bin/ctags'
let g:ctrlp_custom_ignore = 'node_modules\|dist'
set bg=dark
" Settings
set listchars=tab:\ ,trail,nbsp:_,extends,precedes
set list
set hlsearch
set number
set relativenumber
set nowrap
set linebreak
" Enable vim configs in the first or last lines of a file
set modeline
set modelineexpr
" Avoid an extra line at the end of the file
set nofixendofline
set tabstop=4
set shiftwidth=4
set expandtab
set backspace=indent,eol,start
" specific for MacVim set a pleasing font-size
set guifont=Menlo\ Regular:h15
highlight LineNr ctermfg=7
highlight CusrsorLineNr ctermbg=green
highlight CusrsorLine ctermbg=green
colorscheme gruvbox8
" ease CTRL-] since it's very hard to type on german keyboards
" However I can't just remap the command to the matching position since this
" is not a valid input for most unix-terminals. Therefore I just drop the
" CTRL-prefix and use the letter where the bracket would be on us keyboards.
" See: https://stackoverflow.com/a/16748339/4316528
nnoremap ä <C-]>
" <C-T> just don't work right now and that seems like a convenient keybinding
nnoremap ö <C-T>
" General utilities
nnoremap <leader>cd :cd %:p:h<CR>
nnoremap <Leader>gg :Goyo<CR>
nnoremap <Leader>l :set nu! relativenumber! wrap!<CR>
nnoremap <leader>m :make<CR>
nnoremap <Leader>q :qa!<CR>
nnoremap gv :vertical wincmd f<CR>
" Snipmate
imap <leader>l <Plug>snipMateNextOrTrigger
smap <leader>l <Plug>snipMateNextOrTrigger
" Open shell with Ctrl+d to enable a toggle between a shell and vim
nnoremap <silent> <C-d> :botright terminal ++close<CR>
inoremap <silent> <C-d> <Esc>:botright terminal ++close<CR>
" nvim uses a different terminal approach more vim-like actually :-P
if has('nvim')
nnoremap <silent> <C-d> :botright :split term://bash<CR>:resize -100<CR>:set winheight=10 wfh<CR>i
inoremap <silent> <C-d> <Esc>:botright :split term://bash<CR>:resize -100<CR>:set winheight=10 wfh<CR>i
tnoremap <Esc> <C-\><C-n>
endif
" Handle nerdtree and other utility-windows
nnoremap <Leader>, :NERDTreeFocus<CR>
nnoremap <Leader>c :NERDTreeClose<CR>
nnoremap <Leader>n :NERDTreeToggle<CR>
nnoremap <Leader>t :TagbarToggle<CR>
nnoremap <Leader>u :UndotreeToggle<CR>
" Git
nnoremap <Leader>ga. :Git add %<CR>
nnoremap <Leader>gaa :Git add .<CR>
nnoremap <Leader>gb :Git blame<CR>
nnoremap <Leader>gc :Git commit<CR>
nnoremap <Leader>gd :Git diff<CR>
nnoremap <Leader>gl :Git lg<CR>
nnoremap <Leader>gp :Git push -u origin<CR>
nnoremap <Leader>gs :Git status<CR>
nnoremap <Leader>tw :set textwidth=72<CR>
nnoremap <Leader>go :Git pull<CR>
nnoremap <Leader>gf :set textwidth=100 colorcolumn=101 spell<CR>gqqmaggV/^#<CR>kgq`a
" Install these files to ~/.vim/spell/
" http://ftp.vim.org/vim/runtime/spell/en.utf-8.spl
" http://ftp.vim.org/vim/runtime/spell/de.utf-8.spl
nnoremap <Leader>ss :set spell!<CR>
nnoremap <Leader>sd :set spelllang=de_de<CR>
nnoremap <Leader>se :set spelllang=en_us<CR>
" Tabularize
nnoremap <Leader>t, :Tabularize /,/l1<CR>
nnoremap <Leader>tc :Tabularize /;/l1<CR>
nnoremap <Leader>tp :Tabularize /\|/l1<CR>
nnoremap <Leader>tt :Tabularize /\|/l1<CR>
" Open CtrlP faster
nnoremap <Leader>p :CtrlP<CR>
" diffs
if &diff
nnoremap <Leader>1 :diffget LOCAL<CR>
nnoremap <Leader>2 :diffget BASE<CR>
nnoremap <Leader>3 :diffget REMOTE<CR>
nnoremap <Leader>n ]c
nnoremap <Leader>p [c
nnoremap ä ]c
nnoremap ö [c
endif
augroup configgroup
autocmd!
autocmd BufRead,BufNewFile ~/.config/git/* set filetype=gitconfig
autocmd FileType gitconfig set tabstop=4 softtabstop=8 shiftwidth=0 noexpandtab
autocmd FileType terraform set tabstop=2 softtabstop=2 shiftwidth=0 expandtab foldmethod=marker foldmarker={,} foldlevel=2
autocmd FileType javascript set tabstop=2 softtabstop=2 shiftwidth=2 expandtab foldlevel=5
autocmd FileType yaml set tabstop=2 softtabstop=2 shiftwidth=2 expandtab foldlevel=4
" Close when only Nerdtree would remain
autocmd BufEnter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
" Copy global wrap in diff (This way I can use the same behavior in diff as in normal views)
autocmd FilterWritePre * if &diff | setlocal wrap< | endif
" vimwiki
autocmd BufRead,BufNewFile diary.wiki VimwikiDiaryGenerateLinks
autocmd BufRead,BufNewFile *.wiki set wrap nonumber norelativenumber
"autocmd BufRead,BufNewFile *.wiki Goyo 80 | set wrap
autocmd FileType vimwiki set tabstop=2 softtabstop=2 shiftwidth=2 expandtab foldlevel=10
autocmd FileType vimwiki nnoremap <Leader>d :VimwikiDiaryIndex<CR>
autocmd FileType vimwiki nnoremap <Leader>to :VimwikiTOC<CR>
autocmd FileType vimwiki nnoremap <Leader>q :Goyo!<CR>:q<CR>
" On mac ctrl+space is occupied by their spotlight search...
" So I need a workaround to avoid apples stupid keyboard-thing
autocmd FileType vimwiki nnoremap <Leader><Space> :VimwikiToggleListItem<CR>j
autocmd FileType vimwiki nnoremap <Leader>m :VimwikiToggleListItem<CR>
autocmd FileType vimwiki nnoremap <A-Space> :VimwikiToggleListItem<CR>
" end of apple workarounds, I might get used to one of these...
autocmd FileType vimwiki nnoremap <silent> <Leader>x :call system('git add . && git commit -m "Auto commit" && git push')<CR>
autocmd FileType vimwiki nnoremap ZZ :Goyo!<CR>:x<CR>
" Fix broken backspace functionality on mac
if has("unix")
let s:uname = system("uname -s")
if s:uname == "Darwin"
autocmd FileType vimwiki nnoremap <C-H> <Plug>VimwikiGoBackLink
endif
endif
augroup end