aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjdhao <jdhao@hotmail.com>2021-07-17 00:22:33 +0800
committerjdhao <jdhao@hotmail.com>2021-07-17 00:22:33 +0800
commitdc6a510526c3e3e38f4eb23149e0ec89cd03118a (patch)
tree280954b43e09a308c98abe552f1f770b614d6949
parent49f5f0155a58e50d82db6625fbfd9aa603c7bd01 (diff)
Update nvim-lspconfig settings
1. Customize document hover window border color. 2. Show also the source that generates a certain diagnostic message.
-rw-r--r--core/autocommands.vim5
-rw-r--r--lua/config/lsp.lua46
2 files changed, 42 insertions, 9 deletions
diff --git a/core/autocommands.vim b/core/autocommands.vim
index fd4654f..e88a1db 100644
--- a/core/autocommands.vim
+++ b/core/autocommands.vim
@@ -72,6 +72,11 @@ augroup cursor_color
autocmd ColorScheme * highlight Cursor2 guifg=red guibg=red
augroup END
+augroup float_border_color
+ autocmd!
+ autocmd ColorScheme * highlight FloatBorder guifg=LightGreen guibg=NONE
+augroup END
+
augroup auto_close_win
autocmd!
autocmd BufEnter * call s:quit_current_win()
diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua
index 3271fd4..028ec8e 100644
--- a/lua/config/lsp.lua
+++ b/lua/config/lsp.lua
@@ -112,20 +112,48 @@ vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
}
)
+-- Refs: https://github.com/neovim/nvim-lspconfig/wiki/UI-customization#show-source-in-diagnostics
+vim.lsp.handlers["textDocument/publishDiagnostics"] =
+ function(_, _, params, client_id, _)
+ local uri = params.uri
+ local bufnr = vim.uri_to_bufnr(uri)
+
+ if not bufnr then
+ return
+ end
+
+ if not vim.api.nvim_buf_is_loaded(bufnr) then
+ return
+ end
+
+ local diagnostics = params.diagnostics
+ for i, v in ipairs(diagnostics) do
+ diagnostics[i].message = string.format("%s: %s", v.source, v.message)
+ end
+ vim.lsp.diagnostic.save(diagnostics, bufnr, client_id)
+
+ local config = {
+ underline = false,
+ virtual_text = false,
+ signs = true,
+ update_in_insert = false,
+ }
+ vim.lsp.diagnostic.display(diagnostics, bufnr, client_id, config)
+ end
+
-- The following settings works with the bleeding edge neovim.
-- See https://github.com/neovim/neovim/pull/13998.
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(
vim.lsp.handlers.hover, {
border = {
- {"┌", "Normal"},
- {"─", "Normal"},
- {"┐", "Normal"},
- {"│", "Normal"},
- {"┘", "Normal"},
- {"─", "Normal"},
- {"└", "Normal"},
- {"│", "Normal"}
+ {"┌", "FloatBorder"},
+ {"─", "FloatBorder"},
+ {"┐", "FloatBorder"},
+ {"│", "FloatBorder"},
+ {"┘", "FloatBorder"},
+ {"─", "FloatBorder"},
+ {"└", "FloatBorder"},
+ {"│", "FloatBorder"}
}
}
)
-