cider icon indicating copy to clipboard operation
cider copied to clipboard

Compatibility with clojure-lsp?

Open dijonkitchen opened this issue 5 years ago • 11 comments

Is the functionality in CIDER compatible with https://github.com/snoe/clojure-lsp ? I figure that would allow all of the CIDER goodies to work across platforms/editors if it was under LSP.

dijonkitchen avatar Nov 13 '19 16:11 dijonkitchen

Is the functionality in CIDER compatible with https://github.com/snoe/clojure-lsp ?

Compatible in what sense? You can run an LSP server alongside nREPL if that's what you're asking for, but you'll have to be careful with cider-mode and lsp-mode interfering with one another.

I figure that would allow all of the CIDER goodies to work across platforms/editors if it was under LSP.

CIDER's backend is already portable, as nREPL is an open protocol and everything's just nREPL middleware. We can certainly implement LSP in terms of nREPL and provide a runtime-powered alternative to clojure-lsp, but that's not a priority for me and someone will have to tackle it if they want to see it happen.

bbatsov avatar Nov 13 '19 16:11 bbatsov

I use lsp alongside of CIDER. They work fine together but i have the following config. It mainly makes CIDER in charge of indentation and completion.

(use-package lsp-mode
  :init
  (setq lsp-clojure-server-command '("bash" "-c" "cd ~/projects/clojure/clojure-lsp && lein run"))
  (setq lsp-enable-indentation nil)
  (setq lsp-enable-completion-at-point nil)
  ;; (setq indent-region-function #'clojure-indent-function)
  (add-hook 'clojure-mode-hook #'lsp)
  (add-hook 'clojurec-mode-hook #'lsp)
  (add-hook 'clojurescript-mode-hook #'lsp)
  :config
  (require 'lsp-clojure)
  (add-to-list 'lsp-language-id-configuration '(clojure-mode . "clojure"))
  (add-to-list 'lsp-language-id-configuration '(clojurec-mode . "clojure"))
  (add-to-list 'lsp-language-id-configuration '(clojurescript-mode . "clojurescript")))

dpsutton avatar Nov 13 '19 19:11 dpsutton

@dpsutton Alternatively you can disable the LSP indentation/completion when cider-mode kicks in and enable them when it's turned off.

bbatsov avatar Nov 13 '19 19:11 bbatsov

@bbatsov oh i like that! i'm gonna switch it over

dpsutton avatar Nov 13 '19 19:11 dpsutton

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution and understanding!

stale[bot] avatar Feb 11 '20 20:02 stale[bot]

@dpsutton did you manage to make them play well together?

caioaao avatar Mar 11 '20 12:03 caioaao

I'm trying to use LSP + Cider and one problem I see is that Cider redefines the key mappings for things like <M-.> and <C-.>. I'd prefer to be able to tell Cider not to be xref and imenu provider because I prefer LSP for that. Right now the only way to achieve this is to re-set these bindings to what I want after cider-mode is enabled or maybe sth. else.

gdanov avatar Oct 28 '20 21:10 gdanov

Hey all, I hope this helps :) https://emacs-lsp.github.io/lsp-mode/tutorials/clojure-guide/

ericdallo avatar Jan 09 '21 19:01 ericdallo

that's pretty cool, thanks. One problem I keep having is alternating the formatting between cider and lsp. I'm using latest stable releases for both while your example seems to use unstable versions?

gdanov avatar Jan 10 '21 14:01 gdanov

Yes, @gdanov they should not conflict with each other AFAIK, lsp formatting is achieved via lsp-format-buffer or lsp-format-region, while cider use ident-region, what exactly you do to conflict?

ericdallo avatar Jan 10 '21 15:01 ericdallo

lsp seems to be interacting with indent-region by advising it. Not sure how and why

   - paredit-forward-slurp-sexp                                    99  15%
    - paredit-forward-slurp-into-list                              99  15%
     - indent-region                                               99  15%
      - apply                                                      99  15%
       - ad-Advice-indent-region                                   99  15%
        - #<compiled 0x4346481f>                                   99  15%
         - lsp-format-region                                       99  15%

gdanov avatar Jan 18 '21 21:01 gdanov