summary refs log tree commit diff
path: root/.vim/after/plugin/writing.vim
blob: a0163166e0e27172bf95a43906fc16f1135c062d (plain) (blame)
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
" Configuration for writing text in vim

" Grammer checker
let g:grammarous#languagetool_cmd = 'languagetool'

" Minimal UX for concentration
let g:goyo_width = 120
let g:goyo_height = 90
let g:goyo_linenr = 0
nmap <F0> :Goyo<CR>

let g:limelight_conceal_ctermfg = 'gray'
let g:limelight_conceal_ctermbg = 'none'
let g:limelight_conceal_guifg = 'gray'
let g:limelight_conceal_guibg = 'none'

let g:limelight_default_coefficient = 0.5
let g:limelight_paragraph_span = 1
let g:limelight_priority = -1

" goyo enter/leave funcs {{{
function! s:goyo_enter()
    if has('gui_running') || has('gui_vimr')
        " set linespace = 7
    end
    if executable('tmux') && strlen($TMUX)
        silent !tmux set status off
        silent !tmux list-panes -F '\#F' | grep -q Z || tmux resize-pane -Z
    endif

    " set noshowmode
    " set noshowcmd
    set scrolloff=999
    Limelight

    " make sure :q in the last buffer, in Goyo also quits vim
    " let b:quitting = 0
    " let b:quitting_bang = 0
    " autocmd QuitPre <buffer> let b:quitting = 1
    " cabbrev <buffer> q! let b:quitting_bang = 1 <bar> q!
endfunction

function! s:goyo_leave()
    if has('gui_running') || has('gui_vimr')
        " set linespace = 0
    endif
    if executable('tmux') && strlen($TMUX)
        silent !tmux set status on
        silent !tmux list-panes -F '\#F' | grep -q Z || tmux resize-pane -Z
    endif

    " set showmode
    " set showcmd
    set scrolloff=5
    Limelight!

    " make sure :q in the last buffer, in Goyo also quits vim
    " if b:quitting && len(filter(range(1, bufnr('$')), 'buflisted(v:val)')) == 1
    "     if b:quitting_bang
    "       qa!
    "     else
    "       qa
    "     endif
    " endif

    hi SignColumn guibg=none ctermbg=none
endfunction
" }}}

" writing autocommands
function! s:writing_mode_enter()
    set textwidth=120
    " ALEToggle
    " Grammarous keymaps
    nmap <Leader>c :GrammarousCheck --lang=de
    nmap <Leader>gi <Plug>(grammarous-move-to-info-window)
    nmap <Leader>gr <Plug>(grammarous-remove-error)
    nmap <Leader>gd <Plug>(grammarous-disable-rule)
    nmap <Leader>gf <Plug>(grammarous-fixit)
    nmap <Leader>gn <Plug>(grammarous-move-to-next-error)
    nmap <Leader>gp <Plug>(grammarous-move-to-previous-error)
endfunction

augroup Writing
    au!
    au FileType markdown,tex call <SID>writing_mode_enter()
    " goyo autocommands
    au User GoyoEnter nested call <SID>goyo_enter()
    au User GoyoLeave nested call <SID>goyo_leave()
augroup END

" LaTeX
" let g:vimtex_view_general_viewer
"             \ = '/Applications/Skim.app/Contents/SharedSupport/displayline'
" let g:vimtex_view_general_options = '-r @line @pdf @tex'

" " This adds a callback hook that updates Skim after compilation
" let g:vimtex_latexmk_callback_hooks = ['UpdateSkim']
" function! UpdateSkim(status)
"     if !a:status | return | endif

"     let l:out = b:vimtex.out()
"     let l:tex = expand('%:p')
"     let l:cmd = [g:vimtex_view_general_viewer, '-r']
"     if !empty(system('pgrep Skim'))
"         call extend(l:cmd, ['-g'])
"     endif
"     if has('nvim')
"         call jobstart(l:cmd + [line('.'), l:out, l:tex])
"     elseif has('job')
"         call job_start(l:cmd + [line('.'), l:out, l:tex])
"     else
"         call system(join(l:cmd + [line('.'), shellescape(l:out), shellescape(l:tex)], ' '))
"     endif
" endfunction