Dronakurl / injectme.nvim

Neovim plugin to help setup language injections with treesitter
MIT License
40 stars 2 forks source link

Feature discussion: should variable names in injection rules/regexes be case insensitive? #4

Open massimiliano-della-rovere opened 7 months ago

massimiliano-della-rovere commented 7 months ago

In many programming languages constants must or should be written in uppercase. For this reason often the variables containing the snippets of code that needs highlighted injection is in constants.

Dronakurl commented 7 months ago

This can be down with altering the regex. Treesitter supports the i flag of regex (see here: https://github.com/tree-sitter/tree-sitter/issues/261), but I could not get this to work. I just used square brackets to make it insensitive. Like this:

        (assignment
            ((identifier) @_varx (#match? @_varx ".*[hH][tT][mM][lL]$"))
            (string
                (string_content) @injection.content (#set! injection.language "html"))) 

Let me know, which rules you want to have case insensitive.

massimiliano-della-rovere commented 7 months ago

in general all the python regexes/suffixes involving a lowercase variable name should support an uppercase constant too.

Il giorno lun 29 gen 2024 alle ore 22:36 Dronakurl @.***> ha scritto:

This can be down with altering the regex. Treesitter supports the i flag of regex (see here: tree-sitter/tree-sitter#261 https://github.com/tree-sitter/tree-sitter/issues/261), but I could not get this to work. I just used square brackets to make it insensitive. Like this:

    (assignment
        ((identifier) @_varx (#match? @_varx ".*[hH][tT][mM][lL]$"))
        (string
            (string_content) @injection.content (#set! injection.language "html")))

Let me know, which rules you want to have case insensitive.

— Reply to this email directly, view it on GitHub https://github.com/Dronakurl/injectme.nvim/issues/4#issuecomment-1915614544, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHGPTOEXGXZTJTT5SUWUWDYRAI45AVCNFSM6AAAAABCKJTPP2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMJVGYYTINJUGQ . You are receiving this because you authored the thread.Message ID: @.***>