-- Support for the Fennel programming language: https://fennel-lang.org
-- Covers all the keywords up to Fennel version 0.10.0

-- Currently only covers highlighting, not indentation, delimiter
-- matching, or evaluation.

local syntax = require "core.syntax"

syntax.add {
  files = "%.fnl$",
  comment = ";",
  patterns = {
    { pattern = ";.-\n",              type = "comment"  },
    { pattern = { '"', '"', '\\' },   type = "string"   },
    { pattern = "0x[%da-fA-F]+",      type = "number"   },
    { pattern = "-?%d+[%d%.]*",       type = "number"   },
    { pattern = "-?%.?%d+",           type = "number"   },
    { pattern = "%f[^(][^()'%s\"]+",  type = "function" },
    { pattern = "[^()'%s\"]+",        type = "symbol"   },
  },

  symbols = {
    ["accumulate"] = "keyword2",
    ["and"] = "keyword2",
    ["band"] = "keyword2",
    ["bnot"] = "keyword2",
    ["bor"] = "keyword2",
    ["bxor"] = "keyword2",
    ["collect"] = "keyword2",
    ["comment"] = "keyword2",
    ["do"] = "keyword2",
    ["doc"] = "keyword2",
    ["doto"] = "keyword2",
    ["each"] = "keyword2",
    ["eval-compiler"] = "keyword2",
    ["fn"] = "keyword2",
    ["for"] = "keyword2",
    ["global"] = "keyword2",
    ["hashfn"] = "keyword2",
    ["icollect"] = "keyword2",
    ["if"] = "keyword2",
    ["import-macros"] = "keyword2",
    ["include"] = "keyword2",
    ["lambda"] = "keyword2",
    ["length"] = "keyword2",
    ["let"] = "keyword2",
    ["local"] = "keyword2",
    ["lshift"] = "keyword2",
    ["lua"] = "keyword2",
    ["macro"] = "keyword2",
    ["macrodebug"] = "keyword2",
    ["macros"] = "keyword2",
    ["match"] = "keyword2",
    ["not"] = "keyword2",
    ["not="] = "keyword2",
    ["or"] = "keyword2",
    ["partial"] = "keyword2",
    ["pick-args"] = "keyword2",
    ["pick-values"] = "keyword2",
    ["quote"] = "keyword2",
    ["require-macros"] = "keyword2",
    ["rshift"] = "keyword2",
    ["set"] = "keyword2",
    ["set-forcibly!"] = "keyword2",
    ["tset"] = "keyword2",
    ["values"] = "keyword2",
    ["var"] = "keyword2",
    ["when"] = "keyword2",
    ["while"] = "keyword2",

    ["#"] = "keyword",
    ["%"] = "keyword",
    [":"] = "keyword",
    ["λ"] = "keyword2",
    ["*"] = "keyword",
    ["+"] = "keyword",
    ["-"] = "keyword",
    ["->"] = "keyword",
    ["->>"] = "keyword",
    ["-?>"] = "keyword",
    ["-?>>"] = "keyword",
    ["."] = "keyword",
    [".."] = "keyword",
    ["..."] = "keyword",
    ["/"] = "keyword",
    ["//"] = "keyword",
    ["<"] = "keyword",
    ["<="] = "keyword",
    ["="] = "keyword",
    [">"] = "keyword",
    [">="] = "keyword",
    ["?."] = "keyword",
    ["^"] = "keyword",
    ["$"] = "keyword",
    ["$1"] = "keyword",
    ["$2"] = "keyword",
    ["$3"] = "keyword",
    ["$4"] = "keyword",
    ["$5"] = "keyword",
    ["$6"] = "keyword",
    ["$7"] = "keyword",
    ["$8"] = "keyword",
    ["$9"] = "keyword",

    ["nil"] = "literal",
    ["true"] = "literal",
    ["false"] = "literal",
  }
}
