fixed python injections

This commit is contained in:
2024-06-06 01:30:40 -05:00
parent 486d276778
commit cbe3db74f4
2 changed files with 37 additions and 12 deletions
+3 -3
View File
@@ -398,9 +398,9 @@ function M.lsp_zero()
"svelte", "svelte",
"angularls", "angularls",
"tailwindcss", "tailwindcss",
"templ", --"templ",
--"gopls", --"gopls",
--"htmx", --"htmx",
}) })
lsp.configure("pyright", { lsp.configure("pyright", {
@@ -423,7 +423,7 @@ function M.lsp_zero()
filetypes = { "html", "htmldjango", "templ" }, filetypes = { "html", "htmldjango", "templ" },
}) })
lsp.on_attach(function(client, bufnr) lsp.on_attach(function(client, _)
if client.name == "svelte" then if client.name == "svelte" then
vim.api.nvim_create_autocmd("BufWritePost", { vim.api.nvim_create_autocmd("BufWritePost", {
pattern = { "*.js", "*.ts" }, pattern = { "*.js", "*.ts" },
+34 -9
View File
@@ -1,31 +1,56 @@
(type (string (string_content) @python)) (type
(string
(string_content) @injection.content
(#set! injection.include-children)
(#set! injection.language "python")))
(type (subscript (string (string_content) @python))) (type
(subscript
(string
(string_content) @injection.content
(#set! injection.include-children)
(#set! injection.language "python"))))
((assignment ((assignment
(type (identifier) @_type) (type
(string (string_content) @python)) (identifier) @_type)
(string
(string_content) @injection.content
(#set! injection.include-children)
(#set! injection.language "python")))
(#eq? @_type "TypeAlias")) (#eq? @_type "TypeAlias"))
((assignment ((assignment
(type (string (string_content) @_type)) (type
(string (string_content) @python)) (string
(string_content) @_type))
(string
(string_content) @injection.content
(#set! injection.include-children)
(#set! injection.language "python")))
(#eq? @_type "TypeAlias")) (#eq? @_type "TypeAlias"))
(class_definition (class_definition
(argument_list (argument_list
(subscript (subscript
(string (string
(string_content) @python)))) (string_content) @injection.content
(#set! injection.include-children)
(#set! injection.language "python")))))
(((string (string_content) @python) @_str) (((string
(string_content) @injection.content
(#set! injection.include-children)
(#set! injection.language "python")) @_str)
(#match? @_str "^r.*$")) (#match? @_str "^r.*$"))
((call ((call
(identifier) @_function (identifier) @_function
(argument_list (argument_list
(string (string
(string_content) @python))) (string_content) @injection.content
(#set! injection.include-children)
(#set! injection.language "python"))))
(#any-of? @_function "cast" "NewType" "TypeVar" "TypedDict")) (#any-of? @_function "cast" "NewType" "TypeVar" "TypedDict"))
; Too slow ; Too slow