From 22e23ba4162abe49df50fcea0902e41c929dde22 Mon Sep 17 00:00:00 2001 From: Hektor Misplon Date: Thu, 15 May 2025 17:08:35 +0200 Subject: [PATCH] Migrate pandoc 'AnkiDeck' function to neovim --- .config/nvim/ftplugin/pandoc.lua | 15 +++++++++++++++ .vim/ftplugin/pandoc/wiki.vim | 6 ------ 2 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 .config/nvim/ftplugin/pandoc.lua diff --git a/.config/nvim/ftplugin/pandoc.lua b/.config/nvim/ftplugin/pandoc.lua new file mode 100644 index 0000000..1a97d9e --- /dev/null +++ b/.config/nvim/ftplugin/pandoc.lua @@ -0,0 +1,15 @@ +-- 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, {}) diff --git a/.vim/ftplugin/pandoc/wiki.vim b/.vim/ftplugin/pandoc/wiki.vim index 8d928f7..58c9a69 100644 --- a/.vim/ftplugin/pandoc/wiki.vim +++ b/.vim/ftplugin/pandoc/wiki.vim @@ -17,9 +17,3 @@ func! GetContext() endif endfunc com! -nargs=0 GetContext :call GetContext() - -function! Put(str) - put = a:str -endfunction - -com! -nargs=0 AnkiDeck call fzf#run(fzf#wrap({'source': 'get-anki-decks', 'sink': function('Put')}))