fix(tree-sitter): upgrade this mess to 0.12-compatible setup
This commit is contained in:
parent
36ec523cc9
commit
106c5e1b12
3 changed files with 91 additions and 81 deletions
|
|
@ -7,7 +7,16 @@ return {
|
|||
-- require("mini.ai").setup({ n_lines = 500 })
|
||||
require("mini.trailspace").setup() -- highlight trailing space
|
||||
require("mini.cursorword").setup() -- highlight word below cursor
|
||||
require("mini.ai").setup() -- replace within/outside quotes
|
||||
require("mini.ai").setup({ -- replace within/outside quotes
|
||||
mappings = {
|
||||
-- Disable next/last variants to avoid conflict with
|
||||
-- Neovim 0.12 built-in `an`/`in` node selection (see :help v_an)
|
||||
around_next = "",
|
||||
inside_next = "",
|
||||
around_last = "",
|
||||
inside_last = "",
|
||||
},
|
||||
})
|
||||
require("mini.pick").setup({
|
||||
mappings = {
|
||||
move_down = "<C-j>",
|
||||
|
|
|
|||
|
|
@ -1,74 +1,77 @@
|
|||
-- Treesitter
|
||||
-- NOTE: After updating, wipe old plugin cache then reinstall:
|
||||
-- rm -rf ~/.local/share/nvim/lazy/nvim-treesitter
|
||||
-- rm -rf ~/.local/share/nvim/lazy/nvim-treesitter-textobjects
|
||||
-- Then open Neovim and run :Lazy restore
|
||||
return {
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
branch = "master", -- FIXME: switch to main sometime
|
||||
lazy = false,
|
||||
build = ":TSUpdate",
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
enabled = true,
|
||||
dependencies = {
|
||||
"nvim-treesitter/nvim-treesitter-textobjects",
|
||||
},
|
||||
config = function()
|
||||
local treesitter = require("nvim-treesitter.configs")
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
branch = "main",
|
||||
lazy = false,
|
||||
build = ":TSUpdate",
|
||||
enabled = true,
|
||||
config = function()
|
||||
require("nvim-treesitter")
|
||||
.install({
|
||||
"lua",
|
||||
"comment", -- used for TODO:, FIXME:, XXX: and NOTE:
|
||||
"vim",
|
||||
"vimdoc",
|
||||
"bash",
|
||||
"diff",
|
||||
"make",
|
||||
"gitignore",
|
||||
"gitcommit",
|
||||
"markdown",
|
||||
"markdown_inline",
|
||||
"rst",
|
||||
"latex",
|
||||
"elixir",
|
||||
"eex",
|
||||
"heex",
|
||||
"yaml",
|
||||
"html",
|
||||
"css",
|
||||
"javascript",
|
||||
"dockerfile",
|
||||
"query",
|
||||
"hcl",
|
||||
"terraform",
|
||||
"bicep",
|
||||
"csv",
|
||||
"properties",
|
||||
"ini",
|
||||
"python",
|
||||
"regex",
|
||||
"json",
|
||||
"go",
|
||||
"gomod",
|
||||
"gosum",
|
||||
"editorconfig",
|
||||
"http",
|
||||
"toml",
|
||||
"sql",
|
||||
"promql",
|
||||
"nginx",
|
||||
"powershell",
|
||||
})
|
||||
:wait(300000) -- wait max. 5 min
|
||||
|
||||
treesitter.setup({
|
||||
highlight = { enable = true },
|
||||
indent = { enable = true },
|
||||
auto_install = false,
|
||||
-- language list: https://github.com/nvim-treesitter/nvim-treesitter#supported-languages
|
||||
ensure_installed = {
|
||||
"lua",
|
||||
"comment", -- used for TODO:, FIXME:, XXX: and NOTE:
|
||||
"vim",
|
||||
"vimdoc",
|
||||
"bash",
|
||||
"diff",
|
||||
"make",
|
||||
"gitignore",
|
||||
"gitcommit",
|
||||
"markdown",
|
||||
"markdown_inline",
|
||||
"rst",
|
||||
"latex",
|
||||
"elixir",
|
||||
"eex",
|
||||
"heex",
|
||||
"yaml",
|
||||
"html",
|
||||
"css",
|
||||
"javascript",
|
||||
"dockerfile",
|
||||
"query",
|
||||
"hcl",
|
||||
"terraform",
|
||||
"bicep",
|
||||
"csv",
|
||||
"properties",
|
||||
"ini",
|
||||
"python",
|
||||
"regex",
|
||||
"json",
|
||||
"go",
|
||||
"gomod",
|
||||
"gosum",
|
||||
"editorconfig",
|
||||
"http",
|
||||
"toml",
|
||||
"sql",
|
||||
"promql",
|
||||
"nginx",
|
||||
"powershell",
|
||||
},
|
||||
incremental_selection = {
|
||||
enable = true,
|
||||
keymaps = {
|
||||
init_selection = "<C-s>",
|
||||
node_incremental = "<C-s>",
|
||||
scope_incremental = false,
|
||||
node_decremental = "<bs>",
|
||||
},
|
||||
},
|
||||
})
|
||||
end,
|
||||
-- Highlight & indent are built into Neovim 0.11+
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
callback = function()
|
||||
if pcall(vim.treesitter.start) then
|
||||
vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- Incremental node selection (Neovim 0.12+, see :help v_an v_in)
|
||||
-- Built-in: an = expand to parent, in = shrink to child
|
||||
-- mini.ai's `an`/`in` next/last mappings must be disabled (see mini.lua)
|
||||
vim.keymap.set("n", "<C-s>", "van", { desc = "Treesitter: init selection", remap = true })
|
||||
vim.keymap.set("v", "<C-s>", "an", { desc = "Treesitter: expand selection", remap = true })
|
||||
vim.keymap.set("v", "<bs>", "in", { desc = "Treesitter: shrink selection", remap = true })
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue