-
Notifications
You must be signed in to change notification settings - Fork 1
/
WordProcMode.vim
71 lines (57 loc) · 1.54 KB
/
WordProcMode.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
" WordProcMode.vim
" :- Focused writing experience, part of Onesimos Project
"
" Author: Baksi Li <myself@baksili.codes>
"
" License: MIT
"
" TODO:
" - CJK wrap using google/budou (maybe worth a plugin, 'CJKwrap.vim'?)
" - Better implementation of restoring the global (prev) settings
" - https://github.com/amix/vim-zenroom2/blob/master/plugin/zenroom2.vim
func s:Global_set_of(arg)
return split(execute('setg '.a:arg.'?'))[0]
endfun
func! s:PlugInstalled(plugname)
return &runtimepath =~? a:plugname
endfun
let g:WPModeSwitch = 0
function! s:WordProcessingMode()
" Enable
if !g:WPModeSwitch
if s:PlugInstalled('vim-signify')
SignifyDisable
endif
if s:PlugInstalled('goyo') && s:PlugInstalled('limelight')
Goyo | Limelight
else
setlocal nonumber
setlocal textwidth=80
silent on
endif
let g:WPModeSwitch = 1
echo 'WordProcessingMode On'
" Disable
else
if s:PlugInstalled('vim-signify')
SignifyEnable
endif
if s:PlugInstalled('Goyo') && s:PlugInstalled('Limelight')
Goyo! | Limelight!
else
exec 'setlocal '.s:Global_set_of('nu')
exec 'setlocal '.s:Global_set_of('textwidth')
endif
let g:WPModeSwitch = 0
echo 'WordProcessingMode Off'
endif
" set linespace=0
" setlocal smartindent
" setlocal noexpandtab
"setlocal spell spelllang=en_uk,en_us
"inoremap <C-l> <c-g>u<Esc>[s1z=`]a<c-g>u
" Smart word count
" -> excl title, code
" -> excl specific section
endfunction
command! WPModeToggle call <sid>WordProcessingMode()