Giter VIP home page Giter VIP logo

Comments (7)

MaskRay avatar MaskRay commented on July 29, 2024

Have you installed company-lsp?

(defun company-lsp--client-capabilities ()
  "Return the extra client capabilities supported by company-lsp."
  (when company-lsp-enable-snippet
    '(:textDocument (:completion (:completionItem (:snippetSupport t))))))

Can you check if M-: (lsp--client-capabilities) contains (:snippetSupport t)?

When it is true, ccls uses LSP snippets $1 $0 .... These placeholders will cause trouble if you don't configure company-lsp in company-backends. Please make sure company-lsp is the first entry or the only entry of company-backends.

Not directly related but a tip. If you want to disable snippets on ccls's side, you may customize initialization options as follows:

(setq ccls-extra-init-params '(:client (:snippetSupport :json-false)))

but the proposed completion are totally wrong

These pieces of information will be helpful: the project name (if not confidential), how you get compile_commands.json, how the completion is wrong

from emacs-ccls.

dlyr avatar dlyr commented on July 29, 2024

Thanks for your reply, it seems that company-lsp is installed.

company-backends is a variable defined in ‘company.el’.
Its value is (company-lsp company-bbdb company-nxml company-css company-eclim company-semantic company-clang company-xcode company-cmake company-capf company-files
	     (company-dabbrev-code company-gtags company-etags company-keywords)
	     company-oddmuse company-dabbrev)

and

(lsp--client-capabilities)

(:workspace (:applyEdit t :executeCommand (:dynamicRegistration t)) :textDocument (:synchronization (:willSave t :didSave t :willSaveWaitUntil t) :documentSymbol (:symbolKind (:valueSet [1 2 3 4 5 6 7 8 9 10 11 12 ...]) :hierarchicalDocumentSymbolSupport t) :formatting (:dynamicRegistration t) :codeAction (:dynamicRegistration t) :completion (:completionItem (:snippetSupport t))))

For the second issue, I will wait to have this working and try to give you more informations.

from emacs-ccls.

dlyr avatar dlyr commented on July 29, 2024

btw

(setq ccls-extra-init-params '(:client (:snippetSupport :json-false)))

do not change the behavior

from emacs-ccls.

MaskRay avatar MaskRay commented on July 29, 2024

(setq ccls-extra-init-params '(:client (:snippetSupport :json-false)))

Since Sep 14, the initialization option client.snippetSupport: false will instruct ccls to disable LSP snippets in completion items. Please ensure your company-lsp emacs-ccls and ccls are up-to-date.

Can you use strace -e write -f -p $(pgrep -fn ccls) or sysdig -As9999 --unbuffered -p '%evt.time %evt.buffer' "proc.exe contains ccls and fd.type=pipe" to dump textDocument/completion responses?

{"jsonrpc":"2.0","id":11,"result":{"isIncomplete":false,"items":[{"label":"result : struct Result","kind":5,"detail":"Out_cclsInfo","sortText":"...........","filterText":"result","insertText":"result","insertTextFormat":1,"textEdit":{"range":{"start":{"line":64,"character":8},"end":{"line":64,"character":8}},"newText":"result"},"additionalTextEdits":[]}

Take a look what insertText and textEdit are. They should contain $1 style LSP snippets. company-lsp is supposed to interpret them. (setq company-backends '(company-lsp)) may also help.

from emacs-ccls.

dlyr avatar dlyr commented on July 29, 2024

Packages version :
company-lsp 20180917.2244 installed Company completion backend for lsp-mode.
ccls 20181007.524 installed ccls client for lsp-mode
$ git log ea8f6cb8 (HEAD -> master, origin/master, origin/HEAD) Misc

I could not install sysdig (not in debian buster repository as I write these lines ...)
So here is what I get with strace (repages without ascii code)

Content-Length: 466....{"jsonrpc":"2.0","id":6,"result":{"isIncomplete":false,"items":[{"label":"bar(int a, double b, std::string c) -> void","kind":2,"detail":"foo","sortText":"...........","insertText":"bar(${1:int a}, ${2:double b}, ${3:std::string c})$0","filterText":"bar","insertTextFormat":2},{"label":"bar2(double a, double b) -> void","kind":2,"detail":"foo","sortText":"........../","insertText":"bar2(${1:double a}, ${2:double b})$0","filterText":"bar2","insertTextFormat":2}]}}

and with (setq ccls-extra-init-params '(:client (:snippetSupport :json-false)))

Content-Length: 387....{"jsonrpc":"2.0","id":7,"result":{"isIncomplete":false,"items":[{"label":"bar(int a, double b, std::string c) -> void","kind":2,"detail":"foo","sortText":"...........","insertText":"bar(","filterText":"bar","insertTextFormat":1},{"label":"bar2(double a, double b) -> void","kind":2,"detail":"foo","sortText":"........../","insertText":"bar2(","filterText":"bar2","insertTextFormat":1}]}}

Seems coherent with what you expect right ?

But the final insertion still insert the ->void for instance. Btw the behavior is not the same when strace is running (I could not guess why), the completion is just bar( and stops.
Well I test again, and get this insertText ...

Content-Length: 453....{"jsonrpc":"2.0","id":4,"result":{"isIncomplete":false,"items":[{"label":"bar(int a, double b, std::string c) -> void","kind":2,"detail":"foo","sortText":"...........","insertText":"bar(int a, double b, std::string c) -> void","filterText":"bar","insertTextFormat":1},{"label":"bar2(double a, double b) -> void","kind":2,"detail":"foo","sortText":"........../","insertText":"bar2(double a, double b) -> void","filterText":"bar2","insertTextFormat":1}]}}    

from emacs-ccls.

MaskRay avatar MaskRay commented on July 29, 2024

So here is what I get with strace (repages without ascii code)

"insertText":"bar(${1:int a}, ${2:double b}, ${3:std::string c})$0"

This is expected when snippetSupport is enabled (with company-lsp installed)

and with (setq ccls-extra-init-params '(:client (:snippetSupport :json-false)))

"insertText":"bar("

This is also correct. When snippetSupport is disabled, only text before the first placeholder is inserted.

But the final insertion still insert the ->void for instance.

This is the snippetSupport: false case. It couldn't happen. Please make sure company-lsp is indeed chosen as the only company-backends item (you can add more once you get a usable configuration).

You can open company-lsp.el, and add some (message (format "+++ %s %s" label insert-text)) in (defun company-lsp--post-completion (candidate), to confirm company-lsp is used and insertText instead of label is inserted. With ccls HEAD, you should find textEdit.newText in the response.

According to https://microsoft.github.io/language-server-protocol/specification

/**
 * An edit which is applied to a document when selecting this completion. When an edit is provided the value of
 * `insertText` is ignored.
 *
 * *Note:* The range of the edit must be a single line range and it must contain the position at which completion
 * has been requested.
 */
textEdit?: TextEdit;

from emacs-ccls.

dlyr avatar dlyr commented on July 29, 2024

Issue solved:
I first update ccls (and then see textEdit part in company-lsp--post-completion message which was not the case before). Then I get inserted @{$1 chars instead of snippet completion

Then I install and activate yasnippet, I just don't get that I have to to get nice completion working.

I will test now the other issue I have and try to give you proper way to reproduce.
Thanks for all.
++ d

from emacs-ccls.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.