fix(neovim): remove roslyn.nvim hack

Roslyn finally implements `textDocument/semanticTokens/full` by itself.
This commit is contained in:
Alexandre Cavalheiro S. Tiago da Silva 2025-04-23 16:40:04 -03:00
parent c4f9fbb936
commit 350ad7f145
Signed by: wizardlink
GPG key ID: A5767B54367CFBDF

View file

@ -56,60 +56,6 @@ return {
dotnet_enable_references_code_lens = true,
},
},
---@class RoslynPatchedClient: vim.lsp.Client
---@field patched boolean?
---@param client RoslynPatchedClient
---@param bufnr integer
on_attach = function(client, bufnr)
-- Call AstroLSP's on_attach so it registers mappings, formatting, etc.
require("astrolsp").on_attach(client, bufnr)
-- HACK: Patch out the `roslyn-ls` LSP client to have proper
-- semantic tokens.
-- This is a snippet of code taken and modified from:
-- https://github.com/seblyng/roslyn.nvim/wiki#semantic-tokens
if client.patched then
return
else
client.patched = true
end
-- let the runtime know the server can do semanticTokens/full now
client.server_capabilities = vim.tbl_deep_extend("force", client.server_capabilities, {
semanticTokensProvider = {
full = true,
},
})
local lsp_request = client.request
client.request = function(method, params, handler, req_bufnr)
if method ~= vim.lsp.protocol.Methods.textDocument_semanticTokens_full then
return lsp_request(method, params, handler, req_bufnr)
end
local target_bufnr = vim.uri_to_bufnr(params.textDocument.uri)
local line_count = vim.api.nvim_buf_line_count(target_bufnr)
local last_line =
vim.api.nvim_buf_get_lines(target_bufnr, line_count - 1, line_count, true)[1]
local returnvalue = lsp_request("textDocument/semanticTokens/range", {
textDocument = params.textDocument,
range = {
["start"] = {
line = 0,
character = 0,
},
["end"] = {
line = line_count - 1,
character = string.len(last_line) - 1,
},
},
}, handler, req_bufnr)
return returnvalue
end
end,
},
}