feat(lua): add smart column auto, macro notifications, auto‑save debounce, and TSInstallAll command
New Features - Smart column auto‑command that activates only when needed, respecting disabled filetypes - Macro recording notifications with short INFO‑level messages - Auto‑save with 3‑second debounce triggered on TextChanged, InsertLeave, BufLeave, FocusLost - TSInstallAll user command to install all configured Tree‑sitter parsers Enhancements- Cleanup of unused autocmds and simplification of pack_helper registration Bug Fixes -Removed legacy secure .env masking code that caused conceal issues
This commit is contained in:
2 files changed
+24
-31
No files matched your search
+23
-17
@@ -2,9 +2,27 @@ local function augroup(name)
|
|||||||
return vim.api.nvim_create_augroup("nvim_" .. name, { clear = true })
|
return vim.api.nvim_create_augroup("nvim_" .. name, { clear = true })
|
||||||
end
|
end
|
||||||
|
|
||||||
-- -----------------------------------------------------------------------------
|
-- smart column only when needed
|
||||||
-- General UI & Behavior
|
local smart_column_group = vim.api.nvim_create_augroup('SmartColumn', { clear = true })
|
||||||
-- -----------------------------------------------------------------------------
|
vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI', 'BufEnter' }, {
|
||||||
|
group = smart_column_group,
|
||||||
|
callback = function()
|
||||||
|
local limit = 120
|
||||||
|
local disabled_fts = { 'help', 'text', 'markdown', 'oil', 'snacks_dashboard', 'dashboard' }
|
||||||
|
|
||||||
|
if vim.tbl_contains(disabled_fts, vim.bo.filetype) then
|
||||||
|
vim.wo.colorcolumn = ''
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local curr_line = vim.api.nvim_get_current_line()
|
||||||
|
if vim.fn.strdisplaywidth(curr_line) > limit then
|
||||||
|
vim.wo.colorcolumn = tostring(limit)
|
||||||
|
else
|
||||||
|
vim.wo.colorcolumn = ''
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
-- Secure .env Masking (Conceal method)
|
-- Secure .env Masking (Conceal method)
|
||||||
local function toggle_env_mask()
|
local function toggle_env_mask()
|
||||||
@@ -98,10 +116,6 @@ vim.api.nvim_create_autocmd("BufWritePre", {
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- -----------------------------------------------------------------------------
|
|
||||||
-- LSP Related
|
|
||||||
-- -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Document Highlight on CursorHold
|
-- Document Highlight on CursorHold
|
||||||
vim.api.nvim_create_autocmd("LspAttach", {
|
vim.api.nvim_create_autocmd("LspAttach", {
|
||||||
group = augroup("lsp_attach_autocmds"),
|
group = augroup("lsp_attach_autocmds"),
|
||||||
@@ -120,10 +134,6 @@ vim.api.nvim_create_autocmd("LspAttach", {
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- -----------------------------------------------------------------------------
|
|
||||||
-- Filetype Specific
|
|
||||||
-- -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
-- Wrap and spellcheck in text filetypes
|
-- Wrap and spellcheck in text filetypes
|
||||||
vim.api.nvim_create_autocmd("FileType", {
|
vim.api.nvim_create_autocmd("FileType", {
|
||||||
group = augroup("wrap_spell"),
|
group = augroup("wrap_spell"),
|
||||||
@@ -150,10 +160,8 @@ vim.api.nvim_create_user_command("TSInstallAll", function()
|
|||||||
require("nvim-treesitter.install").install(parsers)
|
require("nvim-treesitter.install").install(parsers)
|
||||||
end, { desc = "Install all configured Tree-sitter parsers" })
|
end, { desc = "Install all configured Tree-sitter parsers" })
|
||||||
|
|
||||||
-- -----------------------------------------------------------------------------
|
|
||||||
-- Macro Notifications
|
|
||||||
-- -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
-- Macro Notifications
|
||||||
vim.api.nvim_create_autocmd("RecordingEnter", {
|
vim.api.nvim_create_autocmd("RecordingEnter", {
|
||||||
callback = function()
|
callback = function()
|
||||||
vim.notify("Recording macro...", vim.log.levels.INFO, { title = "Macro", timeout = 1000 })
|
vim.notify("Recording macro...", vim.log.levels.INFO, { title = "Macro", timeout = 1000 })
|
||||||
@@ -167,10 +175,8 @@ vim.api.nvim_create_autocmd("RecordingLeave", {
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- -----------------------------------------------------------------------------
|
|
||||||
-- Auto-Save (3s Debounce)
|
|
||||||
-- -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
-- Auto-Save (3s Debounce)
|
||||||
local save_timer = nil
|
local save_timer = nil
|
||||||
vim.api.nvim_create_autocmd({ "TextChanged", "InsertLeave", "BufLeave", "FocusLost" }, {
|
vim.api.nvim_create_autocmd({ "TextChanged", "InsertLeave", "BufLeave", "FocusLost" }, {
|
||||||
group = augroup("autosave"),
|
group = augroup("autosave"),
|
||||||
|
|||||||
+1
-14
@@ -1,5 +1,5 @@
|
|||||||
--- @class PackHelper
|
--- @class PackHelper
|
||||||
local M = { registered = {} }
|
local M = {}
|
||||||
|
|
||||||
-- Shorthands: gh (default), gl: (GitLab), cb: (Codeberg)
|
-- Shorthands: gh (default), gl: (GitLab), cb: (Codeberg)
|
||||||
local SOURCES = setmetatable({
|
local SOURCES = setmetatable({
|
||||||
@@ -26,21 +26,8 @@ _G.add = function(specs)
|
|||||||
return s
|
return s
|
||||||
end)() or s)
|
end)() or s)
|
||||||
table.insert(res, n)
|
table.insert(res, n)
|
||||||
M.registered[type(n) == "table" and n.src or n] = true
|
|
||||||
end
|
end
|
||||||
if #res > 0 then pcall(vim.pack.add, res) end
|
if #res > 0 then pcall(vim.pack.add, res) end
|
||||||
end
|
end
|
||||||
|
|
||||||
M.clean = function()
|
|
||||||
local del = {}
|
|
||||||
for url in pairs(vim.pack.get()) do
|
|
||||||
if not M.registered[url] then table.insert(del, url) end
|
|
||||||
end
|
|
||||||
if #del == 0 then return vim.notify("Plugins up to date", 2) end
|
|
||||||
if vim.fn.input("Delete " .. #del .. " plugins? (y/n): "):lower() == "y" then
|
|
||||||
for _, u in ipairs(del) do vim.pack.del(u) end
|
|
||||||
vim.notify("Cleaned " .. #del, 2)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
return M
|
||||||
Reference in new issue
Block a user