Open
Conversation
This is an RFC for textDocument/rangeFormatting (line ranges only at present), and `textDocument/formatting`. I'm basing this off the 3.18 spec and have done basic testing with clangd.
Author
|
I've been using this patch locally in my day-today (C/C++ with clangd as my LSP) and it seems stable well. Any comments you have on resolving the TODOs here would be appreciated. Happy to receive comments from other LSP users in particular |
arp242
reviewed
Oct 12, 2024
| command! LSClientDisableDiagnosticHighlights call <SID>DisableHighlights() | ||
| command! LSClientEnableDiagnosticHighlights call <SID>EnableHighlights() | ||
| command! LSClientFormat call lsc#format#formatFile() | ||
| command! -range LSClientFormat '<,'> call lsc#format#formatRange() |
Contributor
There was a problem hiding this comment.
This overrides the :LSClientFormat that calls formatFile(); running it doesn't work:
:100verbose LSClientFormat
Executing: '<,'> call lsc#format#formatRange()
E20: Mark not set
If I do use visual mode to set <' and '> I get:
[lsc:Error] JSON RPC method not found: "RangeFormatting" not yet implemented
I guess my LSP server doesn't implement that.
Anyway, if I comment out this line then it works. Probably need to be a bit smarter about the range being passed and what mode it's in.
arp242
reviewed
Oct 12, 2024
|
|
||
| "call lsc#message#error('onresult') | ||
| if a:textedit == v:null | return | endif | ||
| call lsc#message#log('got edits' . json_encode(a:textedit), 'Info') |
Contributor
There was a problem hiding this comment.
It probably shouldn't have these log lines (there's a few more of them)?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is an RFC for potential
textDocument/rangeFormattingandtextDocument/formattingsupport (line ranges only in the present implementation).I'm basing this off the 3.18 spec and have done basic testing with clangd-15 where things seem to be working well.
Since I'm not particularly familiar with the vim-lsc architecture and formatprg etc, I'm open to any ideas on how to hook up these new functions to formatprg (or not as might be the cleaner case) and how to handle the default formatting options (see FIXME comment in format.vim)