From 6f48b4119dce96ac60c6b5b2de709efc50656295 Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Mon, 5 Oct 2020 12:41:49 +0200 Subject: [PATCH] Make vim Zenmode toggleable --- vim/plugin/zen.vim | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/vim/plugin/zen.vim b/vim/plugin/zen.vim index d605326..7661f75 100644 --- a/vim/plugin/zen.vim +++ b/vim/plugin/zen.vim @@ -1,10 +1,26 @@ +function s:loadState(state) + for name in keys(a:state) + exec "let" name.'="'.a:state[name].'"' + endfor +endfun + +function s:dumpState(state) + let l:newstate = {} + for name in keys(a:state) + exec "let l:newstate[\"".name."\"]=".name + endfor + return l:newstate +endfun + +let s:state = { "&number": "0", "&relativenumber": "0", "&colorcolumn": "0", "&laststatus": "0", "&fillchars": "eob:\\ " } + function Zen() - set nonumber - set norelativenumber - set colorcolumn=0 - set laststatus=0 - if has("nvim") - set fillchars=eob:\ + if exists("g:zenState") + call s:loadState(g:zenState) + unlet g:zenState + else + let g:zenState = s:dumpState(s:state) + call s:loadState(s:state) end endfun