# HG changeset patch # User Ludovic Chabant # Date 1522647899 25200 # Node ID 71a080d4d83c7268a79cbf7359bf09a34776f4a6 # Parent 52c2cfeed50464c366200c7f34a311c40e4cbe1b Vim stuff: Goyo writing mode, Ack with Ag. diff -r 52c2cfeed504 -r 71a080d4d83c vim/autoload/ludo.vim --- a/vim/autoload/ludo.vim Sun Apr 01 22:25:00 2018 -0700 +++ b/vim/autoload/ludo.vim Sun Apr 01 22:44:59 2018 -0700 @@ -16,8 +16,9 @@ " Error message. function! ludo#error(msg) abort + let v:errmsg = "ludo: Error: ".a:msg echohl ErrorMsg - echomsg "ludo: Error: ".a:msg + echom v:errmsg echohl None endfunction @@ -73,3 +74,43 @@ call ludo#trace("Exclude list: ".join(g:pathogen_disabled, ', ')) endfunction +let s:ludo_revert = {} + +function! ludo#on_goyo_enter() + let s:ludo_revert = { + \'spell': &spell, + \'copyindent': ©indent, + \'smartindent': &smartindent, + \'autoindent': &autoindent, + \'list': &list, + \'showmode': &showmode, + \'showcmd': &showcmd, + \'scrolloff': &scrolloff, + \'complete': &complete, + \'background': &background + \} + set spell + set nocopyindent nosmartindent noautoindent nolist noshowmode noshowcmd + set scrolloff=999 + set complete+=s + set bg=light + if !has('gui_running') + let g:solarized_termcolors=256 + endif +endfunction + +function! ludo#on_goyo_leave() + if len(s:ludo_revert) == 0 + call ludo#error("Can't revert settings!") + return + endif + for [key, val] in items(s:ludo_revert) + execute 'let &'.key.' = '.string(val) + endfor + let s:ludo_revert = {} +endfunction + +function! ludo#writingmode() + Goyo +endfunction + diff -r 52c2cfeed504 -r 71a080d4d83c vim/vimrc --- a/vim/vimrc Sun Apr 01 22:25:00 2018 -0700 +++ b/vim/vimrc Sun Apr 01 22:44:59 2018 -0700 @@ -248,6 +248,16 @@ " }}} +" Ack {{{ + +if executable('ag') + let g:ackprg = 'ag --vimgrep' +endif + +nnoremap a :Ack! + +" }}} + " Ctrl-P {{{ " We'll set our own mappings. @@ -441,7 +451,7 @@ endfunction function! _LightlineGutentags() - return gutentags#statusline() + return gutentags#statusline('', '', '♨') endfunction function! _LightlineSyntastic() @@ -653,6 +663,11 @@ nnoremap n nzvzz nnoremap N Nzvzz +" Writing mode. +autocmd! User GoyoEnter nested call ludo#on_goyo_enter() +autocmd! User GoyoLeave nested call ludo#on_goyo_leave() +nmap p :call ludo#writingmode() + " YCM mappings. if s:HasPlugin('youcompleteme') augroup VimRC_YouCompleteMe @@ -808,6 +823,9 @@ let s:local_vimrc = s:vim_home.'/vimrc-local' if filereadable(s:local_vimrc) execute 'source' s:local_vimrc +let s:local_vimrc = s:vim_home.'/vimrc-local' +if filereadable(s:local_vimrc) + execute 'source' s:local_vimrc endif " }}}