Comments (10)
You can use vim.spell.check
and pass in each line of the buffer manually. I don't think we need to provide a first class function for this.
from neovim.
Thanks for the reply. I was thinking it could be useful to have something that would integrate with things like Treesitter automatically (whereas vim.spell.check
is strictly strings), but it might be too niche.
from neovim.
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.
from neovim.
How does it expose something like "get next spelling error"? I went through the source code and it looks like ]s
is hardcoded in C--there isn't an API for getting the location of the next spelling error. I guess my suggestion is to expose whatever method(s) Neovim uses internally to jump to the next spelling error in such a way that they can be called directly in Lua, since presumably they exist in the C codebase (and, since they're implemented in C, are probably faster than comparable Lua implementations). But I'm not 100% sure how complicated that would be.
from neovim.
- You can get the buffer text
- You can iterate words using a pattern.
- You can check if a certain position has a
@spell
capture - You can check the spelling of a string.
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.
from neovim.
That makes sense, thanks. I'll try to implement iteration through @spell
groups tomorrow and see how it goes. If I can get that working it would probably be as close to an ideal solution as is necessary.
from neovim.
You can use
vim.spell.check
and pass in each line of the buffer manually. I don't think we need to provide a first class function for this.
Why would we want to do the work again (and it does not scale at all, huge buffers with a lot of lines will require you to dump the entire contents as arrays of strings into the lua runtime, go through it line by line pass it to the function to in the end obtain information that is already known to vim... what ???? ) ? The spelling checks are already processed and obtained from vim in the buffer, there is no reason to do the same work again, simply to obtain the same information because there is no public api to do so. I think this is a flawed approach. This makes only sense if the user has not enabled spell checking for the buffer and wants to manually compute them and do something else. So both the vim.spell.check and a dedicated api to extract already processed spelling errros, have their applications
from neovim.
Why would we want to do the work again ?
Nvim hasn't done the work yet. It only checks what is visible on screen and does it every screen refresh.
It's best to check the code before making assumptions about how things work.
from neovim.
It does some work for the visible part, so visible spelling errors are processed at least. What you probably mean to imply is that vim does not all about all
the spelling errors at the moment the buffer is read.
from neovim.
It does some work for the visible part, so visible spelling errors are processed at least.
Yes which is usually a very small fraction of the buffer.
And to repeat it does this every single screen redraw (not on reading the buffer) and the results are never cached, so it's not expensive to run and there is no problem doing this again in an interactive context for the whole buffer.
from neovim.
Related Issues (20)
- <afile> cannot be expanded when running with -V1 HOT 2
- Built-in xml tags auto- close and rename HOT 6
- nvim -l does not support reading from stdin HOT 2
- Allow registering additional sources for `vim.lsp.completion` HOT 2
- ShaDa file corruption on nightly HOT 10
- `vim.keymap.del(mode, keymap, {buffer=true})` is broken on 0.10.0 HOT 1
- vim.highlight.range does not support -1 as column value HOT 8
- `/[^\x00-\]` matches non ascii characters HOT 6
- Text edits with the same start position are applied in reverse HOT 5
- Incorrect conceal in help HOT 4
- Setting `clipboard` to "unnamedplus" cannot be reverted in lua HOT 1
- nvim reports error when using "help". HOT 2
- Error with built-in lsp completion HOT 1
- E886: Failed to create directory /Users/{my-user}/.local/state/nvim for writing Sha Da file: permission denied
- Diagnostics don't show when using <C-c> to exit insert mode HOT 1
- LSP completion: display documentation if exists for an item HOT 2
- E5113 error during install HOT 2
- Missing optional for `vim.lsp.inlay_hint.is_enabled` parameter HOT 1
- terminal COLUMNS/LINES not respected at startup, shows a small window (foot terminal) HOT 3
- nvim_set_hl does not work in (v0.9.4 / macOS v14.4.1) HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from neovim.