Skip to content

Commit 3c4b70f

Browse files
committed
vim: update LSP config after neovim/neovim#12655 & nvim-lua/diagnostic-nvim#73
1 parent 94373b9 commit 3c4b70f

File tree

2 files changed

+42
-22
lines changed

2 files changed

+42
-22
lines changed

roles/vim/files/.vim/lua/_/lsp.lua

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
-- :lua print(vim.lsp.get_log_path())
55
-- :lua print(vim.inspect(vim.tbl_keys(vim.lsp.callbacks)))
66

7-
local has_lsp, lsp = pcall(require, "nvim_lsp")
7+
local has_lsp, nvim_lsp = pcall(require, "nvim_lsp")
88

99
if not has_lsp then
1010
return
@@ -36,40 +36,40 @@ end
3636
vim.api.nvim_set_option("omnifunc", "v:lua.vim.lsp.omnifunc")
3737

3838
vim.fn.sign_define(
39-
"LspDiagnosticsErrorSign",
39+
"LspDiagnosticsSignError",
4040
{
4141
text = utils.get_icon("error"),
42-
texthl = "LspDiagnosticsError",
42+
texthl = "LspDiagnosticsDefaultError",
4343
linehl = "",
4444
numhl = ""
4545
}
4646
)
4747

4848
vim.fn.sign_define(
49-
"LspDiagnosticsWarningSign",
49+
"LspDiagnosticsSignWarning",
5050
{
5151
text = utils.get_icon("warn"),
52-
texthl = "LspDiagnosticsWarning",
52+
texthl = "LspDiagnosticsDefaultWarning",
5353
linehl = "",
5454
numhl = ""
5555
}
5656
)
5757

5858
vim.fn.sign_define(
59-
"LspDiagnosticsInformationSign",
59+
"LspDiagnosticsSignInformation",
6060
{
6161
text = utils.get_icon("info"),
62-
texthl = "LspDiagnosticsInformation",
62+
texthl = "LspDiagnosticsDefaultInformation",
6363
linehl = "",
6464
numhl = ""
6565
}
6666
)
6767

6868
vim.fn.sign_define(
69-
"LspDiagnosticsHintSign",
69+
"LspDiagnosticsSignHint",
7070
{
7171
text = utils.get_icon("hint"),
72-
texthl = "LspDiagnosticsHint",
72+
texthl = "LspDiagnosticsDefaultHint",
7373
linehl = "",
7474
numhl = ""
7575
}
@@ -93,18 +93,20 @@ local on_attach = function(client)
9393
utils.bmap("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", map_opts)
9494
utils.bmap("n", "<leader>r", "<cmd>lua vim.lsp.buf.rename()<CR>", map_opts)
9595
utils.bmap("n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", map_opts)
96-
utils.bmap(
97-
"n",
98-
"<leader>ld",
99-
"<cmd>lua vim.lsp.util.show_line_diagnostics()<CR>",
100-
map_opts
101-
)
96+
utils.bmap("n", "dn", "lua vim.lsp.diagnostic.goto_next()", map_opts)
97+
utils.bmap("n", "dp", "<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>", map_opts)
98+
-- utils.bmap(
99+
-- "n",
100+
-- "<leader>ld",
101+
-- "<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>",
102+
-- map_opts
103+
-- )
102104

103105
utils.augroup(
104106
"LSP",
105107
function()
106108
vim.api.nvim_command(
107-
"autocmd CursorHold <buffer> lua vim.lsp.util.show_line_diagnostics()"
109+
"autocmd CursorHold <buffer> lua vim.lsp.diagnostic.show_line_diagnostics()"
108110
)
109111

110112
if resolved_capabilities.document_highlight then
@@ -122,6 +124,22 @@ local on_attach = function(client)
122124
)
123125
end
124126

127+
-- https://github.com/nvim-lua/diagnostic-nvim/issues/73
128+
vim.lsp.handlers["textDocument/publishDiagnostics"] =
129+
vim.lsp.with(
130+
vim.lsp.diagnostic.on_publish_diagnostics,
131+
{
132+
virtual_text = true,
133+
-- virtual_text = {
134+
-- spacing = 4,
135+
-- prefix = "~"
136+
-- },
137+
underline = false,
138+
signs = true,
139+
update_in_insert = false
140+
}
141+
)
142+
125143
-- Uncomment to execute the extension test mentioned above.
126144
-- local function custom_codeAction_callback(_, _, action)
127145
-- print(vim.inspect(action))
@@ -134,11 +152,13 @@ local function root_pattern(...)
134152

135153
return function(startpath)
136154
for _, pattern in ipairs(patterns) do
137-
return lsp.util.search_ancestors(
155+
return vim.lsp.util.search_ancestors(
138156
startpath,
139157
function(path)
140158
if
141-
lsp.util.path.exists(vim.fn.glob(lsp.util.path.join(path, pattern)))
159+
vim.lsp.util.path.exists(
160+
vim.fn.glob(vim.lsp.util.path.join(path, pattern))
161+
)
142162
then
143163
return path
144164
end
@@ -188,7 +208,7 @@ for server, config in pairs(servers) do
188208
local server_disabled = (config.disabled ~= nil and config.disabled) or false
189209

190210
if not server_disabled then
191-
lsp[server].setup(
211+
nvim_lsp[server].setup(
192212
vim.tbl_deep_extend("force", {on_attach = on_attach}, config)
193213
)
194214
end

roles/vim/files/.vim/plugin/color.vim

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ augroup MyCustomColors
2121
\| hi! link ALEWarning DiffChange
2222
\| hi! link ALEWarningSign DiffChange
2323
\| execute(printf('hi! OverLength guibg=%s ctermbg=%s guifg=NONE ctermfg=NONE', '#222222', '234'))
24-
\| hi! link LspDiagnosticsError DiffDelete
25-
\| hi! link LspDiagnosticsWarning DiffChange
26-
\| hi! link LspDiagnosticsHint NonText
24+
\| hi! link LspDiagnosticsDefaultError DiffDelete
25+
\| hi! link LspDiagnosticsDefaultWarning DiffChange
26+
\| hi! link LspDiagnosticsDefaultHint NonText
2727
\| hi! User5 ctermfg=red guifg=red
2828
\| hi! User7 ctermfg=cyan guifg=cyan
2929
\| execute(printf('hi! User4 gui=NONE cterm=NONE guibg=NONE ctermbg=NONE guifg=%s ctermfg=%s', utils#get_color('NonText', 'fg', 'gui'), utils#get_color('NonText','fg', 'cterm')))

0 commit comments

Comments
 (0)