Merge commit 'f035c9318b23aea7479c124d749f5678c060e7b3'
This commit is contained in:
24
dots/.config/nvim/ftplugin/pandoc/anki.lua
Normal file
24
dots/.config/nvim/ftplugin/pandoc/anki.lua
Normal file
@@ -0,0 +1,24 @@
|
||||
vim.cmd([[
|
||||
" Anki helper functions
|
||||
|
||||
" Convert cloze note to regular text
|
||||
"
|
||||
" * `AnkiRemoveAllClozes` all cloze notes in file
|
||||
" * `AnkiRemoveSelectedClozes` all clozes in selected range
|
||||
"
|
||||
" E.g.
|
||||
"
|
||||
" ```markdown
|
||||
" START
|
||||
" Cloze
|
||||
" In this sentence {{c1::this word}} was closed.
|
||||
" END
|
||||
" ```
|
||||
"
|
||||
" ```markdown
|
||||
" In this sentence this word was closed.
|
||||
" ```
|
||||
|
||||
au FileType pandoc com! -range AnkiRemoveAllClozes :%s/\%V{{c\d\+:://ge | :%s/\%V}}//ge | :%s/\%VSTART\nCloze\n//ge | :%s/\%VEND\n//ge
|
||||
au FileType pandoc com! -range AnkiRemoveSelectedClozes :%s/\%V{{c\d\+:://ge | :%s/\%V}}//ge | :%s/\%VSTART\nCloze\n//ge | :%s/\%VEND\n//ge
|
||||
]])
|
||||
37
dots/.config/nvim/ftplugin/pandoc/wiki.lua
Normal file
37
dots/.config/nvim/ftplugin/pandoc/wiki.lua
Normal file
@@ -0,0 +1,37 @@
|
||||
-- NOTE: May want to move this, as it is more specific to wiki than to pandoc
|
||||
vim.api.nvim_create_user_command("AnkiDeck", function()
|
||||
local handle = io.popen("get-anki-decks")
|
||||
local decks = {}
|
||||
for line in handle:lines() do
|
||||
table.insert(decks, line)
|
||||
end
|
||||
handle:close()
|
||||
|
||||
vim.ui.select(decks, { prompt = "Select Anki deck" }, function(choice)
|
||||
if choice then
|
||||
vim.api.nvim_put({ choice }, "", true, true)
|
||||
end
|
||||
end)
|
||||
end, {})
|
||||
|
||||
vim.cmd([[
|
||||
set cc=81
|
||||
set cocu=""
|
||||
func! GetContext()
|
||||
" https://stackoverflow.com/questions/9464844/how-to-get-group-name-of-highlighting-under-cursor-in-vim
|
||||
if !exists("*synstack")
|
||||
return
|
||||
endif
|
||||
let matches = map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
|
||||
if index(matches, 'pandocLaTeXInlineMath') >= 0
|
||||
echo 'math_inline'
|
||||
elseif index(matches, 'pandocLaTeXMathBlock') >= 0
|
||||
echo 'math_block'
|
||||
elseif !empty(matches)
|
||||
echo matches[0]
|
||||
else
|
||||
echo ''
|
||||
endif
|
||||
endfunc
|
||||
com! -nargs=0 GetContext :call GetContext()
|
||||
]])
|
||||
Reference in New Issue
Block a user