experimental dokuwiki vim

This commit is contained in:
Q
2023-12-22 20:37:23 +02:00
parent 5001e1c314
commit 62cdc7bd62
3 changed files with 99 additions and 0 deletions

1
bin/vimdw Symbolic link
View File

@@ -0,0 +1 @@
../vim/vimdw

67
vim/dokuwiki.vim Normal file
View File

@@ -0,0 +1,67 @@
" https://www.dokuwiki.org/wiki:syntax
" h1-6: ====== headings ======
" bb/ii/uu: **bold** //italic// __underline__
" dd: <del>deleted</del>
" l: [[URL|Title]]
" f: ((footnote))
" i/im: {{ wiki:image.png?width }} (can be url)
" -: * unordered
" 1: - ordered list
" c: <code bash file.sh>\n</code>
" ====== headings =======
imap <C-w>h ====== ======<Esc>6hi
imap <C-w>h1 ====== ======<Esc>6hi
imap <C-w>h2 ===== =====<Esc>5hi
imap <C-w>h3 ==== ====<Esc>4hi
imap <C-w>h4 === ===<Esc>3hi
imap <C-w>h5 == ==<Esc>2hi
imap <C-w>h6 = =<Esc>1hi
map wh i====== ======<Esc>6hi
map wh1 i====== ======<Esc>6hi
map wh2 i===== =====<Esc>5hi
map wh3 i==== ====<Esc>4hi
map wh4 i=== ===<Esc>3hi
map wh5 i== ==<Esc>2hi
map wh6 i= =<Esc>1hi
" ==== Bold, Italic, Undeline, del ====
imap <C-w>bo ****<Esc>hi
imap <C-w>it ////<Esc>hi
imap <C-w>un ____<Esc>hi
imap <C-w>dd <lt>del><lt>/del><Esc>5hi
" ==== Lists ====
imap <C-w>- <esc>^i<space><space>*<space>
imap <C-w>1 <esc>^i<space><space>-<space>
imap <C-w>, <esc>:s!^ ! !e<CR>l:noh<CR>a
imap <C-w>. <esc>:s!^! !e<CR>l:noh<CR>a
" ==== Link ====
imap <C-w>l [[\|]]<Esc>2hi
" ==== Footnote ====
imap <C-w>f (())<Esc>1hi
" ==== Image ====
imap <C-w>i {{ :ns:image.jpg?200 \|}}<Esc>19hi
imap <C-w>im {{ :ns:image.jpg?200 \|}}<Esc>19hi
" ==== Code ====
imap <C-w>c <code bash file.sh><CR><CR></code><Esc>ki
map wc i<code bash file.sh><CR><CR></code><Esc>ki
" ==== Todo ====
map wt i<todo></todo><Esc>6hi
imap <C-t> <todo></todo><Esc>6hi
imap <C-w>t <todo></todo><Esc>6hi
imap <C-e> <Esc>$a
map <space> :<C-U>call Flip_todo()<CR>j^
function! Flip_todo ()
s!<todo>!<todo xXx>!eg
s!<todo #[^>]*>!<todo>!eg
s!<todo xXx>!<todo #me>!eg
endfunction
set tabstop=2
set shiftwidth=2
set smartindent
set timeoutlen=1500

31
vim/vimdw Executable file
View File

@@ -0,0 +1,31 @@
#!/bin/bash
function helpexit() {
cat <<EOF
Edit a file with dokuwiki syntax.
In insert mode:
Ctrl-w h1-6: ====== headings ======
Ctrl-w bb/ii/uu: **bold** //italic// __underline__
Ctrl-w dd: <del>deleted</del>
Ctrl-w l: [[URL|Title]]
Ctrl-w f: ((footnote))
Ctrl-w i/im: {{ wiki:image.png?width }} (can be url)
Ctrl-w -: * unordered
Ctrl-w 1: - ordered list
Ctrl-w , and .: de-indent and indent
Ctrl-w c: <code bash file.sh>\n</code>
normal mode:
Space toggles <todo>
EOF
exit
}
[[ -z "$1" ]] && helpexit
[[ "$1" = "-h" ]] && helpexit
case $OSTYPE in
darwin*) LIB=$( dirname $( realpath $0 ) )/dokuwiki.vim ;;
*) LIB=$( dirname $( readlink -f $0 ) )/dokuwiki.vim ;;
esac
vim -S "$LIB" "$@"