mirror of
https://codeberg.org/leana8959/.files.git
synced 2025-12-06 06:39:14 +00:00
79 lines
2.5 KiB
Lua
79 lines
2.5 KiB
Lua
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
|
|
vim.opt.listchars:append("leadmultispace:" .. c)
|
|
end
|
|
end,
|
|
})
|
|
|
|
local auto_colorcolumn = vim.api.nvim_create_augroup("auto_colorcolumn", {})
|
|
local set_colorcolumn_from_textwidth = function() vim.wo.colorcolumn = tostring(vim.bo.textwidth) end
|
|
vim.api.nvim_create_autocmd("OptionSet", {
|
|
group = auto_colorcolumn,
|
|
pattern = "textwidth",
|
|
callback = set_colorcolumn_from_textwidth,
|
|
})
|
|
vim.api.nvim_create_autocmd("BufEnter", {
|
|
group = auto_colorcolumn,
|
|
callback = function()
|
|
if vim.bo.textwidth then
|
|
set_colorcolumn_from_textwidth()
|
|
end
|
|
end,
|
|
})
|
|
|
|
vim.api.nvim_create_autocmd("LspProgress", {
|
|
once = true,
|
|
group = vim.api.nvim_create_augroup("UserLspConfig", {}),
|
|
callback = function() require("fidget").setup {} end,
|
|
})
|
|
|
|
-- Little trick to set the CursorLineNr to colors I like
|
|
-- TODO: maybe upstream this to curry.nvim one day?
|
|
do
|
|
local cursorLineNr = nil
|
|
local group = vim.api.nvim_create_augroup("ModeAwareCursorLineNr", {})
|
|
vim.api.nvim_create_autocmd("Colorscheme", {
|
|
group = group,
|
|
callback = function() cursorLineNr = vim.api.nvim_get_hl(0, { name = "CursorLineNr" }) end,
|
|
})
|
|
|
|
vim.api.nvim_create_autocmd("ModeChanged", {
|
|
pattern = "*:n",
|
|
group = group,
|
|
callback = function() vim.api.nvim_set_hl(0, "CursorLineNr", cursorLineNr) end,
|
|
})
|
|
|
|
vim.api.nvim_create_autocmd("ModeChanged", {
|
|
pattern = "*:i",
|
|
group = group,
|
|
callback = function()
|
|
local function_ = vim.api.nvim_get_hl(0, { name = "Function" })
|
|
vim.api.nvim_set_hl(0, "CursorLineNr", vim.tbl_deep_extend("force", function_, { reverse = true }))
|
|
end,
|
|
})
|
|
|
|
vim.api.nvim_create_autocmd("ModeChanged", {
|
|
pattern = "*:[Vv\22]*",
|
|
group = group,
|
|
callback = function()
|
|
local keyword = vim.api.nvim_get_hl(0, { name = "Keyword" })
|
|
vim.api.nvim_set_hl(0, "CursorLineNr", vim.tbl_deep_extend("force", keyword, { reverse = true }))
|
|
end,
|
|
})
|
|
end
|