Closed mehalter closed 3 weeks ago
Does this PR follow the [Contribution Guidelines](development guidelines)? Following is a partial checklist:
Proper conventional commit scoping:
If you are adding a new plugin, the scope would be the name of the category it is being added into. ex. feat(utility): added noice.nvim plugin
If you are modifying a pre-existing plugin or pack, the scope would be the name of the plugin folder. ex. fix(noice-nvim): fix LSP handler error
[x] Pull request title has the appropriate conventional commit type and scope where the scope is the name of the pre-existing directory in the project as described above
[x] README
is properly formatted and uses fenced in links with <url>
unless they are inside a [title](url)
[x] Proper usage of opts
table rather than setting things up with the config
function.
testing this since I have a working dotnet env on my pc
I'm not going to be doing C# until next Tuesday, I can test and review then
Didnt work for me, the LSP in the pack is broken for Mac🥹
I think the problem is caused by telescope as mentioned here https://github.com/Decodetalkers/csharpls-extended-lsp.nvim/issues/7. Maybe overriding gd to use vim.lsp.buf.definition() instead of telescope methods will solve the problem.
I think the problem is caused by telescope as mentioned here Decodetalkers/csharpls-extended-lsp.nvim#7. Maybe overriding gd to use vim.lsp.buf.definition() instead of telescope methods will solve the problem.
The following configuration works for me. The fix is to override gd
to use vim.lsp.buf.definition
.
{
"Decodetalkers/csharpls-extended-lsp.nvim",
dependencies = {
{
"AstroNvim/astrolsp",
opts = {
config = {
csharp_ls = {
handlers = {
["textDocument/definition"] = function(...) require("csharpls_extended").handler(...) end,
["textDocument/typeDefinition"] = function(...) require("csharpls_extended").handler(...) end,
},
},
},
on_attach = function(client, bufnr)
if client.name ~= "csharp_ls" then return end
vim.keymap.set(
"n",
"gd",
vim.lsp.buf.definition,
{ buffer = bufnr, noremap = true, silent = true, desc = "Go to definition" }
)
end,
},
},
},
},
Thanks for pointing this out @ahmtsen ! I am going to be removing the telescope LSP mappings in the next patch release of AstroNvim because apparently there are many problems with them. Also thanks for the workaround! Once the next release is made I'll go ahead and merge this in.
Also sidenote, you know you can also add on_attach
functions to the config of language servers themselves to add settings for specific language servers. Rather than checking the client.name
you can do something like this:
{
"Decodetalkers/csharpls-extended-lsp.nvim",
dependencies = {
{
"AstroNvim/astrolsp",
opts = {
config = {
csharp_ls = {
handlers = {
["textDocument/definition"] = function(...) require("csharpls_extended").handler(...) end,
["textDocument/typeDefinition"] = function(...) require("csharpls_extended").handler(...) end,
},
on_attach = function(_, bufnr)
vim.keymap.set("n", "gd", vim.lsp.buf.definition, { buffer = bufnr, desc = "Go to definition" })
end,
},
},
},
},
},
},
This should work as intended now that AstroNvim v4.10.2 is released that doesn't use Telescope for LSP mappings out of the box.
Closes #951
📑 Description
This is untested because I don't have a C# environment. @Cretezy this is the correct way to set it up, it's the same way you mentioned you tried it. If it doesn't work it could just be the plugin is broken and we shouldn't add it. Could you give this a try?
ℹ Additional Information