Neoanki is a Neovim plugin that facilitates quickly creating notes in Anki using the AnkiConnect plugin.
Neoanki is focused around simple interactions inside any buffer, instead of just replicating the Anki form in a special buffer.
-
Anki must be started, and you must install the AnkiConnect plugin
-
Have curl installed on your machine
-
Install
plenary.nvim
andNeoanki
using your package manager:
For example, using plug
Plug 'nvim-lua/plenary.nvim'
Plug 'CamdenClark/Neoanki'
Let's say you have the following sentence in a buffer:
The Eiffel Tower is in the city of Paris
You can either manually add a cloze here, or you can select part of the
text in visual mode and call :AnkiWrapCloze
:
The Eiffel Tower is in the city of {{c1::Paris}}
Then, you can highlight the entire sentence in visual mode, and call :AnkiCreateCloze
.
This will create a cloze note with that text.
Let's say you have the following sentence in a buffer:
Where is the Eiffel Tower?
You can highlight the entire sentence in visual mode, and call :AnkiCreateBasic
.
Neovim will prompt you for the back, where you can type in Paris
.
This will create a basic note with that Front and Back text.
Alternatively you can create a basic note in one go by typing out this:
Where is the Eiffel Tower?
===
Paris
You can highlight all three lines in visual mode, and call :AnkiCreateBasic
.
This will skip the prompting step and allow you to directly create a note.
You can select the deck or tags that further calls to :AnkiCreateBasic
and
:AnkiCreateCloze
will use.
Call :AnkiSelectDeck <deck-name>
or :AnkiSelectTags <tag1> <tag2> ...
Here is how you configure options for Neoanki. What's shown is the defaults:
require('anki.config').setup({
deckName = "Default",
anki_connect = { url = "http://localhost:8765", api_key = nil },
tags = {}
})
Running tests requires plenary.nvim to be checked out in the parent directory of this repository. You can then run:
just test
or, more verbose:
nvim --headless --noplugin -u tests/minimal.vim -c "PlenaryBustedDirectory tests/ {minimal_init = 'tests/minimal.vim'}"
Or if you want to run a single test file:
just test chat_spec.lua
nvim --headless --noplugin -u tests/minimal.vim -c "PlenaryBustedDirectory tests/path_to_file.lua {minimal_init = 'tests/minimal.vim'}"
Read the nvim-lua-guide for more information on developing neovim plugins.