Skip to content

kghose/lekha.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Lekha.nvim

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.

Installation

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.

Use in statusline

Add %{%v:lua.require'lekha'.current_chapter()%} to the status line to print the chapter the cursor is in.

Other commands

Lekha supplies two other commands LekhaGotoChapter and LekhaGotoTodo where the auto-completion shows only chapters or TODOs respectively.

Notes

  1. 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.
  2. 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.
  3. 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.

Lua/NeoVim API Concepts

  1. Ordered arrays
  2. Calling NeoVim commands from Lua
  3. Creating autocommands and commands

References

  1. 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.
  2. minimal-bookmarks.nvim
  3. section-wordcount.nvim

About

NeoVim plugin for writers using Markdown

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages