From f5d56602df70950de6b7d40966b00c9939c81763 Mon Sep 17 00:00:00 2001 From: Robert Günzler Date: Sun, 26 Jan 2020 17:16:07 +0100 Subject: Intial commit of v2 See https://drewdevault.com/2019/12/30/dotfiles.html --- .vim/after/ftplugin/c.vim | 81 +++++++++++++++++++++++++++++++++++++++ .vim/after/ftplugin/crontab.vim | 1 + .vim/after/ftplugin/diff.vim | 33 ++++++++++++++++ .vim/after/ftplugin/gitrebase.vim | 8 ++++ .vim/after/ftplugin/go.vim | 77 +++++++++++++++++++++++++++++++++++++ .vim/after/ftplugin/gotmpl.vim | 1 + .vim/after/ftplugin/i3.vim | 1 + .vim/after/ftplugin/ledger.vim | 1 + .vim/after/ftplugin/mail.vim | 22 +++++++++++ .vim/after/ftplugin/make.vim | 2 + .vim/after/ftplugin/markdown.vim | 27 +++++++++++++ .vim/after/ftplugin/python.vim | 3 ++ .vim/after/ftplugin/rust.vim | 72 ++++++++++++++++++++++++++++++++++ .vim/after/ftplugin/snippets.vim | 1 + .vim/after/ftplugin/tex.vim | 0 .vim/after/ftplugin/toml.vim | 6 +++ .vim/after/ftplugin/vim.vim | 1 + 17 files changed, 337 insertions(+) create mode 100644 .vim/after/ftplugin/c.vim create mode 100644 .vim/after/ftplugin/crontab.vim create mode 100644 .vim/after/ftplugin/diff.vim create mode 100644 .vim/after/ftplugin/gitrebase.vim create mode 100644 .vim/after/ftplugin/go.vim create mode 100644 .vim/after/ftplugin/gotmpl.vim create mode 100644 .vim/after/ftplugin/i3.vim create mode 100644 .vim/after/ftplugin/ledger.vim create mode 100644 .vim/after/ftplugin/mail.vim create mode 100644 .vim/after/ftplugin/make.vim create mode 100644 .vim/after/ftplugin/markdown.vim create mode 100644 .vim/after/ftplugin/python.vim create mode 100644 .vim/after/ftplugin/rust.vim create mode 100644 .vim/after/ftplugin/snippets.vim create mode 100644 .vim/after/ftplugin/tex.vim create mode 100644 .vim/after/ftplugin/toml.vim create mode 100644 .vim/after/ftplugin/vim.vim (limited to '.vim/after/ftplugin') diff --git a/.vim/after/ftplugin/c.vim b/.vim/after/ftplugin/c.vim new file mode 100644 index 0000000..85ff8a2 --- /dev/null +++ b/.vim/after/ftplugin/c.vim @@ -0,0 +1,81 @@ +setlocal cindent + +setlocal foldmethod=syntax +setlocal foldlevel=10 + +if exists('g:loaded_gutentags') + let g:gutentags_enabled = 1 +endif + +" toggle between header and implementation in c/cpp +function! Alternate_c() + let file = expand('%') + if match(file, '\.c') > 0 + exe ':e %<.h' + elseif match(file, '\.h') > 0 + exe ':e %<.c' + endif +endfunction + +nmap a :call alternate#alternate() + +" source: https://github.com/igankevich/mesonic/blob/master/plugin/meson.vim +function! MesonProjectDir() + let l:dir = getcwd() " a starting directory to look for meson.build file + let l:project_dir = l:dir " the top-most directory with meson.build file + let l:nesting = 100 " maximal no. of subdirectories in a project + + " find top-most directory with readable meson.build file + while fnamemodify(l:dir, ':p') !=# '/' && l:nesting > 0 + if filereadable(l:dir . '/' . 'meson.build') + let l:project_dir = l:dir + endif + let l:dir = l:dir . '/..' + let l:nesting = l:nesting - 1 + endwhile + + " why one needs to do it two times? + let l:project_dir = fnamemodify(l:project_dir, ':p') + let l:project_dir = fnamemodify(l:project_dir, ':p') + return l:project_dir +endfunction + +if exists('g:loaded_neomake') + function! s:ninja_InitForJob(_jobinfo) dict + " set cwd to project dir + if !has_key(self, 'cwd') + let self.cwd = MesonProjectDir() + endif + " generate new error format lines + " source: https://github.com/igankevich/mesonic/blob/master/compiler/meson.vim#L67 + if !has_key(self, 'errorformat') + let g:meson_error_format = [ + \ '%EMeson encountered an error in file ' . l:project_subdir . '%f\, line %l\, column %c:,%Z%m', + \ '%Dninja: Entering directory `%f''', + \ '%f:%l.%c-%[%^:]%#: %t%[%^:]%#: %m' + \ ] + let self.errorformat = join(g:meson_error_format, ',') + endif + return self + endfunction + function! s:ninja_postprocess(entry) + if empty(a:entry.type) + let a:entry.type = 'E' + endif + endfunction + let g:neomake_c_ninja_maker = { + \ 'exe': 'ninja', + \ 'args': ['-C', 'build'], + \ 'append_file': 0, + \ 'postprocess': function('s:ninja_postprocess'), + \ 'InitForJob': function('s:ninja_InitForJob'), + \ } + let g:neomake_c_ninjaclean_maker = { + \ 'exe': 'ninja', + \ 'args': ['-C', 'build', 'clean'], + \ 'append_file': 0, + \ 'postprocess': function('s:ninja_postprocess'), + \ 'InitForJob': function('s:ninja_InitForJob'), + \ } + let g:neomake_c_enabled_makers = ['ninja'] +endif diff --git a/.vim/after/ftplugin/crontab.vim b/.vim/after/ftplugin/crontab.vim new file mode 100644 index 0000000..46faa33 --- /dev/null +++ b/.vim/after/ftplugin/crontab.vim @@ -0,0 +1 @@ +autocmd filetype crontab setlocal nobackup nowritebackup diff --git a/.vim/after/ftplugin/diff.vim b/.vim/after/ftplugin/diff.vim new file mode 100644 index 0000000..49974ec --- /dev/null +++ b/.vim/after/ftplugin/diff.vim @@ -0,0 +1,33 @@ +" disable annoying plugins +let b:coc_enabled = 0 +silent NeomakeDisable + +command! FindMergeMarker execute 'normal /^<<<<<<' + +" shortcuts for 3-way merges +command! DiffGetLocal :diffget LOCAL +command! DiffGetRemote :diffget REMOTE +" quicksave +command! DiffSave :wqa + +cnoreabbrev fmm FindMergeMarker +cnoreabbrev dgl DiffGetLocal +cnoreabbrev dgr DiffGetRemote +cnoreabbrev ds DiffSave + + +let s:markers = { + \ 'ours': '^<<<<<<< ', + \ 'theirs': '^>>>>>>> ', + \ 'base': '^||||||| ', + \ 'delimiter': '^=======\r\?$', + \ } + +if &diff + " set custom ctags in diff mode + + let _ft=&filetype + let g:vista_ctags_cmd = { + \ _ft: 'ctags --format=2 --excmd=pattern --fields=nksSaf --file-scope=yes --sort=no --append=no --output-format=json --fields=-PF -f-', + \ } +endif diff --git a/.vim/after/ftplugin/gitrebase.vim b/.vim/after/ftplugin/gitrebase.vim new file mode 100644 index 0000000..e97d225 --- /dev/null +++ b/.vim/after/ftplugin/gitrebase.vim @@ -0,0 +1,8 @@ +set keywordprg=:GitShow +command! -nargs=1 -bar GitShow call s:git_show() + +function! s:git_show(commit) abort + let p = popup#new({ 'filetype': 'diff' }) + let p.contents = systemlist("git show ".a:commit) + call p.open() +endfunction diff --git a/.vim/after/ftplugin/go.vim b/.vim/after/ftplugin/go.vim new file mode 100644 index 0000000..b5c0d44 --- /dev/null +++ b/.vim/after/ftplugin/go.vim @@ -0,0 +1,77 @@ +setlocal noexpandtab +setlocal shiftwidth=8 +setlocal tabstop=8 + +let g:go_echo_go_info = 0 +let g:go_auto_type_info = 0 +" let g:go_info_mode = 'gocode' +" let g:go_auto_sameids = 1 +" let g:go_gocode_unimported_packages = 0 +" let g:go_list_type = 'quickfix' +let g:go_template_autocreate = 0 + +let g:go_mod_fmt_autosave = 1 +let g:go_fmt_autosave = 1 +let g:go_fmt_command = 'goimports' +let g:go_fmt_fail_silently = 1 +let g:go_fmt_experimental = 1 " solves https://github.com/fatih/vim-go/issues/502 + +" let g:go_term_enabled = 0 +" let g:go_term_mode = 'split' + +let g:go_metalinter_autosave = 0 +let g:go_metalinter_enabled = ['vet', 'golint', 'errcheck'] +let g:go_metalinter_autosave_enabled = ['vet', 'golint'] +let g:go_metalinter_deadline = '2s' + +" let g:go_highlight_functions = 1 +" let g:go_highlight_methods = 1 +" let g:go_highlight_fields = 1 +" let g:go_highlight_structs = 1 +" let g:go_highlight_interfaces = 1 +" let g:go_highlight_build_constraints = 1 +" let g:go_highlight_types = 1 +" let g:go_highlight_extra_types = 1 +" let g:go_highlight_operators = 1 +" let g:go_highlight_space_tab_error = 1 +" let g:go_highlight_array_whitespace_error = 1 +" let g:go_highlight_trailing_whitespace_error = 1 + +function! Alternate_go() + call (go-alternate-edit) +endfunction + +" augroup go +" au! +" au VimEnter go call vista#RunForNearestMethodOrFunction() +" augroup END + +if exists('g:loaded_neomake') + let g:neomake_go_build_maker = { + \ 'exe': 'go', + \ 'args': 'build', + \ 'append_file': 0, + \ } + " let g:neomake_go_golangci_lint_args = ['run', '--out-format=line-number', '--print-issued-lines=false'] + let g:neomake_go_enabled_makers = ['go', 'golangci_lint'] +endif + +" https://github.com/fatih/dotfiles/blob/master/vimrc#L380 +" create a go doc comment based on the word under the cursor +function! s:create_go_doc_comment() + norm "zyiw + execute ":put! z" + execute ":norm I// \$" +endfunction +nnoremap ui :call create_go_doc_comment() + +" let b:deoplete_disable_auto_complete = 0 +" let g:neoformat_enabled_go = [] +" + +if exists('g:did_coc_loaded') + augroup CoC + au! + au BufWritePre * CocCommand editor.action.organizeImport + augroup END +endif diff --git a/.vim/after/ftplugin/gotmpl.vim b/.vim/after/ftplugin/gotmpl.vim new file mode 100644 index 0000000..cf481c4 --- /dev/null +++ b/.vim/after/ftplugin/gotmpl.vim @@ -0,0 +1 @@ +set commentstring= diff --git a/.vim/after/ftplugin/i3.vim b/.vim/after/ftplugin/i3.vim new file mode 100644 index 0000000..9c2e80a --- /dev/null +++ b/.vim/after/ftplugin/i3.vim @@ -0,0 +1 @@ +set commentstring=#\ %s diff --git a/.vim/after/ftplugin/ledger.vim b/.vim/after/ftplugin/ledger.vim new file mode 100644 index 0000000..0aa29a3 --- /dev/null +++ b/.vim/after/ftplugin/ledger.vim @@ -0,0 +1 @@ +let g:ledger_bin = 'hledger' diff --git a/.vim/after/ftplugin/mail.vim b/.vim/after/ftplugin/mail.vim new file mode 100644 index 0000000..108cbf7 --- /dev/null +++ b/.vim/after/ftplugin/mail.vim @@ -0,0 +1,22 @@ +" backup aerc mails to a draft directory +let g:mail_draft_dir = $HOME.'/.aerc/drafts' + +function! SaveDraft() + if !isdirectory(g:mail_draft_dir) + call mkdir(g:mail_draft_dir, 'p') + endif + let draft = join([g:mail_draft_dir, expand('%:t')], '/') + execute 'silent! write! '.draft +endfunction + +function! RestoreFromDraft() + let draft = join([g:mail_draft_dir, expand('%:t')], '/') + echoerr 'todo' +endfunction + +augroup vim_mail + au! + au CursorHold * call SaveDraft() +augroup END + +set commentstring=>\ %s diff --git a/.vim/after/ftplugin/make.vim b/.vim/after/ftplugin/make.vim new file mode 100644 index 0000000..840c87a --- /dev/null +++ b/.vim/after/ftplugin/make.vim @@ -0,0 +1,2 @@ +" Disable tabs->spaces for Makefiles +autocmd filetype make setlocal noexpandtab diff --git a/.vim/after/ftplugin/markdown.vim b/.vim/after/ftplugin/markdown.vim new file mode 100644 index 0000000..0d42ff0 --- /dev/null +++ b/.vim/after/ftplugin/markdown.vim @@ -0,0 +1,27 @@ +setlocal foldlevel=1 + +if exists('g:loaded_lexima') + let g:lexima_enable_space_rules=0 +endif + +function! s:markdown_underline(bang) + call append(line('.'), substitute(getline('.'), '.', (a:bang ? '-' : '='), 'g')) +endfunction +command! -nargs=0 -bang Underline call s:markdown_underline(0) + +if exists('g:loaded_neomake') + let g:neomake_markdown_shiba_maker = { + \ 'exe': 'shiba', + \ 'args': ['--detach', '%:p'], + \ 'append_file': 0, + \ } + let g:neomake_markdown_enabled_makers = [] +endif + +augroup Markdown + au! + " au FileType markdown NeomakeDisableBuffer + + " Make vim-markdown-folding ignore frontmatter blocks + au BufNewFile,BufRead markdown syntax match Comment /\%^---\_.\{-}---$/ +augroup END diff --git a/.vim/after/ftplugin/python.vim b/.vim/after/ftplugin/python.vim new file mode 100644 index 0000000..667d22e --- /dev/null +++ b/.vim/after/ftplugin/python.vim @@ -0,0 +1,3 @@ +let g:neomake_python_enabled_makers = [] +let g:neoformat_enabled_python = ["yapf"] + diff --git a/.vim/after/ftplugin/rust.vim b/.vim/after/ftplugin/rust.vim new file mode 100644 index 0000000..9bf2ca9 --- /dev/null +++ b/.vim/after/ftplugin/rust.vim @@ -0,0 +1,72 @@ +set tags='./rusty-tags.vi/' + +if exists('g:loaded_lexima') + call lexima#add_rule({'filetype': ['rust'], 'char': "'", 'at': '<\%# | &\%#'}) +endif + +let g:racer_cmd = $HOME.'/.cargo/bin/racer' + +" let g:gutentags_enabled = 0 +" let g:gutentags_define_advanced_commands = 1 +" let g:gutentags_ctags_executable_rust = 'rusty-tags' +" let g:gutentags_ctags_extra_args = ['--omit-deps', 'vi'] +" let g:gutentags_ctags_tagfile = 'rusty-tags.vi' + +" when using standard ctags +let g:tagbar_type_rust = { + \ 'ctagstype' : 'rust', + \ 'kinds' : [ + \'T:types,type definitions', + \'f:functions,function definitions', + \'g:enum,enumeration names', + \'s:structure names', + \'m:modules,module names', + \'c:consts,static constants', + \'t:traits', + \'i:impls,trait implementations', + \] + \} + +" when using universal-ctags +" let g:rust_use_custom_ctags_defs = 1 " if using rust.vim +" let g:tagbar_type_rust = { +" \ 'ctagstype' : 'rust', +" \ 'kinds' : [ +" \ 'n:modules', +" \ 's:structures:1', +" \ 'i:interfaces', +" \ 'c:implementations', +" \ 'f:functions:1', +" \ 'g:enumerations:1', +" \ 't:type aliases:1:0', +" \ 'v:constants:1:0', +" \ 'M:macros:1', +" \ 'm:fields:1:0', +" \ 'e:enum variants:1:0', +" \ 'P:methods:1', +" \ ], +" \ 'sro': '::', +" \ 'kind2scope' : { +" \ 'n': 'module', +" \ 's': 'struct', +" \ 'i': 'interface', +" \ 'c': 'implementation', +" \ 'f': 'function', +" \ 'g': 'enum', +" \ 't': 'typedef', +" \ 'v': 'variable', +" \ 'M': 'macro', +" \ 'm': 'field', +" \ 'e': 'enumerator', +" \ 'P': 'method', +" \ }, +" \ } + +let g:neomake_rust_enabled_makers = ['cargo'] + +" augroup rust +" au! +" augroup END + +" nmap d (rust-doc) +" nmap j (rust-def) diff --git a/.vim/after/ftplugin/snippets.vim b/.vim/after/ftplugin/snippets.vim new file mode 100644 index 0000000..cb39fa6 --- /dev/null +++ b/.vim/after/ftplugin/snippets.vim @@ -0,0 +1 @@ +set list diff --git a/.vim/after/ftplugin/tex.vim b/.vim/after/ftplugin/tex.vim new file mode 100644 index 0000000..e69de29 diff --git a/.vim/after/ftplugin/toml.vim b/.vim/after/ftplugin/toml.vim new file mode 100644 index 0000000..03bf098 --- /dev/null +++ b/.vim/after/ftplugin/toml.vim @@ -0,0 +1,6 @@ +" let g:neoformat_toml_tomlfix = { +" \ 'exe': 'tomlfix', +" \ 'args': ['-w'], +" \ 'replace': 1, +" \ } +" let g:neoformat_enabled_toml = ['tomlfix'] diff --git a/.vim/after/ftplugin/vim.vim b/.vim/after/ftplugin/vim.vim new file mode 100644 index 0000000..a6014c7 --- /dev/null +++ b/.vim/after/ftplugin/vim.vim @@ -0,0 +1 @@ +set foldmethod=marker -- cgit 1.4.1