update:restructure
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
vim.loader.enable()
|
vim.loader.enable()
|
||||||
|
|
||||||
-- pack hooks/commands should be defined before plugin modules run
|
-- pack hooks/commands should be defined before plugin modules run
|
||||||
require("utils.pack").setup()
|
require("commands.pack").setup()
|
||||||
|
|
||||||
-- editor settings and non-plugin keymaps
|
-- editor settings and non-plugin keymaps
|
||||||
require("settings.options")
|
require("settings.options")
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
-- custom mason commands
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
function M.setup_install_defaults_command(tools)
|
function M.setup_install_defaults_command(tools)
|
||||||
81
nvim/lua/commands/pack.lua
Normal file
81
nvim/lua/commands/pack.lua
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
local M = {}
|
||||||
|
|
||||||
|
local pack = require("utils.pack")
|
||||||
|
|
||||||
|
M.registry = pack.registry
|
||||||
|
M.add = pack.add
|
||||||
|
M.names = pack.names
|
||||||
|
|
||||||
|
function M.setup()
|
||||||
|
local group = vim.api.nvim_create_augroup("UserPackHooks", { clear = true })
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd("PackChanged", {
|
||||||
|
group = group,
|
||||||
|
callback = function(ev)
|
||||||
|
local plugin_name, kind = ev.data.spec.name, ev.data.kind
|
||||||
|
if plugin_name == "nvim-treesitter" and kind == "update" then
|
||||||
|
if not ev.data.active then
|
||||||
|
vim.cmd.packadd("nvim-treesitter")
|
||||||
|
end
|
||||||
|
pcall(vim.cmd, "TSUpdate")
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.api.nvim_create_user_command("PackInstall", function()
|
||||||
|
M.add(M.names(), {
|
||||||
|
confirm = false,
|
||||||
|
load = function() end,
|
||||||
|
})
|
||||||
|
vim.notify("PackInstall: ensured all configured plugins are installed", vim.log.levels.INFO)
|
||||||
|
end, { desc = "Install all configured vim.pack plugins without loading" })
|
||||||
|
|
||||||
|
vim.api.nvim_create_user_command("PackUpdate", function(opts)
|
||||||
|
local names = (#opts.fargs > 0) and opts.fargs or nil
|
||||||
|
vim.pack.update(names)
|
||||||
|
end, {
|
||||||
|
nargs = "*",
|
||||||
|
complete = function(arglead)
|
||||||
|
local out = {}
|
||||||
|
for _, name in ipairs(M.names()) do
|
||||||
|
if name:find("^" .. vim.pesc(arglead)) then
|
||||||
|
table.insert(out, name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return out
|
||||||
|
end,
|
||||||
|
desc = "Update vim.pack plugins (optionally pass plugin names)",
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.api.nvim_create_user_command("PackSync", function()
|
||||||
|
vim.pack.update(nil, { target = "lockfile" })
|
||||||
|
end, { desc = "Sync installed plugins to nvim-pack-lock.json" })
|
||||||
|
|
||||||
|
vim.api.nvim_create_user_command("PackClean", function()
|
||||||
|
local stale = vim.iter(vim.pack.get())
|
||||||
|
:filter(function(plugin)
|
||||||
|
return not plugin.active
|
||||||
|
end)
|
||||||
|
:map(function(plugin)
|
||||||
|
return plugin.spec.name
|
||||||
|
end)
|
||||||
|
:totable()
|
||||||
|
|
||||||
|
if #stale == 0 then
|
||||||
|
vim.notify("PackClean: nothing to clean", vim.log.levels.INFO)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local msg = "PackClean will remove:\n - " .. table.concat(stale, "\n - ")
|
||||||
|
local choice = vim.fn.confirm(msg, "&Yes\n&No", 2)
|
||||||
|
if choice ~= 1 then
|
||||||
|
vim.notify("PackClean: cancelled", vim.log.levels.INFO)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.pack.del(stale)
|
||||||
|
vim.notify("PackClean: removed " .. #stale .. " plugin(s)", vim.log.levels.INFO)
|
||||||
|
end, { desc = "Delete inactive vim.pack plugins from disk" })
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local pack = require("utils.pack")
|
local pack = require("commands.pack")
|
||||||
|
|
||||||
function M.setup()
|
function M.setup()
|
||||||
vim.api.nvim_create_autocmd("InsertEnter", {
|
vim.api.nvim_create_autocmd("InsertEnter", {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local pack = require("utils.pack")
|
local pack = require("commands.pack")
|
||||||
|
|
||||||
function M.setup()
|
function M.setup()
|
||||||
vim.api.nvim_create_autocmd("FileType", {
|
vim.api.nvim_create_autocmd("FileType", {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local ui = require("utils.ui")
|
local ui = require("utils.ui")
|
||||||
local pack = require("utils.pack")
|
local pack = require("commands.pack")
|
||||||
|
|
||||||
local function apply_theme_overrides()
|
local function apply_theme_overrides()
|
||||||
local transparent_groups = {
|
local transparent_groups = {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local ui = require("utils.ui")
|
local ui = require("utils.ui")
|
||||||
local pack = require("utils.pack")
|
local pack = require("commands.pack")
|
||||||
|
|
||||||
function M.setup()
|
function M.setup()
|
||||||
pack.add({ "nvim-cmp", "cmp-nvim-lsp", "cmp-buffer", "cmp-path", "luasnip", "cmp_luasnip" })
|
pack.add({ "nvim-cmp", "cmp-nvim-lsp", "cmp-buffer", "cmp-path", "luasnip", "cmp_luasnip" })
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local lazy = require("utils.lazy")
|
local lazy = require("utils.lazy")
|
||||||
local pack = require("utils.pack")
|
local pack = require("commands.pack")
|
||||||
|
|
||||||
local function with_trouble(fn)
|
local function with_trouble(fn)
|
||||||
lazy.load_once("trouble", pack.registry({ "trouble.nvim" }), function()
|
lazy.load_once("trouble", pack.registry({ "trouble.nvim" }), function()
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local pack = require("utils.pack")
|
local pack = require("commands.pack")
|
||||||
local mason_utils = require("utils.mason")
|
local mason_utils = require("commands.mason")
|
||||||
local lsp_tools = require("plugins.lsp_tools")
|
local lsp_tools = require("plugins.lsp-manager")
|
||||||
|
|
||||||
function M.setup()
|
function M.setup()
|
||||||
pack.add({ "mason", "nvim-lspconfig", "conform", "symbol-usage" })
|
pack.add({ "mason", "nvim-lspconfig", "conform", "symbol-usage" })
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local pack = require("utils.pack")
|
local pack = require("commands.pack")
|
||||||
|
|
||||||
function M.setup()
|
function M.setup()
|
||||||
pack.add({ "mini.nvim" })
|
pack.add({ "mini.nvim" })
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local lazy = require("utils.lazy")
|
local lazy = require("utils.lazy")
|
||||||
local pack = require("utils.pack")
|
local pack = require("commands.pack")
|
||||||
|
|
||||||
-- grug guide
|
-- grug guide
|
||||||
-- navigate splits: <C+w><Left> or <Right>
|
-- navigate splits: <C+w><Left> or <Right>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local lazy = require("utils.lazy")
|
local lazy = require("utils.lazy")
|
||||||
local pack = require("utils.pack")
|
local pack = require("commands.pack")
|
||||||
|
|
||||||
local function with_telescope(fn)
|
local function with_telescope(fn)
|
||||||
lazy.load_once("telescope", pack.registry({ "plenary.nvim", "telescope.nvim" }), function()
|
lazy.load_once("telescope", pack.registry({ "plenary.nvim", "telescope.nvim" }), function()
|
||||||
|
|||||||
@@ -1,60 +0,0 @@
|
|||||||
local M = {}
|
|
||||||
|
|
||||||
local lazy = require("utils.lazy")
|
|
||||||
local pack = require("utils.pack")
|
|
||||||
|
|
||||||
local function with_trouble(fn)
|
|
||||||
lazy.load_once("trouble", pack.registry({ "trouble.nvim" }), function()
|
|
||||||
require("trouble").setup({})
|
|
||||||
end)
|
|
||||||
fn()
|
|
||||||
end
|
|
||||||
|
|
||||||
-- grug guide
|
|
||||||
-- navigate splits: <C+w><Left> or <Right>
|
|
||||||
local function with_grug(fn)
|
|
||||||
lazy.load_once("grug-far", pack.registry({ "grug-far.nvim" }), function()
|
|
||||||
require("grug-far").setup({})
|
|
||||||
end)
|
|
||||||
fn(require("grug-far"))
|
|
||||||
end
|
|
||||||
|
|
||||||
function M.setup()
|
|
||||||
vim.keymap.set("n", "<leader>xx", function()
|
|
||||||
with_trouble(function()
|
|
||||||
vim.cmd("Trouble diagnostics toggle")
|
|
||||||
end)
|
|
||||||
end, { desc = "Diagnostics (Trouble)" })
|
|
||||||
|
|
||||||
vim.keymap.set("n", "<leader>xX", function()
|
|
||||||
with_trouble(function()
|
|
||||||
vim.cmd("Trouble diagnostics toggle filter.buf=0")
|
|
||||||
end)
|
|
||||||
end, { desc = "Buffer diagnostics" })
|
|
||||||
|
|
||||||
vim.keymap.set("n", "<leader>xQ", function()
|
|
||||||
with_trouble(function()
|
|
||||||
vim.cmd("Trouble qflist toggle")
|
|
||||||
end)
|
|
||||||
end, { desc = "Quickfix list" })
|
|
||||||
|
|
||||||
vim.keymap.set("n", "<leader>S", function()
|
|
||||||
with_grug(function()
|
|
||||||
vim.cmd("GrugFar")
|
|
||||||
end)
|
|
||||||
end, { desc = "Search/replace project" })
|
|
||||||
|
|
||||||
vim.keymap.set("n", "<leader>s", function()
|
|
||||||
with_grug(function(grug)
|
|
||||||
grug.open({ prefills = { paths = vim.fn.expand("%") } })
|
|
||||||
end)
|
|
||||||
end, { desc = "Search/replace current file" })
|
|
||||||
|
|
||||||
vim.keymap.set("x", "<leader>s", function()
|
|
||||||
with_grug(function(grug)
|
|
||||||
grug.open({ visualSelectionUsage = "operate-within-range" })
|
|
||||||
end)
|
|
||||||
end, { desc = "Search/replace in selection" })
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local pack = require("utils.pack")
|
local pack = require("commands.pack")
|
||||||
|
|
||||||
function M.setup()
|
function M.setup()
|
||||||
pack.add({ "nvim-treesitter" })
|
pack.add({ "nvim-treesitter" })
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local pack = require("utils.pack")
|
local pack = require("commands.pack")
|
||||||
|
|
||||||
function M.setup()
|
function M.setup()
|
||||||
pack.add({ "nvim-web-devicons", "indent-blankline.nvim", "lualine.nvim", "bufferline.nvim" })
|
pack.add({ "nvim-web-devicons", "indent-blankline.nvim", "lualine.nvim", "bufferline.nvim" })
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
-- lazy loading function
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local loaded = {}
|
local loaded = {}
|
||||||
|
|||||||
@@ -14,76 +14,4 @@ function M.names()
|
|||||||
return registry.names()
|
return registry.names()
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.setup()
|
|
||||||
local group = vim.api.nvim_create_augroup("UserPackHooks", { clear = true })
|
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd("PackChanged", {
|
|
||||||
group = group,
|
|
||||||
callback = function(ev)
|
|
||||||
local plugin_name, kind = ev.data.spec.name, ev.data.kind
|
|
||||||
if plugin_name == "nvim-treesitter" and kind == "update" then
|
|
||||||
if not ev.data.active then
|
|
||||||
vim.cmd.packadd("nvim-treesitter")
|
|
||||||
end
|
|
||||||
pcall(vim.cmd, "TSUpdate")
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
vim.api.nvim_create_user_command("PackInstall", function()
|
|
||||||
M.add(M.names(), {
|
|
||||||
confirm = false,
|
|
||||||
load = function() end,
|
|
||||||
})
|
|
||||||
vim.notify("PackInstall: ensured all configured plugins are installed", vim.log.levels.INFO)
|
|
||||||
end, { desc = "Install all configured vim.pack plugins without loading" })
|
|
||||||
|
|
||||||
vim.api.nvim_create_user_command("PackUpdate", function(opts)
|
|
||||||
local names = (#opts.fargs > 0) and opts.fargs or nil
|
|
||||||
vim.pack.update(names)
|
|
||||||
end, {
|
|
||||||
nargs = "*",
|
|
||||||
complete = function(arglead)
|
|
||||||
local out = {}
|
|
||||||
for _, name in ipairs(M.names()) do
|
|
||||||
if name:find("^" .. vim.pesc(arglead)) then
|
|
||||||
table.insert(out, name)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return out
|
|
||||||
end,
|
|
||||||
desc = "Update vim.pack plugins (optionally pass plugin names)",
|
|
||||||
})
|
|
||||||
|
|
||||||
vim.api.nvim_create_user_command("PackSync", function()
|
|
||||||
vim.pack.update(nil, { target = "lockfile" })
|
|
||||||
end, { desc = "Sync installed plugins to nvim-pack-lock.json" })
|
|
||||||
|
|
||||||
vim.api.nvim_create_user_command("PackClean", function()
|
|
||||||
local stale = vim.iter(vim.pack.get())
|
|
||||||
:filter(function(plugin)
|
|
||||||
return not plugin.active
|
|
||||||
end)
|
|
||||||
:map(function(plugin)
|
|
||||||
return plugin.spec.name
|
|
||||||
end)
|
|
||||||
:totable()
|
|
||||||
|
|
||||||
if #stale == 0 then
|
|
||||||
vim.notify("PackClean: nothing to clean", vim.log.levels.INFO)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local msg = "PackClean will remove:\n - " .. table.concat(stale, "\n - ")
|
|
||||||
local choice = vim.fn.confirm(msg, "&Yes\n&No", 2)
|
|
||||||
if choice ~= 1 then
|
|
||||||
vim.notify("PackClean: cancelled", vim.log.levels.INFO)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
vim.pack.del(stale)
|
|
||||||
vim.notify("PackClean: removed " .. #stale .. " plugin(s)", vim.log.levels.INFO)
|
|
||||||
end, { desc = "Delete inactive vim.pack plugins from disk" })
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|||||||
Reference in New Issue
Block a user