Compare commits
3 Commits
f0733e9834
...
c1a96e788c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c1a96e788c | ||
|
|
3e0402178c | ||
|
|
c16ad74d91 |
@ -1,8 +0,0 @@
|
|||||||
# chezmoi:template:left-delimiter=#{{
|
|
||||||
#{{- /* vim: set filetype=toml: */ -}}
|
|
||||||
[".local/share/nvim/lazy/lazy.nvim"]
|
|
||||||
type = "archive"
|
|
||||||
url = "https://github.com/folke/lazy.nvim/archive/refs/tags/v11.17.5.tar.gz"
|
|
||||||
exact = true
|
|
||||||
stripComponents = 1
|
|
||||||
refreshPeriod = "2196h"
|
|
||||||
@ -9,14 +9,10 @@
|
|||||||
# vim ignores
|
# vim ignores
|
||||||
.*.sw[a-z]
|
.*.sw[a-z]
|
||||||
.netrwhist
|
.netrwhist
|
||||||
doc/tags
|
|
||||||
|
|
||||||
# OS X ignores
|
# OS X ignores
|
||||||
.DS_Store
|
.DS_Store
|
||||||
.DS_Store?
|
.DS_Store?
|
||||||
.AppleDouble
|
|
||||||
.LSOverride
|
|
||||||
Icon
|
|
||||||
|
|
||||||
# Thumbnails
|
# Thumbnails
|
||||||
._*
|
._*
|
||||||
|
|||||||
@ -1,5 +1,24 @@
|
|||||||
require("core.config")
|
require("core.config")
|
||||||
vim.opt.runtimepath:prepend(vim.fn.stdpath("data") .. "/lazy/lazy.nvim")
|
|
||||||
|
local lazypath = vim.fn.stdpath("data") .. "/lazy.nvim"
|
||||||
|
if not vim.loop.fs_stat(lazypath) then
|
||||||
|
local out = vim.fn.system({
|
||||||
|
"git", "clone", "--filter=blob:none",
|
||||||
|
"--branch=v11.17.5",
|
||||||
|
"https://github.com/folke/lazy.nvim.git",
|
||||||
|
lazypath,
|
||||||
|
})
|
||||||
|
if vim.v.shell_error ~= 0 then
|
||||||
|
vim.api.nvim_echo({
|
||||||
|
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
|
||||||
|
{ out, "WarningMsg" },
|
||||||
|
}, true, {})
|
||||||
|
vim.fn.getchar()
|
||||||
|
os.exit(1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
vim.opt.runtimepath:prepend(lazypath)
|
||||||
|
|
||||||
require("lazy").setup({
|
require("lazy").setup({
|
||||||
spec = {
|
spec = {
|
||||||
{ import = "plugins" },
|
{ import = "plugins" },
|
||||||
|
|||||||
@ -14,11 +14,55 @@ function M.treesitter_configs()
|
|||||||
require("nvim-treesitter.configs").setup(M.treesitter_config_setup)
|
require("nvim-treesitter.configs").setup(M.treesitter_config_setup)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Works around a crash in nvim-treesitter's bundled `set-lang-from-mimetype!`
|
||||||
|
-- directive (queries/html_tags/injections.scm, used by html/erb/vue/svelte):
|
||||||
|
-- it reads `match[capture_id]` as a single TSNode, but current Neovim core
|
||||||
|
-- always returns an array of nodes there, so `<script type="...">` tags
|
||||||
|
-- crash the whole buffer's treesitter parse. Re-register the directive with
|
||||||
|
-- the same behavior, reading the first node out of the array instead.
|
||||||
|
--
|
||||||
|
-- Must run after nvim-treesitter's own `plugin/query_predicates.lua` has
|
||||||
|
-- registered its (broken) version, or that clobbers this one right back.
|
||||||
|
-- `LazyDone` fires once after all plugins (incl. nvim-treesitter's own
|
||||||
|
-- plugin/ scripts) have finished loading, so it's the reliable hook.
|
||||||
|
vim.api.nvim_create_autocmd("User", {
|
||||||
|
pattern = "LazyDone",
|
||||||
|
once = true,
|
||||||
|
callback = function()
|
||||||
|
M.patch_mimetype_directive()
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
function M.patch_mimetype_directive()
|
||||||
|
local html_script_type_languages = {
|
||||||
|
["importmap"] = "json",
|
||||||
|
["module"] = "javascript",
|
||||||
|
["application/ecmascript"] = "javascript",
|
||||||
|
["text/ecmascript"] = "javascript",
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.treesitter.query.add_directive("set-lang-from-mimetype!", function(match, _, bufnr, pred, metadata)
|
||||||
|
local nodes = match[pred[2]]
|
||||||
|
local node = nodes and nodes[1]
|
||||||
|
if not node then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local type_attr_value = vim.treesitter.get_node_text(node, bufnr)
|
||||||
|
local configured = html_script_type_languages[type_attr_value]
|
||||||
|
if configured then
|
||||||
|
metadata["injection.language"] = configured
|
||||||
|
else
|
||||||
|
local parts = vim.split(type_attr_value, "/", {})
|
||||||
|
metadata["injection.language"] = parts[#parts]
|
||||||
|
end
|
||||||
|
end, { force = true })
|
||||||
|
end
|
||||||
|
|
||||||
M.treesitter_config_setup = {
|
M.treesitter_config_setup = {
|
||||||
-- Add languages to be installed here that you want installed for treesitter
|
-- Add languages to be installed here that you want installed for treesitter
|
||||||
ensure_installed = {
|
ensure_installed = {
|
||||||
"bash", "c", "cpp", "go", "lua", "python", "rust",
|
"bash", "c", "cpp", "go", "lua", "python", "rust",
|
||||||
"tsx", "javascript", "typescript", "vimdoc", "vim",
|
"tsx", "javascript", "typescript", "vimdoc", "vim",
|
||||||
|
"ruby", "html", "embedded_template",
|
||||||
},
|
},
|
||||||
|
|
||||||
auto_install = true,
|
auto_install = true,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user