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/plugin/writing.vim | 108 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 .vim/after/plugin/writing.vim (limited to '.vim/after/plugin/writing.vim') diff --git a/.vim/after/plugin/writing.vim b/.vim/after/plugin/writing.vim new file mode 100644 index 0000000..d868304 --- /dev/null +++ b/.vim/after/plugin/writing.vim @@ -0,0 +1,108 @@ +" Configuration for writing text in vim + +" Grammer checker +let g:grammarous#languagetool_cmd = 'languagetool' + +" Minimal UX for concentration +let g:goyo_width = 120 +let g:goyo_height = 90 +let g:goyo_linenr = 0 +nmap :Goyo + +let g:limelight_default_coefficient = 0.5 +let g:limelight_paragraph_span = 1 +" let g:limelight_default_coefficient = 0.5 +" let g:limelight_paragraph_span = 1 +let g:limelight_priority = -1 + +" goyo enter/leave funcs {{{ +function! s:goyo_enter() + if has('gui_running') || has('gui_vimr') + " set linespace = 7 + + elseif exists('$TMUX') + silent !tmux set status off + endif + + " set noshowmode + " set noshowcmd + set scrolloff=999 + Limelight + + " make sure :q in the last buffer, in Goyo also quits vim + let b:quitting = 0 + let b:quitting_bang = 0 + autocmd QuitPre let b:quitting = 1 + cabbrev q! let b:quitting_bang = 1 q! +endfunction + +function! s:goyo_leave() + if has('gui_running') || has('gui_vimr') + " set linespace = 0 + + elseif exists('$TMUX') + silent !tmux set status on + endif + + " set showmode + " set showcmd + set scrolloff=5 + Limelight! + + " make sure :q in the last buffer, in Goyo also quits vim + if b:quitting && len(filter(range(1, bufnr('$')), 'buflisted(v:val)')) == 1 + if b:quitting_bang + qa! + else + qa + endif + endif +endfunction +" }}} + +" writing autocommands +function! s:writing_mode_enter() + set textwidth=120 + " ALEToggle + " Grammarous keymaps + nmap c :GrammarousCheck --lang=de + nmap gi (grammarous-move-to-info-window) + nmap gr (grammarous-remove-error) + nmap gd (grammarous-disable-rule) + nmap gf (grammarous-fixit) + nmap gn (grammarous-move-to-next-error) + nmap gp (grammarous-move-to-previous-error) +endfunction + +augroup Writing + au! + au FileType markdown,tex call writing_mode_enter() + " goyo autocommands + au User GoyoEnter nested call goyo_enter() + au User GoyoLeave nested call goyo_leave() +augroup END + +" LaTeX +" let g:vimtex_view_general_viewer +" \ = '/Applications/Skim.app/Contents/SharedSupport/displayline' +" let g:vimtex_view_general_options = '-r @line @pdf @tex' + +" " This adds a callback hook that updates Skim after compilation +" let g:vimtex_latexmk_callback_hooks = ['UpdateSkim'] +" function! UpdateSkim(status) +" if !a:status | return | endif + +" let l:out = b:vimtex.out() +" let l:tex = expand('%:p') +" let l:cmd = [g:vimtex_view_general_viewer, '-r'] +" if !empty(system('pgrep Skim')) +" call extend(l:cmd, ['-g']) +" endif +" if has('nvim') +" call jobstart(l:cmd + [line('.'), l:out, l:tex]) +" elseif has('job') +" call job_start(l:cmd + [line('.'), l:out, l:tex]) +" else +" call system(join(l:cmd + [line('.'), shellescape(l:out), shellescape(l:tex)], ' ')) +" endif +" endfunction -- cgit 1.4.1