mirror of
https://github.com/pojokcodeid/nvim-lazy.git
synced 2025-06-21 08:35:48 +02:00
enc: overide command TSInstallInfo
This commit is contained in:
parent
d41d9b4cf5
commit
d31ffccdca
2 changed files with 125 additions and 45 deletions
|
@ -1,47 +1,50 @@
|
||||||
return {
|
return {
|
||||||
{ "nvim-lua/plenary.nvim", event = "VeryLazy" },
|
{ "nvim-lua/plenary.nvim", event = "VeryLazy" },
|
||||||
{
|
{
|
||||||
"nvim-treesitter/nvim-treesitter",
|
"nvim-treesitter/nvim-treesitter",
|
||||||
event = { "BufRead", "VeryLazy" },
|
event = { "BufRead", "VeryLazy" },
|
||||||
version = false,
|
version = false,
|
||||||
build = ":TSUpdate",
|
build = ":TSUpdate",
|
||||||
lazy = true,
|
lazy = true,
|
||||||
cmd = {
|
cmd = {
|
||||||
"TSInstall",
|
"TSInstall",
|
||||||
"TSInstallInfo",
|
-- "TSInstallInfo",
|
||||||
"TSInstallSync",
|
"TSInstallSync",
|
||||||
"TSUpdate",
|
"TSUpdate",
|
||||||
"TSUpdateSync",
|
"TSUpdateSync",
|
||||||
"TSUninstall",
|
"TSUninstall",
|
||||||
"TSUninstallInfo",
|
"TSUninstallInfo",
|
||||||
"TSInstallFromGrammar",
|
"TSInstallFromGrammar",
|
||||||
},
|
},
|
||||||
opts = function()
|
opts = function()
|
||||||
return {
|
return {
|
||||||
highlight = { enable = true },
|
highlight = { enable = true },
|
||||||
indent = { enable = true },
|
indent = { enable = true },
|
||||||
ensure_installed = { "lua", "luadoc", "printf", "vim", "vimdoc" },
|
ensure_installed = { "lua", "luadoc", "printf", "vim", "vimdoc" },
|
||||||
incremental_selection = {
|
incremental_selection = {
|
||||||
enable = true,
|
enable = true,
|
||||||
},
|
},
|
||||||
autopairs = {
|
autopairs = {
|
||||||
enable = true,
|
enable = true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
config = function(_, opts)
|
config = function(_, opts)
|
||||||
if type(opts.ensure_installed) == "table" then
|
if type(opts.ensure_installed) == "table" then
|
||||||
---@type table<string, boolean>
|
---@type table<string, boolean>
|
||||||
local added = {}
|
local added = {}
|
||||||
opts.ensure_installed = vim.tbl_filter(function(lang)
|
opts.ensure_installed = vim.tbl_filter(function(lang)
|
||||||
if added[lang] then
|
if added[lang] then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
added[lang] = true
|
added[lang] = true
|
||||||
return true
|
return true
|
||||||
end, opts.ensure_installed)
|
end, opts.ensure_installed)
|
||||||
end
|
end
|
||||||
require("nvim-treesitter.configs").setup(opts)
|
require("nvim-treesitter.configs").setup(opts)
|
||||||
end,
|
vim.api.nvim_create_user_command("TSInstallInfo", function()
|
||||||
},
|
vim.cmd("Telescope treesitter_info")
|
||||||
|
end, {})
|
||||||
|
end,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,3 +91,80 @@ keymap("n", "<A-l>", "<cmd>terminal live-server<cr>", opts)
|
||||||
|
|
||||||
-- close current buffer
|
-- close current buffer
|
||||||
keymap("n", "<S-t>", "<cmd>lua require('auto-bufferline.configs.utils').bufremove()<cr>", opts)
|
keymap("n", "<S-t>", "<cmd>lua require('auto-bufferline.configs.utils').bufremove()<cr>", opts)
|
||||||
|
|
||||||
|
-- vim.keymap.set("n", "<leader>ti", function()
|
||||||
|
-- local api = vim.api
|
||||||
|
-- local parser_configs = require("nvim-treesitter.parsers").get_parser_configs()
|
||||||
|
-- local parsers = vim.tbl_keys(parser_configs)
|
||||||
|
-- table.sort(parsers)
|
||||||
|
--
|
||||||
|
-- local choices = {}
|
||||||
|
-- local lookup = {}
|
||||||
|
--
|
||||||
|
-- for _, parser in ipairs(parsers) do
|
||||||
|
-- local is_installed = #api.nvim_get_runtime_file("parser/" .. parser .. ".so", false) > 0
|
||||||
|
--
|
||||||
|
-- local label = (is_installed and "[✓] " or "[✗] ") .. parser
|
||||||
|
-- table.insert(choices, label)
|
||||||
|
-- lookup[label] = parser
|
||||||
|
-- end
|
||||||
|
--
|
||||||
|
-- vim.ui.select(choices, {
|
||||||
|
-- prompt = "Treesitter ([✓]= installed, [✗] = not installed)",
|
||||||
|
-- }, function(choice)
|
||||||
|
-- if choice then
|
||||||
|
-- local parser_name = lookup[choice]
|
||||||
|
-- if parser_name then
|
||||||
|
-- vim.cmd("TSInstall " .. parser_name)
|
||||||
|
-- end
|
||||||
|
-- end
|
||||||
|
-- end)
|
||||||
|
-- end, { desc = "Install Treesitter" })
|
||||||
|
--
|
||||||
|
-- vim.keymap.set("n", "<leader>tu", function()
|
||||||
|
-- local parsers = require("nvim-treesitter.info").installed_parsers()
|
||||||
|
-- table.sort(parsers)
|
||||||
|
-- local choices = {}
|
||||||
|
-- local lookup = {}
|
||||||
|
--
|
||||||
|
-- for _, parser in ipairs(parsers) do
|
||||||
|
-- local label = "[✓] " .. parser
|
||||||
|
-- table.insert(choices, label)
|
||||||
|
-- lookup[label] = parser
|
||||||
|
-- end
|
||||||
|
--
|
||||||
|
-- vim.ui.select(choices, {
|
||||||
|
-- prompt = "Uninstall Treesitter",
|
||||||
|
-- }, function(choice)
|
||||||
|
-- if choice then
|
||||||
|
-- local parser_name = lookup[choice]
|
||||||
|
-- if parser_name then
|
||||||
|
-- vim.cmd("TSUninstall " .. parser_name)
|
||||||
|
-- end
|
||||||
|
-- end
|
||||||
|
-- end)
|
||||||
|
-- end, { desc = "Uninstall Treesitter" })
|
||||||
|
|
||||||
|
vim.api.nvim_create_user_command("TSIsInstalled", function()
|
||||||
|
local parsers = require("nvim-treesitter.info").installed_parsers()
|
||||||
|
table.sort(parsers)
|
||||||
|
local choices = {}
|
||||||
|
local lookup = {}
|
||||||
|
|
||||||
|
for _, parser in ipairs(parsers) do
|
||||||
|
local label = "[✓] " .. parser
|
||||||
|
table.insert(choices, label)
|
||||||
|
lookup[label] = parser
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.ui.select(choices, {
|
||||||
|
prompt = "Uninstall Treesitter",
|
||||||
|
}, function(choice)
|
||||||
|
if choice then
|
||||||
|
local parser_name = lookup[choice]
|
||||||
|
if parser_name then
|
||||||
|
vim.cmd("TSUninstall " .. parser_name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end, {})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue