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

neovim creates wrong directory for parsers #23261

Open
2 of 6 tasks
dominicattal opened this issue Feb 1, 2025 · 6 comments
Open
2 of 6 tasks

neovim creates wrong directory for parsers #23261

dominicattal opened this issue Feb 1, 2025 · 6 comments
Labels

Comments

@dominicattal
Copy link

dominicattal commented Feb 1, 2025

Description / Steps to reproduce the issue

After installing neovim using pacman -S mingw-w64-ucrt-x86_64-neovim, whenever I tried to open a help page with :h, I would get this error message:

Error detected while processing BufNewFile Autocommands for "*":
Error executing lua callback: ...pData\Local\msys2\ucrt64\share\nvim\runtime\filetype.lua:35: Error executing lua: ...pData\Local\msys2\ucrt64\share\nvim\runt
ime\filetype.lua:36: BufNewFile Autocommands for "*"..FileType Autocommands for "*"..function <SNR>1_LoadFTPlugin[20]..script C:\Users\attal\AppData\Local\msy
s2\ucrt64\share\nvim\runtime\ftplugin\lua.lua: Vim(runtime):E5113: Error while calling lua chunk: ...crt64\share\nvim\runtime/lua/vim/treesitter/language.lua:
107: no parser for 'lua' language, see :help treesitter-parsers
stack traceback:
        [C]: in function 'error'
        ...crt64\share\nvim\runtime/lua/vim/treesitter/language.lua:107: in function 'add'
        ...4\share\nvim\runtime/lua/vim/treesitter/languagetree.lua:111: in function 'new'
        ...l\msys2\ucrt64\share\nvim\runtime/lua/vim/treesitter.lua:41: in function '_create_parser'
        ...l\msys2\ucrt64\share\nvim\runtime/lua/vim/treesitter.lua:108: in function 'get_parser'
        ...l\msys2\ucrt64\share\nvim\runtime/lua/vim/treesitter.lua:416: in function 'start'
        ...a\Local\msys2\ucrt64\share\nvim\runtime\ftplugin\lua.lua:2: in main chunk
        [C]: in function 'nvim_cmd'
        ...pData\Local\msys2\ucrt64\share\nvim\runtime\filetype.lua:36: in function <...pData\Local\msys2\ucrt64\share\nvim\runtime\filetype.lua:35>
        [C]: in function 'nvim_buf_call'
        ...pData\Local\msys2\ucrt64\share\nvim\runtime\filetype.lua:35: in function <...pData\Local\msys2\ucrt64\share\nvim\runtime\filetype.lua:10>
stack traceback:
        [C]: in function 'nvim_cmd'
        ...pData\Local\msys2\ucrt64\share\nvim\runtime\filetype.lua:36: in function <...pData\Local\msys2\ucrt64\share\nvim\runtime\filetype.lua:35>
        [C]: in function 'nvim_buf_call'
        ...pData\Local\msys2\ucrt64\share\nvim\runtime\filetype.lua:35: in function <...pData\Local\msys2\ucrt64\share\nvim\runtime\filetype.lua:10>
stack traceback:
        [C]: in function 'nvim_buf_call'
        ...pData\Local\msys2\ucrt64\share\nvim\runtime\filetype.lua:35: in function <...pData\Local\msys2\ucrt64\share\nvim\runtime\filetype.lua:10>

Upon further inspection, I found that the package is downloading a directory parsers instead of parser at /ucrt64/share/nvim/runtime, as indicated by the nvim documentation for treesitter-parsers:

Parsers are searched for as parser/{lang}.* in any 'runtimepath' directory.
If multiple parsers for the same language are found, the first one is used.
(NOTE: This typically implies the priority "user config > plugins > bundled".)

Renaming the directory to parser seemed to fix the issue.

Expected behavior

Using pacman -S mingw-w64-ucrt-x86_64-neovim to install neovim should create a parser directory in the runtime directory

Actual behavior

Using pacman -S mingw-w64-ucrt-x86_64-neovim creates a directory parsers instead of parser in the runtime directory

Verification

Windows Version

MINGW64_NT-10.0-22000

MINGW environments affected

  • MINGW64
  • MINGW32
  • UCRT64
  • CLANG64
  • CLANGARM64

Are you willing to submit a PR?

Yes

@lazka
Copy link
Member

lazka commented Feb 2, 2025

The package does not contain such a directory, so I wonder where it is coming from

@calebabutler
Copy link

calebabutler commented Feb 24, 2025

I also got this issue. I think this package is missing dependencies added in newer versions of neovim. When building without bundled dependencies on Debian (which, msys2 also builds without bundled dependencies) the user needs to install tree-sitter-c, tree-sitter-lua, tree-sitter-markdown, tree-sitter-query, tree-sitter-vim, and tree-sitter-vimdoc (I found these links here). Maybe these packages can be added to msys2 and then added as dependencies for neovim, or maybe they can somehow be bundled with the neovim package.

Edit: Changed the link to where to find the treesitter parsers and to tree-sitter-lua to ones I think are more accurate

@calebabutler
Copy link

Looking at the arch linux equivalent tree-sitter-lua package and testing it myself, it looks like you can build a tree-sitter parser by just cloning the git repository, commenting out a section saying windows is not supported, and running mingw32-make. For me, this creates the *.so file that needs to be in the parser directory in any of the neovim runtime paths (probably best either in /ucrt64/share/nvim/runtime/parser or /ucrt64/lib/nvim/parser).

The nvim-treesitter plugin compiles tree-sitter packages on Windows a slightly different way by calling the compiler directly rather than using make, but I have not yet figured out what flags it uses for gcc, or what files it specifically compiles.

@calebabutler
Copy link

calebabutler commented Feb 24, 2025

Quick fix shell script to resolve this problem:

mkdir -p /ucrt64/lib/nvim/parser
git clone https://github.com/tree-sitter/tree-sitter-c
git clone https://github.com/MunifTanjim/tree-sitter-lua
git clone https://github.com/tree-sitter-grammars/tree-sitter-markdown
git clone https://github.com/tree-sitter-grammars/tree-sitter-query
git clone https://github.com/tree-sitter-grammars/tree-sitter-vim
git clone https://github.com/neovim/tree-sitter-vimdoc

# Fix for tree-sitter-markdown
mv tree-sitter-markdown/tree-sitter-markdown/grammar.js tree-sitter-markdown/tree-sitter-markdown/src/
mv tree-sitter-markdown/tree-sitter-markdown-inline/grammar.js tree-sitter-markdown/tree-sitter-markdown-inline/src/

for dir in */
do
    cd $dir
    OS="unknown" mingw32-make # To get around Windows not being supported
    cp *.so /ucrt64/lib/nvim/parser/
    cd ..
done

# Fix for tree-sitter-markdown
cp tree-sitter-markdown/tree-sitter-markdown/*.so /ucrt64/lib/nvim/parser/
cp tree-sitter-markdown/tree-sitter-markdown-inline/*.so /ucrt64/lib/nvim/parser/

# Rename files to remove 'libtree-sitter'
cd /ucrt64/lib/nvim/parser
rename 'libtree-sitter-' '' *.so

Edit: Added a rename fix

Edit 2: Before running the above, make sure to install mingw-w64-ucrt-x86_64-toolchain, git, and mingw-w64-ucrt-x86_64-tree-sitter

@ognevny
Copy link
Collaborator

ognevny commented Feb 25, 2025

neovim doesn't run tree-sitter itself IIUC? looking at tree-sitter-* recipes, looks like neovim could do the same with tree-sitter CLI installed

@ognevny
Copy link
Collaborator

ognevny commented Feb 25, 2025

ah, in Arch there are also these packages. got it (they also use library + language grammars)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants