Lekha
is a minimalist (in appearance and function) NeoVim plugin for novel
writing:
- It expects the work to be all in one file.
- Top level headings (Lines that start with
#
) are interpreted as chapters. - Lines that start with markdown comments (
<!--
) are interpreted as TODOs. - It uses NeoVim's native command auto-complete feature to display chapters,
chapter word counts and TODOs when the
LekhaGoto
command is called (Please see screenshot above). - There is no split pane. This reduces visual clutter while keeping the information accessible.
git clone
the repository (or just copy the lua
folder) to somewhere in your
runtime path. Then add something like this to your markdown.vim
:
-- Register Lekha commands
lua require("lekha").enable()
-- Register a convenient shortcut key
nmap <Tab> :LekhaGoto<Space>
Now by hitting Tab twice in normal mode you can access the LekhaGoto
command
and NeoVim's auto-complete will list chapters and TODOs.
Add %{%v:lua.require'lekha'.current_chapter()%}
to the status line to print
the chapter the cursor is in.
Lekha
supplies two other commands LekhaGotoChapter
and LekhaGotoTodo
where
the auto-completion shows only chapters or TODOs respectively.
- I had little trouble writing this NeoVim plugin in Lua though I had never written a NeoVim plugin before and didn't know Lua. The NeoVim documentation is adequate though I had to supplement with web searches for a few things.
- Vim/NeoVim's editing efficiency impresses me. I have a 140,000 word manuscript and Vim/NeoVim handles it without any issue. I used VS Code for a long time but when I tried editing the manuscript with it, the simple task of word wrapping (which needs a plugin on VS Code) broke in a subtle way making it unusable.
- I used an O(N) algorithm (N = manuscript length). It takes ~20ms to process a 140,000 word (~800 kB)text, which is decently fast for an interpreted, studiously dynamic language.
- Ordered arrays
- Calling NeoVim commands from Lua
- Creating autocommands and commands
- outline.nvim is both way more powerful and not powerful enough for my writing needs. It has a split-pane outline view, but not per-chapter word count and no TODO/bookmark feature.
- minimal-bookmarks.nvim
- section-wordcount.nvim