1

Using Emacs 30, eglot is built in emacs and now it supports inlay hints capability of LSPs. Now I want to use clangd with eglot with inlay hints enabled, but it seems that it does not work out of the box and requires some configurations. These are what I have tried without luck:

(add-hook 'eglot-managed-mode-hook #'eglot-inlay-hints-mode) 

Which does nothing special

Creating a global clangd config file in ~/.config/clangd/config.yaml with these configurations:

Hover: ShowAKA: Yes Diagnostics: UnusedIncludes: Strict InlayHints: Designators: Yes Enabled: Yes ParameterNames: Yes DeducedTypes: Yes 

It also does nothing. Appending this to .emacs to forcefully start clangd with config file enabled does nothing:

(with-eval-after-load 'eglot (add-to-list 'eglot-server-programs '(c-mode . ("clangd" "--enable-config")) `(c++-mode . ("clangd" "--enable-config")))) 

Checking eglot output buffer, I've observed that Inlayhints capablity is sent as json-false. Here's the capabilities part:

 :capabilities (:workspace (:applyEdit t :executeCommand (:dynamicRegistration :json-false) :workspaceEdit (:documentChanges t) :didChangeWatchedFiles (:dynamicRegistration t) :symbol (:dynamicRegistration :json-false) :configuration t :workspaceFolders t) :textDocument (:synchronization (:dynamicRegistration :json-false :willSave t :willSaveWaitUntil t :didSave t) :completion (:dynamicRegistration :json-false :completionItem (:snippetSupport t :deprecatedSupport t :resolveSupport (:properties ["documentation" "details" "additionalTextEdits"]) :tagSupport (:valueSet [1])) :contextSupport t) :hover (:dynamicRegistration :json-false :contentFormat ["plaintext"]) :signatureHelp (:dynamicRegistration :json-false :signatureInformation (:parameterInformation (:labelOffsetSupport t) :activeParameterSupport t)) :references (:dynamicRegistration :json-false) :definition (:dynamicRegistration :json-false :linkSupport t) :declaration (:dynamicRegistration :json-false :linkSupport t) :implementation (:dynamicRegistration :json-false :linkSupport t) :typeDefinition (:dynamicRegistration :json-false :linkSupport t) :documentSymbol (:dynamicRegistration :json-false :hierarchicalDocumentSymbolSupport t :symbolKind (:valueSet [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26])) :documentHighlight (:dynamicRegistration :json-false) :codeAction (:dynamicRegistration :json-false :codeActionLiteralSupport (:codeActionKind (:valueSet ["quickfix" "refactor" "refactor.extract" "refactor.inline" "refactor.rewrite" "source" "source.organizeImports"])) :isPreferredSupport t) :formatting (:dynamicRegistration :json-false) :rangeFormatting (:dynamicRegistration :json-false) :rename (:dynamicRegistration :json-false) :inlayHint (:dynamicRegistration :json-false) :publishDiagnostics (:relatedInformation :json-false :codeDescriptionSupport :json-false :tagSupport (:valueSet [1 2]))) 

How can I make it work?

1
  • "Checking eglot output buffer, I've observed that Inlayhints capablity is sent as json-false". No it's not. It's sent as true, only its "dynamic registration" is not supported. Commented Apr 1, 2023 at 8:41

2 Answers 2

3

Eglot requires clangd version to be atleast 15 to enable inlay-hints feature and it is enabled out of the box and does not require additional configurations.

1

Clangd has a separate option argument --inlay-hints - try adding this to command line in your configuration.

1
  • The flag -inlay-hints is obsolete and ignored in clangd 14. Commented Apr 1, 2023 at 8:21

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.