-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Programmatic way of getting spelling errors #29167
Comments
You can use |
Thanks for the reply. I was thinking it could be useful to have something that would integrate with things like Treesitter automatically (whereas |
I guess the main point is that Neovim already exposes everything needed for this to be implemented so there isn't anything that can't be done via a custom function or plugin. |
How does it expose something like "get next spelling error"? I went through the source code and it looks like |
It isn't exactly the same as what the C codebase does, but I'm not sure it needs to be. And I'm not sure it's even feasible given how it is implemented in C. Last time I checked I remember being quite ad-hoc. We can, if need be, improve the API for any one of these points. |
That makes sense, thanks. I'll try to implement iteration through |
Problem
The neovim spell checker is very useful, but there doesn't seem to be any straightforward way to get all spelling mistakes in a buffer with Lua without iterating through them with
]s
. Ideally, there would be a function likevim.fn.get_spelling_errors(bufnr)
that would return all errors in a buffer as a table (while preserving things like Treesitter context-dependence that are ignored byvim.spell.check()
.Expected behavior
The new feature would look like a function that returns the same result that would be provided by iterating through the buffer with
]s
and writing down each mistake found. This would solve the problem, and it would be useful because it would (probably) be faster than iterating through, would definitely be more elegant, and would be simpler to run in the background as it wouldn't require moving and then resetting the cursor. Something like:The text was updated successfully, but these errors were encountered: