mirror of https://github.com/lapce/lapce.git
added queries for svelte (#1702)
This commit is contained in:
parent
939853808a
commit
a937a67222
|
@ -3,6 +3,7 @@
|
|||
## Unreleased
|
||||
|
||||
### Features/Changes
|
||||
- [#1702](https://github.com/lapce/lapce/pull/1702) Improved svelte treesitter queries
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
|
|
|
@ -0,0 +1,110 @@
|
|||
; src: https://github.com/helix-editor/helix/blob/master/runtime/queries/svelte/highlights.scm
|
||||
; licence: https://github.com/helix-editor/helix/blob/master/LICENSE
|
||||
; spdx: MPL-2.0
|
||||
|
||||
(tag_name) @tag
|
||||
(erroneous_end_tag_name) @error
|
||||
(comment) @comment
|
||||
(attribute_name) @tag.attribute
|
||||
(attribute
|
||||
(quoted_attribute_value) @string)
|
||||
(text) @text @spell
|
||||
|
||||
((element (start_tag (tag_name) @_tag) (text) @text.title)
|
||||
(#match? @_tag "^(h[0-9]|title)$"))
|
||||
|
||||
((element (start_tag (tag_name) @_tag) (text) @text.strong)
|
||||
(#match? @_tag "^(strong|b)$"))
|
||||
|
||||
((element (start_tag (tag_name) @_tag) (text) @text.emphasis)
|
||||
(#match? @_tag "^(em|i)$"))
|
||||
|
||||
((element (start_tag (tag_name) @_tag) (text) @text.strike)
|
||||
(#match? @_tag "^(s|del)$"))
|
||||
|
||||
((element (start_tag (tag_name) @_tag) (text) @text.underline)
|
||||
(#eq? @_tag "u"))
|
||||
|
||||
((element (start_tag (tag_name) @_tag) (text) @text.literal)
|
||||
(#match? @_tag "^(code|kbd)$"))
|
||||
|
||||
((element (start_tag (tag_name) @_tag) (text) @text.uri)
|
||||
(#eq? @_tag "a"))
|
||||
|
||||
((attribute
|
||||
(attribute_name) @_attr
|
||||
(quoted_attribute_value (attribute_value) @text.uri))
|
||||
(#match? @_attr "^(href|src)$"))
|
||||
|
||||
[
|
||||
"<"
|
||||
">"
|
||||
"</"
|
||||
"/>"
|
||||
] @tag.delimiter
|
||||
|
||||
"=" @operator
|
||||
((element (start_tag (tag_name) @_tag) (text) @text.title)
|
||||
(#match? @_tag "^(h[0-9]|title)$"))
|
||||
|
||||
((element (start_tag (tag_name) @_tag) (text) @text.strong)
|
||||
(#match? @_tag "^(strong|b)$"))
|
||||
|
||||
((element (start_tag (tag_name) @_tag) (text) @text.emphasis)
|
||||
(#match? @_tag "^(em|i)$"))
|
||||
|
||||
((element (start_tag (tag_name) @_tag) (text) @text.strike)
|
||||
(#match? @_tag "^(s|del)$"))
|
||||
|
||||
((element (start_tag (tag_name) @_tag) (text) @text.underline)
|
||||
(#eq? @_tag "u"))
|
||||
|
||||
((element (start_tag (tag_name) @_tag) (text) @text.literal)
|
||||
(#match? @_tag "^(code|kbd)$"))
|
||||
|
||||
((element (start_tag (tag_name) @_tag) (text) @text.uri)
|
||||
(#eq? @_tag "a"))
|
||||
|
||||
((attribute
|
||||
(attribute_name) @_attr
|
||||
(quoted_attribute_value (attribute_value) @text.uri))
|
||||
(#match? @_attr "^(href|src)$"))
|
||||
|
||||
(tag_name) @tag
|
||||
(attribute_name) @property
|
||||
(erroneous_end_tag_name) @error
|
||||
(comment) @comment
|
||||
|
||||
[
|
||||
(attribute_value)
|
||||
(quoted_attribute_value)
|
||||
] @string
|
||||
|
||||
[
|
||||
(text)
|
||||
(raw_text_expr)
|
||||
] @none
|
||||
|
||||
[
|
||||
(special_block_keyword)
|
||||
(then)
|
||||
(as)
|
||||
] @keyword
|
||||
|
||||
[
|
||||
"{"
|
||||
"}"
|
||||
] @punctuation.bracket
|
||||
|
||||
"=" @operator
|
||||
|
||||
[
|
||||
"<"
|
||||
">"
|
||||
"</"
|
||||
"/>"
|
||||
"#"
|
||||
":"
|
||||
"/"
|
||||
"@"
|
||||
] @tag.delimiter
|
|
@ -0,0 +1,24 @@
|
|||
;src: https://github.com/nvim-treesitter/nvim-treesitter/blob/master/queries/svelte/indents.scm
|
||||
;licence https://github.com/nvim-treesitter/nvim-treesitter/blob/master/LICENSE
|
||||
; spdx: Apache-2.0
|
||||
|
||||
[
|
||||
(element)
|
||||
(if_statement)
|
||||
(each_statement)
|
||||
(await_statement)
|
||||
(script_element)
|
||||
(style_element)
|
||||
] @indent
|
||||
|
||||
[
|
||||
(end_tag)
|
||||
(else_statement)
|
||||
(if_end_expr)
|
||||
(each_end_expr)
|
||||
(await_end_expr)
|
||||
">"
|
||||
"/>"
|
||||
] @branch
|
||||
|
||||
(comment) @ignore
|
|
@ -0,0 +1,32 @@
|
|||
; src: https://github.com/helix-editor/helix/blob/master/runtime/queries/svelte/injections.scm
|
||||
; licence: https://github.com/helix-editor/helix/blob/master/LICENSE
|
||||
; spdx: MPL-2.0
|
||||
|
||||
((style_element
|
||||
(raw_text) @injection.content)
|
||||
(#set! injection.language "css"))
|
||||
|
||||
((attribute
|
||||
(attribute_name) @_attr
|
||||
(quoted_attribute_value (attribute_value) @css))
|
||||
(#eq? @_attr "style"))
|
||||
|
||||
((script_element
|
||||
(raw_text) @injection.content)
|
||||
(#set! injection.language "javascript"))
|
||||
|
||||
((raw_text_expr) @injection.content
|
||||
(#set! injection.language "javascript"))
|
||||
|
||||
(
|
||||
(script_element
|
||||
(start_tag
|
||||
(attribute
|
||||
(quoted_attribute_value (attribute_value) @_lang)))
|
||||
(raw_text) @injection.content)
|
||||
(#match? @_lang "(ts|typescript)")
|
||||
(#set! injection.language "typescript")
|
||||
)
|
||||
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
|
@ -733,8 +733,8 @@ pub enum LapceLanguage {
|
|||
SyntaxProperties {
|
||||
id: LapceLanguage::Svelte,
|
||||
language: tree_sitter_svelte::language,
|
||||
highlight: tree_sitter_svelte::HIGHLIGHT_QUERY,
|
||||
injection: Some(tree_sitter_svelte::INJECTION_QUERY),
|
||||
highlight: include_str!("../queries/svelte/highlights.scm"),
|
||||
injection: Some(include_str!("../queries/svelte/injections.scm")),
|
||||
comment: "//",
|
||||
indent: " ",
|
||||
code_lens: (DEFAULT_CODE_LENS_LIST, DEFAULT_CODE_LENS_IGNORE_LIST),
|
||||
|
|
Loading…
Reference in New Issue