Reorganize vim plugin settings

Setting everything during PlugLoad function caused some plugins to
misbehave. Plugins are now loaded by Plug and their settings can be
either set with a file in the plugin directory (this mimicks the old way
of setting plugin up during load) or in after/ directory, which sets
options *after* everything has loaded.
This commit is contained in:
Marty Oehme 2020-02-03 22:16:23 +01:00
parent 6b79eeef5d
commit 756e45e037
29 changed files with 305 additions and 274 deletions

View file

@ -0,0 +1,15 @@
" PLUGIN: DEOPLETE
" For async completion
" enable deoplete at startup
let g:deoplete#enable_at_startup = 1
let g:deoplete#enable_ignore_case = 1
let g:deoplete#enable_smart_case = 1
let g:deoplete#enable_camel_case = 1
let g:deoplete#enable_refresh_always = 1
let g:deoplete#max_abbr_width = 0
let g:deoplete#max_menu_width = 0
call deoplete#custom#var('omni', 'input_patterns', {
\ 'pandoc': '@',
\})
call deoplete#enable()

View file

@ -0,0 +1,6 @@
" PLUGIN: ECHODOC
let g:echodoc#type="virtual"
set splitbelow
set completeopt+=menuone,noinsert,noselect
set completeopt-=preview
autocmd CompleteDone * pclose

View file

@ -0,0 +1,21 @@
" lazy loading since they require a lot of startup time
let s:ide_features_loaded=0
function! Autocomplete_linting_init() abort
if s:ide_features_loaded || !has('nvim')
return
endif
let s:ide_features_loaded=1
call plug#load('ale', 'deoplete.nvim', 'echodoc.vim')
call echodoc#enable()
call deoplete#custom#var('omni', 'input_patterns', {
\ 'pandoc': '@',
\})
call deoplete#enable()
endfunction
" augroup load_ide_features
" autocmd!
" autocmd InsertEnter * call Autocomplete_linting_init()
" augroup END

View file

@ -0,0 +1,20 @@
" PROSE: function to automatically enables markdown plugins for md & txt files
function! Prose()
call plug#load('vim-pencil')
call plug#load('goyo.vim')
call plug#load('limelight.vim')
call pencil#init()
" PLUGIN: vim-textobj-sentence
" enable extended sentence textobject use on md and plaintext files
call textobj#sentence#init()
" hide the markdown cruft
setlocal conceallevel=2
setlocal foldlevel=2
endfunction
" enable syntax highlighting for codeblocks WITHIN markdown
let g:markdown_fenced_languages = ['html', 'python', 'bash=sh', 'javascipt', 'go']
" call the prose function defined above for any md files
au FileType pandoc,markdown,md,mkd call Prose()
" or invoke it manually by writing :Prose
command! -nargs=0 Prose call Prose()

View file

@ -0,0 +1,3 @@
" PLUGIN: vim-pandoc-syntax
let g:pandoc#syntax#conceal#use = 1
let g:pandoc#syntax#conceal#urls = 1

View file

@ -0,0 +1,28 @@
" PLUGIN: vim-pandoc
" handle markdown files with pandoc (and pandoc syntax!)
let g:pandoc#modules#disabled = ["folding", "keyboard"]
let g:pandoc#modules#enabled = ["formatting", "bibliographies", "completion", "metadata", "menu", "spell", "hypertext"]
let g:pandoc#filetypes#pandoc_markdown = 1
let g:pandoc#filetypes#handled = [ "extra", "latex", "markdown", "pandoc", "rst", "textile" ]
" disable all default keymaps
let g:pandoc#keyboard#use_default_mappings=0
let g:pandoc#hypertext#use_default_mappings=0
" if there's a pdf and an html or similar, open the pdf
let g:pandoc#command#prefer_pdf=1
" look for bibtex files w/ same name as edited one, then .bib in current dir, yaml frontmatter, and finally the globally set bibs file
let g:pandoc#biblio#sources="bcyg"
" the globally set bibs file
if $BIBFILE ==? ""
let g:pandoc#biblio#bibs=[expand("~/documents/library/academia/academia.bib")]
else
let g:pandoc#biblio#bibs=[expand($BIBFILE)]
endif
let g:pandoc#biblio#use_bibtool=1
let g:pandoc#biblio#use_preview=1
let g:pandoc#completion#bib#mode='citeproc'
let g:pandoc#folding#fold_yaml=1
let g:pandoc#folding#fastfolds=1
" let g:pandoc#folding#level=2
let g:pandoc#spell#default_langs=["en_us", "de_de"]
let g:pandoc#hypertext#ausosave_on_edit_open_link=1
let g:pandoc#hypertext#create_if_no_alternates_exists=1

