diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index d311674a..cef96912 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -229,6 +229,7 @@ | robot | ✓ | | | | | `robotframework_ls` | | robots.txt | ✓ | ✓ | | ✓ | | | | ron | ✓ | | ✓ | ✓ | ✓ | `ron-lsp` | +| rpmspec | ✓ | | | | | | | rshtml | ✓ | ✓ | | | | `rshtml-analyzer`, `vscode-html-language-server`, `superhtml` | | rst | ✓ | | | | | | | ruby | ✓ | ✓ | ✓ | ✓ | ✓ | `ruby-lsp`, `solargraph` | diff --git a/languages.toml b/languages.toml index 812fb1d8..27708b5d 100644 --- a/languages.toml +++ b/languages.toml @@ -4116,6 +4116,16 @@ indent = { tab-width = 4, unit = "\t" } name = "supercollider" source = { git = "https://github.com/madskjeldgaard/tree-sitter-supercollider", rev = "3b35bd0fded4423c8fb30e9585c7bacbcd0e8095" } +[[language]] +name = "rpmspec" +scope = "source.rpmspec" +file-types = ["spec"] +comment-token = "#" + +[[grammar]] +name = "rpmspec" +source = { git = "https://gitlab.com/cryptomilk/tree-sitter-rpmspec", rev = "d0275cd1316d9b7a2e0fae028ce95a5a18741e1d" } + [[language]] name = "pkgbuild" scope = "source.bash" diff --git a/runtime/queries/rpmspec/highlights.scm b/runtime/queries/rpmspec/highlights.scm new file mode 100644 index 00000000..f0f6f619 --- /dev/null +++ b/runtime/queries/rpmspec/highlights.scm @@ -0,0 +1,182 @@ +; Specific parametric macro expansion rules (must come first) +(macro_expansion_call + (builtin) @function.macro) + +(macro_expansion_call + (identifier) @function.macro) + +(macro_expansion_call + option: (macro_option) @variable.parameter + argument: [ + (word) @variable.parameter + (concatenation + (word) @variable.parameter) + (macro_expansion) @function.call + (macro_simple_expansion) @function.call + ]) + +; Highlight macro options in parametric expansions +(macro_option) @variable.parameter + +; Macro expansion rules +(macro_expansion + (builtin) @variable.builtin + argument: (_) @variable.parameter) + +(macro_expansion + (identifier) @function.call + argument: [ + (word) @variable.parameter + (concatenation + (word) @variable.parameter) + ]) + +; Macro definition and undefinition +(macro_definition + "%" @punctuation.special + (builtin) @keyword.directive.define + (identifier) @keyword.macro) +(macro_undefinition + (builtin) @keyword.directive.define + (identifier) @keyword.macro) + +; General punctuation for macros +(macro_simple_expansion + "%" @punctuation.special) @none +(macro_expansion + "%{" @punctuation.special + "}" @punctuation.special) @none + +; General identifier and builtin rules (must come after specific rules) +(special_variable_name) @constant +(builtin) @variable.builtin + +(setup_macro + argument: [ + (setup_flag) @variable.parameter + (setup_source_option) @variable.parameter + ((setup_name_option + directory: (_) @string) @variable.parameter) + ]) + +(patch_macro + [ + (patch_flag) @variable.parameter + (patch_number_option) @variable.parameter + (patch_string_option) @variable.parameter + (patch_long_option) @variable.parameter + ]) + +[ + (tag) + (dependency_tag) +] @type.definition + +(integer) @constant.numeric.integer +(float) @constant.numeric.float +(version) @constant.numeric.float + +(comment) @comment +;(string) @string +(quoted_string) @string + +(description + (section_name) @type.definition) +(package + (section_name) @type.definition) +(files + (section_name) @type.definition) +(changelog + (section_name) @type.definition) + +(prep_scriptlet + (section_name) @function.builtin) +(generate_buildrequires + (section_name) @function.builtin) +(conf_scriptlet + (section_name) @function.builtin) +(build_scriptlet + (section_name) @function.builtin) +(install_scriptlet + (section_name) @function.builtin) +(check_scriptlet + (section_name) @function.builtin) +(clean_scriptlet + (section_name) @function.builtin) + +[ + "%pre" + "%post" + "%preun" + "%postun" + "%pretrans" + "%posttrans" + "%preuntrans" + "%postuntrans" + "%verify" +] @function.builtin + +[ + "%triggerprein" + "%triggerin" + "%triggerun" + "%triggerpostun" +] @function.builtin + +[ + "%filetriggerin" + "%filetriggerun" + "%filetriggerpostun" + "%transfiletriggerin" + "%transfiletriggerun" + "%transfiletriggerpostun" +] @function.builtin + +[ + "%artifact" + "%attr" + "%config" + "%dir" + "%doc" + "%docdir" + "%ghost" + "%license" + "%missingok" + "%readme" +] @keyword.type + +[ + "!=" + "<" + "<=" + "==" + ">" + ">=" + "and" + "&&" + "or" + "||" +] @operator + +[ + "with" + "without" + "defined" + "undefined" +] @keyword.operator + +[ + "%if" + "%ifarch" + "%ifos" + "%ifnarch" + "%ifnos" + "%elif" + "%elifarch" + "%elifos" + "%else" + "%endif" +] @keyword.conditional + +; Fallback rule for identifiers (commented out due to conflicts with parametric macros) +; (identifier) @variable