Skip to content
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

nvim-treesitter config for Ruby on Rails is slow #1141

Closed
jrupinski opened this issue Sep 13, 2024 · 12 comments
Closed

nvim-treesitter config for Ruby on Rails is slow #1141

jrupinski opened this issue Sep 13, 2024 · 12 comments

Comments

@jrupinski
Copy link

jrupinski commented Sep 13, 2024

Describe the bug

Current default config for nvim-treesitter is slow on Ruby files (navigation has tiny lag on ~300 line files, probably smaller too)

It seems it's due to changes made for Ruby in this commit .

They probably made sense at the time, I don't think they're still required.
After reverting the changes, it seems to work as snappy as expected.
To be exact - additional_vim_regex_highlighting = { 'ruby' } seems to be the one causing slowdowns.

To Reproduce

  1. Install a fresh copy of kickstart.nvim
  2. Open a .rb file, navigate around it using hjkl (should be couple hundred ms late)
  3. open init.lua, revert the changes from commit mentioned , so nvim-treesitter config looks like this:
    opts = {
     (...)
      highlight = { enable = true },
      indent = { enable = true },
    },
  1. Open the same .rb file, it should work much snappier.

Desktop

  • OS: macOS 14.6.1 (23G93)
  • Terminal: Kitty 0.35.2

Neovim Version

NVIM v0.10.1
Build type: Release
LuaJIT 2.1.1725453128

@feoh
Copy link
Collaborator

feoh commented Sep 16, 2024

This has nothing to do with kickstart.nvim - please file a bug with treesitter.

@feoh feoh closed this as completed Sep 16, 2024
@rmacklin
Copy link
Contributor

@feoh I think they're proposing that line should be removed from kickstart.nvim's config

@feoh
Copy link
Collaborator

feoh commented Sep 24, 2024

@rmacklin Thanks for pointing that out. Re-opening.

Now who's up for generating a pull request I can review? :) Issues are fine but diffs are spiffier :P

@feoh feoh reopened this Sep 24, 2024
@feoh
Copy link
Collaborator

feoh commented Sep 24, 2024

@jrupinski Please just file a pull request and I'll merge it. This makes sense to me.

@feoh
Copy link
Collaborator

feoh commented Sep 25, 2024

Actually giving this a careful read, I'm unsure whether or not this request actually makes sense.

If I understand correctly, the line in question enables fuller syntax highlighting for Ruby regex syntax, at the expense of some startup time.

@rmacklin Is that your understanding as well? If so, I don't think we should remove it. I'd entertain a PR that adds a comment citing the fact that this can increase startup time if this feature isn't desired by removing it, but simply making that decision for all Neovim Ruby users feels like the wrong call to me.

If folks disagree, please feel free to re-open or better provide a PR and we can hash it out there and then.

@feoh feoh closed this as completed Sep 25, 2024
@rmacklin
Copy link
Contributor

rmacklin commented Sep 25, 2024

I interpreted "navigation has lag" to mean that e.g. scrolling through was laggy, not that it was just slow to initially start up. But perhaps @jrupinski can clarify.

@jrupinski
Copy link
Author

jrupinski commented Sep 26, 2024

Hi, to clarify - I'm not talking start-up, nor does it affect it AFAIK.

Navigation has an input delay of sorts, not sure whether it's due to a specific case (eg. moving between different code blocks) or if it lags overall.

The change proposed was indeed part of kickstart, not treesitter, and seems to fix the issue (I've been working with this change for a month now as part of my day job in RoR project)

I'll create a PR then 🙂 I should have done that from the start but wanted to verify/discuss it with someone associated with the project.

@JaredSharplin
Copy link

Was going to open an issue but found this. I've been experiencing the same navigation lag in large ruby files and found removing additional_vim_regex_highlighting = { 'ruby' } fixed it. From what I can tell from looking online additional_vim_regex_highlighting is discouraged: https://www.reddit.com/r/neovim/comments/yxjrkr/treesitter_syntax_highlighting_too_slow_on_large/

@feoh
Copy link
Collaborator

feoh commented Jan 6, 2025

I don’t edit much Ruby at all so if you’d like, please feel free to submit a full request with this setting removed and I’ll be happy to merge it.

@feoh
Copy link
Collaborator

feoh commented Jan 7, 2025

@JaredSharplin Thinking about this I'm going to propose a PR to remove this setting.

Ruby/Rails peeps, if removing this will destroy your world, speak now or forever hold your peace :)

@feoh
Copy link
Collaborator

feoh commented Jan 7, 2025

@jrupinski @JaredSharplin Would this do the trick?

Please weigh in. I'd also REALLY appreciate other rubyists commenting on this change.

@feoh
Copy link
Collaborator

feoh commented Jan 9, 2025

There's no solution to this. The "fix" breaks indenting for folks with ruby LSP.

Folks who don't use the LSP and want better perf can comment it out in their forks. Closing.

@feoh feoh closed this as completed Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants