feat(lua): Cleanup autocmds and add LSP attach features- New Features:
- Added LSP attach autocmd with document highlight and inlay hints. - Enhancements: - Removed deprecated autocmds and unused options. - Bug Fixes: - None.
This commit is contained in:
2 files changed
+8
-26
No files matched your search
+8
-19
@@ -63,13 +63,6 @@ vim.api.nvim_create_autocmd("BufWritePre", {
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Highlight on yank
|
|
||||||
vim.api.nvim_create_autocmd("TextYankPost", {
|
|
||||||
group = augroup("highlight_yank"),
|
|
||||||
callback = function()
|
|
||||||
vim.highlight.on_yank({ timeout = 200 })
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
-- Resize splits if window got resized
|
-- Resize splits if window got resized
|
||||||
vim.api.nvim_create_autocmd("VimResized", {
|
vim.api.nvim_create_autocmd("VimResized", {
|
||||||
@@ -79,17 +72,6 @@ vim.api.nvim_create_autocmd("VimResized", {
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Go to last location when opening a buffer
|
|
||||||
vim.api.nvim_create_autocmd("BufReadPost", {
|
|
||||||
group = augroup("last_loc"),
|
|
||||||
callback = function()
|
|
||||||
local mark = vim.api.nvim_buf_get_mark(0, '"')
|
|
||||||
local lcount = vim.api.nvim_buf_line_count(0)
|
|
||||||
if mark[1] > 0 and mark[1] <= lcount then
|
|
||||||
pcall(vim.api.nvim_win_set_cursor, 0, mark)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
-- Close specific filetypes with <q>
|
-- Close specific filetypes with <q>
|
||||||
vim.api.nvim_create_autocmd("FileType", {
|
vim.api.nvim_create_autocmd("FileType", {
|
||||||
@@ -116,11 +98,13 @@ vim.api.nvim_create_autocmd("BufWritePre", {
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Document Highlight on CursorHold
|
-- LSP Attach Features
|
||||||
vim.api.nvim_create_autocmd("LspAttach", {
|
vim.api.nvim_create_autocmd("LspAttach", {
|
||||||
group = augroup("lsp_attach_autocmds"),
|
group = augroup("lsp_attach_autocmds"),
|
||||||
callback = function(args)
|
callback = function(args)
|
||||||
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
||||||
|
|
||||||
|
-- Document Highlight
|
||||||
if client and client:supports_method("textDocument/documentHighlight") then
|
if client and client:supports_method("textDocument/documentHighlight") then
|
||||||
vim.api.nvim_create_autocmd({ "CursorHold" }, {
|
vim.api.nvim_create_autocmd({ "CursorHold" }, {
|
||||||
buffer = args.buf,
|
buffer = args.buf,
|
||||||
@@ -131,6 +115,11 @@ vim.api.nvim_create_autocmd("LspAttach", {
|
|||||||
callback = vim.lsp.buf.clear_references,
|
callback = vim.lsp.buf.clear_references,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Inlay Hints
|
||||||
|
if client and client.server_capabilities.inlayHintProvider and vim.lsp.inlay_hint then
|
||||||
|
vim.lsp.inlay_hint.enable(true, { bufnr = args.buf })
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ local options = {
|
|||||||
undofile = true, -- save state of file on write
|
undofile = true, -- save state of file on write
|
||||||
undodir = vim.fn.stdpath("cache") .. "/undo",
|
undodir = vim.fn.stdpath("cache") .. "/undo",
|
||||||
undolevels = 10000,
|
undolevels = 10000,
|
||||||
autoread = true, -- autoread changes from other sources
|
|
||||||
signcolumn = "yes",
|
signcolumn = "yes",
|
||||||
cursorline = true,
|
cursorline = true,
|
||||||
cursorlineopt = "number",
|
cursorlineopt = "number",
|
||||||
@@ -19,10 +18,8 @@ local options = {
|
|||||||
backup = false, -- creates a backup file
|
backup = false, -- creates a backup file
|
||||||
writebackup = false, -- do not edit backups
|
writebackup = false, -- do not edit backups
|
||||||
winminwidth = 5, -- Minimum window width
|
winminwidth = 5, -- Minimum window width
|
||||||
termguicolors = true, -- set term gui colors (most terminals support this)
|
|
||||||
showtabline = 0, -- always show tabs
|
showtabline = 0, -- always show tabs
|
||||||
showcmd = false,
|
showcmd = false,
|
||||||
mouse = "a", -- allow the mouse to be used in neovim
|
|
||||||
confirm = true, -- Confirm to save changes before exiting modified buffer
|
confirm = true, -- Confirm to save changes before exiting modified buffer
|
||||||
|
|
||||||
-- tabs
|
-- tabs
|
||||||
@@ -31,8 +28,6 @@ local options = {
|
|||||||
expandtab = true, -- <tab> key will create " " instead of "\t"
|
expandtab = true, -- <tab> key will create " " instead of "\t"
|
||||||
shiftwidth = 4, -- indent change after backspace and >> <<
|
shiftwidth = 4, -- indent change after backspace and >> <<
|
||||||
softtabstop = 4, -- number of spaces instead of tab
|
softtabstop = 4, -- number of spaces instead of tab
|
||||||
autoindent = true, -- auto indent
|
|
||||||
smartindent = true, -- make indenting smarter again
|
|
||||||
list = true,
|
list = true,
|
||||||
listchars = { tab = "» ", trail = "·", nbsp = "␣" },
|
listchars = { tab = "» ", trail = "·", nbsp = "␣" },
|
||||||
showbreak = string.rep(" ", 3),
|
showbreak = string.rep(" ", 3),
|
||||||
@@ -40,8 +35,6 @@ local options = {
|
|||||||
-- Search
|
-- Search
|
||||||
ignorecase = true,
|
ignorecase = true,
|
||||||
smartcase = true,
|
smartcase = true,
|
||||||
hlsearch = true,
|
|
||||||
wildmenu = true,
|
|
||||||
wildmode = "longest:full,full",
|
wildmode = "longest:full,full",
|
||||||
wildoptions = "pum",
|
wildoptions = "pum",
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user