Giter VIP home page Giter VIP logo

Comments (19)

vigoux avatar vigoux commented on May 27, 2024 1

Oh I see now, I quite overlooked it to be honest... Then we have to come up with some kind of aliasing... Or to actually rename the parser for tsx and csharp

from nvim-treesitter.

kyazdani42 avatar kyazdani42 commented on May 27, 2024 1

indeed, this is just a draft atm

from nvim-treesitter.

vigoux avatar vigoux commented on May 27, 2024

Hmm I don't really like that way of fixing it though, as it changes the behaviour of nvim itself to fit our purposes. Binding typescriptreact files to tsx using the base query mechanism sounds better to me.

from nvim-treesitter.

kyazdani42 avatar kyazdani42 commented on May 27, 2024

yes i started working on it and it was not great. So i thought changing the name of tsx to typescriptreact would solve everything but i dont like it much. What is this base query mechanism you are talking about ?

from nvim-treesitter.

vigoux avatar vigoux commented on May 27, 2024

This one : #63

from nvim-treesitter.

kyazdani42 avatar kyazdani42 commented on May 27, 2024

the query is not the issue here, the parser is.
Basically when you have tsx, you need to use the tsx parser. The issue here is that tsx is not a filetype in vim but typescriptreact is, so it doesn't find either the parser nor the query.
Another issue arose when i found that the .so file need to have a name that match their repo name too. So the csharp parser also cannot work first of all because csharp files are cs filetypes, and if you force the csharp filetype, you get this:

E5108: Error executing lua Failed to load parser: uv_dlsym: ...nvim-treesitter/parser/csharp.so: undefined symbol: tree_sitter_csharp

from nvim-treesitter.

kyazdani42 avatar kyazdani42 commented on May 27, 2024

i think you might have misunderstood the base purpose of #63 which was to introduce the ability to use multiple query files and not to use different parsers :)

from nvim-treesitter.

steelsojka avatar steelsojka commented on May 27, 2024

I original was doing an alias implementation in my ts/js pr, but I started going down a rabbit hole that seemed to be to much for that pr. Pretty much anywhere it had to reference the filetype, we would have to look up our aliases... this included setting the autocommands as well.

from nvim-treesitter.

kyazdani42 avatar kyazdani42 commented on May 27, 2024

This issue is actually more complicated to resolve in a proper manner than expected.
We cannot change the name of the parsers, because neovim would then fail to link names in the treesitter lib (treesitter-tsx would look for treesitter-typescriptreact symbols and fail because they don't exist !)
This is an issue related to binding filetypes to parsers i believe, which might need to be reported upstream (neovim).
@vigoux what do you think ? Should we find a dirty workaround or fix the issue upstream ?

from nvim-treesitter.

vigoux avatar vigoux commented on May 27, 2024

Why can't we change the name of the parser? Symbol resolution is not related to the name of the file.
If we rename tsx.so to typescriptreact.so, it should work just fine.

from nvim-treesitter.

kyazdani42 avatar kyazdani42 commented on May 27, 2024
Error executing lua Failed to load parser: uv_dlsym: .../nvim-treesitter/parser/typescriptreact.so: undefined symbol: tree_sitter_typescriptreact

obviously something doesn't work. I'm not too sure where this comes from, but i believe this is something to do with the way neovim (or more specifically, the libuv) loads the parsers

from nvim-treesitter.

kyazdani42 avatar kyazdani42 commented on May 27, 2024

int uv_dlsym(uv_lib_t* lib, const char* name, void** ptr). And i believe name which should be the name of the library is a concatenation of treesitter with _${FT}

from nvim-treesitter.

kyazdani42 avatar kyazdani42 commented on May 27, 2024

and as the library is called treesitter_tsx, trying to load treesitter_typescript react does not work at all. Not sure how this should be solved

from nvim-treesitter.

vigoux avatar vigoux commented on May 27, 2024

Then I don't really know. I think that having a map and aliases this would be the easiest. Using parsers.lua would be great for that (does it still exists though?).

from nvim-treesitter.

kyazdani42 avatar kyazdani42 commented on May 27, 2024

This is why i asked for a dirty workaround, as this would involve changing a lot of code that should not be affected by that.
If you want, take a look at src/nvim/lua/treesitter.c, line 126 in neovim, we could potentially fix that there, and it would require very small change from our side.
EDIT: we could change this in the lua side though. runtime/lua/vim/treesitter.lua line 59.
EDIT2: well this whole code is pretty tightly tide to the filetypes. I'll try to come up with a proper solution.

from nvim-treesitter.

vigoux avatar vigoux commented on May 27, 2024

Then go for it 😉

from nvim-treesitter.

kyazdani42 avatar kyazdani42 commented on May 27, 2024

maybe the best solution right now is to fork parsers we need to change the names for, recompile them so they provide the api with the name we chose.

from nvim-treesitter.

kyazdani42 avatar kyazdani42 commented on May 27, 2024

csharp name will be renamed to cs and tsx name will be renamed to typescriptreact (unfortunately)

from nvim-treesitter.

vigoux avatar vigoux commented on May 27, 2024

That doesn't seem right though... I think that we should dig into the hints you gave on previous comments to find a better way to fix this.

from nvim-treesitter.

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.