[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Tree sitter support for C-like languages
From: |
Yuan Fu |
Subject: |
Re: Tree sitter support for C-like languages |
Date: |
Wed, 16 Nov 2022 12:10:22 -0800 |
> On Nov 16, 2022, at 12:02 PM, Theodor Thornhill <theo@thornhill.no> wrote:
>
> Yuan Fu <casouri@gmail.com> writes:
>
>> I noticed that the new fontification is much busier than cc-mode, so here’s
>> some of my thoughts:
>>
>
> Yeah, I just made it very colorful mostly to prove the point that we
> have very granular control. I think Randys patch was very good, because
> imo _most_ of the noise is the bracket/pointer/operators etc.
That seems to be a trend for tree-sitter fontification ;-) Neovim does similar
things.
>>
>> :language mode
>> :override t
>> :feature 'expression
>> '((assignment_expression
>> left: (identifier) @font-lock-variable-name-face)
>>
>> I think assignment should be isolated out to an “assignment” feature,
>> where we highlight the lhs target of the assignment: the identifier,
>> the field, etc. For example, the assignment group in Python [1]
>>
>
> Sure!
>
>>
>> (call_expression
>> function: (identifier) @font-lock-function-name-face)
>>
>> (field_expression
>> field: (field_identifier) @font-lock-variable-name-face)
>>
>> (field_expression
>> argument: (identifier) @font-lock-variable-name-face
>> field: (field_identifier) @font-lock-variable-name-face)
>>
>> (pointer_expression
>> argument: (identifier) @font-lock-variable-name-face))
>>
>> They highlight every single use of functions and fields, so they should be
>> level 3. (And I’ll disable them personally :-) Highlighting the field and
>> the functions should be two different features IMO.
>
> Yep, I agree! Go ahead :-)
I should clarify that I “And I’ll disable them personally” meant “I’ll disable
them in my personal config”, but anyway.
>
>>
>> :language mode
>> :override t
>> :feature 'statement
>> '((expression_statement (identifier) @font-lock-variable-name-face)
>> (labeled_statement
>> label: (statement_identifier) @font-lock-type-face))
>>
>
> stuff like:
> ```
> add_edge: // <- this thing
> gx += WINDOW_LEFT_EDGE_X (w);
> gy += WINDOW_TOP_EDGE_Y (w);
>
> store_rect: // <- and this thing
> STORE_NATIVE_RECT (*rect, gx, gy, width, height);
>
> ```
>
> I think you should just tweak it like you want. I think it's very
> time-consuming creating separate patches and bug-reports for small
> tweaks and maintenance issues. I trust your judgment here, though I
> also think that Randy had some nice ideas :)
>
> Just hack away!
Thanks! Will do.
Yuan
- Re: Tree sitter support for C-like languages, (continued)
Re: Tree sitter support for C-like languages, Yuan Fu, 2022/11/16
- Re: Tree sitter support for C-like languages, Theodor Thornhill, 2022/11/16
- Re: Tree sitter support for C-like languages, Yuan Fu, 2022/11/16
- Re: Tree sitter support for C-like languages, Yuan Fu, 2022/11/21
- Re: Tree sitter support for C-like languages, Theodor Thornhill, 2022/11/21
- Re: Tree sitter support for C-like languages, Yuan Fu, 2022/11/22