From fc52e86ef482c2db5a7b75707a407730245d3a63 Mon Sep 17 00:00:00 2001 From: Briain O'Driscoll Date: Mon, 9 May 2022 19:15:51 +0100 Subject: [PATCH 1/2] amend global on_attach function --- lua/user/lsp/handlers.lua | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/lua/user/lsp/handlers.lua b/lua/user/lsp/handlers.lua index fb8b7f8..035e7d4 100644 --- a/lua/user/lsp/handlers.lua +++ b/lua/user/lsp/handlers.lua @@ -46,18 +46,13 @@ end local function lsp_highlight_document(client) -- Set autocommands conditional on server_capabilities - if client.resolved_capabilities.document_highlight then - vim.api.nvim_exec( - [[ - augroup lsp_document_highlight - autocmd! * - autocmd CursorHold lua vim.lsp.buf.document_highlight() - autocmd CursorMoved lua vim.lsp.buf.clear_references() - augroup END - ]], - false - ) - end + -- if client.server_capabilities.document_highlight then + local status_ok, illuminate = pcall(require, "illuminate") + if not status_ok then + return + end + illuminate.on_attach(client) + -- end end local function lsp_keymaps(bufnr) @@ -85,9 +80,11 @@ local function lsp_keymaps(bufnr) end M.on_attach = function(client, bufnr) - if client.name == "tsserver" then - client.resolved_capabilities.document_formatting = false - end +-- vim.notify(client.name .. " starting...") +-- TODO: refactor this into a method that checks if string in list +-- if client.name == "tsserver" then +-- client.resolved_capabilities.document_formatting = false +-- end lsp_keymaps(bufnr) lsp_highlight_document(client) end From 8610b9d9a8a0e511a910334a98a24a165efdca34 Mon Sep 17 00:00:00 2001 From: Briain O'Driscoll Date: Mon, 9 May 2022 19:15:51 +0100 Subject: [PATCH 2/2] amend global on_attach function open_float instead of show_line_diagnostics --- lua/user/lsp/handlers.lua | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/lua/user/lsp/handlers.lua b/lua/user/lsp/handlers.lua index fb8b7f8..3c401de 100644 --- a/lua/user/lsp/handlers.lua +++ b/lua/user/lsp/handlers.lua @@ -46,18 +46,12 @@ end local function lsp_highlight_document(client) -- Set autocommands conditional on server_capabilities - if client.resolved_capabilities.document_highlight then - vim.api.nvim_exec( - [[ - augroup lsp_document_highlight - autocmd! * - autocmd CursorHold lua vim.lsp.buf.document_highlight() - autocmd CursorMoved lua vim.lsp.buf.clear_references() - augroup END - ]], - false - ) - end + local status_ok, illuminate = pcall(require, "illuminate") + if not status_ok then + return + end + illuminate.on_attach(client) + -- end end local function lsp_keymaps(bufnr) @@ -76,7 +70,7 @@ local function lsp_keymaps(bufnr) bufnr, "n", "gl", - 'lua vim.lsp.diagnostic.show_line_diagnostics({ border = "rounded" })', + 'lua vim.diagnostic.open_float({ border = "rounded" })', opts ) vim.api.nvim_buf_set_keymap(bufnr, "n", "]d", 'lua vim.diagnostic.goto_next({ border = "rounded" })', opts) @@ -85,6 +79,8 @@ local function lsp_keymaps(bufnr) end M.on_attach = function(client, bufnr) +-- vim.notify(client.name .. " starting...") +-- TODO: refactor this into a method that checks if string in list if client.name == "tsserver" then client.resolved_capabilities.document_formatting = false end