View file

@ -0,0 +1,7 @@
" Design
" PLUGIN: AIRLINE
let g:airline_powerline_fonts=1
" disable automatically refreshing the mux statusbar since it breaks tmux
" prefix highlighting. Instead, when changing vim statusbar just create
" snapshot with :TmuxlineSnapshot file and stick it into tmux config manually
let g:airline#extensions#tmuxline#enabled = 1

View file

@ -0,0 +1,26 @@
" PLUGIN: ALE
" clearer Error and warning signs for the gutter
let g:ale_sign_error = ''
let g:ale_sign_warning = ''
let g:ale_fix_on_save = 1
let g:ale_fixers = {
\'javascipt': ['eslint', 'prettier'],
\'html': ['tidy','prettier'],
\'typescript': ['prettier','tslint'],
\'*': ['remove_trailing_lines', 'trim_whitespace'],
\'go': ['gofmt'],
\'sh': ['shfmt'],
\'zsh': ['shfmt'],
\}
let g:ale_linters = {
\ 'go': ['gopls'],
\ 'sh': ['language_server','shellcheck'],
\ 'zsh': ['language_server','shellcheck'],
\}
" Enable integration with airline.
if exists("g:airline_theme")
let g:airline#extensions#ale#enabled = 1
endif

View file

@ -0,0 +1,4 @@
" Enable italics for colorschemes that support them
let g:gruvbox_italic=1
let g:one_allow_italics=1
let g:pencil_terminal_italics=1

View file

@ -0,0 +1,34 @@
" PLUGIN: fzf.vim
" set some fzf defaults
" windows drops down from above, 40% of the screen
let g:fzf_layout = { 'up': '~40%' }
" any Fzf command is prefixed with Fzf
" this groups them nicely together, and avoids confusion when suddenly :Buffer
" or :Files would appear as a command otherwise
let g:fzf_command_prefix = 'Fzf'
" let the colors come from our colorscheme
let g:fzf_colors =
\ { 'fg': ['fg', 'Normal'],
\ 'bg': ['bg', 'Normal'],
\ 'hl': ['fg', 'Comment'],
\ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'],
\ 'bg+': ['bg', 'CursorLine', 'CursorColumn'],
\ 'hl+': ['fg', 'Statement'],
\ 'info': ['fg', 'PreProc'],
\ 'border': ['fg', 'Ignore'],
\ 'prompt': ['fg', 'Conditional'],
\ 'pointer': ['fg', 'Exception'],
\ 'marker': ['fg', 'Keyword'],
\ 'spinner': ['fg', 'Label'],
\ 'header': ['fg', 'Comment'] }
" add some additional actions TODO perhaps unify with NerdTree mappings
let g:fzf_action = {
\ 'ctrl-t': 'tab split',
\ 'ctrl-x': 'split',
\ 'ctrl-v': 'vsplit' }
" FzfRg but also search through hidden files
command! -bang -nargs=* FzfRgHidden
\ call fzf#vim#grep(
\ 'rg --column --line-number --no-heading --color=always --smart-case --hidden '.shellescape(<q-args>), 1,
\ fzf#vim#with_preview(), <bang>0)

View file

@ -0,0 +1,21 @@
" PLUGIN: goyo.vim
" set up functions for entering/exiting distraction free mode, or leaving it
function! s:goyo_enter()
" remove the tmux status bar for actual distraction free environment
silent !tmux set status off
" maximize the tmux pane that vim is in if any (usually I have vim open as the only pane)
silent !tmux list-panes -F '\#F' | grep -q Z || tmux resize-pane -Z
" disable line highlighting, we really don't need it for prose
set nocursorline
" enable limelight which highlights whatever paragraph you are in and lowlights the rest
Limelight
endfunction
function! s:goyo_leave()
silent !tmux set status on
silent !tmux list-panes -F '\#F' | grep -q Z && tmux resize-pane -Z
set cursorline
Limelight!
endfunction
" actually call the functions on entering/leaving goyo
autocmd! User GoyoEnter nested call <SID>goyo_enter()
autocmd! User GoyoLeave nested call <SID>goyo_leave()

View file

@ -0,0 +1,19 @@
" PLUGIN: NERDTree
" " Ecosystem
" " Plug 'tpope/vim-fugitive' - Will have to take a closer look some other time
" highlight the line the cursor is on
let NERDTreeHighlightCursorline = 1
" remove Press ? for help
let NERDTreeMinimalUI=1
" loads nerdtree plugin when starting vim with a directory
" this is necessary when we lazyload nerdtree with vimplug above
" since it would only get loaded with nttoggle otherwise, and run netrw
augroup nerd_loader
autocmd!
autocmd VimEnter * silent! autocmd! FileExplorer
autocmd BufEnter,BufNew *
\ if isdirectory(expand('<amatch>'))
\| call plug#load('nerdtree')
\| execute 'autocmd! nerd_loader'
\| endif
augroup END

View file

@ -0,0 +1,8 @@
" PLUGIN: notational-fzf-vim
" Configure notational-fzf-vim
if $WIKIROOT ==? ""
let g:nv_search_paths = [ expand('~/documents/notes') ]
else
let g:nv_search_paths = [ $WIKIROOT ]
endif
let g:nv_wrap_preview_text=1

View file

@ -0,0 +1,12 @@
" custom preset with left-justified window list
" PLUGIN: TMUXLINE
let g:tmuxline_preset = {
\'a' : '#S',
\'b' : '#(whoami)',
\'c' : '#I:#P',
\'win' : '#I #W',
\'cwin' : [' ', '#I #W'],
\'x' : '#{?client_prefix,#[fg=colour232]#[bg=brightblue],} %H:%M:%S',
\'y' : '%d-%b-%y',
\'z' : '#H',
\'options' : {}}

View file

@ -0,0 +1,25 @@
" PLUGIN: vim-go
" change the tabstops for go to use tabs and a width of 4
" this conforms with the gofmt expectations
au FileType go set noexpandtab
au FileType go set shiftwidth=4
au FileType go set softtabstop=4
au FileType go set tabstop=4
" enable all sorts of highlighting options for
" variables/functions/arguments...
let g:go_highlight_build_constraints = 1
let g:go_highlight_extra_types = 1
let g:go_highlight_fields = 1
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_operators = 1
let g:go_highlight_structs = 1
let g:go_highlight_types = 1
" enable highlighting of other uses of the same variable
let g:go_auto_sameids = 1
" automatically import needed dependencies
" TODO do I need this? not doing it automatically does lead to more conscious
" decision making on imports
let g:go_fmt_command = "goimports"
" show type information for variables in the status line
let g:go_auto_type_info = 1

View file

@ -0,0 +1,4 @@
" PLUGIN: vim-pencil
" set default wrap mode to hard - TODO test which mode works better for
" me, it seems hardmode has trouble with markdown lists (see issue #31)
let g:pencil#wrapModeDefault = 'soft' " default is 'hard'

View file

@ -0,0 +1,7 @@
" PLUGIN: vim-sneak
" sneak around your files using
" repeatedly pressing fFtTsS will advance the search instead of starting a new
" one. To start a new one, press any other key, then fFtTsS
let g:sneak#s_next = 1
" use ignorecase/smartcase, depending on vim setting
let g:sneak#use_ic_scs = 1

View file

@ -0,0 +1,4 @@
" PLUGIN: tmux-navigator
" add seamless movement between vim and tmux, switch windows with C-hjkl
" automatically save the current buffer when navigating away from vim
let g:tmux_navigator_save_on_switch = 1

View file

@ -0,0 +1,12 @@
" PLUGIN: wiki.vim
if $WIKIROOT ==? ""
let g:wiki_root = expand('~/documents/notes')
else
let g:wiki_root = $WIKIROOT
endif
" filetypes to automatically enable the plugin for, seems to take file endings
" rather than vim ft
let g:wiki_filetypes = ['md', 'mkd', 'markdown', 'wiki']
let g:wiki_link_extension = '.md'
let g:wiki_link_target_type = 'md'
let g:wiki_mappings_use_defaults = 1