diff --git a/dotfiles/mail.org b/dotfiles/mail.org index 2ff0d65..6bc79f3 100644 --- a/dotfiles/mail.org +++ b/dotfiles/mail.org @@ -348,7 +348,7 @@ bind index,pager y edit-label *** Open in Vim #+BEGIN_SRC conf bind index,pager V noop -macro index,pager V "|nvim -u ~/.vim/vimrc.mutt -c 'setlocal ft=mail' -c 'setlocal buftype=nofile' -" "open in vim" +macro index,pager V "|nvim -c 'setlocal ft=mail' -c 'setlocal buftype=nofile' -" "open in vim" #+END_SRC *** Make quick html view macro @@ -776,7 +776,7 @@ unset record ** Use Vim to compose email, with a few default options. #+BEGIN_SRC conf -set editor = "nvim -u ~/.vim/vimrc.mutt -c ':Goyo' -c '/\\n--' -c ':noh' -c 'startinsert'" +set editor = "nvim -c ':Goyo' -c '/\\n--' -c ':noh' -c 'startinsert'" #+END_SRC ** Basic Options diff --git a/dotfiles/vim.org b/dotfiles/vim.org index 294d8dc..7eac41a 100644 --- a/dotfiles/vim.org +++ b/dotfiles/vim.org @@ -778,9 +778,39 @@ let g:webdevicons_enable_ctrlp = 1 ** junegunn/goyo.vim #+BEGIN_SRC conf -let g:goyo_width=100 -let g:goyo_margin_top = 2 -let g:goyo_margin_bottom = 2 + let g:goyo_width=100 + let g:goyo_margin_top = 2 + let g:goyo_margin_bottom = 2 +#+END_SRC + +This is for soft line breaks +#+BEGIN_SRC conf + function! s:goyo_enter() + set wrap linebreak nolist textwidth=0 wrapmargin=0 + + let b:quitting = 0 + let b:quitting_bang = 0 + autocmd QuitPre let b:quitting = 1 + cabbrev q! let b:quitting_bang = 1 q! + endfunction +#+END_SRC + +Quit Vim if this is the only remaining buffer +#+BEGIN_SRC conf + function! s:goyo_leave() + if b:quitting && len(filter(range(1, bufnr('$')), 'buflisted(v:val)')) == 1 + if b:quitting_bang + qa! + else + qa + endif + endif + endfunction +#+END_SRC + +#+BEGIN_SRC conf + autocmd! User GoyoEnter call goyo_enter() + autocmd! User GoyoLeave call goyo_leave() #+END_SRC ** tpope/vim-surround