mirror of
https://codeberg.org/leana8959/.files.git
synced 2025-12-06 14:49:14 +00:00
nvim: refactor cmds into commands
This commit is contained in:
parent
1bdcd3386e
commit
7ae86384f6
14 changed files with 89 additions and 147 deletions
29
.config/nvim/plugin/autocommands.lua
Normal file
29
.config/nvim/plugin/autocommands.lua
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
vim.api.nvim_create_autocmd("TextYankPost", {
|
||||
group = vim.api.nvim_create_augroup("Visual", {}),
|
||||
callback = function()
|
||||
vim.highlight.on_yank {
|
||||
higroup = "IncSearch",
|
||||
timeout = 100,
|
||||
}
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("OptionSet", {
|
||||
pattern = "shiftwidth",
|
||||
callback = function()
|
||||
if vim.o.expandtab then
|
||||
local c = ""
|
||||
for _ = c:len(), vim.o.shiftwidth + 1 do
|
||||
c = c .. " "
|
||||
end
|
||||
return vim.opt.lcs:append("leadmultispace:" .. c)
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("OptionSet", {
|
||||
pattern = "textwidth",
|
||||
callback = function() vim.wo.colorcolumn = tostring(vim.bo.textwidth) end,
|
||||
})
|
||||
24
.config/nvim/plugin/commands.lua
Normal file
24
.config/nvim/plugin/commands.lua
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
vim.api.nvim_create_user_command("Retab", function(opts)
|
||||
if #opts.fargs ~= 2 then
|
||||
return print("should have exactly two argument: [src] and [dst]")
|
||||
end
|
||||
local src = tonumber(opts.fargs[1])
|
||||
local dst = tonumber(opts.fargs[2])
|
||||
if src == nil then
|
||||
print("first argument [src] is not a valid number")
|
||||
end
|
||||
if dst == nil then
|
||||
print("second argument [dst] is not a valid number")
|
||||
end
|
||||
|
||||
vim.bo.shiftwidth = src
|
||||
vim.bo.tabstop = src
|
||||
vim.bo.expandtab = false
|
||||
vim.cmd("%retab!")
|
||||
vim.bo.shiftwidth = dst
|
||||
vim.bo.tabstop = dst
|
||||
vim.bo.expandtab = true
|
||||
vim.cmd("%retab!")
|
||||
end, { nargs = "+" })
|
||||
|
||||
vim.api.nvim_create_user_command("W", function() vim.cmd.w() end, {})
|
||||
8
.config/nvim/plugin/ftdetect.lua
Normal file
8
.config/nvim/plugin/ftdetect.lua
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
vim.filetype.add {
|
||||
extension = {
|
||||
[".*Caddyfile"] = "caddyfile",
|
||||
hledger = "ledger",
|
||||
pro = "projet",
|
||||
typ = "typst",
|
||||
},
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue