changeset 430:71a080d4d83c

Vim stuff: Goyo writing mode, Ack with Ag.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 01 Apr 2018 22:44:59 -0700
parents 52c2cfeed504
children e0bb52007402
files vim/autoload/ludo.vim vim/vimrc
diffstat 2 files changed, 61 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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': &copyindent,
+                \'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
+
--- 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 <Leader>a :Ack!<Space>
+
+" }}}
+
 " 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 <leader>p :call ludo#writingmode()<CR>
+
 " 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
 
 " }}}