Skip to content

Conversation

@oxfist
Copy link

@oxfist oxfist commented Aug 9, 2023

This PR adds support for syntax such as source <afile>. According to Neovim docs under :h afile, this is valid syntax but the parser currently errors out with this:
image

@oxfist
Copy link
Author

oxfist commented Aug 9, 2023

@clason this is a fairly small change to fix an issue that breaks parsing of valid syntax. Are you able to review it? 🙏🏼

@clason
Copy link
Collaborator

clason commented Aug 9, 2023

There's a bunch of unrelated changes in this PR; I'd prefer these to be made separately (if at all).

And I'm not sure that is the correct fix, as these are not filenames. It's better to create a proper node for these constructs.

@oxfist
Copy link
Author

oxfist commented Aug 9, 2023

I'll remove the unrelated changes and can update the PR to add a new node node for these no problem 👍🏼

@oxfist
Copy link
Author

oxfist commented Aug 9, 2023

@clason please let me know if this works better, happy to help get this fixed.

@oxfist oxfist changed the title Add angle brackets as possible characters within filenames Add node for angle bracket delimited built-in reference Aug 9, 2023
@clason
Copy link
Collaborator

clason commented Aug 10, 2023

Yes, that is better. Can you update the queries, too? (And more complex tests?)

@clason clason requested a review from vigoux August 10, 2023 07:21
@clason
Copy link
Collaborator

clason commented Aug 10, 2023

The issue is that this syntax is valid only in autocommands.

@oxfist
Copy link
Author

oxfist commented Aug 22, 2023

@clason I'm having trouble getting the highlights to work. I've updated grammar.js with the following:

module.exports = grammar({
    // ...
    builtin_reference: ($) => /<[A-Za-z]+>/,
    // ...
    source_statement: ($) =>
      bang_range_command(
        $,
        "source",
        optional(field("file", choice($.filename, $.builtin_reference)))
      ),
    // ...
});

This makes the tests pass, but then in highlights.scm I added this query, and for some reason the node doesn't have the capture group I've defined:

(autocmd_statement command: (source_statement file: (builtin_reference) @variable.builtin))

I'm able to get the right node type, and even get the proper node highlighted in the Treesitter playground with the query above:
CleanShot 2023-08-22 at 6 26 22@2x

Any help or guidance to figure this out would be very much appreciated! 🙏🏼

@clason clason marked this pull request as draft May 3, 2025 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants