Skip to content

Conversation

Guldoman
Copy link
Member

Next thing to add is ${...}, $(...).

Related to #563.

@PerilousBooklet what do you think about this? It should fix the issue you found.

@PerilousBooklet
Copy link
Contributor

There's a problem with the :: that follow a target's name:
image
I think we should color that like it was before, completely blue.

@PerilousBooklet
Copy link
Contributor

Also wouldn't it be better to color the special targets (es. .PHONY:) with operator instead of literal? That's what VSCode does. Personally I would prefer to use function, just like with normal targets (es. all: or all::).

@Guldoman
Copy link
Member Author

There's a problem with the :: that follow a target's name:

Didn't know that was a thing, we can definitely add that to the regexes for target definition.

Also wouldn't it be better to color the special targets (es. .PHONY:) with operator instead of literal

Targets with a . in front of them are highlighted as keyword2, as you can see in your screenshot.
literal is used for assignments.

@PerilousBooklet
Copy link
Contributor

PerilousBooklet commented Jul 12, 2025

Also versioned numbers like v1.2.3 should be colored. This %f[%w_]v?[%d%.]+%f[^%w_] should do the trick.
Basically just add v? between %f[%w_] and [%d%.]+%f[^%w_].

@Guldoman
Copy link
Member Author

Also versioned numbers like v1.2.3 should be colored. This %f[%w_]v?[%d%.]+%f[^%w_] should do the trick. Basically just add v? between %f[%w_] and [%d%.]+%f[^%w_].

To be honest I would just remove that rule, and simply match numbers by themselves.

In general this syntax needs a lot of work, but we can at least properly highlight rules and assignments

@PerilousBooklet
Copy link
Contributor

By the way, which existing reference are we going to use? VSCode? Or do we just use Make's syntax reference?

@Guldoman
Copy link
Member Author

@PerilousBooklet
Copy link
Contributor

Ok, great!

@PerilousBooklet
Copy link
Contributor

PerilousBooklet commented Jul 13, 2025

Also versioned numbers like v1.2.3 should be colored. This %f[%w_]v?[%d%.]+%f[^%w_] should do the trick. Basically just add v? between %f[%w_] and [%d%.]+%f[^%w_].

To be honest I would just remove that rule, and simply match numbers by themselves.

In general this syntax needs a lot of work, but we can at least properly highlight rules and assignments

So you would remove { pattern = "%f[%w_]v?[%d%.]+%f[^%w_]", type = "number" }, and maybe replace it with { pattern = "v?[%d.?]+", type = "number" }, ?

@PerilousBooklet
Copy link
Contributor

PerilousBooklet commented Jul 13, 2025

Also we should add the language syntax references header comment:

-- Language Syntax References
-- https://www.gnu.org/software/make/manual/make.html
-- https://www.gnu.org/software/make/manual/html_node/Quick-Reference.html

right below

-- mod-version:3
local syntax = require "core.syntax"

@PerilousBooklet
Copy link
Contributor

PerilousBooklet commented Jul 13, 2025

I'm working on { pattern = "%$%(.-%)", type = "keyword2" }, and { pattern = "%$%{.-%}", type = "keyword2" },, for $(...) and ${...}, but they're not complete yet.
Postponed to a later date.

@PerilousBooklet
Copy link
Contributor

So, the following should have all modifications:

-- mod-version:3
local syntax = require "core.syntax"

-- Language Syntax References
-- https://www.gnu.org/software/make/manual/make.html
-- https://www.gnu.org/software/make/manual/html_node/Quick-Reference.html

syntax.add {
  name = "Makefile",
  files = { PATHSEP .. "[Mm]akefile$", "%.mk$" },
  comment = "#",
  patterns = {
    { pattern = "#.*",                    type = "comment"  },
    { pattern = [[\.]],                   type = "normal"   },
    { pattern = "$[@^<%%?+|*]",           type = "keyword2" },
    { pattern = "$%(.-%)",                type = "symbol"   },
    { pattern = "v?[%d.?]+",              type = "number"   },
    { regex = [[^\s*+[^:#=\s]+\s*+()(?::{1,3}|[?+!])?=]], type = { "literal", "operator" } },
    { regex = [[^\s*+\.[^:=]+\s*+()::?]], type = { "keyword2", "operator" } },
    { regex = [[^\s*+[^:=]+\s*+()::?]],   type = { "function", "operator" } },
    { pattern = "-?[^%s:#=+?!]+%f[%s]",   type = "normal"   },
  },
  symbols = {
    ["define"] = "keyword",
    ["endef"] = "keyword",
    ["undefine"] = "keyword",
    ["ifdef"] = "keyword",
    ["ifndef"] = "keyword",
    ["ifeq"] = "keyword",
    ["ifneq"] = "keyword",
    ["else"] = "keyword",
    ["endif"] = "keyword",
    ["include"] = "keyword",
    ["-include"] = "keyword",
    ["sinclude"] = "keyword",
    ["override"] = "keyword",
    ["export"] = "keyword",
    ["unexport"] = "keyword",
    ["private"] = "keyword",
    ["vpath"] = "keyword",
  },
}

@PerilousBooklet
Copy link
Contributor

Actually the .PHONY: target doesn't get matched with the code above.

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