Fork me on GitHub
#spacemacs
<
2022-04-29
>
Brian Beckman01:04:14

? Spacemacs + clj-refactor problems ? [SOLVED; ty @didibus and @jr0cket] Some documentation says that installing the clojure layer in Spacemacs automatically loads clj-refactor, but none of the cljr-blahblah functions show up in Meta-X. Then I read I should do (clojure :variables clojure-enable-clj-refactor t)) in the layer spec, but that sends Spacemacs into death-recovery mode. Then I tried installing the clj-refactor package in the Spacemacs place dotspacemacs-additional-packages and doing

(require 'clj-refactor)
(defun my-clojure-mode-hook ()
  (clj-refactor-mode 1)
  (yas-minor-mode 1)
  (cljr-add-keybindings-with-prefix "C-c C-m")
  )
(add-hook 'clojure-mode-hook #'my-clojure-mode-hook) 
and various permutations of that in dotspacemacs/user-config, but still none of the cljr-blahblah functions show up. any clues for me?

didibus05:04:40

All I have is:

(clojure :variables
              clojure-backend 'cider
              clojure-enable-clj-refactor t
              clojure-enable-linters 'clj-kondo)
And I'm on the develop branch, and it works

👍 1
practicalli-johnny08:04:13

The official guide to the Clojure layer is at https://develop.spacemacs.org/layers/+lang/clojure/README.html#enabling-sayid-or-clj-refactor Yes, @didibus is correct that clj-refactor and other features are optional on the layer. Any http://www.spacemacs.org layer documentation is likely to be several years out of date, so the http://develop.spacemacs.org version should be used. develop branch has been the default branch for a long time now, and the defacto branch used for many years.

👍 1
practicalli-johnny08:04:36

You could also refer to https://practical.li/spacemacs/ which uses the develop branch of Spacemacs

👍 1
Drew Verlee05:04:42

And for the weirdest bug i have ever come across. simple moving my mouse over this variable causes emacs to to use 100% cpu and crash

Drew Verlee05:04:19

i'm going to see if re-naming it does anything, just bc i have no idea what better to do.

Drew Verlee05:04:23

yes. re-naming it means it doesn't crash. I can reliable crash emacs just with that specific name.

Drew Verlee05:04:09

maybe bc it starts with "comment"?

practicalli-johnny08:04:23

I wonder if its Emacs that is using the CPU or is Emacs blocked by a process it shelled out to that is using the CPU? e.g. clojure-lsp ? Perhaps look at the spawned processes as the mouse moves over that name https://practical.li/spacemacs/install-spacemacs/troubleshooting.html#issues-with-spawned-processes If Emacs lsp-ui has the docs mouse over docs enabled, you may have found a bug with lsp-ui or possibly clojure-lsp

👀 1
ericdallo15:05:02

I don't think it's LSP related but you never know 😂 I suspect it could be related to clojure-mode or something, I suggest you toggle-debug-on-quit and when everything freezes or cause the issue hit C-g to get a stack where emacs was

jacob.maine18:05:06

I’ve had freezes too, always when interacting with functions whose name starts with “comment”! For me, I don’t think it was on hover, though I can’t remember perfectly. I’d also be surprised if it’s clojure-lsp, since clojure-lsp operates primarily on tokens (i.e. the full function name), not parts of tokens. But you never know.

☝️ 1
practicalli-johnny19:05:25

I've just sent the CPU to over 100% after typing in comment-selection which should have been a snippet that expanded, but it wasn't recognised as a snippet and now Emacs is keeping my laptop warm... TAB or j with the cursor over comment sends the Emacs process into a frenzy... C-g stops what ever process is using all the cpu...

practicalli-johnny20:05:54

Interesting. Logging the commands I get C-g pupo/close-window which seems to suggest that purpose-popwin is trying to do something. Could the auto-completion be using purpose-powin to draw the popups and somehow be getting stuck trying to do something?

ericdallo20:05:23

never heard of that package/function 😂 which package calls it in the stack? lsp-mode/clojure-mode etc

practicalli-johnny20:05:13

line 38 has an lsp process

ericdallo20:05:03

still, it seems to come from clojure--looking-at-non-logical-sexp , clojure-mode

practicalli-johnny20:05:54

I can instantly fix the issue by running lsp-workspace-shutdown

practicalli-johnny20:05:07

but then I dont have LSP anymore and I am sad 😞

ericdallo20:05:14

probably lsp is trying to do something that under the hood end up calling a clojure-mode function which causes that

practicalli-johnny20:05:20

seems like a case of clojure-mode conflicting with clojure-lsp in some strange way as it just doesnt happen with lsp disabled

ericdallo20:05:23

so the fix would be on clojure-mode still

ericdallo20:05:24

yeah, it's the lsp hover feature, which tries to color the token using the major mode, in this case clojure-mode, which seems that function has some performance regex issue

ericdallo20:05:41

if you manage to repro calling that function manually, you could open a issue on clojure-mode

practicalli-johnny20:05:34

Is that the hover feature for docs, or for auto-complete (or are they the same thing)

practicalli-johnny20:05:29

Ah yes, if I disable docs popup completely then I do not get the lockup with lsp running. Initially I had disabled the docs popup for the cursor but not for mouse, so a little strange ciojure-mode is causing a lockup. I will try and see if I can figure out something meaningful to report on clojure-mode Thank you.

👍 1
ericdallo20:05:53

yeah, probably the issue is that the hover docs show markdown clojure code, and to color that markdown we call the major mode which knows how to color it, in this case clojure-mode

practicalli-johnny21:05:34

Hmm, I has assumed there wouldnt be any docs for the piece of text by itself, i.e. comment-seperatoror (spelt incorrectly on purpose) yet lsp seems to be trying to font lock the markdown for it. Is this normal?

lsp--fontlock-with-mode("
clojure\ncomment-separatoror\n
\n\n----\n\n*[/home/..." lsp--render-markdown)
  lsp--render-string("
clojure\ncomment-separatoror\n
\n\n----\n\n*[/home/..." "markdown")
  lsp--render-element(#<hash-table equal 2/2 0x1591b67bd835>)
  #f(compiled-function (contents server-id) #<bytecode 0x7a9334e0f6d7b8a>)(#<hash-table equal 2/2 0x1591b67bd835> clojure-lsp)
  apply(#f(compiled-function (contents server-id) #<bytecode 0x7a9334e0f6d7b8a>) #<hash-table equal 2/2 0x1591b67bd835> clojure-lsp nil)
  lsp-clients-extract-signature-on-hover(#<hash-table equal 2/2 0x1591b67bd835> clojure-lsp)

practicalli-johnny21:05:17

Oh, it seems like lsp is rendering docs for text, although if I change the text and hover over with the mouse the doc is for the previous text.. very strange..

practicalli-johnny21:05:56

This is quite curious. Originally the text was comment-separatoror and then I change it to fish-and-chips and when I hover over with the mouse I get a doc with the previous text.

ericdallo21:05:42

Sounds like outdated analysis from clojure-lsp, although not related to the performance issue

practicalli-johnny21:05:25

I think its because the backtrace has stopped everything in Emacs. I guess that is how it works, first time I've tried to use it in a while. I've had to reboot emacs.

👍 1