GithubHelp home page GithubHelp logo

Comments (10)

lewis6991 avatar lewis6991 commented on June 25, 2024 2

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.

ravibrock avatar ravibrock commented on June 25, 2024

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.

lewis6991 avatar lewis6991 commented on June 25, 2024

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.

ravibrock avatar ravibrock commented on June 25, 2024

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.

lewis6991 avatar lewis6991 commented on June 25, 2024
  • 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.

ravibrock avatar ravibrock commented on June 25, 2024

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.

asmodeus812 avatar asmodeus812 commented on June 25, 2024

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.

lewis6991 avatar lewis6991 commented on June 25, 2024

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.

asmodeus812 avatar asmodeus812 commented on June 25, 2024

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.

lewis6991 avatar lewis6991 commented on June 25, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.