treesitter html highlighting/injections
This commit is contained in:
@@ -126,6 +126,7 @@ opt.mouse = ""
|
|||||||
vim.cmd([[hi CursorLine cterm=NONE ctermbg=darkgray ctermfg=white]])
|
vim.cmd([[hi CursorLine cterm=NONE ctermbg=darkgray ctermfg=white]])
|
||||||
vim.cmd([[au BufRead,BufNewFile .env.* set filetype=sh]])
|
vim.cmd([[au BufRead,BufNewFile .env.* set filetype=sh]])
|
||||||
vim.cmd([[au BufRead,BufNewFile Dockerfile.* set filetype=dockerfile]])
|
vim.cmd([[au BufRead,BufNewFile Dockerfile.* set filetype=dockerfile]])
|
||||||
|
vim.cmd([[au BufRead,BufNewFile *.html set filetype=html]])
|
||||||
|
|
||||||
-- redo folds on write
|
-- redo folds on write
|
||||||
vim.cmd([[au BufWrite * normal zx]])
|
vim.cmd([[au BufWrite * normal zx]])
|
||||||
|
|||||||
+17
-4
@@ -169,8 +169,7 @@ function M.lualine()
|
|||||||
lualine_c = {},
|
lualine_c = {},
|
||||||
lualine_x = {},
|
lualine_x = {},
|
||||||
lualine_y = {},
|
lualine_y = {},
|
||||||
lualine_z = {
|
lualine_z = {},
|
||||||
},
|
|
||||||
},
|
},
|
||||||
extensions = {},
|
extensions = {},
|
||||||
})
|
})
|
||||||
@@ -180,11 +179,11 @@ function M.nvim_treesitter()
|
|||||||
local highlight_disable = {
|
local highlight_disable = {
|
||||||
typescript = true,
|
typescript = true,
|
||||||
tsx = true,
|
tsx = true,
|
||||||
html = true,
|
--html = true,
|
||||||
javascript = true,
|
javascript = true,
|
||||||
cpp = true,
|
cpp = true,
|
||||||
}
|
}
|
||||||
local rainbow_disable = vim.tbl_extend("force", highlight_disable, { svelte = true })
|
local rainbow_disable = vim.tbl_extend("force", highlight_disable, { svelte = true, html = true })
|
||||||
|
|
||||||
local too_many_lines = function(bufnr)
|
local too_many_lines = function(bufnr)
|
||||||
return vim.api.nvim_buf_line_count(bufnr) > 5000
|
return vim.api.nvim_buf_line_count(bufnr) > 5000
|
||||||
@@ -215,6 +214,19 @@ function M.nvim_treesitter()
|
|||||||
vim.opt.foldmethod = "expr"
|
vim.opt.foldmethod = "expr"
|
||||||
vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
|
vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local parser_config = require("nvim-treesitter.parsers").get_parser_configs()
|
||||||
|
parser_config.htmldjango = {
|
||||||
|
install_info = {
|
||||||
|
url = "~/code/treesitter/tree-sitter-htmldjango", -- local path or git repo
|
||||||
|
files = { "src/parser.c" },
|
||||||
|
-- optional entries:
|
||||||
|
branch = "main", -- default branch in case of git repo if different from master
|
||||||
|
generate_requires_npm = false, -- if stand-alone parser without npm dependencies
|
||||||
|
requires_generate_from_grammar = false, -- if folder contains pre-generated src/parser.c
|
||||||
|
},
|
||||||
|
filetype = "htmldjango", -- if filetype does not match the parser name
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.nvim_lspconfig()
|
function M.nvim_lspconfig()
|
||||||
@@ -325,6 +337,7 @@ function M.nvim_lsp_installer()
|
|||||||
"svelte",
|
"svelte",
|
||||||
"tailwindcss",
|
"tailwindcss",
|
||||||
"zls",
|
"zls",
|
||||||
|
"emmet_ls",
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, s in ipairs(auto_servers) do
|
for _, s in ipairs(auto_servers) do
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ require("packer").startup(function(use)
|
|||||||
run = ":TSUpdate",
|
run = ":TSUpdate",
|
||||||
})
|
})
|
||||||
use("nvim-treesitter/nvim-treesitter-context")
|
use("nvim-treesitter/nvim-treesitter-context")
|
||||||
|
use("nvim-treesitter/playground")
|
||||||
use("neovim/nvim-lspconfig")
|
use("neovim/nvim-lspconfig")
|
||||||
use("williamboman/nvim-lsp-installer")
|
use("williamboman/nvim-lsp-installer")
|
||||||
use("nvim-lua/plenary.nvim")
|
use("nvim-lua/plenary.nvim")
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
; inherits: html
|
||||||
|
|
||||||
|
(attribute_name) @keyword
|
||||||
|
|
||||||
|
[
|
||||||
|
"<"
|
||||||
|
">"
|
||||||
|
"</"
|
||||||
|
"/>"
|
||||||
|
] @punctuation.bracket
|
||||||
|
|
||||||
|
(doctype) @comment
|
||||||
|
|
||||||
|
((tag_name) @type (#match? @type "^(head|body)$"))
|
||||||
|
|
||||||
|
((tag_name) @comment (#eq? @comment "html"))
|
||||||
|
|
||||||
|
(element
|
||||||
|
(start_tag
|
||||||
|
((tag_name) @function)
|
||||||
|
(attribute (attribute_name) @_alpine))
|
||||||
|
(#lua-match? @_alpine "^[@:]%l+.-$"))
|
||||||
|
|
||||||
|
(element
|
||||||
|
(start_tag
|
||||||
|
(attribute (attribute_name) @_alpine))
|
||||||
|
(end_tag ((tag_name) @function))
|
||||||
|
(#lua-match? @_alpine "^[@:]%l+.-$"))
|
||||||
|
|
||||||
|
(element
|
||||||
|
(start_tag
|
||||||
|
((tag_name) @function)
|
||||||
|
(attribute (attribute_name) @_alpine))
|
||||||
|
(#lua-match? @_alpine "^x[-]%l+$"))
|
||||||
|
|
||||||
|
(element
|
||||||
|
(start_tag
|
||||||
|
(attribute (attribute_name) @_alpine))
|
||||||
|
(end_tag ((tag_name) @function))
|
||||||
|
(#lua-match? @_alpine "^x[-]%l+$"))
|
||||||
|
|
||||||
|
(element
|
||||||
|
(self_closing_tag
|
||||||
|
((tag_name) @function)
|
||||||
|
(attribute (attribute_name) @_alpine))
|
||||||
|
(#lua-match? @_alpine "^[@:]%l+.-$"))
|
||||||
|
|
||||||
|
(element
|
||||||
|
(self_closing_tag
|
||||||
|
((tag_name) @function)
|
||||||
|
(attribute (attribute_name) @_alpine))
|
||||||
|
(#lua-match? @_alpine "^x[-]%l+$"))
|
||||||
|
|
||||||
|
(element (start_tag ((tag_name) @function) (#eq? @function "template")))
|
||||||
|
(element (end_tag ((tag_name) @function) (#eq? @function "template")))
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
((attribute
|
||||||
|
(attribute_name) @_alpine
|
||||||
|
(quoted_attribute_value (attribute_value) @javascript))
|
||||||
|
(#lua-match? @_alpine "^[@:]%l+.-$"))
|
||||||
|
|
||||||
|
((attribute
|
||||||
|
(attribute_name) @_alpine
|
||||||
|
(quoted_attribute_value (attribute_value) @javascript))
|
||||||
|
(#lua-match? @_alpine "^x[-]%l+$"))
|
||||||
|
|
||||||
|
(script_element
|
||||||
|
(raw_text) @javascript)
|
||||||
|
|
||||||
|
((text) @python (#lua-match? @python "^{%p%s+%l+%s+.-%s+%p}$"))
|
||||||
|
|
||||||
|
((text) @python (#lua-match? @python "^{{%s+.-%s+}}$"))
|
||||||
|
|
||||||
|
((attribute
|
||||||
|
(attribute_name) @_hyperscript
|
||||||
|
(quoted_attribute_value (attribute_value) @python))
|
||||||
|
(#eq? @_hyperscript "_"))
|
||||||
Reference in New Issue
Block a user