Skip to content
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

Not seeing suggestion in C++ (lsp + company) #20

Closed
apmanol opened this issue Mar 19, 2023 · 8 comments
Closed

Not seeing suggestion in C++ (lsp + company) #20

apmanol opened this issue Mar 19, 2023 · 8 comments

Comments

@apmanol
Copy link

apmanol commented Mar 19, 2023

Hello all,

trying to play around with this awesome software, bad it doesn't work in C++ mode with lsp enabled.

A snippet of the .emacs can be found https://gist.github.com/apmanol/6ab0bb12174d3f1fc9b7b2ff1e4fa909 it's a setup with lsp + company + company lsp.

The server seems to work as it seems in the logs and in the diagnose but autocomplete doesn't work.
Furthermore, without lsp mode i.e. scratch, I can see suggestions and server communication.

completion-at-point-functions is a variable defined in ‘minibuffer.el’.

Its value is
(codeium-completion-at-point tags-completion-at-point-function)

Probably, I miss something, but I can't find out anything.

thanks for any tips.

@Alan-Chen99
Copy link
Contributor

Alan-Chen99 commented Mar 20, 2023

whats the value of completion-at-point-functions local to the buffer you are completing in?
If you instead see lsp completions, then you need to manually reorder the priorities (probably on your mode hook). If you want to see both I recommend cape-super-capf

Edit: I meant "completion-at-point-functions" instead of "codeium-completion-at-point"

@akhil3417
Copy link

akhil3417 commented Mar 21, 2023

a better way would be to prepend codeium-completion-at-point to current value of completion-at-point-functions and call it manually in buffers you want codeium completion , different modes have different buffer local values for completion , if you are trying to add a hook add an delay of few seconds so that its setup correctly after the default mode hooks have been setup.

(defun add-codeium-completion ()
  (interactive)
  (setq completion-at-point-functions
        (cons 'codeium-completion-at-point
              completion-at-point-functions))
  (setq-local company-frontends
              '(company-pseudo-tooltip-frontend
                company-preview-frontend))
  (setq company-minimum-prefix-length 0))

(defun remove-codeium-completion ()
  (interactive)
  (setq completion-at-point-functions
        (delete 'codeium-completion-at-point
                completion-at-point-functions))
  (setq company-frontends
        '(company-box-frontend company-preview-frontend))
  (setq company-minimum-prefix-length 2))

for adding delay you can use :

    (add-hook 'python-mode-hook
                (lambda)
                (run-with-timer 2 nil
                                (lambda()
                                  (add-hook 'post-command-hook
                                    #'add-codeium-completion))))

@Alan-Chen99
Copy link
Contributor

Alan-Chen99 commented Mar 21, 2023

While what @akhil3417 have is fine, you probably want something much less aggressive, like

(add-hook 'python-mode-hook
    (let ((buf (current-buffer)))
        (run-with-timer 2 nil
            (lambda ()
                (with-current-buffer buf
                    (add-codeium-completion))))))

You would otherwise have a very hard time of turning codeium off.

@Alan-Chen99
Copy link
Contributor

Also, if you don't have any other deferred things, you shouldn't need the timer.

@apmanol
Copy link
Author

apmanol commented Mar 22, 2023

whats the value of completion-at-point-functions local to the buffer you are completing in? If you instead see lsp completions, then you need to manually reorder the priorities (probably on your mode hook). If you want to see both I recommend cape-super-capf

Edit: I meant "completion-at-point-functions" instead of "codeium-completion-at-point"

Its value is
(lsp-completion-at-point codeium-completion-at-point tags-completion-at-point-function)
Local in buffer xxx.cpp```

@apmanol
Copy link
Author

apmanol commented Mar 22, 2023

I removed the company-lsp because it isn't supported anymore, from lsp-mode and now codeium is autocompleting only the comments in the code! That is some progress.

@apmanol
Copy link
Author

apmanol commented Mar 25, 2023

I replaced the company with corfu and cape + capf and things are much better now.

Would you like to leave the bug open, since the setup with the company didn't go very smoothly?

@fortenforge
Copy link
Contributor

Closing this since your issue is resolved. I created a new issue to track the particular problem you had with company.

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

No branches or pull requests

4 participants