doomemacs icon indicating copy to clipboard operation
doomemacs copied to clipboard

Clojure w/ LSP & Cider does not autocomplete in source buffers

Open JonsSpaghetti opened this issue 2 years ago • 5 comments

I confirm that...

  • [X] I have searched the issue tracker, documentation, FAQ, Discourse, and Google, in case this issue has already been reported/resolved.

  • [X] I have read "How to Debug Issues", and will use it to provide as much information about this issue as possible.

  • [X] The issue can be reproduced on the latest available commit of Doom.

  • [X] The issue can be reproduced on a stable release of Emacs, such as 27 or 28. (Doom does not support development builds like 29+ or any version ending in .50 or .9x)

Expected behavior

When I type a symbol in my source buffer, a dropdown menu should display completion options as I type.

Current behavior

When I type in the nrepl buffer I can see completion options in a dropdown. When my TAB is set to use company-indent-or-complete-common I can see completion options in my minibuffer after hitting tab. When I type in a source buffer, I see no completion options at any point even if setting my TAB to use the company-indent-or-complete-common function. The message I see is "No Completion" even when I know one exists.

When enabling nrepl-toggle-message-logging, I see that when I'm typing in the repl. I get these messages:

(-->
  id                        "183"
  op                        "complete"
  session                   "f96cd993-b963-445a-a91b-1ed72abc0ef6"
  time-stamp                "2023-08-29 06:07:33.562218426"
  context                   ":same"
  enhanced-cljs-completion? "t"
  ns                        "io.testproj"
  prefix                    "gr"
)
(<--
  id          "183"
  session     "f96cd993-b963-445a-a91b-1ed72abc0ef6"
  time-stamp  "2023-08-29 06:07:33.585709800"
  completions ((dict "candidate" "greet" "ns" "io.testproj" "type" "function")
 (dict "candidate" "group-by" "ns" "clojure.core" "type" "function"))
  status      ("done")
)

However, when I type in a source buffer, I never see these complete ops and only see eldoc ops.

No backtrace is available because there are no error messages. No concerning output in *Messages*.

After reading through some additional online posts today, I did see that folks were saying that lsp mode loads some stuff that overrides the cider-mode completion so I went ahead and removed the +lsp from my init.el and re-sync'ed my doom and that did solve the issue.

Steps to reproduce

  1. Set up doom config to only have lsp & clojure +lsp enabled.
  2. Open a clojure project
  3. cider-jack-in
  4. visit the repl and type some function/namespace name.
  5. Visit a source buffer and type some function/namespace name.

System Information

https://pastebin.com/3ecvdGmx

JonsSpaghetti avatar Aug 29 '23 11:08 JonsSpaghetti

I had the same problem, but it turned out I was using an old version of clojure-lsp. Upgrading the clojure-lsp and ensuring that lsp-clojure-custom-server-command points to the correct version seems to have fixed autocompletion for me.

mjmeintjes avatar Sep 02 '23 23:09 mjmeintjes

I had the same problem, but it turned out I was using an old version of clojure-lsp. Upgrading the clojure-lsp and ensuring that lsp-clojure-custom-server-command points to the correct version seems to have fixed autocompletion for me.

@mjmeintjes if you don't mind me asking, do you recall the versions before and after? I have the same issue, but I'm currently on the most recent clojure-lsp (2023.08.06-00.28.06). Thanks!

runejuhl avatar Oct 15 '23 20:10 runejuhl

I'm

I had the same problem, but it turned out I was using an old version of clojure-lsp. Upgrading the clojure-lsp and ensuring that lsp-clojure-custom-server-command points to the correct version seems to have fixed autocompletion for me.

@mjmeintjes if you don't mind me asking, do you recall the versions before and after? I have the same issue, but I'm currently on the most recent clojure-lsp (2023.08.06-00.28.06). Thanks!

I'm currently using the following versions:

clojure-lsp --version
clojure-lsp 2023.05.04-19.38.01
clj-kondo 2023.04.15-SNAPSHOT 

They seem to work ok.

Not sure what version I was using previously, but it was a couple of years old.

Note that I had the latest version installed, but my lsp-clojure-custom-server-command variable was still pointing to the old version for some reason.

mjmeintjes avatar Oct 16 '23 02:10 mjmeintjes

I put this in the original post but will re add here that it does seem like +lsp in my init.el does seem to interfere with cider mode so when I removed that everything started working. If the version upgrade doesn't work for you I suggest giving that a try.

JonsSpaghetti avatar Oct 16 '23 03:10 JonsSpaghetti

Spacemacs user here. Thanks to this thread I found the following observing similar issues https://github.com/emacs-lsp/lsp-mode/issues/4526

I either:

  • Disablelsp-completion-mode which solves my issue.
  • Add the snippet and rerun clojure-mode which resets it instead of toggling... https://github.com/emacs-lsp/lsp-mode/issues/4526#issuecomment-2282924124

Just upgraded the following from 2023 versions, no difference.

clojure-lsp --version 
clojure-lsp 2024.08.05-18.16.00
clj-kondo 2024.08.01

dmg46664 avatar Oct 05 '24 14:10 dmg46664