Giter VIP home page Giter VIP logo

Comments (8)

clason avatar clason commented on June 16, 2024

How would you expect them to be highlighted?

from nvim-treesitter.

AlejandroSuero avatar AlejandroSuero commented on June 16, 2024

@clason I am not sure, inside the define call it could treat them as bash|zsh|sh|... commands when in an .{bash|zsh|sh|...} files. For example:

  • define style_calls inside a .sh file:
define call inside sh
  (command) ; [31:3 - 20]
   name: (command_name) ; [31:3 - 8]
    (word) ; [31:3 - 8]
   argument: (word) ; [31:10 - 20]
  (command) ; [32:4 - 24]
   name: (command_name) ; [32:4 - 24]
    (command_substitution) ; [32:4 - 24]
     (command) ; [32:6 - 23]
      name: (command_name) ; [32:6 - 9]
       (word) ; [32:6 - 9]
      argument: (concatenation) ; [32:11 - 16]
       (simple_expansion) ; [32:11 - 12]
        (special_variable_name) ; [32:12 - 12]
       (word) ; [32:13 - 16]
      argument: (word) ; [32:18 - 18]
      argument: (command_substitution) ; [32:20 - 23]
       (command) ; [32:22 - 22]
        name: (command_name) ; [32:22 - 22]
         (number) ; [32:22 - 22]
  (command) ; [33:4 - 25]
   name: (command_name) ; [33:4 - 7]
    (word) ; [33:4 - 7]
   argument: (concatenation) ; [33:9 - 25]
    (expansion) ; [33:9 - 16]
     (variable_name) ; [33:11 - 15]
    (ERROR) ; [33:17 - 20]
    (word) ; [33:21 - 24]
    (word) ; [33:25 - 25]
  (command) ; [34:4 - 18]
   name: (command_name) ; [34:4 - 7]
    (word) ; [34:4 - 7]
   argument: (expansion) ; [34:9 - 18]
    (variable_name) ; [34:11 - 17]
  (command) ; [35:3 - 7]
   name: (command_name) ; [35:3 - 7]
    (word) ; [35:3 - 7]

:Inspect: style_calls as @variable.parameter and numbers and Uppercase variables as @string.

  • target call inside sh:
target call install sh
  (command) ; [31:3 - 7]
   name: (command_name) ; [31:3 - 7]
    (word) ; [31:3 - 7]
  (command) ; [32:4 - 43]
   name: (command_name) ; [32:4 - 43]
    (concatenation) ; [32:4 - 43]
     (word) ; [32:4 - 4]
     (command_substitution) ; [32:5 - 43]
      (command) ; [32:7 - 42]
       name: (command_name) ; [32:7 - 10]
        (word) ; [32:7 - 10]
       argument: (concatenation) ; [32:12 - 42]
        (word) ; [32:12 - 23]
        (string) ; [32:24 - 42]
         (string_content) ; [32:25 - 41]

:Inspect: style_calls as @variable.parameter and "..." as @string

from nvim-treesitter.

clason avatar clason commented on June 16, 2024

That's not possible, though. The make query can't know what file it is in. Feel free to make a PR adding a bash injection; maybe that is good enough. But if it isn't, then the current state is the best we can do.

from nvim-treesitter.

AlejandroSuero avatar AlejandroSuero commented on June 16, 2024

@clason it will be my first time touching this code base, do you know where should I do it?

from nvim-treesitter.

clason avatar clason commented on June 16, 2024

The relevant query is make/injections.scm.

from nvim-treesitter.

AlejandroSuero avatar AlejandroSuero commented on June 16, 2024

@clason one question I have, what should I do to put the injection?

  • This is what make/injections.scm contains.
((comment) @injection.content
  (#set! injection.language "comment"))

((shell_text) @injection.content
  (#set! injection.language "bash"))

((shell_command) @injection.content
  (#set! injection.language "bash"))
  • This is what make/highlights.scm contains:
(define_directive
  "define" @keyword
  name: (word) @string.special.symbol
  [
    "="
    ":="
    "::="
    ; ":::="
    "?="
    "!="
  ]? @operator
  "endef" @keyword)

My question is, wouldn't be better to assign to highlights.scm value: (...) and try to match it there? Seems that the problem that I have is that value: is not set and therefore it takes it as raw_text as default.

from nvim-treesitter.

clason avatar clason commented on June 16, 2024

No, since we can only assign single captures to single nodes exposed by the parser.

If you are not (yet) sufficiently familiar with treesitter queries, no worries; but then you'll have to wait for some else to do this. (Queries are community contributed.)

from nvim-treesitter.

AlejandroSuero avatar AlejandroSuero commented on June 16, 2024

@clason I haven't written a single one yet 😥 but I will give it a try, in the meantime if anyone does it will be nice too ✌️.

from nvim-treesitter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.