Skip to content

CamdenClark/neoanki

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Neoanki

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.

Requirements and Installation

  1. Anki must be started, and you must install the AnkiConnect plugin

  2. Have curl installed on your machine

  3. Install plenary.nvim and Neoanki using your package manager:

For example, using plug

Plug 'nvim-lua/plenary.nvim'
Plug 'CamdenClark/Neoanki'

Creating a cloze note

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.

Creating a basic note

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.

Alternative basic note creation

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.

Changing the deck or tags mid-session

You can select the deck or tags that further calls to :AnkiCreateBasic and :AnkiCreateCloze will use.

Call :AnkiSelectDeck <deck-name> or :AnkiSelectTags <tag1> <tag2> ...

Configuration

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 = {}
})

Development

Run tests

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.

About

a lightweight integration with anki for neovim

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published