Revisión | e7545ce40bf17b35e81511895f5b80c302ba6070 (tree) |
---|---|
Tiempo | 2023-04-25 16:16:53 |
Autor | badcoff33 <none@none> |
Commiter | badcoff33 |
move preview code to seperate file
@@ -21,11 +21,6 @@ nnoremap <buffer> <LocalLeader>x :call <SID>ToggleTodo()<CR> | ||
21 | 21 | " some math calculation |
22 | 22 | nnoremap <buffer> g== o<C-r>="= "..luaeval(getline(line(".") - 1))<CR> |
23 | 23 | |
24 | -" Plugin EasyAlign tables | |
25 | -if exists(":EasyAlign") | |
26 | - vnoremap <buffer> <Tab> :EasyAlign *\|<CR>`. | |
27 | -endif | |
28 | - | |
29 | 24 | " Make heading underlined |
30 | 25 | nnoremap <buffer> <localleader>1 yypVr=k |
31 | 26 | nnoremap <buffer> <localleader>2 yypVr-k |
@@ -71,48 +66,3 @@ function! s:ToggleTodo() | ||
71 | 66 | endif |
72 | 67 | endfunction |
73 | 68 | |
74 | -" Preview in HTML {{{ | |
75 | - | |
76 | -let b:markdown_css_file = g:vim_home .. "\\templates\\simple.css" | |
77 | -if !filereadable(b:markdown_css_file) | |
78 | - let b:markdown_css_file = "" | |
79 | -else | |
80 | - let b:markdown_css_file = " --css=" .. b:markdown_css_file | |
81 | -endif | |
82 | - | |
83 | -let b:markdown_template_file = g:vim_home .. "\\templates\\template.html" | |
84 | -if !filereadable(b:markdown_template_file) | |
85 | - let b:markdown_template_file = "" | |
86 | -else | |
87 | - let b:markdown_template_file = " --template=" .. b:markdown_template_file | |
88 | -endif | |
89 | - | |
90 | -let b:markdown_command = "pandoc -f gfm -t html5 --toc --toc-depth=3" | |
91 | - \ .. b:markdown_css_file | |
92 | - \ .. b:markdown_template_file | |
93 | - \ .." --metadata title=\""..expand("%:t:r").."\"" | |
94 | - \ .." -o "..getenv("TEMP")..g:slash..expand("%:t")..".html" | |
95 | - \ .." "..getenv("TEMP")..g:slash.."_"..expand("%:t") | |
96 | - | |
97 | -function! s:OpenHTML() | |
98 | - exe "terminal ++close ++hidden cmd /C start" getenv("TEMP")..g:slash..expand("%:t")..".html" | |
99 | -endfunction | |
100 | - | |
101 | -function! s:MakeHTML(...) | |
102 | - if exists("b:markdown_command") | |
103 | - silent exe "write!" getenv("TEMP")..g:slash.."_"..expand("%:t") | |
104 | - silent exe "bwipeout!" getenv("TEMP")..g:slash.."_"..expand("%:t") | |
105 | - call run#RunStart(#{ | |
106 | - \ cmd: b:markdown_command, | |
107 | - \ background: v:true, | |
108 | - \ no_write: v:true | |
109 | - \ }) | |
110 | - endif | |
111 | -endfunction | |
112 | - | |
113 | -command! -buffer MarkdownOpenPreview call <SID>OpenHTML() | |
114 | -command! -buffer MarkdownUpdatePreview call <SID>MakeHTML() | |
115 | - | |
116 | -autocmd FocusLost <buffer> call s:MakeHTML() | |
117 | - | |
118 | -" }}} |
@@ -0,0 +1,44 @@ | ||
1 | +" Preview Markdown as HTML | |
2 | + | |
3 | +let b:markdown_css_file = g:vim_home .. "\\templates\\simple.css" | |
4 | +if !filereadable(b:markdown_css_file) | |
5 | + let b:markdown_css_file = "" | |
6 | +else | |
7 | + let b:markdown_css_file = " --css=" .. b:markdown_css_file | |
8 | +endif | |
9 | + | |
10 | +let b:markdown_template_file = g:vim_home .. "\\templates\\template.html" | |
11 | +if !filereadable(b:markdown_template_file) | |
12 | + let b:markdown_template_file = "" | |
13 | +else | |
14 | + let b:markdown_template_file = " --template=" .. b:markdown_template_file | |
15 | +endif | |
16 | + | |
17 | +let b:markdown_command = "pandoc -f gfm -t html5 --toc --toc-depth=3" | |
18 | + \ .. b:markdown_css_file | |
19 | + \ .. b:markdown_template_file | |
20 | + \ .." --metadata title=\""..expand("%:t:r").."\"" | |
21 | + \ .." -o "..getenv("TEMP")..g:slash..expand("%:t")..".html" | |
22 | + \ .." "..getenv("TEMP")..g:slash.."_"..expand("%:t") | |
23 | + | |
24 | +function! s:OpenHTML() | |
25 | + exe "terminal ++close ++hidden cmd /C start" getenv("TEMP")..g:slash..expand("%:t")..".html" | |
26 | +endfunction | |
27 | + | |
28 | +function! s:MakeHTML(...) | |
29 | + if exists("b:markdown_command") | |
30 | + silent exe "write!" getenv("TEMP")..g:slash.."_"..expand("%:t") | |
31 | + silent exe "bwipeout!" getenv("TEMP")..g:slash.."_"..expand("%:t") | |
32 | + call run#RunStart(#{ | |
33 | + \ cmd: b:markdown_command, | |
34 | + \ background: v:true, | |
35 | + \ no_write: v:true | |
36 | + \ }) | |
37 | + endif | |
38 | +endfunction | |
39 | + | |
40 | +command! -buffer MarkdownOpenPreview call <SID>OpenHTML() | |
41 | +command! -buffer MarkdownUpdatePreview call <SID>MakeHTML() | |
42 | + | |
43 | +autocmd FocusLost <buffer> call s:MakeHTML() | |
44 | + |