aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMinijackson <minijackson@riseup.net>2025-09-11 15:27:19 +0200
committerChristian Clason <ch.clason+github@icloud.com>2025-09-22 15:41:39 +0200
commit53819acac287632ee2b62e0f7b63057904984906 (patch)
treeee48d51e73c675c5cd6f73cbaaa1a157427023d8
parentfix: align line continuation highlights (#8146) (diff)
downloadnvim-treesitter-53819acac287632ee2b62e0f7b63057904984906.tar
nvim-treesitter-53819acac287632ee2b62e0f7b63057904984906.tar.gz
nvim-treesitter-53819acac287632ee2b62e0f7b63057904984906.tar.bz2
nvim-treesitter-53819acac287632ee2b62e0f7b63057904984906.tar.lz
nvim-treesitter-53819acac287632ee2b62e0f7b63057904984906.tar.xz
nvim-treesitter-53819acac287632ee2b62e0f7b63057904984906.tar.zst
nvim-treesitter-53819acac287632ee2b62e0f7b63057904984906.zip
feat(snl): add parser and queries
-rw-r--r--SUPPORTED_LANGUAGES.md2
-rw-r--r--lua/nvim-treesitter/parsers.lua9
-rw-r--r--runtime/queries/snl/folds.scm21
-rw-r--r--runtime/queries/snl/highlights.scm245
-rw-r--r--runtime/queries/snl/indents.scm61
-rw-r--r--runtime/queries/snl/injections.scm117
-rw-r--r--runtime/queries/snl/locals.scm65
7 files changed, 520 insertions, 0 deletions
diff --git a/SUPPORTED_LANGUAGES.md b/SUPPORTED_LANGUAGES.md
index 61371d0e0..2cc4bd6a9 100644
--- a/SUPPORTED_LANGUAGES.md
+++ b/SUPPORTED_LANGUAGES.md
@@ -265,6 +265,7 @@ jsx (queries only)[^jsx] | unstable | `HFIJ ` | | @steelsojka
[smali](https://github.com/tree-sitter-grammars/tree-sitter-smali) | unstable | `HFIJL` | | @amaanq
[smithy](https://github.com/indoorvivants/tree-sitter-smithy) | unstable | `H  J ` | | @amaanq, @keynmol
[snakemake](https://github.com/osthomas/tree-sitter-snakemake) | unstable | `HFIJL` | | @osthomas
+[snl](https://github.com/minijackson/tree-sitter-snl)[^snl] | unstable | `HFIJL` | | @minijackson
[solidity](https://github.com/JoranHonig/tree-sitter-solidity) | unstable | `HF J ` | | @amaanq
[soql](https://github.com/aheber/tree-sitter-sfapex) | unstable | `H    ` | | @aheber, @xixiafinland
[sosl](https://github.com/aheber/tree-sitter-sfapex) | unstable | `H    ` | | @aheber, @xixiafinland
@@ -359,4 +360,5 @@ jsx (queries only)[^jsx] | unstable | `HFIJ ` | | @steelsojka
[^query]: Tree-sitter query language
[^sflog]: Salesforce debug log
[^slang]: Shader Slang
+[^snl]: EPICS Sequencer's SNL files
<!--parserinfo-->
diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua
index 0ddc29cd4..6a64739fa 100644
--- a/lua/nvim-treesitter/parsers.lua
+++ b/lua/nvim-treesitter/parsers.lua
@@ -2081,6 +2081,15 @@ return {
maintainers = { '@osthomas' },
tier = 2,
},
+ snl = {
+ install_info = {
+ url = 'https://github.com/minijackson/tree-sitter-snl',
+ revision = '846e2d6809ac5863a15b5494f20fd267c21221c8',
+ },
+ maintainers = { '@minijackson' },
+ readme_note = "EPICS Sequencer's SNL files",
+ tier = 2,
+ },
solidity = {
install_info = {
revision = '4e938a46c7030dd001bc99e1ac0f0c750ac98254',
diff --git a/runtime/queries/snl/folds.scm b/runtime/queries/snl/folds.scm
new file mode 100644
index 000000000..65e50c62f
--- /dev/null
+++ b/runtime/queries/snl/folds.scm
@@ -0,0 +1,21 @@
+[
+ (for_statement)
+ (if_statement)
+ (while_statement)
+ (funcdef)
+ (structdef)
+ (comment)
+ (preproc_if)
+ (preproc_elif)
+ (preproc_else)
+ (preproc_ifdef)
+ (preproc_function_def)
+ (init_expr)
+ (entry)
+ (state_set)
+ (state)
+ (exit)
+] @fold
+
+(initial_defn
+ (preproc_include))+ @fold
diff --git a/runtime/queries/snl/highlights.scm b/runtime/queries/snl/highlights.scm
new file mode 100644
index 000000000..423a7deb7
--- /dev/null
+++ b/runtime/queries/snl/highlights.scm
@@ -0,0 +1,245 @@
+(identifier) @variable
+
+[
+ "enum"
+ "struct"
+ "union"
+] @keyword.type
+
+[
+ "assign"
+ "const"
+ "entry"
+ "exit"
+ "foreign"
+ "monitor"
+ "option"
+ "program"
+ "ss"
+ "state"
+ "sync"
+ "syncq"
+ "to"
+ "typename"
+] @keyword
+
+"sizeof" @keyword.operator
+
+"return" @keyword.return
+
+[
+ "while"
+ "for"
+ "continue"
+ "break"
+] @keyword.repeat
+
+[
+ "if"
+ "else"
+ "when"
+] @keyword.conditional
+
+[
+ "#elif"
+ "#else"
+ "#endif"
+ "#if"
+ "#ifdef"
+ "#ifndef"
+ (preproc_directive)
+ (line_marker)
+] @keyword.directive
+
+"#define" @keyword.directive.define
+
+"#include" @keyword.import
+
+[
+ "("
+ ")"
+ "["
+ "]"
+ "{"
+ "}"
+] @punctuation.bracket
+
+[
+ "."
+ ","
+ ";"
+] @punctuation.delimiter
+
+[
+ "%%"
+ "%{"
+ "}%"
+ "..."
+] @punctuation.special
+
+[
+ "+"
+ "-"
+ "*"
+ "&"
+ "!"
+ "~"
+ "++"
+ "--"
+ "="
+ ">>"
+ "<<"
+ "/"
+ ">"
+ ">="
+ "<"
+ "<="
+ "=="
+ "!="
+ "^"
+ "|"
+ "||"
+ "&&"
+ "%"
+ "*="
+ "/="
+ "%="
+ "+="
+ "-="
+ "<<="
+ ">>="
+ "&="
+ "^="
+ "|="
+] @operator
+
+(comma_expr
+ "," @operator)
+
+[
+ (true)
+ (false)
+] @boolean
+
+(conditional_expression
+ [
+ "?"
+ ":"
+ ] @keyword.conditional.ternary)
+
+[
+ (string_literal)
+ (system_lib_string)
+] @string
+
+(parameter_expansion
+ [
+ "{"
+ "}"
+ ] @string.special)
+
+(parameter_expansion
+ (identifier) @constant)
+
+(escape_sequence) @string.escape
+
+(null) @constant.builtin
+
+[
+ (number_literal)
+ (char_literal)
+] @number
+
+((preproc_arg) @function.macro
+ (#set! "priority" 90))
+
+(preproc_defined) @function.macro
+
+(call_expression
+ function: (identifier) @function.call)
+
+(call_expression
+ function: (field_expression
+ field: (identifier) @function.call))
+
+(function_declarator
+ declarator: (identifier) @function)
+
+(preproc_function_def
+ name: (identifier) @function.macro)
+
+(field_expression
+ field: (identifier) @property)
+
+(type_qualifier) @keyword.modifier
+
+(structdef
+ name: (identifier) @type.definition)
+
+[
+ (basetype)
+ (type_expr)
+] @type
+
+(prim_type) @type.builtin
+
+(program
+ name: (identifier) @constant)
+
+(state_set
+ name: (identifier) @function)
+
+(state
+ name: (identifier) @function)
+
+(transition
+ name: (identifier) @function)
+
+(option
+ name: (identifier) @constant)
+
+((identifier) @constant
+ (#lua-match? @constant "^[A-Z][A-Z%d_]*$"))
+
+(preproc_def
+ name: (_) @constant.macro)
+
+(preproc_call
+ directive: (preproc_directive) @_u
+ argument: (_) @constant.macro
+ (#eq? @_u "#undef"))
+
+(comment) @comment @spell
+
+(param_decl
+ (declarator
+ (identifier) @variable.parameter))
+
+((identifier) @variable.parameter
+ (#has-ancestor? @variable.parameter param_decl))
+
+(param_decl
+ (declarator
+ (pointer_declarator) @variable.parameter))
+
+(preproc_params
+ (identifier) @variable.parameter)
+
+((call_expression
+ function: (_) @function.builtin)
+ (#any-of? @function.builtin
+ "delay" "pvPut" "pvPutComplete" "pvArrayPutComplete" "pvPutCancel" "pvArrayPutCancel" "pvGet"
+ "pvGetComplete" "pvArrayGetComplete" "pvGetCancel" "pvArrayGetCancel" "pvGetQ" "pvFreeQ"
+ "pvFlushQ" "pvAssign" "pvAssignSubst" "pvMonitor" "pvArrayMonitor" "pvStopMonitor"
+ "pvArrayStopMonitor" "pvSync" "pvArraySync" "pvCount" "pvStatus" "pvSeverity" "pvMessage"
+ "pvTimeStamp" "pvAssigned" "pvConnected" "pvArrayConnected" "pvIndex" "pvFlush" "pvChannelCount"
+ "pvAssignCount" "pvConnectCount" "efSet" "efClear" "efTest" "efTestAndClear" "macValueGet"
+ "optGet"))
+
+((identifier) @constant.builtin
+ (#any-of? @constant.builtin
+ "pvStatOK" "pvStatERROR" "pvStatDISCONN" "pvStatREAD" "pvStatWRITE" "pvStatHIHI" "pvStatHIGH"
+ "pvStatLOLO" "pvStatLOW" "pvStatSTATE" "pvStatCOS" "pvStatCOMM" "pvStatTIMEOUT" "pvStatHW_LIMIT"
+ "pvStatCALC" "pvStatSCAN" "pvStatLINK" "pvStatSOFT" "pvStatBAD_SUB" "pvStatUDF" "pvStatDISABLE"
+ "pvStatSIMM" "pvStatREAD_ACCESS" "pvStatWRITE_ACCESS" "pvSevrOK" "pvSevrERROR" "pvSevrNONE"
+ "pvSevrMINOR" "pvSevrMAJOR" "pvSevrINVALID" "DEFAULT" "ASYNC" "SYNC" "NOEVFLAG"))
diff --git a/runtime/queries/snl/indents.scm b/runtime/queries/snl/indents.scm
new file mode 100644
index 000000000..0d6523615
--- /dev/null
+++ b/runtime/queries/snl/indents.scm
@@ -0,0 +1,61 @@
+[
+ (field_declaration_list)
+ (state_set)
+ (state)
+ (block)
+ (member_decl)
+] @indent.begin
+
+(block
+ "}" @indent.end)
+
+[
+ "else"
+ "}"
+] @indent.branch
+
+(call_expression) @indent.begin
+
+(call_expression
+ ")" @indent.end)
+
+(if_statement
+ condition: (_) @indent.begin)
+
+(if_statement
+ consequence: (_) @_consequence
+ (#not-kind-eq? @_consequence block)) @indent.begin
+
+(else_statement
+ consequence: (_) @_consequence
+ (#not-kind-eq? @_consequence block)) @indent.begin
+
+(while_statement
+ body: (statement
+ (_) @_body)
+ (#not-kind-eq? @_body block)) @indent.begin
+
+(for_statement
+ body: (statement
+ (_) @_body)
+ (#not-kind-eq? @_body block)) @indent.begin
+
+(init_declarator) @indent.begin
+
+(transition
+ condition: (_) @indent.begin)
+
+[
+ "#define"
+ "#ifdef"
+ "#if"
+ "#else"
+ "#endif"
+] @indent.zero
+
+[
+ (preproc_arg)
+ (string_literal)
+] @indent.ignore
+
+(comment) @indent.auto
diff --git a/runtime/queries/snl/injections.scm b/runtime/queries/snl/injections.scm
new file mode 100644
index 000000000..b595d8033
--- /dev/null
+++ b/runtime/queries/snl/injections.scm
@@ -0,0 +1,117 @@
+((comment) @injection.content
+ (#set! injection.language "comment"))
+
+((c_code) @injection.content
+ (#set! injection.language "c"))
+
+((preproc_arg) @injection.content
+ (#set! injection.self))
+
+((call_expression
+ function: (identifier) @_function
+ (args
+ .
+ [
+ (string_literal
+ (string_content) @injection.content)
+ (concatenated_string
+ (string_literal
+ (string_content) @injection.content))
+ ]))
+ ; format-ignore
+ (#any-of? @_function
+ "printf" "printf_s"
+ "vprintf" "vprintf_s"
+ "scanf" "scanf_s"
+ "vscanf" "vscanf_s"
+ "wprintf" "wprintf_s"
+ "vwprintf" "vwprintf_s"
+ "wscanf" "wscanf_s"
+ "vwscanf" "vwscanf_s"
+ "cscanf" "_cscanf"
+ "printw"
+ "scanw")
+ (#set! injection.language "printf"))
+
+((call_expression
+ function: (identifier) @_function
+ (args
+ (_)
+ .
+ [
+ (string_literal
+ (string_content) @injection.content)
+ (concatenated_string
+ (string_literal
+ (string_content) @injection.content))
+ ]))
+ ; format-ignore
+ (#any-of? @_function
+ "fprintf" "fprintf_s"
+ "sprintf"
+ "dprintf"
+ "fscanf" "fscanf_s"
+ "sscanf" "sscanf_s"
+ "vsscanf" "vsscanf_s"
+ "vfprintf" "vfprintf_s"
+ "vsprintf"
+ "vdprintf"
+ "fwprintf" "fwprintf_s"
+ "vfwprintf" "vfwprintf_s"
+ "fwscanf" "fwscanf_s"
+ "swscanf" "swscanf_s"
+ "vswscanf" "vswscanf_s"
+ "vfscanf" "vfscanf_s"
+ "vfwscanf" "vfwscanf_s"
+ "wprintw"
+ "vw_printw" "vwprintw"
+ "wscanw"
+ "vw_scanw" "vwscanw")
+ (#set! injection.language "printf"))
+
+((call_expression
+ function: (identifier) @_function
+ (args
+ (_)
+ .
+ (_)
+ .
+ [
+ (string_literal
+ (string_content) @injection.content)
+ (concatenated_string
+ (string_literal
+ (string_content) @injection.content))
+ ]))
+ ; format-ignore
+ (#any-of? @_function
+ "sprintf_s"
+ "snprintf" "snprintf_s"
+ "vsprintf_s"
+ "vsnprintf" "vsnprintf_s"
+ "swprintf" "swprintf_s"
+ "snwprintf_s"
+ "vswprintf" "vswprintf_s"
+ "vsnwprintf_s"
+ "mvprintw"
+ "mvscanw")
+ (#set! injection.language "printf"))
+
+((call_expression
+ function: (identifier) @_function
+ (args
+ (_)
+ .
+ (_)
+ .
+ (_)
+ .
+ [
+ (string_literal
+ (string_content) @injection.content)
+ (concatenated_string
+ (string_literal
+ (string_content) @injection.content))
+ ]))
+ (#any-of? @_function "mvwprintw" "mvwscanw")
+ (#set! injection.language "printf"))
diff --git a/runtime/queries/snl/locals.scm b/runtime/queries/snl/locals.scm
new file mode 100644
index 000000000..35c8da5c9
--- /dev/null
+++ b/runtime/queries/snl/locals.scm
@@ -0,0 +1,65 @@
+; Functions definitions
+(function_declarator
+ declarator: (identifier) @local.definition.function)
+
+(preproc_function_def
+ name: (identifier) @local.definition.macro) @local.scope
+
+(preproc_def
+ name: (identifier) @local.definition.macro)
+
+((identifier) @local.definition.parameter
+ (#has-ancestor? @local.definition.parameter param_decl))
+
+(init_declarator
+ (declarator
+ (identifier)) @local.definition.var)
+
+(array_declarator
+ (identifier) @local.definition.var)
+
+; Struct
+(member_decl
+ (declarator
+ (identifier)) @local.definition.field)
+
+(structdef
+ name: (identifier) @local.definition.type)
+
+; References
+((field_expression
+ field: (identifier) @local.reference)
+ (#set! reference.kind "field"))
+
+((call_expression
+ function: (identifier) @local.reference)
+ (#set! reference.kind "call"))
+
+((basetype
+ (identifier) @local.reference)
+ (#set! reference.kind "type"))
+
+; SNL specific
+(state_set
+ name: (identifier) @local.definition)
+
+(state
+ name: (identifier) @local.definition)
+
+(state_statement
+ name: (identifier) @local.reference)
+
+(transition
+ name: (identifier) @local.reference)
+
+(identifier) @local.reference
+
+[
+ (for_statement)
+ (if_statement)
+ (while_statement)
+ (source_file)
+ (block)
+ (state_set)
+ (state_block)
+] @local.scope