-
Notifications
You must be signed in to change notification settings - Fork 28
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
Add support for opening source generated documents #115
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow this looks great! Thank you very much!
I just had one question, and otherwise I just want to test it a little bit first.
The code looks very simple and is easily understandable🙌
callback = function() | ||
local uri = vim.fn.expand('<amatch>') | ||
local buf = vim.api.nvim_get_current_buf() | ||
vim.bo[buf].modifiable = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand it correctly, we only set modified here to be able to set the lines in the handler, and then immediately set it to nomodifiable again after that?
Is it possible to set it to modifiable just before setting the lines inside the handler or doesn't that work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that this is also done for the jdtls, so it is probably fine🤷♂️ I was just curious
I just tried it a bit, and seems good👍 I just added a commit to format the code while I was already having it open and format on save is turned on for me |
Thanks! |
This PR adds support for opening and handling source generated documents. The reloading of open source generated documents is currently not implement, but should not be to hard to add.
The "BufReadCmd" callback is inspired by https://github.com/mfussenegger/nvim-jdtls/blob/master/lua/jdtls.lua#L1186 (including the vim.wait call).
The VsCode extension has also added support for source generated documents. (initial: dotnet/vscode-csharp#7581, refresh support: dotnet/vscode-csharp#7791, src location: `https://github.com/dotnet/vscode-csharp/blob/main/src/lsptoolshost/sourceGeneratedFilesContentProvider.ts)
Notes from manual testing:
The VsCode extension and this extension returns some times different results when executing the "go to reference" command.
E.g. In VsCode 3 references are found (
t.Print()
,public partial Regex Print();
andpublic partial global::System.Text.RegularExpressions.Regex Print() => global::System.Text.RegularExpressions.Generated.Print_0.Instance;
)while this extension only returns 2 references (
public partial Regex Print();
andpublic partial global::System.Text.RegularExpressions.Regex Print() => global::System.Text.RegularExpressions.Generated.Print_0.Instance;
).But if the cursor is at the source generate method name, VsCode and this extension returns both 3 references.
I guess that this is not a direct problem with this PR, but rather some difference in the lsp client setup/lsp client implementation that lead to this behavior.
For a better telescope support two thinks must be done: