diff options
| author | Serhii Khoma <srghma@gmail.com> | 2025-01-16 23:34:37 +0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-16 17:34:37 +0100 |
| commit | 8758abeb4d7c0fb501226d584cd45a1c6836f535 (patch) | |
| tree | 59ff4aa550627cdbd7f75b9ac7f46e8f82aa9fdd | |
| parent | bot(lockfile): update earthfile, gotmpl, heex, helm, vhs (#7557) (diff) | |
| download | nvim-treesitter-8758abeb4d7c0fb501226d584cd45a1c6836f535.tar nvim-treesitter-8758abeb4d7c0fb501226d584cd45a1c6836f535.tar.gz nvim-treesitter-8758abeb4d7c0fb501226d584cd45a1c6836f535.tar.bz2 nvim-treesitter-8758abeb4d7c0fb501226d584cd45a1c6836f535.tar.lz nvim-treesitter-8758abeb4d7c0fb501226d584cd45a1c6836f535.tar.xz nvim-treesitter-8758abeb4d7c0fb501226d584cd45a1c6836f535.tar.zst nvim-treesitter-8758abeb4d7c0fb501226d584cd45a1c6836f535.zip | |
feat(idris): add parser and queries (#7274)
| -rw-r--r-- | README.md | 1 | ||||
| -rw-r--r-- | lockfile.json | 3 | ||||
| -rw-r--r-- | lua/nvim-treesitter/parsers.lua | 9 | ||||
| -rw-r--r-- | queries/idris/folds.scm | 1 | ||||
| -rw-r--r-- | queries/idris/highlights.scm | 224 | ||||
| -rw-r--r-- | queries/idris/injections.scm | 2 | ||||
| -rw-r--r-- | queries/idris/locals.scm | 33 |
7 files changed, 273 insertions, 0 deletions
@@ -291,6 +291,7 @@ We are looking for maintainers to add more parsers and to write query files for - [x] [hurl](https://github.com/pfeiferj/tree-sitter-hurl) (maintained by @pfeiferj) - [x] [hyprlang](https://github.com/luckasRanarison/tree-sitter-hyprlang) (maintained by @luckasRanarison) - [x] [idl](https://github.com/cathaysia/tree-sitter-idl) (maintained by @cathaysia) +- [x] [idris](https://github.com/kayhide/tree-sitter-idris) (maintained by @srghma) - [x] [ini](https://github.com/justinmk/tree-sitter-ini) (experimental, maintained by @theHamsta) - [x] [inko](https://github.com/inko-lang/tree-sitter-inko) (maintained by @yorickpeterse) - [x] [ipkg](https://github.com/srghma/tree-sitter-ipkg) (maintained by @srghma) diff --git a/lockfile.json b/lockfile.json index 16ea9c486..327783fd7 100644 --- a/lockfile.json +++ b/lockfile.json @@ -353,6 +353,9 @@ "idl": { "revision": "86ff7f19747a761dc8ba72f4045fd64aed94ba4c" }, + "idris": { + "revision": "c56a25cf57c68ff929356db25505c1cc4c7820f6" + }, "ini": { "revision": "962568c9efa71d25720ab42c5d36e222626ef3a6" }, diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index d2259c9bb..61c0505b7 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -1051,6 +1051,15 @@ list.idl = { maintainers = { "@cathaysia" }, } +list.idris = { + install_info = { + url = "https://github.com/kayhide/tree-sitter-idris", + files = { "src/parser.c", "src/scanner.c" }, + }, + filetype = "idris2", + maintainers = { "@srghma" }, +} + list.ini = { install_info = { url = "https://github.com/justinmk/tree-sitter-ini", diff --git a/queries/idris/folds.scm b/queries/idris/folds.scm new file mode 100644 index 000000000..2f4885165 --- /dev/null +++ b/queries/idris/folds.scm @@ -0,0 +1 @@ +(function) @fold diff --git a/queries/idris/highlights.scm b/queries/idris/highlights.scm new file mode 100644 index 000000000..f39deaec6 --- /dev/null +++ b/queries/idris/highlights.scm @@ -0,0 +1,224 @@ +; ------------------------------------------------------------------------------ +; Literals and comments +[ + (integer) + (quantity) +] @number + +(literal + (number)) @number.float + +(char) @character + +[ + (string) + (pat_string) + (triple_quote_string) +] @string + +(comment) @comment @spell + +((comment) @comment.documentation + (#lua-match? @comment.documentation "^|||")) + +(unit) @constant + +; more general captures are moved to the top +; before overwritten later by more specific captures +[ + (loname) + (caname) +] @variable + +; ------------------------------------------------------------------------------ +; Punctuation +[ + "(" + ")" + "{" + "@{" + "}" + "[" + "[<" + "]" +] @punctuation.bracket + +[ + (comma) + (colon) + (pat_op) + (tuple_operator) +] @punctuation.delimiter + +(pat_name + (loname) @variable.parameter) + +; ------------------------------------------------------------------------------ +; Types +(signature + (loname) @type) + +; ------------------------------------------------------------------------------ +; Keywords, operators, imports +[ + "if" + "then" + "else" + "case" + "of" +] @keyword.conditional + +[ + "import" + "module" + "namespace" + "parameters" +] @keyword.import + +[ + (operator) + (equal) + (wildcard) + "." + "|" + "=>" + "⇒" + "<=" + "⇐" + "->" + "→" + "<-" + "←" + "\\" + "`" +] @operator + +(qualified_loname + (caname) @module) + +(qualified_caname + (caname) @constructor) + +(qualified_operator + (caname) @module) + +(import + (caname) @module) + +(module + (caname) @module) + +[ + (where) + "rewrite" + "interface" + "implementation" + "using" + "record" + "as" + "do" + (forall) + (fixity) + (impossible) + (with) + (proof) +] @keyword.operator + +[ + "data" + "let" + "in" + (visibility) + (totality) +] @keyword.modifier + +[ + "=" + "$=" + ":=" +] @operator + +(hole) @label + +[ + (pragma_language) + (pragma_default) + (pragma_builtin) + (pragma_name) + (pragma_ambiguity_depth) + (pragma_auto_implicit_depth) + (pragma_logging) + (pragma_prefix_record_projections) + (pragma_transform) + (pragma_unbound_implicits) + (pragma_auto_lazy) + (pragma_search_timeout) + (pragma_nf_metavar_threshold) + (pragma_cg) + (pragma_allow_overloads) + (pragma_deprecate) + (pragma_inline) + (pragma_noinline) + (pragma_tcinline) + (pragma_hide) + (pragma_unhide) + (pragma_unsafe) + (pragma_spec) + (pragma_foreign) + (pragma_foreign_impl) + (pragma_export) + (pragma_nomangle) + (pragma_hint) + (pragma_defaulthint) + (pragma_globalhint) + (pragma_extern) + (pragma_macro) + (pragma_start) + (pragma_rewrite) + (pragma_pair) + (pragma_integerLit) + (pragma_stringLit) + (pragma_charLit) + (pragma_doubleLit) + (pragma_TTImpLit) + (pragma_declsLit) + (pragma_nameLit) + (pragma_runElab) + (pragma_search) + (pragma_World) + (pragma_MkWorld) + (pragma_syntactic) +] @label + +; ------------------------------------------------------------------------------ +; Functions and variables +(exp_name + (loname) @function.call) + +(constructor + "constructor" @keyword.function + . + (caname) @constructor) + +(exp_record_access + field: (_) @variable.member) + +(signature + name: (loname) @function) + +(function + (lhs + (funvar + subject: [ + (loname) + (caname) + ] @function))) + +(data + name: (data_name) @type) + +(interface_head + name: (interface_name) @type) + +(implementation_head + (interface_name) @type) diff --git a/queries/idris/injections.scm b/queries/idris/injections.scm new file mode 100644 index 000000000..2f0e58eb6 --- /dev/null +++ b/queries/idris/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) diff --git a/queries/idris/locals.scm b/queries/idris/locals.scm new file mode 100644 index 000000000..c46f831f7 --- /dev/null +++ b/queries/idris/locals.scm @@ -0,0 +1,33 @@ +(signature + name: (loname)) @local.definition.var + +(signature + name: (caname)) @local.definition.type + +(function + (lhs + (funvar + subject: (loname)))) @local.definition.function + +(function + (lhs + (funvar + subject: (caname)))) @local.definition.function + +(type_var + (loname)) @local.definition.type + +(pat_name + (loname)) @local.definition.var + +(pat_name + (caname)) @local.definition.var + +(exp_name + (loname)) @local.reference + +(exp_name + (caname)) @local.reference + +(function + (rhs) @local.scope) |
