Fork me on GitHub
#practicalli
<
2022-11-25
>
Drew Verlee03:11:32

Do you get constant auto complete suggestions? I sure don't, not in any editor (vs or emacs). I'll eval a ns require and still not get completions for those fns brought in.

practicalli-johnny05:11:51

I do get auto-completion most of the time, although there are a few days when it just doesn't work. LSP auto-completion sometime seems to fail if there is something it doesn't like about the code structure, e.g unbalanced Parens or code it can't parse (and something LSP related seemed to occasionally make Emacs unresponsive on the MaxOSX, but never happened on Linux) I think I have had fewer issues with Neovim auto-completion, but I use Emacs more, so more opportunity to fail

practicalli-johnny05:11:46

I haven't use VS Code & Calva in over a year, it's not an effective tool for my workflow. Although the VS Code Live Share is amazing way to collaborate, but I could get anyone to use it for Clojure in a previous job as no one liked the key binding

practicalli-johnny05:11:08

Cider auto-completion (disabling LSP backend) n the REPL was very reliable, although there was the odd day when something didn't work. Usually I just take a break and restart the editor.

practicalli-johnny05:11:53

The most reliable auto-completion I've found was in rebel readline, although that isn't an editor it's a rich terminal Repl UI :)

practicalli-johnny05:11:16

I notice auto-completion issues the most when snippets don't work (I use a lot of snippets), or requiring my own namespaces or calling my own function. I guess I'd probably notice issues when using libraries, not so much with Clojure.core

practicalli-johnny05:11:43

On a side note,I haven't found a good way to configure docs with LSP, so still use cider-doc for that. LSP docs are detailed in the doc popup, but I find that very distracting to have it on. I should ask if there is a way to trigger it with a key binding. The LSP describe thing at point rarely gives anything useful, seems to be missing most of the docs or not as detailed as cider-doc

Drew Verlee07:11:36

I'll try to create a minimal example of where i don't get auto complete where i would expect it.

👍 1
Drew Verlee21:12:31

@U05254DQM contintuing our dicussion from like a month ago. Here is an example where i'm not getting auto complete. I can push this to github if you want along with anything else. I would be in your debt for figuring out why this happens... Here is basically all the code:

(ns core
  (:require [ :as io]
            [clojure.edn :as edn]))


(def error (-> "errors/error.edn"
               slurp
               edn/))
I have run cider-jack-in, that works and edn/ where is my cursor, when pressing tab does nothing when it should return completions. I will however, get tab completion in other cases, projects, times, etc.. it just comes and goes like the wind.

Drew Verlee00:12:59

I bet i have some really fundemental computer package that's not behaving all the time. Like i loaded up the file in doom, and it also didn't auto complete. Then i restarted spacemacs and tried again, and it did. How on earth does one debug something like that.

practicalli-johnny09:12:25

Sounds like a Heisenbug I'll take a look today and see what results I get

practicalli-johnny11:12:00

I wonder if its a conflict between Clojure LSP and CIDER? Or some configuration missing from my Clojure LSP config. In my latest tests I get the following results with the project describe above (closing and opening Emacs between each test) • CIDER REPL only (jack-in) - completion is consistent - a namespace or buffer containing a namespace must be loaded before any completions work (except special forms which always work), this is standard CIDER requirement. • Clojure LSP - no completions on edn/, io/, clojure.edn/ or http://clojure.java.io/ • Clojure LSP and then CIDER REPL (jack-in) no completions • Clojure LSP starting automatically when opening the file, killed LSP with , b s (`lsp-workspace-shutdown`) and start CIDER REPL (jack-in) - completions do not work with LSP alone, after shutting down LSP and then starting CIDER REPL and evaluating the core.clj buffer, , e b then completions for edn/ , io/ work instantly Versions of software used LSP :: lsp-mode <tel:202211302254|20221130.2254>, Emacs 28.1, gnu/linux CIDER 1.6.0-snapshot (package: <tel:202211092212|20221109.2212>)

practicalli-johnny12:12:08

Testing the same project with Neovim 8 and the https://github.com/practicalli/neovim-config-redux seems to work better, although there are subtle differences. I run an external Rebel repl with clojure -M:repl/rebel (practicalli/clojure-deps-edn config) The config starts LSP when a Clojure file is loaded - completion only works for fully qualified name, clojure.edn/ Neovim also automatically connects to the running repl, but does not evaluate anything. Evaluating the buffer then completion with aliases works, edn/ io/

practicalli-johnny12:12:13

Trying Emacs with an external REPL, similar results to using jack-in. However, this time I shut down Clojure LSP (`, s b`) after starting the REPL. Once I evaluated the buffer, the alias completions worked straight away, edn/ io/

practicalli-johnny12:12:26

So initial thoughts are if running Clojure LSP and completions are not working, switch LSP off and evaluate the buffer (or ns form) and require alias completions should work.

practicalli-johnny15:12:50

I https://clojurians.slack.com/archives/CPABC1H61/p1671197029520839 in the #lsp channel and LSP should be doing this kind of completion if you have it enabled. I am not able to get LSP completion to work with my Spacemacs configuration though. I tried the add-hook suggestion, but it makes no difference, so I will just disable LSP in Emacs when I want completion to work and use the CIDER completion instead (which seems to work flawlessly). Or use Neovim...

practicalli-johnny16:12:30

Hmm, it seems some namespaces are not completing when others are. I added a utils namespace to the project and when I required that with an alias, then I could complete using that alias (public functions only of course)

Drew Verlee19:12:46

Thanks for looking into this. I read the LSP thread. See the headache is that sometimes it works for me to. So i have low confidence its just a matter of updating things. And honestly given no reason why the updates would impact this, why would it? This has been happening to me for a year on and off. What we have in common is that im using an old (8 months or so probably) version of your spacemacs config. So could there be something in that, or spacemacs in general that is causing it to be finicky. I have looked and found nothing. The further headache is that i'm not sure how to get good diagnostics info, i raised this question about completions to the cider team and they (over simplification) punted it to LSP. LSP seems to be doing the same (imo). I need to learn exactly how to debug who should be doing the completions and why they aren't and until i provide that level of information (basically fixing the issue) i think autocomplete is going to come and go.

practicalli-johnny20:12:01

After updating Clojure CLI, Clojure-lsp and Emacs lsp-mode package in Spacemacs, I now have LSP doing completion with or without the REPL running. Although I still get some aliases that do not autocomplete. Using the CIDER REPL still seems more reliable but only when LSP is switched off....

Drew Verlee21:12:25

@U05254DQM how are you updating lsp btw. at one point i was doing two steps update the emacs package via "udpate packages" and i think there was also an update-lsp script i was running. Im not sure thats still the best way. This is the script:

➜  cloudwatch git:(master) which update-lsp
update-lsp: aliased to sudo bash < <(curl -s )

practicalli-johnny22:12:49

lsp-update-server shows will update the lsp server for the current mode or if multiple lsp servers are installed, prompts with a list of servers. Selecting one will update that server, downloading the latest available version and placing in into .emacs.d/.cache/lsp or .config/emacs/.cache/lsp if using XDG location for Spacemacs. I also have a clojure-lsp binary installed in ~/.local/bin which I simply download from the https://github.com/clojure-lsp/clojure-lsp/releases for my operating system (for use when I run LSP with other editors or command line stuff)

practicalli-johnny22:12:37

I suspect its an issue with the Emacs lsp-mode or other lsp client code, as Neovim is working fine with treesitter lsp client. Changing the names of the aliases used for requires sometimes makes completion work, but I havent found any useful patterns except to call the alias something different to the last name of the library being required.