Skip to content

[clangd] Check for editsNearCursor client capability under experimental capabilities #114699

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

Merged
merged 1 commit into from
Nov 5, 2024

Conversation

HighCommander4
Copy link
Collaborator

This is done to support clients which only support adding custom (language-specific or server-specific) capabilities under 'experimental'.

Fixes clangd/clangd#2201

…al capabilities

This is done to support clients which only support adding custom
(language-specific or server-specific) capabilities under
'experimental'.

Fixes clangd/clangd#2201
@llvmbot
Copy link
Member

llvmbot commented Nov 3, 2024

@llvm/pr-subscribers-clang-tools-extra

@llvm/pr-subscribers-clangd

Author: Nathan Ridge (HighCommander4)

Changes

This is done to support clients which only support adding custom (language-specific or server-specific) capabilities under 'experimental'.

Fixes clangd/clangd#2201


Full diff: https://github.com/llvm/llvm-project/pull/114699.diff

1 Files Affected:

  • (modified) clang-tools-extra/clangd/Protocol.cpp (+10)
diff --git a/clang-tools-extra/clangd/Protocol.cpp b/clang-tools-extra/clangd/Protocol.cpp
index c08f80442eaa06..5a303123b5ce84 100644
--- a/clang-tools-extra/clangd/Protocol.cpp
+++ b/clang-tools-extra/clangd/Protocol.cpp
@@ -504,6 +504,16 @@ bool fromJSON(const llvm::json::Value &Params, ClientCapabilities &R,
                   P.field("offsetEncoding")))
       return false;
   }
+
+  if (auto *Experimental = O->getObject("experimental")) {
+    if (auto *TextDocument = Experimental->getObject("textDocument")) {
+      if (auto *Completion = TextDocument->getObject("completion")) {
+        if (auto EditsNearCursor = Completion->getBoolean("editsNearCursor"))
+          R.CompletionFixes |= *EditsNearCursor;
+      }
+    }
+  }
+
   return true;
 }
 

Copy link
Collaborator

@hokein hokein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(No action required) – we have other extensions in clangd e.g. references.container offsetEncoding. Do we plan to do the same thing for them?

@HighCommander4
Copy link
Collaborator Author

(No action required) – we have other extensions in clangd e.g. references.container offsetEncoding. Do we plan to do the same thing for them?

Good question; I was initially thinking of doing it as needed / when someone asks for it. But maybe it would be better to add them all up front, so when a need for another one arises, the support is already in a clangd release. I can do that in a follow-up patch.

@HighCommander4 HighCommander4 merged commit 7de1eff into llvm:main Nov 5, 2024
11 checks passed
@rchl
Copy link

rchl commented Nov 5, 2024

Personally I haven't yet looked if other custom capabilities are relevant for the editor I use (Sublime Text) but I also think it would makes sense to be with all of them (and follow the spec).

PhilippRados pushed a commit to PhilippRados/llvm-project that referenced this pull request Nov 6, 2024
…al capabilities (llvm#114699)

This is done to support clients which only support adding custom
(language-specific or server-specific) capabilities under
'experimental'.

Fixes clangd/clangd#2201
@HighCommander4
Copy link
Collaborator Author

(No action required) – we have other extensions in clangd e.g. references.container offsetEncoding. Do we plan to do the same thing for them?

Good question; I was initially thinking of doing it as needed / when someone asks for it. But maybe it would be better to add them all up front, so when a need for another one arises, the support is already in a clangd release. I can do that in a follow-up patch.

Sent out #116531 for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Respect custom editsNearCursor capability being set on capabilities.experimental object
4 participants