diff vim/autoload/ludo.vim @ 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 67f14a8c2304
children b7682004288d
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
+