aboutsummaryrefslogtreecommitdiff
path: root/plugins/language_sh.lua
blob: c4153c21c253853570ade5bbcaf3be5f52cd35d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
local syntax = require "core.syntax"

syntax.add {
  files = { "%.sh$" },
  headers = "^#!.*bin.*sh\n",
  comment = "#",
  patterns = {
    { pattern = "#.*\n",                  type = "comment"  },
    { pattern = [[\.]],                   type = "normal"   },
    { pattern = { '"', '"', '\\' },       type = "string"   },
    { pattern = { "'", "'", '\\' },       type = "string"   },
    { pattern = { '`', '`', '\\' },       type = "string"   },
    { pattern = "%f[%w_][%d%.]+%f[^%w_]", type = "number"   },
    { pattern = "[!<>|&%[%]=*]",          type = "operator" },
    { pattern = "%f[%S]%-[%w%-_]+",       type = "function" },
    { pattern = "${.*}",                  type = "keyword2" },
    { pattern = "$[%a_@*][%w_]*",         type = "keyword2" },
    { pattern = "[%a_][%w_]*",            type = "symbol"   },
  },
  symbols = {
    ["case"]     = "keyword",
    ["do"]       = "keyword",
    ["done"]     = "keyword",
    ["elif"]     = "keyword",
    ["else"]     = "keyword",
    ["esac"]     = "keyword",
    ["fi"]       = "keyword",
    ["for"]      = "keyword",
    ["function"] = "keyword",
    ["if"]       = "keyword",
    ["in"]       = "keyword",
    ["select"]   = "keyword",
    ["then"]     = "keyword",
    ["time"]     = "keyword",
    ["until"]    = "keyword",
    ["while"]    = "keyword",
    ["echo"]     = "keyword",
    ["true"]     = "literal",
    ["false"]    = "literal",
  },
}