nvim: Update for nvim LSP diagnostics

The diagnostic-nvim plugin got merged upstream and as a result the
plugin is not required anymore. LSP diagnostic highlight group names
were also updated.

See the below issues for notes on migration.
https://github.com/neovim/neovim/pull/12655
https://github.com/nvim-lua/diagnostic-nvim/issues/73
This commit is contained in:
Sanchayan Maity 2020-11-21 11:05:07 +05:30
parent a25d54afee
commit 50a5d55fe4
4 changed files with 26 additions and 31 deletions

View file

@ -181,28 +181,32 @@ local highlight_groups = {
Question = {bg=black, fg=yellow, style='underline'},
--[[ 4.2.11. LSP ]]
LspDiagnosticsError = 'Error' ,
LspDiagnosticsErrorFloating = 'ErrorMsg',
LspDiagnosticsErrorSign = 'ErrorMsg',
LspDiagnosticsDefaultError = 'Error' ,
LspDiagnosticsFloatingError = 'ErrorMsg',
LspDiagnosticsSignError = 'ErrorMsg',
LspDiagnosticsWarning = 'Warning' ,
LspDiagnosticsWarningFloating = 'WarningMsg',
LspDiagnosticsWarningSign = 'WarningMsg',
LspDiagnosticsDefaultWarning = 'Warning' ,
LspDiagnosticsFloatingWarning = 'WarningMsg',
LspDiagnosticsSignWarning = 'WarningMsg',
LspDiagnosticsHint = 'Hint' ,
LspDiagnosticsHintFloating = 'HintMsg',
LspDiagnosticsHintSign = 'HintMsg',
LspDiagnosticsDefaultHint = 'Hint' ,
LspDiagnosticsFloatingHint = 'HintMsg',
LspDiagnosticsSignHint = 'HintMsg',
LspDiagnosticsInformation = 'Info' ,
LspDiagnosticsInformationFloating = 'InfoMsg',
LspDiagnosticsInformationSign = 'InfoMsg',
LspDiagnosticsDefaultInformation = 'Info' ,
LspDiagnosticsFloatingInformation = 'InfoMsg',
LspDiagnosticsSignInformation = 'InfoMsg',
LspDiagnosticsUnderline = {style={'undercurl', color=white}},
LspDiagnosticsUnderlineError = {style={'undercurl', color=red}},
LspDiagnosticsUnderlineHint = {style={'undercurl', color=purple}},
LspDiagnosticsUnderlineInfo = {style={'undercurl', color=pink}},
LspDiagnosticsUnderlineInformation = {style={'undercurl', color=pink}},
LspDiagnosticsUnderlineWarning = {style={'undercurl', color=red}},
LspDiagnosticsVirtualTextError = {color=red},
LspDiagnosticsVirtualTextHint = {color=purple},
LspDiagnosticsVirtualTextInformation = {color=pink},
LspDiagnosticsVirtualTextWarning = {color=red},
--[[ 4.2.12. Cursor ]]
Cursor = {bg=white, fg=black, style='inverse'},
CursorIM = 'Cursor',

View file

@ -1,5 +1,4 @@
local nvim_lsp = require('lspconfig')
local diagnostic = require('diagnostic')
local completion = require('completion')
local lsp_status = require('lsp-status')
@ -47,7 +46,6 @@ end
local on_attach = function(client, bufnr)
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
diagnostic.on_attach(client, bufnr)
completion.on_attach(client, bufnr)
lsp_status.on_attach(client, bufnr)
@ -65,10 +63,11 @@ local on_attach = function(client, bufnr)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<Leader>de', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<Leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'pd', '<cmd>lua peek_definition()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '[d', ':PrevDiagnostic<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', ']d', ':NextDiagnostic<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '[D', ':PrevDiagnosticCycle<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', ']D', ':NextDiagnosticCycle<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev { wrap = false }<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next { wrap = false }<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '[D', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', ']D', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'do', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
end
local servers = { 'hls', 'rust_analyzer' }

View file

@ -1,4 +0,0 @@
vim.g.diagnostic_enable_virtual_text = 0
vim.g.diagnostic_show_sign = 1
vim.g.diagnostic_auto_popup_while_jump = 1
vim.g.diagnostic_insert_delay = 1

View file

@ -122,10 +122,6 @@ local init = function ()
'neovim/nvim-lspconfig',
config = "require('lsp')",
}
use {
'nvim-lua/diagnostic-nvim',
config = "require('modules.diagnostic')"
}
use 'nvim-lua/lsp-status.nvim'
-- Language support & syntax highlighting
-- Haskell