nvimdots icon indicating copy to clipboard operation
nvimdots copied to clipboard

query.lua:259: query: invalid node type at position 574 for language swift

Open Saafo opened this issue 2 months ago • 5 comments

Version confirmation

  • [X] Confirm

Following prerequisites

  • [X] Confirm

Not a user config issue

  • [X] Confirm

Neovim version

0.9.5

Operating system/version

14.2.1

Terminal name/version

Warp

$TERM environment variable

No response

Branch info

main (Default/Latest)

Fetch Preferences

SSH (use_ssh = true)

How to reproduce the issue

  1. open a swift file(empty is ok, and add import Foundation and so on)

Expected behavior

No error occurred.

Actual behavior

image

Some error occurred.

Additional information

I'm not sure whether it's reproducible on other devices.

Saafo avatar Apr 16 '24 05:04 Saafo

seems like an upstream issue.

CharlesChiuGit avatar Apr 16 '24 05:04 CharlesChiuGit

I'm not sure which upstream it relates to 😭 so I post it here

Saafo avatar Apr 16 '24 05:04 Saafo

I'm not sure which upstream it relates to 😭 so I post it here

It seems like this issue is indeed on our end. I also work with Swift daily and can reliably reproduce this problem: err_msg

Just a quick confirmation: have u followed the instructions outlined in one of our pinned issues to obliterate any potential treesitter-compiled binary issues? If that doesn't work, u could try waiting for 1-2 secs after entering the TUI but before starting ur editing.[^1]

[^1]: At first glance it appears that the problem is related to how Treesitter operates. We load Treesitter on the BufReadPre event with its configuration (function) wrapped inside a scheduled event. This might be accidentally blocked by other ongoing operations, mainly because the parser itself is slow or the file is large. Consequently, one may observe that the file isn't being parsed, and Treesitter highlights aren't being applied (hence the error). I'll work on a fix later once I've identified the root cause. For now, the workaround I can suggest is precisely the one I mentioned earlier.

Jint-lzxy avatar Apr 16 '24 16:04 Jint-lzxy

@Jint-lzxy Thanks for the hint! I tried the solution (TSUpdate && TSInstall! swift) and restart nvim, the issue is gone. Does this work for you?

Another issue is that I've met the tree-sitter or other plugins issue once before, and I notice that the error continues generate no matter how I press enter or esc. This prevents me from using nvim AS A BASIC TEXT EDITOR. I think the error of tree sitter shouldn't prevent the most basic text edit feature.

Saafo avatar Apr 17 '24 09:04 Saafo

I tried the solution (TSUpdate && TSInstall! swift) and restart nvim, the issue is gone. Does this work for you?

Yeah I find it super handy for like 99% of parser-related issues lol

Another issue is that I've met the tree-sitter or other plugins issue once before, and I notice that the error continues generate no matter how I press enter or esc. This prevents me from using nvim AS A BASIC TEXT EDITOR. I think the error of tree sitter shouldn't prevent the most basic text edit feature.

Yep that's exactly what I was saying earlier, and your points totally make sense. I switched the loading event to BufReadPost for Treesitter recently, and haven't had any problems since. I'll give it a thorough test later, but I'm pretty sure this should be the right way to go lmao

Jint-lzxy avatar Apr 18 '24 12:04 Jint-lzxy