diff options
author | Brahmajit Das <listout@listout.xyz> | 2025-06-04 03:54:05 +0530 |
---|---|---|
committer | Brahmajit Das <listout@listout.xyz> | 2025-06-04 03:54:05 +0530 |
commit | 9c1e451bebd8603b379a669df5985d001bb8a366 (patch) | |
tree | c39f5c86eb800f77a6f2d677565691270d4263aa /lua/config/autocmds.lua | |
parent | 267c30a1e6d307e29b51c84351d556c34bc3c581 (diff) |
lua: config: autocmds: removing lspattach
Signed-off-by: Brahmajit Das <listout@listout.xyz>
Diffstat (limited to 'lua/config/autocmds.lua')
-rw-r--r-- | lua/config/autocmds.lua | 56 |
1 files changed, 0 insertions, 56 deletions
diff --git a/lua/config/autocmds.lua b/lua/config/autocmds.lua index 7efc2bf..7688bb4 100644 --- a/lua/config/autocmds.lua +++ b/lua/config/autocmds.lua @@ -65,59 +65,3 @@ vim.api.nvim_create_autocmd({ "ColorScheme", "BufReadPost" }, { vim.cmd.syntax([[match PRDiffDel /\v^[\-]((\-\-)|(\@\@ )|(\+\+)|(index )|(diff ))@!.*/]]) end, }) - -vim.api.nvim_create_autocmd("LspAttach", { - group = vim.api.nvim_create_augroup('lsp-attach', { clear = true }), - callback = function(event) - local map = function(keys, func, desc) - vim.keymap.set("n", keys, func, { buffer = event.buf, desc = "LSP: " .. desc }) - end - - -- defaults: - -- https://neovim.io/doc/user/news-0.11.html#_defaults - - map("gl", vim.diagnostic.open_float, "Open Diagnostic Float") - map("K", vim.lsp.buf.hover, "Hover Documentation") - map("gs", vim.lsp.buf.signature_help, "Signature Documentation") - map("gD", vim.lsp.buf.declaration, "Goto Declaration") - map("<leader>la", vim.lsp.buf.code_action, "Code Action") - map("<leader>lr", vim.lsp.buf.rename, "Rename all references") - map("<leader>lf", vim.lsp.buf.format, "Format") - map("<leader>v", "<cmd>vsplit | lua vim.lsp.buf.definition()<cr>", "Goto Definition in Vertical Split") - - local function client_supports_method(client, method, bufnr) - if vim.fn.has 'nvim-0.11' == 1 then - return client:supports_method(method, bufnr) - else - return client.supports_method(method, { bufnr = bufnr }) - end - end - - local client = vim.lsp.get_client_by_id(event.data.client_id) - if client and client_supports_method(client, vim.lsp.protocol.Methods.textDocument_documentHighlight, event.buf) then - local highlight_augroup = vim.api.nvim_create_augroup('lsp-highlight', { clear = false }) - - -- When cursor stops moving: Highlights all instances of the symbol under the cursor - -- When cursor moves: Clears the highlighting - vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { - buffer = event.buf, - group = highlight_augroup, - callback = vim.lsp.buf.document_highlight, - }) - vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, { - buffer = event.buf, - group = highlight_augroup, - callback = vim.lsp.buf.clear_references, - }) - - -- When LSP detaches: Clears the highlighting - vim.api.nvim_create_autocmd('LspDetach', { - group = vim.api.nvim_create_augroup('lsp-detach', { clear = true }), - callback = function(event2) - vim.lsp.buf.clear_references() - vim.api.nvim_clear_autocmds { group = 'lsp-highlight', buffer = event2.buf } - end, - }) - end - end, -}) |