Skip to content

Commit

Permalink
Up(nvim): 0.5.1 to 0.6.0: update aucmd & hi groups
Browse files Browse the repository at this point in the history
update LSP highlight groups, and autocmd for changes in
diagnostics

tags:
    LSP, highlight groups, version bump, software update, autocmd
  • Loading branch information
PrashanthaTP committed Dec 13, 2021
1 parent 9a03ce7 commit 8429bcb
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions .config/nvim/lua/plugins/nvim-lspconfig/init.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
local nvim_lsp = require("lspconfig")
local utils = require("plugins.nvim-lspconfig.utils")
local on_attach = utils.on_attach
-- Use a loop to conveniently call 'setup' on multiple servers and
-- map buffer local keybindings when the language server attaches

local servers = {
"pyright", "clangd", "cmake", "tsserver", "cssls", "sumneko_lua"
"pyright", "clangd", "cmake", "tsserver", "cssls", "sumneko_lua"
}
local capabilities = require("cmp_nvim_lsp").update_capabilities(vim.lsp
.protocol
Expand All @@ -21,6 +20,9 @@ for _, lsp in ipairs(servers) do
end
--]]
-- vim.lsp.set_log_level("debug")
--------------------------------------------------------------------------------
-- Import servers configurations
--------------------------------------------------------------------------------
require("plugins.nvim-lspconfig.servers.pyright").setup(on_attach, capabilities)
require("plugins.nvim-lspconfig.servers.clangd").setup(on_attach, capabilities)
require("plugins.nvim-lspconfig.servers.cmake").setup(on_attach, capabilities)
Expand All @@ -31,14 +33,29 @@ require("plugins.nvim-lspconfig.servers.tsserver").setup(on_attach, capabilities
require("plugins.nvim-lspconfig.servers.efm").setup(on_attach, capabilities)
--require("plugins.nvim-lspconfig.servers.diagnosticls").setup(on_attach,capabilities)
--
function _G.updateLocationList()
vim.lsp.diagnostic.set_loclist({open_loclist = false})
end

--------------------------------------------------------------------------------
-- Update location list with LSP Diagnostics
--------------------------------------------------------------------------------
---reference : https://rafaelleru.github.io/blog/quickfix-autocomands/
--- reference for autocmd : https://github.com/neovim/neovim/issues/14090#issuecomment-979424077
function _G.updateLocationList()
vim.lsp.diagnostic.set_loclist({open_loclist = false})
end

vim.cmd([[
augroup UPDATE_LOCATION_LIST_WITH_LSP_LINTS
autocmd!
autocmd! User LspDiagnosticsChanged :call v:lua.updateLocationList()
autocmd! DiagnosticChanged :call v:lua.updateLocationList()
augroup END
]])

--------------------------------------------------------------------------------
-- Highlight groups for LSP virtual texts
-- Nvim 0.6.0 and up
--------------------------------------------------------------------------------
vim.cmd([[
"highlight! DiagnosticVirtualTextHint guifg=#FF0000 ctermfg=Red
highlight! DiagnosticVirtualTextWarning guifg=Red ctermfg=Red
highlight! DiagnosticVirtualTextError guifg=Red ctermfg=Red
]])

0 comments on commit 8429bcb

Please sign in to comment.