mirror of
https://github.com/helix-editor/helix.git
synced 2024-11-22 01:16:18 +04:00
feat: Add Ohm
language support (#9991)
* feat: Add `Ohm` language support Hope this commit makes it into release :) * Update runtime/queries/ohm/highlights.scm Co-authored-by: Michael Davis <mcarsondavis@gmail.com> * chore: final newline --------- Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
This commit is contained in:
parent
47995bfb0c
commit
2d9e336f64
@ -128,6 +128,7 @@
|
||||
| ocaml | ✓ | | ✓ | `ocamllsp` |
|
||||
| ocaml-interface | ✓ | | | `ocamllsp` |
|
||||
| odin | ✓ | | ✓ | `ols` |
|
||||
| ohm | ✓ | ✓ | ✓ | |
|
||||
| opencl | ✓ | ✓ | ✓ | `clangd` |
|
||||
| openscad | ✓ | | | `openscad-lsp` |
|
||||
| org | ✓ | | | |
|
||||
|
@ -3408,3 +3408,25 @@ formatter = { command = "prettier", args = ['--parser', 'glimmer'] }
|
||||
[[grammar]]
|
||||
name = "glimmer"
|
||||
source = { git = "https://github.com/ember-tooling/tree-sitter-glimmer", rev = "5dc6d1040e8ff8978ff3680e818d85447bbc10aa" }
|
||||
|
||||
[[language]]
|
||||
name = "ohm"
|
||||
scope = "source.ohm"
|
||||
injection-regex = "ohm"
|
||||
file-types = ["ohm"]
|
||||
comment-token = "//"
|
||||
block-comment-tokens = [
|
||||
{ start = "/*", end = "*/" },
|
||||
{ start = "/**", end = "*/" },
|
||||
]
|
||||
indent = { tab-width = 2, unit = " " }
|
||||
|
||||
[language.auto-pairs]
|
||||
'"' = '"'
|
||||
'{' = '}'
|
||||
'(' = ')'
|
||||
'<' = '>'
|
||||
|
||||
[[grammar]]
|
||||
name = "ohm"
|
||||
source = { git = "https://github.com/novusnota/tree-sitter-ohm", rev = "80f14f0e477ddacc1e137d5ed8e830329e3fb7a3" }
|
||||
|
122
runtime/queries/ohm/highlights.scm
Normal file
122
runtime/queries/ohm/highlights.scm
Normal file
@ -0,0 +1,122 @@
|
||||
; See: https://docs.helix-editor.com/master/themes.html#syntax-highlighting
|
||||
|
||||
; attribute
|
||||
; ---------
|
||||
|
||||
(case_name) @attribute
|
||||
|
||||
; comment.line
|
||||
; ------------
|
||||
|
||||
[
|
||||
(singleline_comment)
|
||||
(rule_descr)
|
||||
] @comment.line
|
||||
|
||||
; comment.block
|
||||
; -------------
|
||||
|
||||
(multiline_comment) @comment.block
|
||||
|
||||
; function.method
|
||||
; ---------------
|
||||
|
||||
(rule
|
||||
name: (identifier) @function.method)
|
||||
|
||||
; function.builtin
|
||||
; ----------------
|
||||
|
||||
; Lexical
|
||||
((identifier) @function.builtin
|
||||
(#any-of? @function.builtin
|
||||
"any"
|
||||
"alnum"
|
||||
"end"
|
||||
"digit" "hexDigit"
|
||||
"letter"
|
||||
"space"
|
||||
"lower" "upper" "caseInsensitive"
|
||||
"listOf" "nonemptyListOf" "emptyListOf"
|
||||
"applySyntactic")
|
||||
(#is-not? local))
|
||||
|
||||
; Syntactic
|
||||
((identifier) @function.builtin
|
||||
(#any-of? @function.builtin "ListOf" "NonemptyListOf" "EmptyListOf")
|
||||
(#is-not? local))
|
||||
|
||||
; function.method (continuing)
|
||||
; ---------------
|
||||
|
||||
(term
|
||||
base: (identifier) @function.method)
|
||||
|
||||
; string.special
|
||||
; --------------
|
||||
|
||||
(escape_char) @constant.character.escape
|
||||
|
||||
; string
|
||||
; ------
|
||||
|
||||
[
|
||||
(terminal_string)
|
||||
(one_char_terminal)
|
||||
] @string
|
||||
|
||||
; type
|
||||
; ----
|
||||
|
||||
(super_grammar
|
||||
name: (identifier) @type)
|
||||
|
||||
(grammar
|
||||
name: (identifier) @type)
|
||||
|
||||
; operator
|
||||
; --------
|
||||
|
||||
[
|
||||
; "=" ":=" "+="
|
||||
(define) (override) (extend)
|
||||
|
||||
; "&" "~"
|
||||
(lookahead) (negative_lookahead)
|
||||
|
||||
; "#"
|
||||
(lexification)
|
||||
|
||||
; "*" "+" "?"
|
||||
(zero_or_more) (one_or_more) (zero_or_one)
|
||||
|
||||
; "..."
|
||||
(super_splice)
|
||||
|
||||
"<:" ".." "|"
|
||||
] @operator
|
||||
|
||||
; punctuation.bracket
|
||||
; -------------------
|
||||
|
||||
[
|
||||
"<"
|
||||
">"
|
||||
"{"
|
||||
"}"
|
||||
] @punctuation.bracket
|
||||
|
||||
(alt
|
||||
"(" @punctuation.bracket
|
||||
")" @punctuation.bracket)
|
||||
|
||||
; punctuation.delimiter
|
||||
; ---------------------
|
||||
|
||||
"," @punctuation.delimiter
|
||||
|
||||
; variable.parameter
|
||||
; ------------------
|
||||
|
||||
(formals
|
||||
(identifier) @variable.parameter)
|
37
runtime/queries/ohm/indents.scm
Normal file
37
runtime/queries/ohm/indents.scm
Normal file
@ -0,0 +1,37 @@
|
||||
; See: https://docs.helix-editor.com/guides/indent.html
|
||||
|
||||
; indent
|
||||
; ------
|
||||
|
||||
[
|
||||
; <..., ...>
|
||||
(formals)
|
||||
(params)
|
||||
|
||||
; (...| ...)
|
||||
(alt)
|
||||
] @indent
|
||||
|
||||
; outdent
|
||||
; -------
|
||||
|
||||
[
|
||||
"}"
|
||||
")"
|
||||
">"
|
||||
] @outdent
|
||||
|
||||
; align
|
||||
; -----
|
||||
|
||||
; | ... | ...
|
||||
(rule_body
|
||||
. (top_level_term) @anchor
|
||||
(#set! "scope" "tail")) @align
|
||||
|
||||
; N/A or unused:
|
||||
; --------------
|
||||
; indent.always
|
||||
; outdent.always
|
||||
; extend
|
||||
; extend.prevent-once
|
7
runtime/queries/ohm/injections.scm
Normal file
7
runtime/queries/ohm/injections.scm
Normal file
@ -0,0 +1,7 @@
|
||||
; See: https://docs.helix-editor.com/guides/injection.html
|
||||
|
||||
((singleline_comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
((multiline_comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
40
runtime/queries/ohm/textobjects.scm
Normal file
40
runtime/queries/ohm/textobjects.scm
Normal file
@ -0,0 +1,40 @@
|
||||
; See: https://docs.helix-editor.com/guides/textobject.html
|
||||
|
||||
; function.inside & around
|
||||
; ------------------------
|
||||
|
||||
(rule
|
||||
body: (_) @function.inside) @function.around
|
||||
|
||||
; class.inside & around
|
||||
; ---------------------
|
||||
|
||||
(grammar
|
||||
body: (_) @class.inside) @class.around
|
||||
|
||||
; parameter.inside & around
|
||||
; -------------------------
|
||||
|
||||
(formals
|
||||
((_) @parameter.inside . ","? @parameter.around) @parameter.around)
|
||||
|
||||
(rule_body
|
||||
((_) @parameter.inside . "|"? @parameter.around) @parameter.around)
|
||||
|
||||
(params
|
||||
((_) @parameter.inside . ","? @parameter.around) @parameter.around)
|
||||
|
||||
(alt
|
||||
((_) @parameter.inside . "|"? @parameter.around) @parameter.around)
|
||||
|
||||
; comment.inside
|
||||
; --------------
|
||||
|
||||
(multiline_comment)+ @comment.inside
|
||||
(singleline_comment)+ @comment.inside
|
||||
|
||||
; comment.around
|
||||
; --------------
|
||||
|
||||
(multiline_comment)+ @comment.around
|
||||
(singleline_comment)+ @comment.around
|
Loading…
Reference in New Issue
Block a user