refactor: simplify startup profiles and ignore local tooling configs
This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
local M = {}
|
||||
|
||||
function M.setup()
|
||||
local ok_configs, ts_configs = pcall(require, "nvim-treesitter.configs")
|
||||
if not ok_configs then
|
||||
vim.schedule(function()
|
||||
vim.notify("nvim-treesitter is not available yet. Run :lua vim.pack.update() and restart.",
|
||||
vim.log.levels.WARN)
|
||||
end)
|
||||
return
|
||||
end
|
||||
|
||||
ts_configs.setup({
|
||||
ensure_installed = {
|
||||
"bash",
|
||||
"c",
|
||||
"diff",
|
||||
"html",
|
||||
"javascript",
|
||||
"jsdoc",
|
||||
"json",
|
||||
"jsonc",
|
||||
"lua",
|
||||
"luadoc",
|
||||
"luap",
|
||||
"markdown",
|
||||
"markdown_inline",
|
||||
"printf",
|
||||
"python",
|
||||
"query",
|
||||
"regex",
|
||||
"toml",
|
||||
"tsx",
|
||||
"typescript",
|
||||
"vim",
|
||||
"vimdoc",
|
||||
"xml",
|
||||
"yaml",
|
||||
},
|
||||
highlight = { enable = true },
|
||||
indent = { enable = true },
|
||||
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",
|
||||
["]a"] = "@parameter.inner",
|
||||
},
|
||||
goto_next_end = {
|
||||
["]F"] = "@function.outer",
|
||||
["]C"] = "@class.outer",
|
||||
["]A"] = "@parameter.inner",
|
||||
},
|
||||
goto_previous_start = {
|
||||
["[f"] = "@function.outer",
|
||||
["[c"] = "@class.outer",
|
||||
["[a"] = "@parameter.inner",
|
||||
},
|
||||
goto_previous_end = {
|
||||
["[F"] = "@function.outer",
|
||||
["[C"] = "@class.outer",
|
||||
["[A"] = "@parameter.inner",
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
local ok_move, move = pcall(require, "nvim-treesitter.textobjects.move")
|
||||
if not ok_move then
|
||||
return
|
||||
end
|
||||
|
||||
for name, fn in pairs(move) do
|
||||
if name:find("goto") == 1 then
|
||||
move[name] = function(query, ...)
|
||||
if vim.wo.diff then
|
||||
local config = ts_configs.get_module("textobjects.move")[name]
|
||||
for key, textobject in pairs(config or {}) do
|
||||
if query == textobject and key:find("[%]%[][cC]") then
|
||||
vim.cmd("normal! " .. key)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return fn(query, ...)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
Reference in New Issue
Block a user