Fork me on GitHub
#emacs
<
2022-11-16
>
devn16:11:14

i seem to be having issues with a fresh install of doom emacs

devn16:11:40

namely, I cannot complete (System/g|) for example in the buffer, but it will complete in the cider REPL buffer

jkxyz16:11:22

Are you using clojure-lsp? I’m not sure if it supports Java method completions yet, and with (clojure +lsp) in init.el, it now disables cider completion in Clojure buffers in favor of just lsp. It’s kinda frustrating when doing interop work so I wrote a function to toggle between cider and lsp completion. Can’t guarantee it works 100%.

(defun jk/toggle-cider-completion ()
  "Toggle between lsp-mode and cider-mode completion in the current buffer."
  (interactive)
  (if (-contains-p completion-at-point-functions #'cider-complete-at-point)
      (progn
        (remove-hook 'completion-at-point-functions #'cider-complete-at-point t)
        (add-hook 'completion-at-point-functions #'lsp-completion-at-point nil t))
    (progn
      (add-hook 'completion-at-point-functions #'cider-complete-at-point nil t)
      (remove-hook 'completion-at-point-functions #'lsp-completion-at-point t))))

devn17:11:43

i have both cider and lsp

devn17:11:53

so i assumed i’d get cider AND lsp

devn17:11:28

in my init.el i only have clojure, not (clojure +lsp)

devn17:11:42

and then i configure clojure-lsp in config.el

devn17:11:46

maybe one is clobbering the other

jkxyz17:11:15

If you’re configuring clojure-lsp manually then I would imagine that you’d get both completions by default. Doom explicitly disables cider completions but only with +lsp afaik. It may be that they’re clobbering each other somehow, yeah.

devn17:11:46

hmmm, thanks for your help. will try to explicitly turn off lsp’s completions, though i guess i was hoping for both to work magically together 🙂

jkxyz17:11:51

No problem. If you find a good solution please share :) I’ve been doing a lot of interop lately and this workaround was my quick solution. You could try to describe-variable on completion-at-point-functions to see if cider is there or if it’s being removed somehow

devn17:11:21

yep that was it

devn17:11:05

(setq lsp-enable-completion-at-point nil)

devn17:11:13

and now it is using cider completion

jkxyz17:11:18

So I guess lsp-mode is disabling cider completion. I wish there was an easy way to get the best of both worlds…

devn17:11:36

same here 😕

devn17:11:02

it may also just be the order that the modes are loaded in or how i have my hooks executing

devn17:11:46

so perhaps lsp doesn’t actively disable cider completion, it just sets itself up to handle completion

jkxyz17:11:24

I think that’s probably it

Cora (she/her)04:11:45

calva tries to use both, fwiw, but doesn't surprise me that the clojure module leans hard on lsp when it's enabled. I don't actually use company mode myself

Cora (she/her)04:11:35

also, fwiw @U06DQC6MA there's a #doom-emacs channel

djm08:11:03

I think you can get the best of both worlds with https://github.com/minad/cape. Something like

(setq-local completion-at-point-functions (list (cape-super-capf #'cider-complete-at-point
                                                                 #'lsp-completion-at-point)))
to set it up temporarily in the current buffer. (May or maybe not do anything useful in Doom)

👍 1
Jimmy Miller16:11:13

I am getting really weird behavior from moving my mouse in the terminal. I think this is emacs misinterpreting escape sequences it is getting? Here is a gif of me just moving my mouse, no keypresses or anything. It just starts inserting "M" and ";" and random numbers. I think this started when I updated emacs. I have (xterm-mouse-mode 1). My term is set to xterm-256color. Anyone run into this issue? Any idea how to fix it?

dpsutton17:11:25

which terminal? And can you try in another terminal? (i have no idea but what a fascinating bug)

😅 1
Jimmy Miller17:11:13

MacOS terminal. Will try iterm2

enn17:11:49

@U5K8NTHEZ I have had the same problem since some recent upgrade of something (emacs? iterm? not sure). So has @U0GTWEP96. Neither of us has found a solution yet (except to disable xterm-mouse-mode which is not really a solution). If you figure it out please let me know!

Jimmy Miller17:11:57

Must be emacs since I don't use iterm

Jimmy Miller17:11:17

Yep. I can recreate in iterm

Jimmy Miller17:11:24

So happy to hear others are having the problem!

enn17:11:56

Yes, I get it in all terminal emulators so must not be iterm. It happened at the same time that the values reported by M-x list-colors-display changed (I know because it broke my color theme). I used to have 256 colors with names like color102. Now I have 556 colors with names like lightsalmon3. I suspect a relationship but I don’t know enough about Emacs and ANSI color stuff to say for sure.

Jimmy Miller17:11:21

Yes, my color scheme broke as well

César Olea18:11:18

What would be the steps to reproduce? Run emacs in terminal, M-x xterm-mouse-mode and start moving the mouse? I'd like to try and reproduce.

Jimmy Miller18:11:01

It is hard for me to make a minimal reproducible case. Because the gif is the exception it usually doesn't happen that frequently. I can get it to happen in different modes, different files etc. One thing that seems to make it happen more often is doing a cider jack-in on a clojure repl. This is emacs init.el btw https://github.com/jimmyhmiller/dotfiles/blob/master/.emacs.d/init.el

enn18:11:55

@U02DNF3TW3E it only happens in Clojure buffers (including CIDER repls) for me.

Jimmy Miller19:11:51

Doing some testing, I can get it to work in other modes, but only after a cider jack-in has been run in my emacs session.

😱 1
César Olea19:11:14

It might have something with cider or emacs-mode and not necessarily with emacs. I can't reproduce starting emacs with -Q but I haven't tried loading cider with an emacs instance started with -Q. I'll try later.

Jimmy Miller19:11:12

Yes it does seem to be cider. At the very least, as soon as I cider-jack-in I can reliably recreate it.

dpsutton19:11:42

that is… strange

Jimmy Miller19:11:42

If you do c-h k and move the mouse around, you can see how the coordinates are sent for the mouse. Those seem to somehow be making their way into the buffer and misunderstood.

Casey21:11:25

Wow this is a fascinating bug. I haven't experienced this issue but I'll be watching to see what the cause is. 🍿

César Olea00:11:22

I'm running emacs -Q -nw in a terminal (alacritty) in Ubuntu and eval'ed the following code:

(let ((frame-background-mode 'dark))
  (frame-set-background-mode nil))

(defvar bootstrap-version)

(let ((bootstrap-file
      (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
      (bootstrap-version 5))
  (unless (file-exists-p bootstrap-file)
    (with-current-buffer
        (url-retrieve-synchronously
        ""
        'silent 'inhibit-cookies)
      (goto-char (point-max))
      (eval-print-last-sexp)))
  (load bootstrap-file nil 'nomessage))

(straight-use-package 'use-package)

(setq straight-use-package-by-default t)

(use-package clojure-mode)
(use-package cider)
Feel free to ignore the straight.el parts. I then M-x xterm-mouse-mode and M-x cider-jack-in move my mouse like crazy and can't reproduce 😞 I was kinda hoping that I could see it in my computer.

enn13:11:00

just curious, what color space do you see with M-x list-colors-display?

Jimmy Miller15:11:59

I see 256 colors. Is there other information you need from that command?

Jimmy Miller15:11:09

@U02DNF3TW3E I ran your commands and evaled that and was able to recreate it. So maybe its a mac thing?

César Olea16:11:17

Maybe. I have a mac M1 available I'll try to replicate there as well.

César Olea22:11:06

Unfortunately I was unable to replicate on Mac either. MacOS Monterey w/ Emacs 29 (self compiled) running in Alacritty as terminal. Sorry I’m not of much help.

enn13:11:17

Jimmy: thanks. I had this hypothesis that this problem was related to a change in color space, because I thought I was seeing ANSI color codes, but if you still have 256 colors it sounds like probably not. I think your explanation of mouse movement cursor control codes making it into the buffer makes more sense.

tcrawley13:12:21

I did some debugging here, and I think it is caused by something that changed in emacs 28. Using cider 1.5.0 & clojure-mode 5.15.1, I can recreate this in emacs 28.1 (only after running cider-jack-in) , but can't in emacs 27.1. I'm on linux.

tcrawley14:12:54

Though using @U02DNF3TW3E’s code above and starting emacs with -Q (with the addition of (xterm-mouse-mode 1) ), I can't recreate it. So it may be from an interaction with some other package I have installed.

Jimmy Miller15:12:21

@U06SGCEHJ that sounds right to me. I have another Mac that is still on 27 that had no problems.