Skip to content

Commit f7fa22f

Browse files
committed
fix(lsp/roslyn): skip semantictokens/full for razor/cshtml
Roslyn's full semantic tokens request is now bypassed for .razor and .cshtml files, preventing issues with cohosted Razor where semantictokens/full are not supported. This avoids unnecessary or problematic LSP requests for these file types.
1 parent dbd677f commit f7fa22f

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

lsp/roslyn.lua

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,26 @@ return {
9292
on_dir(root_dir)
9393
end,
9494
on_init = {
95+
---@param client vim.lsp.Client
9596
function(client)
9697
-- Although roslyn supports prepareRename, cohosted razor doesnt. So we need to disable it
9798
client.server_capabilities.renameProvider = true
9899

100+
local orig_request = client.request
101+
102+
--- @param method vim.lsp.protocol.Method.ClientToServer.Request LSP method name.
103+
--- @param params? table LSP request params.
104+
client.request = function(_, method, params, ...)
105+
if method == "textDocument/semanticTokens/full" then
106+
---@class lsp.SemanticTokensParams
107+
local res = params
108+
if res.textDocument.uri:match("%.razor$") or res.textDocument.uri:match("%.cshtml$") then
109+
return
110+
end
111+
end
112+
return orig_request(client, method, params, ...)
113+
end
114+
99115
if not client.config.root_dir then
100116
return
101117
end

0 commit comments

Comments
 (0)