-
-
Notifications
You must be signed in to change notification settings - Fork 336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The diagnostics of sumneko_lua
does not appear after :e
#946
Comments
This isn't a clear issue description... Here is a more appropriate issue description. Servers by convention send diagnostics when text document's are opened. Here is the RPC log, note the diagnostics are only returned after sending the first didChange notification after the client sends textDocument/didClose followed by textDocument/didOpen: [DEBUG][2022-02-08 14:21:52] .../vim/lsp/rpc.lua:347 "rpc.send" {
jsonrpc = "2.0",
method = "textDocument/didClose",
params = {
textDocument = {
uri = "file:///Users/michael/Repositories/nvim-lspconfig/test/minimal_init.lua"
}
}
}
[DEBUG][2022-02-08 14:21:52] .../vim/lsp/rpc.lua:347 "rpc.send" {
jsonrpc = "2.0",
method = "textDocument/didOpen",
params = {
textDocument = {
languageId = "lua",
text = "local on_windows = vim.loop.os_uname().version:match 'Windows'\n\nlocal function join_paths(...)\n local path_sep = on_windows and '\\\\' or '/'\n local result = table.concat({ ... }, path_sep)\n return result\nend\n\nvim.cmd [[set runtimepath=$VIMRUNTIME]]\n\nlocal temp_dir = vim.loop.os_getenv 'TEMP' or '/tmp'\n\nvim.cmd('set packpath=' .. join_paths(temp_dir, 'nvim', 'site'))\n\nlocal package_root = join_paths(temp_dir, 'nvim', 'site', 'pack')\nlocal install_path = join_paths(package_root, 'packer', 'start', 'packer.nvim')\nlocal compile_path = join_paths(install_path, 'plugin', 'packer_compiled.lua')\n\nlocal function load_plugins()\n require('packer').startup {\n {\n 'wbthomason/packer.nvim',\n 'neovim/nvim-lspconfig',\n },\n config = {\n package_root = package_root,\n compile_path = compile_path,\n },\n }\nend\n\n_G.load_config = function()\n vim.lsp.set_log_level 'trace'\n if vim.fn.has 'nvim-0.5.1' == 1 then\n require('vim.lsp.log').set_format_func(vim.inspect)\n end\n local nvim_lsp = require 'lspconfig'\n local on_attach = function(_, bufnr)\n local function buf_set_keymap(...)\n vim.api.nvim_buf_set_keymap(bufnr, ...)\n end\n local function buf_set_option(...)\n vim.api.nvim_buf_set_option(bufnr, ...)\n end\n\n buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')\n\n -- Mappings.\n local opts = { noremap = true, silent = true }\n buf_set_keymap('n', 'gD', '<Cmd>lua vim.lsp.buf.declaration()<CR>', opts)\n buf_set_keymap('n', 'gd', '<Cmd>lua vim.lsp.buf.definition()<CR>', opts)\n buf_set_keymap('n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts)\n buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)\n buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)\n buf_set_keymap('n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)\n buf_set_keymap('n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)\n buf_set_keymap('n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)\n buf_set_keymap('n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)\n buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)\n buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)\n buf_set_keymap('n', '<space>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)\n buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)\n buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)\n buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)\n end\n\n -- Add the server that troubles you here\n local name = 'sumneko_lua'\n if not name then\n print 'You have not defined a server name, please edit minimal_init.lua'\n end\n if not nvim_lsp[name].document_config.default_config.cmd and not cmd then\n print [[You have not defined a server default cmd for a server\n that requires it please edit minimal_init.lua]]\n end\n\n nvim_lsp[name].setup {\n cmd = cmd,\n on_attach = on_attach,\n }\n\n print [[You can find your log at $HOME/.cache/nvim/lsp.log. Please paste in a github issue under a details tag as described in the issue template.]]\nend\n\nif vim.fn.isdirectory(install_path) == 0 then\n vim.fn.system { 'git', 'clone', 'https://github.com/wbthomason/packer.nvim', install_path }\n load_plugins()\n require('packer').sync()\n vim.cmd [[autocmd User PackerComplete ++once lua load_config()]]\nelse\n load_plugins()\n require('packer').sync()\n _G.load_config()\nend\n",
uri = "file:///Users/michael/Repositories/nvim-lspconfig/test/minimal_init.lua",
version = 0
}
}
}
[DEBUG][2022-02-08 14:21:53] .../vim/lsp/rpc.lua:347 "rpc.send" {
jsonrpc = "2.0",
method = "textDocument/didChange",
params = {
contentChanges = { {
range = {
end = {
character = 0,
line = 13
},
start = {
character = 0,
line = 13
}
},
rangeLength = 0,
text = "e"
} },
textDocument = {
uri = "file:///Users/michael/Repositories/nvim-lspconfig/test/minimal_init.lua",
version = 6
}
}
}
[DEBUG][2022-02-08 14:21:53] .../vim/lsp/rpc.lua:454 "rpc.receive" {
jsonrpc = "2.0",
method = "$/status/report",
params = {
text = "😺Lua",
tooltip = "Workspace : /Users/michael/Repositories/nvim-lspconfig\nCached files: 147/146\nMemory usage: 15M"
}
}
[TRACE][2022-02-08 14:21:53] .../lua/vim/lsp.lua:792 "notification" "$/status/report" {
text = "😺Lua",
tooltip = "Workspace : /Users/michael/Repositories/nvim-lspconfig\nCached files: 147/146\nMemory usage: 15M"
}
[DEBUG][2022-02-08 14:21:53] .../vim/lsp/rpc.lua:454 "rpc.receive" {
jsonrpc = "2.0",
method = "textDocument/publishDiagnostics",
params = {
diagnostics = { {
code = "exp-in-action",
data = "syntax",
message = "Unexpected <exp> .",
range = {
end = {
character = 1,
line = 13
},
start = {
character = 0,
line = 13
}
},
severity = 1,
source = "Lua Syntax Check."
}, {
code = "undefined-global",
message = "Undefined global `vim`.",
range = {
end = {
character = 3,
line = 8
},
start = {
character = 0,
line = 8
}
},
severity = 2,
source = "Lua Diagnostics."
}, {
code = "undefined-global",
message = "Undefined global `vim`.",
range = {
end = {
character = 3,
line = 12
},
start = {
character = 0,
line = 12
}
},
severity = 2,
source = "Lua Diagnostics."
}, {
code = "undefined-global",
message = "Undefined global `vim`.",
range = {
end = {
character = 5,
line = 88
},
start = {
character = 2,
line = 88
}
},
severity = 2,
source = "Lua Diagnostics."
}, {
code = "undefined-global",
message = "Undefined global `vim`.",
range = {
end = {
character = 20,
line = 10
},
start = {
character = 17,
line = 10
}
},
severity = 2,
source = "Lua Diagnostics."
}, {
code = "undefined-global",
message = "Undefined global `vim`.",
range = {
end = {
character = 5,
line = 32
},
start = {
character = 2,
line = 32
}
},
severity = 2,
source = "Lua Diagnostics."
}, {
code = "undefined-global",
message = "Undefined global `vim`.",
range = {
end = {
character = 5,
line = 85
},
start = {
character = 2,
line = 85
}
},
severity = 2,
source = "Lua Diagnostics."
}, {
code = "undefined-global",
message = "Undefined global `cmd`.",
range = {
end = {
character = 70,
line = 71
},
start = {
character = 67,
line = 71
}
},
severity = 2,
source = "Lua Diagnostics."
}, {
code = "undefined-global",
message = "Undefined global `cmd`.",
range = {
end = {
character = 13,
line = 77
},
start = {
character = 10,
line = 77
}
},
severity = 2,
source = "Lua Diagnostics."
}, {
code = "undefined-global",
message = "Undefined global `vim`.",
range = {
end = {
character = 6,
line = 84
},
start = {
character = 3,
line = 84
}
},
severity = 2,
source = "Lua Diagnostics."
}, {
code = "undefined-global",
message = "Undefined global `vim`.",
range = {
end = {
character = 46,
line = 34
},
start = {
character = 43,
line = 34
}
},
severity = 2,
source = "Lua Diagnostics."
}, {
code = "undefined-global",
message = "Undefined global `vim`.",
range = {
end = {
character = 22,
line = 0
},
start = {
character = 19,
line = 0
}
},
severity = 2,
source = "Lua Diagnostics."
}, {
code = "undefined-global",
message = "Undefined global `vim`.",
range = {
end = {
character = 8,
line = 33
},
start = {
character = 5,
line = 33
}
},
severity = 2,
source = "Lua Diagnostics."
}, {
code = "undefined-global",
message = "Undefined global `vim`.",
range = {
end = {
character = 9,
line = 39
},
start = {
character = 6,
line = 39
}
},
severity = 2,
source = "Lua Diagnostics."
}, {
code = "undefined-global",
message = "Undefined global `vim`.",
range = {
end = {
character = 9,
line = 42
},
start = {
character = 6,
line = 42
}
},
severity = 2,
source = "Lua Diagnostics."
} },
uri = "file:///Users/michael/Repositories/nvim-lspconfig/test/minimal_init.lua",
version = 6
}
} |
The specification says: My understanding is that when you start the language server with a workspace, closing a file would not clear the diagnostics for that file. |
I believe contextually this is more referring to the server's responsibility for clearing rather than presenting diagnostics (embedding the full quote here for discussion).
I think that from a symmetry standpoint it is more elegant that when a client sends the didClose notification, from the server's point of view, there is no internal state/assumption that the client is caching previous diagnostics for that buffer. Instead I agree the spec is a little ambiguous, but my reading the above does not rule out sending diagnostics for a given URI on |
Clear cache when `didOpen`. This avoids clearing the cache according to the situation in the diagnostic business.
confirmed from neovim/nvim-lspconfig#1701
Update
To save your time read the first comment by @mjlbach below: #946 (comment)
Description
As title. How to make things clear? This is the DEMO:
(This might be helpful but I'm not sure: neovim/nvim-lspconfig#1192)
lua_bug.mov
To Reproduce
As shown in the DEMO.
Expected behavior
As shown in the DEMO.
Environment (please complete the following information):
Additional context
Add any other context about the problem here.
Neovim version:
nvim-lspconfig, which commit used
LSP log
The text was updated successfully, but these errors were encountered: