on master help sign in
Add support for Agda (#8285)

* agda language support (wip) * improve highlights * disable agda-language-server * minor addendum to documentation * cargo xtask docgen * oh i can just do this neat * minor comment cleanup * upstream updated * imports: missed a spot --------- Co-authored-by: Michael Davis <mcarsondavis@gmail.com>

commitc56cd6ee8b9312a620d4fc38eea90a49613f5d72 authorJJ <git@toki.la> dateFri 15 Dec 2023, 20:29 (3 years ago) parent914c834
4 files changed+154
book/src/generated/lang-support.md+1 book/src/guides/adding_languages.md+2 languages.toml+27 runtime/queries/agda/highlights.scm+124
book/src/generated/lang-support.md+1
@@ -1,5 +1,6 @@
11| Language | Syntax Highlighting | Treesitter Textobjects | Auto Indent | Default LSP |
22| --- | --- | --- | --- | --- |
3+| agda | ✓ | | | |
34| astro | ✓ | | | |
45| awk | ✓ | ✓ | | `awk-language-server` |
56| bash | ✓ | ✓ | ✓ | `bash-language-server` |
book/src/guides/adding_languages.md+2
@@ -36,6 +36,7 @@ below.
36363. Refer to the
3737 [tree-sitter website](https://tree-sitter.github.io/tree-sitter/syntax-highlighting#queries)
3838 for more information on writing queries.
39+4. A list of highlight captures can be found [on the themes page](https://docs.helix-editor.com/themes.html#scopes).
3940
4041> 💡 In Helix, the first matching query takes precedence when evaluating
4142> queries, which is different from other editors such as Neovim where the last
@@ -51,3 +52,4 @@ below.
5152 grammars.
5253- If a parser is causing a segfault, or you want to remove it, make sure to
5354 remove the compiled parser located at `runtime/grammars/<name>.so`.
55+- If you are attempting to add queries and Helix is unable to locate them, ensure that the environment variable `HELIX_RUNTIME` is set to the location of the `runtime` folder you're developing in.
languages.toml+27
@@ -3,6 +3,7 @@
33
44[language-server]
55
6+als = { command = "als" }
67awk-language-server = { command = "awk-language-server" }
78bash-language-server = { command = "bash-language-server", args = ["start"] }
89bass = { command = "bass", args = ["--lsp"] }
@@ -2920,6 +2921,32 @@ file-types = ["gmi"]
29202921name = "gemini"
29212922source = { git = "https://git.sr.ht/~nbsp/tree-sitter-gemini", rev = "3cc5e4bdf572d5df4277fc2e54d6299bd59a54b3" }
29222923
2924+[[language]]
2925+name = "agda"
2926+scope = "source.agda"
2927+injection-regex = "agda"
2928+file-types = ["agda"]
2929+roots = []
2930+comment-token = "--"
2931+# language-servers = [ "als" ]
2932+# the agda language server is of questionable functionality.
2933+auto-format = false
2934+indent = { tab-width = 2, unit = " " }
2935+
2936+[language.auto-pairs]
2937+'"' = '"'
2938+"'" = "'"
2939+'{' = '}'
2940+'(' = ')'
2941+'[' = ']'
2942+
2943+# [language.debugger]
2944+# ?? can this be used for proof assistant support? explore
2945+
2946+[[grammar]]
2947+name = "agda"
2948+source = { git = "https://github.com/tree-sitter/tree-sitter-agda", rev = "c21c3a0f996363ed17b8ac99d827fe5a4821f217" }
2949+
29232950[[language]]
29242951name = "templ"
29252952scope = "source.templ"
runtime/queries/agda/highlights.scmnew file+124
@@ -0,0 +1,124 @@
1+;; Punctuation
2+[ "." ";" ":"] @punctuation.delimiter
3+[ "(" ")" "{" "}" ] @punctuation.bracket
4+
5+;; Constants
6+(integer) @constant.numeric.integer
7+; (float) @constant.numeric.float
8+(literal) @string
9+
10+;; Pragmas and comments
11+(comment) @comment
12+(pragma) @attribute
13+(macro) @function.macro
14+
15+;; Imports
16+(module_name) @namespace
17+(import_directive (id) @namespace)
18+[(module) (import) (open)] @keyword.control.import
19+
20+;; Types
21+(typed_binding (expr) @type)
22+(record (expr) @type)
23+(data (expr) @type)
24+(signature (expr) @type)
25+(function (rhs (expr) @type))
26+; todo: these are too general. ideally, any nested (atom)
27+; https://github.com/tree-sitter/tree-sitter/issues/880
28+
29+;; Variables
30+(untyped_binding (atom) @variable)
31+(typed_binding (atom) @variable)
32+(field_name) @variable.other.member
33+
34+;; Functions
35+(function_name) @function
36+;(function (lhs
37+; . (atom) @function
38+; (atom) @variable.parameter))
39+; todo: currently fails to parse, upstream tree-sitter bug
40+
41+;; Data
42+[(data_name) (record_name)] @constructor
43+((atom) @constant.builtin.boolean
44+ (#any-of? @constant.builtin.boolean "true" "false" "True" "False"))
45+
46+"Set" @type.builtin
47+
48+; postulate
49+; type_signature
50+; pattern
51+; id
52+; bid
53+; typed_binding
54+; primitive
55+; private
56+; record_signature
57+; record_assignments
58+; field_assignment
59+; module_assignment
60+; renaming
61+; import_directive
62+; lambda
63+; let
64+; instance
65+; generalize
66+; record
67+; fields
68+; syntax
69+; hole_name
70+; data_signature
71+
72+;; Keywords
73+[
74+ "where"
75+ "data"
76+ "rewrite"
77+ "postulate"
78+ "public"
79+ "private"
80+ "tactic"
81+ "Prop"
82+ "quote"
83+ "renaming"
84+ "in"
85+ "hiding"
86+ "constructor"
87+ "abstract"
88+ "let"
89+ "field"
90+ "mutual"
91+ "infix"
92+ "infixl"
93+ "infixr"
94+ "record"
95+ "overlap"
96+ "instance"
97+ "do"
98+] @keyword
99+
100+[
101+ "="
102+] @operator
103+
104+; = | -> : ? \ .. ... λ ∀ →
105+; (_LAMBDA) (_FORALL) (_ARROW)
106+; "coinductive"
107+; "eta-equality"
108+; "field"
109+; "inductive"
110+; "interleaved"
111+; "macro"
112+; "no-eta-equality"
113+; "pattern"
114+; "primitive"
115+; "quoteTerm"
116+; "rewrite"
117+; "syntax"
118+; "unquote"
119+; "unquoteDecl"
120+; "unquoteDef"
121+; "using"
122+; "variable"
123+; "with"
124+