Adding Spell Check To The Neovim Tree-Sitter Plugin
Introduction
These are my notes for adding spell check to new sections of my tree-sitter neopolitan plugin for neovim.
The key was to do this in
((paragraph_first_word) @spell)
((word) @spell)
Where these already existed:
(paragraph_first_word) @neo_paragraph_first_word
(word) @neo_paragraph_nth_word
the tree-sitter plugin is currently set up so that each section type has to be added individually to use spell check. I'm not going to mess with that too much since the real goal is to make an LSP for neopolitan that is more robust.
Adding A New Section
-
The project is
workshop/tree-sitter-neopolitan
-
Run
start-full-gen-and-test
-
Create a new test in the
corpus
directory by copying an existing one -
Start by creating a
choice
entry for the section in thegrammar.js
file based on the name of the section type (e.g.endnote_section
) -
Add the new section function in the main body of the
grammar.js
file.(e.g. copy
p_section
and replace thep_token
in it with whatever the name of the new section is) -
Add the
$.NAME_token
entry to the list ofexternals
in thegrammar.js
file alphabetical order. -
Add a key for the token in the
TokenType
ofsrc/scanner.cc
-
Follow the directions in the comments of
find_token
in thesrc/scanner.cc
file. -
Follow the directions in the README.neo for how to install the update.
NOTE: You might have to use VS code to read the file because nvim might fight with the plugin until it's been fully re-installed/updated.