From a55590f07cd5b4c9adc2cc894d07c0a3d29a4816 Mon Sep 17 00:00:00 2001 From: gryf Date: Thu, 13 Feb 2025 09:24:42 +0100 Subject: [PATCH] Add commands for wrapper function on vw2html --- vimrc | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/vimrc b/vimrc index 0d20bf2..457053f 100644 --- a/vimrc +++ b/vimrc @@ -343,10 +343,11 @@ function s:SetRestSettings() "{{{2 endfunction "}}} function s:SetVimwikiSettings() "{{{2 + let b:ale_enabled=0 setlocal spell - map :Vimwiki2HTML + setlocal makeprg=vw2html\ \"%\" map :Vimwiki2HTMLBrowse - map :VimwikiAll2HTML + map :PyVimwikiAll2Html endfunction "}}} function s:SetGitcommitSettings() "{{{2 @@ -355,8 +356,8 @@ function s:SetGitcommitSettings() "{{{2 endfunction "}}} -autocmd BufRead *.mako set filetype=mako -autocmd BufRead *.ass, *asm set filetype=kickass +autocmd BufRead,BufNewFile *.mako set filetype=mako +autocmd BufRead,BufNewFile *.ass, *asm set filetype=kickass " make the current line highlighted only on current window autocmd WinEnter * setlocal cursorline @@ -527,6 +528,7 @@ let g:vimwiki_list = [{'path': '~/vimwiki/', \ 'template_default': 'default', \ 'template_ext': '.tpl', \ 'css_name': 'vimwiki_style.css'}] +let g:vimwiki_valid_html_tags = 'b,i,s,u,sub,sup,kbd,br,hr,span' "redefine tab key for vimwiki map wn VimwikiNextWord map wp VimwikiPrevWord @@ -748,6 +750,27 @@ function s:CycleDiffAlgorithm() echom 'Set diff algorithm to: ' . split(l:nextalgo, ':')[1] endfunction +" Convert wiki files to HTML +command -bang -nargs=? PyVimwikiAll2Html call ConvertVimwikiToHtml(0, 0) +command -bang -nargs=? PyVimwikiHtml call ConvertVimwikiToHtml(0, 1) +function ConvertVimwikiToHtml(forced, currentfile) + if &ft != 'vimwiki' + " not vimwiki file, do nothing + return + endif + let l:command = 'vw2html' + if a:forced == 1 + let l:command = l:command . ' -f' + endif + + if a:currentfile == 1 + let l:command = l:command . ' ' . bufname("%") + endif + + call system(l:command) + echom "Conversion to HTML done with command: " . l:command +endfunction + "write files as a root using sudo command W w !sudo tee "%" > /dev/null "}}}