Comments (19)
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.
indeed, this is just a draft atm
from nvim-treesitter.
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.
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.
This one : #63
from nvim-treesitter.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Then go for it 😉
from nvim-treesitter.
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.
csharp name will be renamed to cs
and tsx name will be renamed to typescriptreact
(unfortunately)
from nvim-treesitter.
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)
- neovim freezes if ampersand on string in typescript files HOT 2
- python: arguments in Callable not highlighted as types HOT 1
- tree-sitter-disassembly issue HOT 5
- Consider adding a highlight capture for struct/enum/union keywords HOT 13
- [Question]: How to disable conceal highlight?
- E5108: Error executing lua ...nvim/lazy/nvim-treesitter/lua/nvim-treesitter/locals.lua:58: attempt to index field 'local' (a nil value) HOT 3
- nvim_treesitter#indent() should respect `breakindent` settings HOT 1
- conceal HOT 9
- Misleading capture names for type qualifiers and lifetimes HOT 4
- Markdown missing header mark highlights HOT 5
- Inconsitent highlighting between instances
- Error while highlighting markdown with code fences after update. HOT 4
- feat: add gularen parser HOT 1
- Delay actual highlight to make buffer open instantly HOT 2
- Typescript parser cannot be installed HOT 2
- `///` comments are not parsed as doxygen HOT 5
- Add fold text function as well as foldexpr function HOT 1
- My Custom Highlight Change Due To Update HOT 1
- Error detected while processing BufReadPost Autocommands for "*": HOT 4
- My Custom Highlight Change Due To Update HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nvim-treesitter.