Files
dotfiles/nvim/.config/nvim/lua/romanzy/commands.lua
T
2026-11-06 10:07:06 +01:00

38 lines
1.2 KiB
Lua

local uc = vim.api.nvim_create_user_command
local ac = vim.api.nvim_create_autocmd
local aug = vim.api.nvim_create_augroup
uc("W", "w|e", { desc = "write file then refresh buffer" })
uc("ProjectDiagnostics", require("romanzy.custom.project_diagnostics").run,
{ desc = "check project warnings and errors" })
ac("TextYankPost", {
desc = "Highlight when yanking text",
group = aug("highlight-yank", { clear = true }),
callback = function()
vim.highlight.on_yank()
end,
})
uc("NormFormat", "!c_formatter_42 *.c *.h", { desc = "comply with the norm in C" })
vim.cmd("cnoreabbrev wn noautocmd write")
uc("GitBackup", function(opts)
vim.fn.system({ "git", "stash", "push", "-m", opts.args })
vim.fn.system({ "git", "stash", "apply", "--index", "stash@{0}" })
end, {
nargs = 1,
desc = "Stash changes without affecting the status",
})
-- ac("LspAttach", {
-- desc = "Notify user about attached LSP clients",
-- group = aug("LSPOnAttach", { clear = true }),
-- callback = function(event)
-- local client = vim.lsp.get_client_by_id(event.data.client_id)
-- if client then
-- vim.notify(client.name .. " attached", vim.log.levels.INFO, {})
-- end
-- end,
-- })