tree-sitter-d icon indicating copy to clipboard operation
tree-sitter-d copied to clipboard

"visibilty type name" is parsed incorrectly

Open nxuv opened this issue 1 year ago • 3 comments

In

const string varname;

string is not being highlighted as type

nxuv avatar May 01 '24 16:05 nxuv

I believe "string" is considered a special value.

However, highlighting is a combination of the grammar and the queries. And queries are determined by the environment/editor you are using it in. Please provide some detail on this.

gdamore avatar Jul 27 '24 14:07 gdamore

Actually, it's not a special value... at least not in the grammar. But it might be in the syntax queries. Based on other bugs filed, I guess you're using neovim. I suspect the query is making "string" a builtin type. (Which it sort of is.)

gdamore avatar Jul 27 '24 15:07 gdamore

I am using neovim with tree-sitter indeed.

The problem here actually is that of possible added modifiers, which includes const, are interfering with highlighting of type. Also forgot to check here how things like const(string) var would work

nxuv avatar Jul 27 '24 15:07 nxuv

So I've pushed into main a new update that treats string and the other builtin aliases just like other built in types.

Probably the queries for neovim will need to be updated to take advantage of this (and also update to the latest submodule).

gdamore avatar Jul 29 '24 05:07 gdamore

I'm going to close this here. Neovim's queries will need to be updated to benefit fully. A ticket should be filed against neovim (or the neovim plugin for D if that's separate). I'm happy to work with the author of that to take advantage of the new syntax nodes ... I'm not a user of neovim myself so it's not something I will do on my own.

gdamore avatar Jul 29 '24 18:07 gdamore

Once again, neovim doesn't need updating since it uses upstream default branch for treesitter languages, as in whatever commit you make will be used when user installs/updates query for language

nxuv avatar Jul 29 '24 18:07 nxuv