Feat: add hover boxes and diagnostics from lsp
This commit is contained in:
328
grammar/hover.scm
Normal file
328
grammar/hover.scm
Normal file
@@ -0,0 +1,328 @@
|
||||
;; #82AAFF #000000 1 0 1 4
|
||||
(setext_heading
|
||||
(paragraph) @markup.heading.1
|
||||
(setext_h1_underline) @markup.heading.1)
|
||||
|
||||
;; #82AAFF #000000 1 0 1 4
|
||||
(setext_heading
|
||||
(paragraph) @markup.heading.2
|
||||
(setext_h2_underline) @markup.heading.2)
|
||||
|
||||
(atx_heading
|
||||
(atx_h1_marker)) @markup.heading.1
|
||||
|
||||
(atx_heading
|
||||
(atx_h2_marker)) @markup.heading.2
|
||||
|
||||
;; #82AAFF #000000 1 0 0 4
|
||||
(atx_heading
|
||||
(atx_h3_marker)) @markup.heading.3
|
||||
|
||||
;; #82AAFF #000000 1 0 0 4
|
||||
(atx_heading
|
||||
(atx_h4_marker)) @markup.heading.4
|
||||
|
||||
;; #82AAFF #000000 1 0 0 4
|
||||
(atx_heading
|
||||
(atx_h5_marker)) @markup.heading.5
|
||||
|
||||
;; #82AAFF #000000 1 0 0 4
|
||||
(atx_heading
|
||||
(atx_h6_marker)) @markup.heading.6
|
||||
|
||||
;; #82AAFF #000000 0 0 0 4
|
||||
(info_string) @label
|
||||
|
||||
;; #FF6347 #000000 0 0 0 4
|
||||
(pipe_table_header
|
||||
(pipe_table_cell) @markup.heading)
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 4
|
||||
(pipe_table_header
|
||||
"|" @punctuation.special)
|
||||
|
||||
(pipe_table_row
|
||||
"|" @punctuation.special)
|
||||
|
||||
(pipe_table_delimiter_row
|
||||
"|" @punctuation.special)
|
||||
|
||||
(pipe_table_delimiter_cell) @punctuation.special
|
||||
|
||||
;; #AAD94C #000000 0 0 0 2
|
||||
(indented_code_block) @markup.raw.block
|
||||
|
||||
(fenced_code_block) @markup.raw.block
|
||||
|
||||
(fenced_code_block
|
||||
(fenced_code_block_delimiter) @markup.raw.block)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @label))
|
||||
|
||||
;; #7dcfff #000000 0 0 1 6
|
||||
(link_destination) @markup.link.url
|
||||
|
||||
;; #7dcfff #000000 0 0 1 6
|
||||
[
|
||||
(link_title)
|
||||
(link_label)
|
||||
] @markup.link.label
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 4
|
||||
((link_label)
|
||||
.
|
||||
":" @punctuation.delimiter)
|
||||
|
||||
;; #9ADE7A #000000 0 0 0 4
|
||||
[
|
||||
(list_marker_plus)
|
||||
(list_marker_minus)
|
||||
(list_marker_star)
|
||||
(list_marker_dot)
|
||||
(list_marker_parenthesis)
|
||||
] @markup.list
|
||||
|
||||
(thematic_break) @punctuation.special
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 4
|
||||
(task_list_marker_unchecked) @markup.list.unchecked
|
||||
|
||||
;; #AAD94C #000000 0 0 0 4
|
||||
(task_list_marker_checked) @markup.list.checked
|
||||
|
||||
[
|
||||
(plus_metadata)
|
||||
(minus_metadata)
|
||||
] @keyword.directive
|
||||
|
||||
[
|
||||
(block_continuation)
|
||||
(block_quote_marker)
|
||||
] @punctuation.special
|
||||
|
||||
;; #AAD94C #000000 0 0 0 6
|
||||
(backslash_escape) @string.escape
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^ruby$"))
|
||||
;; !ruby
|
||||
(code_fence_content) @injection.ruby)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^bash$"))
|
||||
;; !bash
|
||||
(code_fence_content) @injection.bash)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^cpp$"))
|
||||
;; !cpp
|
||||
(code_fence_content) @injection.cpp)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^h$"))
|
||||
;; !h
|
||||
(code_fence_content) @injection.h)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^c$"))
|
||||
;; !c
|
||||
(code_fence_content) @injection.h)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^css$"))
|
||||
;; !css
|
||||
(code_fence_content) @injection.css)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^fish$"))
|
||||
;; !fish
|
||||
(code_fence_content) @injection.fish)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^go$"))
|
||||
;; !go
|
||||
(code_fence_content) @injection.go)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^haskell$"))
|
||||
;; !haskell
|
||||
(code_fence_content) @injection.haskell)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^html$"))
|
||||
;; !html
|
||||
(code_fence_content) @injection.html)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^javascript$"))
|
||||
;; !javascript
|
||||
(code_fence_content) @injection.javascript)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^json$"))
|
||||
;; !json
|
||||
(code_fence_content) @injection.json)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^lua$"))
|
||||
; - lua format in hover boxes is typed making it unparsable as normal lua
|
||||
; - TODO: add a lua grammar with typing or remove this injection
|
||||
(code_fence_content) @injection.lua)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^regex$"))
|
||||
;; !regex
|
||||
(code_fence_content) @injection.regex)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^query$"))
|
||||
;; !query
|
||||
(code_fence_content) @injection.query)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^markdown$"))
|
||||
;; !markdown
|
||||
(code_fence_content) @injection.markdown)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^markdown_inline$"))
|
||||
;; !markdown_inline
|
||||
(code_fence_content) @injection.markdown_inline)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^erb$"))
|
||||
;; !embedded_template
|
||||
(code_fence_content) @injection.embedded_template)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^python$"))
|
||||
;; !python
|
||||
(code_fence_content) @injection.python)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^php$"))
|
||||
;; !php
|
||||
(code_fence_content) @injection.php)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^rust$"))
|
||||
;; !rust
|
||||
(code_fence_content) @injection.rust)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^sql$"))
|
||||
;; !sql
|
||||
(code_fence_content) @injection.sql)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^gitattributes$"))
|
||||
;; !gitattributes
|
||||
(code_fence_content) @injection.gitattributes)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^gitignore$"))
|
||||
;; !gitignore
|
||||
(code_fence_content) @injection.gitignore)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^gdscript$"))
|
||||
;; !gdscript
|
||||
(code_fence_content) @injection.gdscript)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^make$"))
|
||||
;; !make
|
||||
(code_fence_content) @injection.make)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^diff$"))
|
||||
;; !diff
|
||||
(code_fence_content) @injection.diff)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^ini$"))
|
||||
;; !ini
|
||||
(code_fence_content) @injection.ini)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^nginx$"))
|
||||
;; !nginx
|
||||
(code_fence_content) @injection.nginx)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^toml$"))
|
||||
;; !toml
|
||||
(code_fence_content) @injection.toml)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^yaml$"))
|
||||
;; !yaml
|
||||
(code_fence_content) @injection.yaml)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^gomod$"))
|
||||
;; !gomod
|
||||
(code_fence_content) @injection.gomod)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^man$"))
|
||||
;; !man
|
||||
(code_fence_content) @injection.man)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^cabal$"))
|
||||
;; !cabal
|
||||
(code_fence_content) @injection.cabal)
|
||||
|
||||
;; !html
|
||||
(html_block) @injection.html
|
||||
|
||||
;; !yaml
|
||||
(minus_metadata) @injection.yaml
|
||||
|
||||
;; !toml
|
||||
(plus_metadata) @injection.toml
|
||||
|
||||
;; !markdown_inline
|
||||
(paragraph) @inline
|
||||
|
||||
(pipe_table_row
|
||||
(pipe_table_cell) @inline)
|
||||
|
||||
(block_quote ((paragraph) @inline))
|
||||
@@ -85,8 +85,7 @@
|
||||
value: [(arrow_function) (function_expression)]) @definition.function
|
||||
|
||||
;; #59C2FF #000000 0 0 0 0
|
||||
(
|
||||
(call_expression
|
||||
((call_expression
|
||||
function: (identifier) @name) @reference.call
|
||||
(#not-match? @name "^(require)$"))
|
||||
|
||||
|
||||
23
grammar/man.scm
Normal file
23
grammar/man.scm
Normal file
@@ -0,0 +1,23 @@
|
||||
;; #82AAFF #000000 1 0 1 2
|
||||
(title) @markup.heading.1
|
||||
|
||||
;; #ccefc9 #000000 0 0 0 0
|
||||
(section_title) @markup.heading.2
|
||||
|
||||
;; #FF8F40 #000000 1 0 0 2
|
||||
(subsection_title) @markup.heading.3
|
||||
|
||||
;; #AAD94C #000000 0 0 0 3
|
||||
(option) @variable.parameter
|
||||
|
||||
;; #FFD700 #000000 1 0 0 3
|
||||
(reference) @markup.link.label
|
||||
|
||||
;; #C792EA #000000 0 0 0 3
|
||||
(footer) @markup.heading
|
||||
|
||||
(section_heading
|
||||
(section_title) @_title
|
||||
;; #FFD700 #000000 1 0 0 1
|
||||
(block) @injection.content
|
||||
(#match? @_title "SYNOPSIS"))
|
||||
@@ -297,6 +297,12 @@
|
||||
;; !gomod
|
||||
(code_fence_content) @injection.gomod)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^man$"))
|
||||
;; !man
|
||||
(code_fence_content) @injection.man)
|
||||
|
||||
(fenced_code_block
|
||||
(info_string
|
||||
(language) @injection.language (#match? @injection.language "^cabal$"))
|
||||
|
||||
@@ -507,3 +507,9 @@
|
||||
(heredoc_content) @cabal_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "CABAL")))
|
||||
|
||||
(heredoc_body
|
||||
;; !man
|
||||
(heredoc_content) @man_injection
|
||||
((heredoc_end) @lang
|
||||
(#match? @lang "MAN")))
|
||||
|
||||
316
grammar/typescript.scm
Normal file
316
grammar/typescript.scm
Normal file
@@ -0,0 +1,316 @@
|
||||
; ============================================================
|
||||
; Identifiers
|
||||
; ============================================================
|
||||
|
||||
;; #FFFFFF #000000 0 0 0 1
|
||||
(identifier) @variable
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 2
|
||||
((identifier) @constant
|
||||
(#match? @constant "^[A-Z_][A-Z0-9_]*$"))
|
||||
|
||||
;; #F07178 #000000 0 0 0 3
|
||||
((identifier) @variable.builtin
|
||||
(#match? @variable.builtin
|
||||
"^(arguments|console|window|document|globalThis|process|module|exports)$"))
|
||||
|
||||
;; #59C2FF #000000 0 0 0 1
|
||||
((identifier) @constructor
|
||||
(#match? @constructor "^[A-Z][a-zA-Z0-9]*$"))
|
||||
|
||||
; ============================================================
|
||||
; Properties
|
||||
; ============================================================
|
||||
|
||||
;; #F07178 #000000 0 0 0 1
|
||||
(property_identifier) @property
|
||||
|
||||
; ============================================================
|
||||
; Functions
|
||||
; ============================================================
|
||||
|
||||
;; #FFB454 #000000 0 0 0 3
|
||||
(function_declaration
|
||||
name: (identifier) @function)
|
||||
|
||||
(function_expression
|
||||
name: (identifier) @function)
|
||||
|
||||
;; #FFB454 #000000 0 0 0 2
|
||||
(method_definition
|
||||
name: (property_identifier) @function.method)
|
||||
|
||||
(variable_declarator
|
||||
name: (identifier) @function
|
||||
value: [(function_expression) (arrow_function)])
|
||||
|
||||
(assignment_expression
|
||||
left: (identifier) @function
|
||||
right: [(function_expression) (arrow_function)])
|
||||
|
||||
(pair
|
||||
key: (property_identifier) @function.method
|
||||
value: [(function_expression) (arrow_function)])
|
||||
|
||||
; ------------------------------------------------------------
|
||||
; Function calls
|
||||
; ------------------------------------------------------------
|
||||
|
||||
;; #FFB454 #000000 0 0 0 2
|
||||
(call_expression
|
||||
function: (identifier) @function.call)
|
||||
|
||||
;; #FFB454 #000000 0 0 0 2
|
||||
(call_expression
|
||||
function: (member_expression
|
||||
property: (property_identifier) @function.method))
|
||||
|
||||
; ============================================================
|
||||
; Highlighted definitions & references
|
||||
; ============================================================
|
||||
|
||||
;; #FFB454 #000000 0 0 0 3
|
||||
(assignment_expression
|
||||
left: [
|
||||
(identifier) @name
|
||||
(member_expression
|
||||
property: (property_identifier) @name)
|
||||
]
|
||||
right: [(arrow_function) (function_expression)]
|
||||
) @definition.function
|
||||
|
||||
;; #FFB454 #000000 0 0 0 3
|
||||
(pair
|
||||
key: (property_identifier) @name
|
||||
value: [(arrow_function) (function_expression)]) @definition.function
|
||||
|
||||
;; #59C2FF #000000 0 0 0 0
|
||||
((call_expression
|
||||
function: (identifier) @name) @reference.call
|
||||
(#not-match? @name "^(require)$"))
|
||||
|
||||
;; #7dcfff #000000 0 0 0 2
|
||||
(new_expression
|
||||
constructor: (_) @name) @reference.class
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 2
|
||||
(export_statement value: (assignment_expression left: (identifier) @name right: ([
|
||||
(number)
|
||||
(string)
|
||||
(identifier)
|
||||
(undefined)
|
||||
(null)
|
||||
(new_expression)
|
||||
(binary_expression)
|
||||
(call_expression)
|
||||
]))) @definition.constant
|
||||
|
||||
; ============================================================
|
||||
; Parameters
|
||||
; ============================================================
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 1
|
||||
(formal_parameters
|
||||
[
|
||||
(identifier) @variable.parameter
|
||||
(array_pattern
|
||||
(identifier) @variable.parameter)
|
||||
(object_pattern
|
||||
[
|
||||
(pair_pattern value: (identifier) @variable.parameter)
|
||||
(shorthand_property_identifier_pattern) @variable.parameter
|
||||
])
|
||||
])
|
||||
|
||||
; ============================================================
|
||||
; Keywords (split into semantic groups)
|
||||
; ============================================================
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 1
|
||||
; Declarations
|
||||
[
|
||||
"var"
|
||||
"let"
|
||||
"const"
|
||||
"function"
|
||||
"class"
|
||||
] @keyword.declaration
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 1
|
||||
; Control flow
|
||||
[
|
||||
"if"
|
||||
"else"
|
||||
"switch"
|
||||
"case"
|
||||
"default"
|
||||
"for"
|
||||
"while"
|
||||
"do"
|
||||
"break"
|
||||
"continue"
|
||||
"return"
|
||||
"throw"
|
||||
"try"
|
||||
"catch"
|
||||
"finally"
|
||||
"extends"
|
||||
] @keyword.control
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 1
|
||||
; Imports / exports
|
||||
[
|
||||
"import"
|
||||
"export"
|
||||
"from"
|
||||
"as"
|
||||
] @keyword.import
|
||||
|
||||
;; #F29668 #000000 0 0 0 1
|
||||
; Operators-as-keywords
|
||||
[
|
||||
"in"
|
||||
"instanceof"
|
||||
"new"
|
||||
"delete"
|
||||
"typeof"
|
||||
"void"
|
||||
"await"
|
||||
"yield"
|
||||
] @keyword.operator
|
||||
|
||||
;; #FF8F40 #000000 0 0 0 1
|
||||
; Modifiers
|
||||
[
|
||||
"async"
|
||||
"static"
|
||||
"get"
|
||||
"set"
|
||||
] @keyword.modifier
|
||||
|
||||
; ============================================================
|
||||
; Literals
|
||||
; ============================================================
|
||||
|
||||
;; #F07178 #000000 0 0 0 1
|
||||
(this) @variable.builtin
|
||||
(super) @variable.builtin
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 4
|
||||
[
|
||||
(true)
|
||||
(false)
|
||||
(null)
|
||||
(undefined)
|
||||
] @constant.builtin
|
||||
|
||||
;; #D2A6FF #000000 0 0 0 2
|
||||
(number) @number
|
||||
|
||||
;; #D2A6FF #000000 0 1 0 2
|
||||
((string) @use_strict
|
||||
(#match? @use_strict "^['\"]use strict['\"]$"))
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0
|
||||
(string) @string
|
||||
|
||||
;; #AAD94C #000000 0 0 0 0
|
||||
(template_string) @string.special
|
||||
|
||||
;; #99ADBF #000000 0 1 0 1
|
||||
(comment) @comment
|
||||
|
||||
; ============================================================
|
||||
; Operators & punctuation
|
||||
; ============================================================
|
||||
|
||||
;; #F29668 #000000 0 1 0 1
|
||||
[
|
||||
"+"
|
||||
"-"
|
||||
"*"
|
||||
"/"
|
||||
"%"
|
||||
"**"
|
||||
"++"
|
||||
"--"
|
||||
"=="
|
||||
"!="
|
||||
"==="
|
||||
"!=="
|
||||
"<"
|
||||
"<="
|
||||
">"
|
||||
">="
|
||||
"&&"
|
||||
"||"
|
||||
"??"
|
||||
"!"
|
||||
"~"
|
||||
"&"
|
||||
"|"
|
||||
"^"
|
||||
"<<"
|
||||
">>"
|
||||
">>>"
|
||||
"="
|
||||
"+="
|
||||
"-="
|
||||
"*="
|
||||
"/="
|
||||
"%="
|
||||
"<<="
|
||||
">>="
|
||||
">>>="
|
||||
"&="
|
||||
"|="
|
||||
"^="
|
||||
"&&="
|
||||
"||="
|
||||
"??="
|
||||
"=>"
|
||||
] @operator
|
||||
|
||||
;; #BFBDB6 #000000 0 0 0 1
|
||||
[
|
||||
"."
|
||||
","
|
||||
";"
|
||||
] @punctuation.delimiter
|
||||
|
||||
;; #BFBDB6 #000000 0 0 0 1
|
||||
[
|
||||
"("
|
||||
")"
|
||||
"["
|
||||
"]"
|
||||
"{"
|
||||
"}"
|
||||
] @punctuation.bracket
|
||||
|
||||
;; #7dcfff #000000 0 0 0 2
|
||||
(template_substitution
|
||||
"${" @punctuation.special
|
||||
"}" @punctuation.special)
|
||||
|
||||
; ============================================================
|
||||
; JSX
|
||||
; ============================================================
|
||||
|
||||
;; #59C2FF #000000 0 0 0 4
|
||||
(jsx_opening_element (identifier) @tag2)
|
||||
(jsx_closing_element (identifier) @tag2)
|
||||
(jsx_self_closing_element (identifier) @tag2)
|
||||
|
||||
;; #F07178 #000000 0 0 0 3
|
||||
(jsx_attribute (property_identifier) @attribute2)
|
||||
|
||||
;; #BFBDB6 #000000 0 0 0 3
|
||||
(jsx_opening_element (["<" ">"]) @punctuation.bracket2)
|
||||
(jsx_closing_element (["</" ">"]) @punctuation.bracket2)
|
||||
(jsx_self_closing_element (["<" "/>"]) @punctuation.bracket2)
|
||||
|
||||
; Injections
|
||||
|
||||
;; !regex
|
||||
(regex) @string.regex
|
||||
Reference in New Issue
Block a user