✨ feat(nvim): treesitter dots parsers
This commit is contained in:
parent
47a56ed244
commit
91306b8366
2 changed files with 138 additions and 48 deletions
|
@ -24,6 +24,7 @@ require("lazy").setup({
|
||||||
{ import = "lazyvim.plugins.extras.linting.eslint" },
|
{ import = "lazyvim.plugins.extras.linting.eslint" },
|
||||||
{ import = "lazyvim.plugins.extras.formatting.prettier" },
|
{ import = "lazyvim.plugins.extras.formatting.prettier" },
|
||||||
-- { import = "lazyvim.plugins.extras.coding.copilot" },
|
-- { import = "lazyvim.plugins.extras.coding.copilot" },
|
||||||
|
{ import = "lazyvim.plugins.extras.util.dot" },
|
||||||
{ import = "lazyvim.plugins.extras.lang.yaml" },
|
{ import = "lazyvim.plugins.extras.lang.yaml" },
|
||||||
{ import = "lazyvim.plugins.extras.coding.yanky" },
|
{ import = "lazyvim.plugins.extras.coding.yanky" },
|
||||||
{ import = "lazyvim.plugins.extras.util.project" },
|
{ import = "lazyvim.plugins.extras.util.project" },
|
||||||
|
|
|
@ -1,16 +1,71 @@
|
||||||
return {
|
return {
|
||||||
{
|
{
|
||||||
"nvim-treesitter/nvim-treesitter",
|
"nvim-treesitter/nvim-treesitter",
|
||||||
opts = function(_, opts)
|
version = false, -- last release is way too old and doesn't work on Windows
|
||||||
opts.autotag = {
|
build = ":TSUpdate",
|
||||||
enable = true,
|
event = { "LazyFile", "VeryLazy" },
|
||||||
}
|
dependencies = {
|
||||||
|
{
|
||||||
opts.endwise = {
|
"nvim-treesitter/nvim-treesitter-textobjects",
|
||||||
enable = true,
|
config = function()
|
||||||
}
|
-- When in diff mode, we want to use the default
|
||||||
|
-- vim text objects c & C instead of the treesitter ones.
|
||||||
vim.list_extend(opts.ensure_installed, {
|
local move = require("nvim-treesitter.textobjects.move") ---@type table<string,fun(...)>
|
||||||
|
local configs = require("nvim-treesitter.configs")
|
||||||
|
for name, fn in pairs(move) do
|
||||||
|
if name:find("goto") == 1 then
|
||||||
|
move[name] = function(q, ...)
|
||||||
|
if vim.wo.diff then
|
||||||
|
local config = configs.get_module("textobjects.move")[name] ---@type table<string,string>
|
||||||
|
for key, query in pairs(config or {}) do
|
||||||
|
if q == query and key:find("[%]%[][cC]") then
|
||||||
|
vim.cmd("normal! " .. key)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return fn(q, ...)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
cmd = { "TSUpdateSync" },
|
||||||
|
keys = {
|
||||||
|
{ "<c-space>", desc = "Increment selection" },
|
||||||
|
{ "<bs>", desc = "Decrement selection", mode = "x" },
|
||||||
|
},
|
||||||
|
---@type TSConfig
|
||||||
|
---@diagnostic disable-next-line: missing-fields
|
||||||
|
opts = {
|
||||||
|
autotag = { enable = true },
|
||||||
|
endwise = { enable = true },
|
||||||
|
highlight = { enable = true },
|
||||||
|
indent = { enable = true },
|
||||||
|
ensure_installed = {
|
||||||
|
"bash",
|
||||||
|
"c",
|
||||||
|
"diff",
|
||||||
|
"html",
|
||||||
|
"javascript",
|
||||||
|
"jsdoc",
|
||||||
|
"json",
|
||||||
|
"jsonc",
|
||||||
|
"lua",
|
||||||
|
"luadoc",
|
||||||
|
"luap",
|
||||||
|
"markdown",
|
||||||
|
"markdown_inline",
|
||||||
|
"python",
|
||||||
|
"query",
|
||||||
|
"regex",
|
||||||
|
"toml",
|
||||||
|
"tsx",
|
||||||
|
"typescript",
|
||||||
|
"vim",
|
||||||
|
"vimdoc",
|
||||||
|
"yaml",
|
||||||
"arduino",
|
"arduino",
|
||||||
"diff",
|
"diff",
|
||||||
"dart",
|
"dart",
|
||||||
|
@ -46,7 +101,41 @@ return {
|
||||||
"todotxt",
|
"todotxt",
|
||||||
"vim",
|
"vim",
|
||||||
"vue",
|
"vue",
|
||||||
})
|
"hypr",
|
||||||
|
},
|
||||||
|
incremental_selection = {
|
||||||
|
enable = true,
|
||||||
|
keymaps = {
|
||||||
|
init_selection = "<C-space>",
|
||||||
|
node_incremental = "<C-space>",
|
||||||
|
scope_incremental = false,
|
||||||
|
node_decremental = "<bs>",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
textobjects = {
|
||||||
|
move = {
|
||||||
|
enable = true,
|
||||||
|
goto_next_start = { ["]f"] = "@function.outer", ["]c"] = "@class.outer" },
|
||||||
|
goto_next_end = { ["]F"] = "@function.outer", ["]C"] = "@class.outer" },
|
||||||
|
goto_previous_start = { ["[f"] = "@function.outer", ["[c"] = "@class.outer" },
|
||||||
|
goto_previous_end = { ["[F"] = "@function.outer", ["[C"] = "@class.outer" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
---@param opts TSConfig
|
||||||
|
config = function(_, opts)
|
||||||
|
if type(opts.ensure_installed) == "table" then
|
||||||
|
---@type table<string, boolean>
|
||||||
|
local added = {}
|
||||||
|
opts.ensure_installed = vim.tbl_filter(function(lang)
|
||||||
|
if added[lang] then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
added[lang] = true
|
||||||
|
return true
|
||||||
|
end, opts.ensure_installed)
|
||||||
|
end
|
||||||
|
require("nvim-treesitter.configs").setup(opts)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue