Unnamed repository; edit this file 'description' to name the repository.
Add support for KConfig (#14205)
| -rw-r--r-- | book/src/generated/lang-support.md | 1 | ||||
| -rw-r--r-- | languages.toml | 9 | ||||
| -rw-r--r-- | runtime/queries/kconfig/folds.scm | 9 | ||||
| -rw-r--r-- | runtime/queries/kconfig/highlights.scm | 86 | ||||
| -rw-r--r-- | runtime/queries/kconfig/indents.scm | 11 | ||||
| -rw-r--r-- | runtime/queries/kconfig/injections.scm | 2 | ||||
| -rw-r--r-- | runtime/queries/kconfig/locals.scm | 17 |
7 files changed, 135 insertions, 0 deletions
diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index edd06636..39531c11 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -134,6 +134,7 @@ | jsx | ✓ | ✓ | ✓ | ✓ | ✓ | `typescript-language-server` | | julia | ✓ | ✓ | ✓ | | | `julia` | | just | ✓ | ✓ | ✓ | ✓ | | `just-lsp` | +| kconfig | ✓ | | ✓ | | | | | kdl | ✓ | ✓ | ✓ | | | | | koka | ✓ | | ✓ | | | `koka` | | kotlin | ✓ | ✓ | ✓ | | | `kotlin-language-server` | diff --git a/languages.toml b/languages.toml index 7cdcc510..21a26a2f 100644 --- a/languages.toml +++ b/languages.toml @@ -4654,6 +4654,15 @@ name = "requirements" source = { git = "https://github.com/tree-sitter-grammars/tree-sitter-requirements", rev = "caeb2ba854dea55931f76034978de1fd79362939" } [[language]] +name = "kconfig" +file-types = ["kconfig", { glob = "kconfig.*" }] +scope = "source.kconfig" + +[[grammar]] +name = "kconfig" +source = { git = "https://github.com/tree-sitter-grammars/tree-sitter-kconfig" , rev = "9ac99fe4c0c27a35dc6f757cef534c646e944881" } + +[[language]] name = "doxyfile" scope = "source.doxyfile" injection-regex = "[Dd]oxyfile" diff --git a/runtime/queries/kconfig/folds.scm b/runtime/queries/kconfig/folds.scm new file mode 100644 index 00000000..980667df --- /dev/null +++ b/runtime/queries/kconfig/folds.scm @@ -0,0 +1,9 @@ +[ + (config) + (menuconfig) + (choice) + (comment_entry) + (menu) + (if) + (help_text) +] @fold diff --git a/runtime/queries/kconfig/highlights.scm b/runtime/queries/kconfig/highlights.scm new file mode 100644 index 00000000..8baf3988 --- /dev/null +++ b/runtime/queries/kconfig/highlights.scm @@ -0,0 +1,86 @@ +[ + "source" + "osource" + "rsource" + "orsource" +] @keyword.control.import + +[ + "mainmenu" + "config" + "configdefault" + "menuconfig" + "choice" + "endchoice" + "comment" + "menu" + "endmenu" + "prompt" + "default" + "range" + "help" + (optional) + (modules) +] @keyword + +[ + "if" + "endif" + "depends on" + "select" + "imply" + "visible if" +] @keyword.control.conditional + +[ + "def_bool" + "def_tristate" +] @keyword.function + +[ + "||" + "&&" + "=" + "!=" + "<" + ">" + "<=" + ">=" + "!" +] @operator + +[ + "bool" + "tristate" + "int" + "hex" + "string" +] @type.builtin + +[ "(" ")" ] @punctuation.bracket + +(macro_variable ["$(" ")"] @punctuation.special) + +(symbol) @variable + +[ + (string) + (macro_content) + (text) +] @string + +(config name: (name (symbol) @constant)) +(configdefault name: (name (symbol) @constant)) +(menuconfig name: (name (symbol) @constant)) +(choice name: (name (symbol) @constant)) + +((symbol) @constant + (#match? @constant "[A-Z0-9]+")) + +(mainmenu name: (string) @markup.heading) +(comment_entry name: (string) @markup.heading) +(menu name: (string) @markup.heading) + +(source (string) @string.special.url @string.special) + +(comment) @comment diff --git a/runtime/queries/kconfig/indents.scm b/runtime/queries/kconfig/indents.scm new file mode 100644 index 00000000..c9f411be --- /dev/null +++ b/runtime/queries/kconfig/indents.scm @@ -0,0 +1,11 @@ +(help_text (text) @align) + +[ + (config) + (menuconfig) + (choice) + (comment_entry) + (menu) + (if) + (help_text) +] @indent diff --git a/runtime/queries/kconfig/injections.scm b/runtime/queries/kconfig/injections.scm new file mode 100644 index 00000000..2f0e58eb --- /dev/null +++ b/runtime/queries/kconfig/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/runtime/queries/kconfig/locals.scm b/runtime/queries/kconfig/locals.scm new file mode 100644 index 00000000..0bb5b089 --- /dev/null +++ b/runtime/queries/kconfig/locals.scm @@ -0,0 +1,17 @@ +[ + (symbol) + (string) +] @local.reference + +[ + (config) + (menuconfig) + (choice) + (comment_entry) + (menu) + (if) +] @local.scope + +(type_definition (string) @local.definition.type) +(type_definition (input_prompt (string) @local.definition.type)) +(type_definition_default (expression (string) @local.definition.type)) |