Skip to content

Commit

Permalink
docs(VimwikiReference): update manual
Browse files Browse the repository at this point in the history
build(Makefile): use target $@ and pre-commit. Add EditorConfig.

test(vimrc): adopt Vimwiki Wiki configuration. Add SetSyntax.
  • Loading branch information
jfishe committed Jan 1, 2024
1 parent abfd27b commit c4ab0fe
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 24 deletions.
47 changes: 47 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

EditorrConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true

[*.{js,py,html,html5}]
charset = utf-8

[*.{md,mdpp,diff,vim}]
trim_trailing_whitespace = false

[{vimrc,gvimrc}]
trim_trailing_whitespace = false

[*.py]
indent_style = space
indent_size = 4

[Makefile]
indent_style = tab

[*.{json,yml}]
indent_style = space
indent_size = 2

[*.{cs}]
indent_size = 4
trim_trailing_whitespace = true

[*.{json}]
indent_size = 2
trim_trailing_whitespace = true

[*.{ps1,psm1,psd1}]
indent_size = 4
trim_trailing_whitespace = true

[*.{ps1xml,props,xml,yaml}]
indent_size = 2
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

## Version 0.6 (development)

- Use pandoc `citeproc` to convert reference citations, replacing the anchor
links.
- Vim command `:VimwikiReference` converts
[Pandoc Citations](https://pandoc.org/MANUAL.html#citation-syntax)
to [reference links](https://pandoc.org/MANUAL.html#reference-links),
e.g.,`[anchor:]`, replacing the current file.
- BUILD: Use pre-commit to remove trailing spaces from Vim help.

## Version 0.5 (2023-12-04)

Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ ${vimdoc_targets}: | ${lua-filter}/include-files.lua ${lua-filter}/panvimdoc.lua
--lua-filter=${lua-filter}/include-files.lua \
--lua-filter=${lua-filter}/skip-blocks.lua \
--to=${lua-filter}/panvimdoc.lua \
--output=doc/panvimwiki.txt \
--output=$@ \
$<
pipx run pre-commit run --files $@

${lua-filter}/include-files.lua ${lua-filter}/panvimdoc.lua ${lua-filter}/skip-blocks.lua: | build/
cd build && \
Expand Down
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,13 +244,17 @@ After concatenating DiaryNotes for the week, behave as [VimwikiConvert](#vimwiki

##### VimwikiReference

If in markdown format, pandoc reads the current buffer, with citeproc
references to a BibLaTeX or other supported database, and appends references
links and the complete citation, according to the default citation style
language (CSL). Pandoc also converts the citeproc style references to markdown
links. `VimwikiReference` overwrites the file, so Vim may prompt to reload the
buffer (cf. `:h W12`). If you choose not to reload the buffer, `:h :DiffOrig`
allows review of the changes.
If in markdown format, convert
[Pandoc Citations](https://pandoc.org/MANUAL.html#citation-syntax)
in the current file to
[reference links](https://pandoc.org/MANUAL.html#reference-links)
and append to the end of the file. The Yaml metadata should
[specify the bibliographic data](https://pandoc.org/MANUAL.html#specifying-bibliographic-data).

The reference link conversion assumes Pandoc's default citation style
language (CSL). `VimwikiReference` overwrites the file, so Vim may prompt to
reload the buffer (cf. Warning `:h W12`). If you choose not to reload the
buffer, `:h :DiffOrig` allows review of the changes.

### Settings

Expand Down
17 changes: 10 additions & 7 deletions doc/panvimwiki.txt
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,16 @@ After concatenating DiaryNotes for the week, behave as

VimwikiReference *panvimwiki-VimwikiReference*

If in markdown format, pandoc reads the current buffer, with citeproc
references to a BibLaTeX or other supported database, and appends references
links and the complete citation, according to the default citation style
language (CSL). Pandoc also converts the citeproc style references to markdown
links. `VimwikiReference` overwrites the file, so Vim may prompt to reload the
buffer (cf. |W12|). If you choose not to reload the buffer, |:DiffOrig| allows
review of the changes.
If in markdown format, convert Pandoc Citations
<https://pandoc.org/MANUAL.html#citation-syntax> in the current file to
reference links <https://pandoc.org/MANUAL.html#reference-links> and append to
the end of the file. The Yaml metadata should specify the bibliographic data
<https://pandoc.org/MANUAL.html#specifying-bibliographic-data>.

The reference link conversion assumes Pandoc’s default citation style
language (CSL). `VimwikiReference` overwrites the file, so Vim may prompt to
reload the buffer (cf. Warning |W12|). If you choose not to reload the buffer,
|:DiffOrig| allows review of the changes.


SETTINGS *panvimwiki-settings*
Expand Down
78 changes: 71 additions & 7 deletions tests/vim/vimrc
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,86 @@ execute 'set rtp+=' .. panvimwiki_path .. '/after'
execute 'set rtp-=' .. expand("~/.vim")
execute 'set rtp-=' .. expand("~/.vim/after")

" Configure Vimwiki
let s:wiki_1 = {}
let s:wiki_1.path = g:my_wiki . '/vimwiki/'
let s:wiki_1.path_html = g:my_wiki . '/vimwiki_html/html'
let s:wiki_1.template_path = g:my_wiki . '/vimwiki_html/templates/'
let g:vimwiki_list = [ s:wiki_1 ]
" Wikis configuration {{{
" Declare default syntax {{{
let vimwiki_default = {}
let vimwiki_default.path = g:my_wiki .. '/vimwiki/'
let vimwiki_default.path_html = g:my_wiki .. '/vimwiki_html/html'
let vimwiki_default.template_path = g:my_wiki .. '/vimwiki_html/templates/'
let vimwiki_default.syntax = 'default'
let vimwiki_default.ext = '.wiki'
let vimwiki_default.name = 'DefaultSyntax'
" }}}
" Declare markdown syntax - https://github.github.com/gfm/ {{{
let vimwiki_markdown = {}
let vimwiki_markdown.path = g:my_wiki .. '/vimwiki/'
let vimwiki_markdown.path_html = g:my_wiki .. '/vimwiki_html/html'
let vimwiki_markdown.syntax = 'markdown'
let vimwiki_markdown.ext = '.md'
let vimwiki_markdown.name = 'MarkdownSyntax'
" }}}

let g:vimwiki_list = [vimwiki_default, vimwiki_markdown]
let g:vimwiki_list_vimrc = [vimwiki_default, vimwiki_markdown]
" }}}


" Configure Panvimwiki
let g:panvimwiki_settings = {}
let g:panvimwiki_settings.extra_args = [
\ '--shift-heading-level-by', '1',
\ '--data-dir', s:wiki_1.template_path
\ '--data-dir', vimwiki_default.template_path
\ ]
let g:panvimwiki_settings.format = 'docx'

set loadplugins
filetype plugin indent on
syntax enable

function! SetSyntax(vw_syn)
" Change the syntax using a temporary wiki
" Change extension and wiki_nr
let index=0
if a:vw_syn ==# 'default'
let ext = 'wiki'
let index=0
elseif a:vw_syn ==# 'markdown'
let ext = 'md'
let index=1
else
Log 'ERROR: Invalid syntax "' . a:vw_syn . '" in SetSyntax()'
Log 'NOTE: function only accepts "media" for setting mediawiki syntax'
return
endif

" Change temporary wiki
let path = expand('%:p:h')
let new_temp_wiki_settings = {
\ 'path': path,
\ 'ext': ext,
\ 'syntax': a:vw_syn,
\ 'bullet_types': g:vimwiki_wikilocal_vars[index]['bullet_types'],
\ }

" Remove any temporary wikis each time this function is called.
" This is necessary to ensure syntax is properly set when running multiple tests
" NOTE: this assumes there are 3 defined wikis in the vimrc. The last wiki
" contains default settings for temporary wikis (so there are always
" num wikis in vimrc + 1)
let num_wikis = len(g:vimwiki_wikilocal_vars)
while num_wikis > 3
call remove(g:vimwiki_wikilocal_vars, num_wikis - 1)
let num_wikis = num_wikis - 1
endwhile

" Add the new wiki
call vimwiki#vars#add_temporary_wiki(new_temp_wiki_settings)
call vimwiki#vars#set_bufferlocal('wiki_nr', 2)

" Verify syntax was set correctly
Assert vimwiki#vars#get_wikilocal('syntax') ==# a:vw_syn,
\ 'ERROR: Vimwiki syntax not set correctly: '
\ . 'Want: ' . a:vw_syn . ' '
\ . 'Have: ' . vimwiki#vars#get_wikilocal('syntax')
endfunction
" vim:tabstop=2:shiftwidth=2:expandtab:foldmethod=marker:textwidth=79

0 comments on commit c4ab0fe

Please sign in to comment.