JuliaEditorSupport / julia-vim

Vim support for Julia.
http://julialang.org/
Other
745 stars 93 forks source link

Visual select block does not work with astrovim's default config #300

Open sash-a opened 1 year ago

sash-a commented 1 year ago

Hi there, this could absolutely be because I'm a complete vim noob, but vaj does not seem to be working correctly for me. Given this example:

module Test

greet() = print("Hello World!")

for i in 1:100
   nothing
end

end # module

If I put my cursor at the start of the for loop and type vaj it only selects the end at the end of the loop instead of the whole loop, so vaj y p would just paste end instead of the whole for loop block.

Using nvim 0.7.3 with astro nvim's config, julia-vim is the only other custom plugin I am using other than adding the julia ls (not sure if that counts as a plugin). Also on Pop!_OS if that helps.

Hneuschmidt commented 1 year ago

I have this same problem with my config (not using astrovim). The other movement commands also do not work (reliably), especially using % does not work at all.

:echo JuliaGetMatchWords() always returns \<\>:\<\> which is not correct I assume.

Hneuschmidt commented 1 year ago

Okay I did some more digging. The issue stems from me (and AstroVim) using Treesitter for syntax highlighting.

The filetype plugin from julia-vim relies on synID() in line 58: let attr = synIDattr(synID(l, c, 1),"name").

However, when using treesitter for syntax highlighting, synID() always returns 0 which breaks the rest of the JuliaGetMatchWords() function.

In case you (@sash-a) haven't found some other solution, you can make the navigation commands work by disabling treesitter for julia files.

You can do that like this:

require"nvim-treesitter.configs".setup({ ignore_install = {"julia"} }),

in your treesitter configuration and then uninstalling the TS parser for julia:

:TSUninstall julia

It would be nice if there was a way to use julia specific navigation while also using treesitter, but disabling it resolves the problem as a workaround.

ArbitRandomUser commented 4 months ago

i seem to run into this behaviour without Treesitter installed , i can confirm that my juliagetmatchwords returns

\%(\%(\%(@\%([#(]\@!\S\)\+\|\<\%(local\|global\)\)\s\+\)\@<!\%(\%(@\%([#(]\@!\S\)\+\|\<\%(local\|global\)\)\s\+\)\+\%(\.\s*\|@\)\@<!\<\%(function\|macro\|begin\|mutable\s\+struct\|\%(mutable\s\+\)\@<!struct\|\%(abstract\|primitive\)\s\+type\|let\|do\|\%(bare\)\?module\|quot
e\|if\|for\|while\|try\)\>\)\|\%(\%(\%(@\%([#(]\@!\S\)\+\|\<\%(local\|global\)\)\s\+\)\@<!\%(\.\s*\|@\)\@<!\<\%(function\|macro\|begin\|mutable\s\+struct\|\%(mutable\s\+\)\@<!struct\|\%(abstract\|primitive\)\s\+type\|let\|do\|\%(bare\)\?module\|quote\|if\|for\|while\|try\)\
>\):\<end\>