Skip to content

feat: support standard lsp method for handling source generated content#355

Draft
sebastianstudniczek wants to merge 6 commits into
seblyng:mainfrom
sebastianstudniczek:feat/standard-lsp-methods-for-source-generated-files
Draft

feat: support standard lsp method for handling source generated content#355
sebastianstudniczek wants to merge 6 commits into
seblyng:mainfrom
sebastianstudniczek:feat/standard-lsp-methods-for-source-generated-files

Conversation

@sebastianstudniczek

@sebastianstudniczek sebastianstudniczek commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

Starting with roslyn version 5.7.0-1.26217.5 roslyn no longer uses custom lsp methods for handling source generated content.
Official lsp methods from 3.18 version workspace/textDocumentContent and workspace/textDocumentContent/refresh should be used.

LSP Spec https://microsoft.github.io/language-server-protocol/specifications/lsp/3.18/specification/#workspace_textDocumentContent

Related: dotnet/roslyn#83119

@sebastianstudniczek sebastianstudniczek force-pushed the feat/standard-lsp-methods-for-source-generated-files branch 2 times, most recently from 5fd3334 to 67e3485 Compare April 21, 2026 23:06
@sebastianstudniczek sebastianstudniczek marked this pull request as ready for review April 21, 2026 23:09
@sebastianstudniczek sebastianstudniczek force-pushed the feat/standard-lsp-methods-for-source-generated-files branch from 67e3485 to afc7d9d Compare April 21, 2026 23:21
@sebastianstudniczek

sebastianstudniczek commented Apr 25, 2026

Copy link
Copy Markdown
Contributor Author

Guess we can wait until LSP 3.18 is officialy out

@tris203

tris203 commented Apr 25, 2026

Copy link
Copy Markdown
Collaborator

If this method was upstreamed in neovim, would this let us delete this code entirely?

@sebastianstudniczek

sebastianstudniczek commented Apr 25, 2026

Copy link
Copy Markdown
Contributor Author

Looks like it, since there is no roslyn specific code. Maybe it's better to try to upstream it right away instead of putting it in this plugin (altough this forces people on stable to wait for new neovim release).

@tris203

tris203 commented Apr 25, 2026

Copy link
Copy Markdown
Collaborator

if its small changes, then its possible they would backport

or i would feel more confortable vendoring the upstreamed code exactly

@sebastianstudniczek

sebastianstudniczek commented Apr 25, 2026

Copy link
Copy Markdown
Contributor Author

Sounds good, I will create an issue in neovim repo then

@sebastianstudniczek

sebastianstudniczek commented Apr 26, 2026

Copy link
Copy Markdown
Contributor Author

Actually there is currently roslyn specific check for buffer name roslyn-source-generated://* so need to check how this can be handled. LSP spec defines schemes (types of content that server can provide) for server capability options so this might be the answer.

EDIT:
Yes, roslyn exposes this value roslyn-source-generated in server_capabilities

vim.api.nvim_create_autocmd("LspAttach", {
  callback = function(ev)
    local client = assert(vim.lsp.get_client_by_id(ev.data.client_id))
    if not client:supports_method("workspace/textDocumentContent") then
      return
    end

    local schemes = assert(vim.tbl_get(client.server_capabilities, "workspace", "textDocumentContent", "schemes"))

@sebastianstudniczek

Copy link
Copy Markdown
Contributor Author

Keeping as draft for now for people who need this

@sebastianstudniczek sebastianstudniczek force-pushed the feat/standard-lsp-methods-for-source-generated-files branch from 023d2af to 40a505a Compare May 18, 2026 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants