Files
deb-lite-xl/debian/extra/plugins/language_nix.lua
T
vhaudiquet 3bae6fd448 Bundle curated community plugins (2.1.8-4)
Vendored from upstream, pinned by commit (see debian/extra/README.source):
- gitstatus, gitopen, fontconfig, open_ext, select_colorscheme,
  smoothcaret, nerdicons (font mapping patched to DATADIR, Ships the
  Symbols Nerd Font Mono TTF, SIL OFL 1.1)
- lite-xl-lsp (complete LSP client; idle until a language server is
  configured) plus the lite-xl-widgets library it requires
- 104 language syntax plugins (none duplicate the nine bundled in core)

settings GUI left out upstream is broken: it requires a
libraries.widget.fonts widget that does not exist in
lite-xl-widgets at any revision.

Co-developed-with: ZCode (Z.ai)
2026-09-16 22:45:02 +02:00

88 lines
2.5 KiB
Lua

-- mod-version:3
-- https://nixos.wiki/wiki/Overview_of_the_Nix_Language
local syntax = require "core.syntax"
local function merge_tables(a, b)
for _, v in pairs(b) do
table.insert(a, v)
end
end
local default_symbols = {
["import"] = "keyword2",
["with"] = "keyword2",
["builtins"] = "keyword2",
["inherit"] = "keyword2",
["assert"] = "keyword2",
["let"] = "keyword2",
["in"] = "keyword2",
["rec"] = "keyword2",
["if"] = "keyword",
["else"] = "keyword",
["then"] = "keyword",
["true"] = "literal",
["false"] = "literal",
["null"] = "literal",
}
local default_patterns = {}
local string_interpolation = {
{ pattern = {"%${", "}"}, type = "keyword2", syntax = {
patterns = default_patterns,
symbols = default_symbols,
}},
{ pattern = "[%S][%w]*", type = "string" },
}
merge_tables(default_patterns, {
{ pattern = "#.*", type = "comment" },
{ pattern = {"/%*", "%*/"}, type = "comment" },
{ pattern = "-?%.?%d+", type = "number" },
-- interpolation
{ pattern = {"%${", "}"}, type = "keyword2", syntax = {
patterns = default_patterns,
symbols = default_symbols,
}},
{ pattern = {'"', '"', '\\'}, type = "string", syntax = {
patterns = string_interpolation,
symbols = {},
}},
{ pattern = {"''", "''"}, type = "string", syntax = {
patterns = string_interpolation,
symbols = {},
}},
-- operators
{ pattern = "[%+%-%?!>%*]", type = "operator" },
{ pattern = "/ ", type = "operator" },
{ pattern = "< ", type = "operator" },
{ pattern = "//", type = "operator" },
{ pattern = "&&", type = "operator" },
{ pattern = "%->", type = "operator" },
{ pattern = "||", type = "operator" },
{ pattern = "==", type = "operator" },
{ pattern = "!=", type = "operator" },
{ pattern = ">=", type = "operator" },
{ pattern = "<=", type = "operator" },
-- paths (function because its not used otherwise)
{ pattern = "%.?%.?/[^%s%[%]%(%){};,:]+", type = "function" },
{ pattern = "~/[^%s%[%]%(%){};,:]+", type = "function" },
{ pattern = {"<", ">"}, type = "function" },
-- every other symbol
{ pattern = "[%a%-%_][%w%-%_]*", type = "symbol" },
{ pattern = ";%.,:", type = "normal" },
})
syntax.add {
name = "Nix",
files = {"%.nix$"},
comment = "#",
block_comment = {"/*", "*/"},
patterns = default_patterns,
symbols = default_symbols,
}