home/.config/nvim/lua/events.lua
2025-05-28 16:39:25 +02:00

40 lines
No EOL
955 B
Lua

local on = vim.api.nvim_create_autocmd
local group = vim.api.nvim_create_augroup("autocmds", {clear = true})
on({ "LspAttach" }, {
desc = "LSP completion",
group = group,
callback = function(ev)
local client = vim.lsp.get_client_by_id(ev.data.client_id)
if client:supports_method("textDocument/completion") then
vim.lsp.completion.enable(true, client.id, ev.buf, { autotrigger = true })
end
end,
})
on({ "TextYankPost" }, {
desc = "Highlight when copying text",
group = group,
callback = function()
vim.highlight.on_yank()
end,
})
on({ "BufNewFile", "BufRead" }, {
desc = "Enable word wrap in text files and markdown documents",
group = group,
pattern = { "*.txt", "*.md" },
callback = function()
vim.opt_local.wrap = true
vim.opt_local.signcolumn = "no"
end,
})
on({ "TermOpen", "TermEnter" }, {
desc = "Disable sign column in terminals",
group = group,
callback = function()
vim.opt_local.signcolumn = "no"
end,
})