4
4
-- :lua print(vim.lsp.get_log_path())
5
5
-- :lua print(vim.inspect(vim.tbl_keys(vim.lsp.callbacks)))
6
6
7
- local has_lsp , lsp = pcall (require , " nvim_lsp" )
7
+ local has_lsp , nvim_lsp = pcall (require , " nvim_lsp" )
8
8
9
9
if not has_lsp then
10
10
return
36
36
vim .api .nvim_set_option (" omnifunc" , " v:lua.vim.lsp.omnifunc" )
37
37
38
38
vim .fn .sign_define (
39
- " LspDiagnosticsErrorSign " ,
39
+ " LspDiagnosticsSignError " ,
40
40
{
41
41
text = utils .get_icon (" error" ),
42
- texthl = " LspDiagnosticsError " ,
42
+ texthl = " LspDiagnosticsDefaultError " ,
43
43
linehl = " " ,
44
44
numhl = " "
45
45
}
46
46
)
47
47
48
48
vim .fn .sign_define (
49
- " LspDiagnosticsWarningSign " ,
49
+ " LspDiagnosticsSignWarning " ,
50
50
{
51
51
text = utils .get_icon (" warn" ),
52
- texthl = " LspDiagnosticsWarning " ,
52
+ texthl = " LspDiagnosticsDefaultWarning " ,
53
53
linehl = " " ,
54
54
numhl = " "
55
55
}
56
56
)
57
57
58
58
vim .fn .sign_define (
59
- " LspDiagnosticsInformationSign " ,
59
+ " LspDiagnosticsSignInformation " ,
60
60
{
61
61
text = utils .get_icon (" info" ),
62
- texthl = " LspDiagnosticsInformation " ,
62
+ texthl = " LspDiagnosticsDefaultInformation " ,
63
63
linehl = " " ,
64
64
numhl = " "
65
65
}
66
66
)
67
67
68
68
vim .fn .sign_define (
69
- " LspDiagnosticsHintSign " ,
69
+ " LspDiagnosticsSignHint " ,
70
70
{
71
71
text = utils .get_icon (" hint" ),
72
- texthl = " LspDiagnosticsHint " ,
72
+ texthl = " LspDiagnosticsDefaultHint " ,
73
73
linehl = " " ,
74
74
numhl = " "
75
75
}
@@ -93,18 +93,20 @@ local on_attach = function(client)
93
93
utils .bmap (" n" , " gi" , " <cmd>lua vim.lsp.buf.implementation()<CR>" , map_opts )
94
94
utils .bmap (" n" , " <leader>r" , " <cmd>lua vim.lsp.buf.rename()<CR>" , map_opts )
95
95
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
+ -- )
102
104
103
105
utils .augroup (
104
106
" LSP" ,
105
107
function ()
106
108
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()"
108
110
)
109
111
110
112
if resolved_capabilities .document_highlight then
@@ -122,6 +124,22 @@ local on_attach = function(client)
122
124
)
123
125
end
124
126
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
+
125
143
-- Uncomment to execute the extension test mentioned above.
126
144
-- local function custom_codeAction_callback(_, _, action)
127
145
-- print(vim.inspect(action))
@@ -134,11 +152,13 @@ local function root_pattern(...)
134
152
135
153
return function (startpath )
136
154
for _ , pattern in ipairs (patterns ) do
137
- return lsp .util .search_ancestors (
155
+ return vim . lsp .util .search_ancestors (
138
156
startpath ,
139
157
function (path )
140
158
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
+ )
142
162
then
143
163
return path
144
164
end
@@ -188,7 +208,7 @@ for server, config in pairs(servers) do
188
208
local server_disabled = (config .disabled ~= nil and config .disabled ) or false
189
209
190
210
if not server_disabled then
191
- lsp [server ].setup (
211
+ nvim_lsp [server ].setup (
192
212
vim .tbl_deep_extend (" force" , {on_attach = on_attach }, config )
193
213
)
194
214
end
0 commit comments