emacs

Consider also joining #cider, #lsp and #inf-clojure, where most of the tool-specific discussions are happening.
shem 2020-05-11T06:27:54.229600Z

@pesterhazy does this coexist peacefully with Cider, or is it orthogonal?

pesterhazy 2020-05-11T06:42:19.231300Z

@shem I haven’t tried but I think they can be combined (like flycheck-joker can be combined with cider)

shem 2020-05-11T06:43:19.231800Z

ok, will try it at some point.

practicalli-john 2020-05-11T11:37:41.241400Z

@shem @pesterhazy CIDER in terms of features is already a super-set of the current Language Server Protocol, although CIDER is using nrepl rather than the LSP specification. If you are satisfied with CIDER then the only benefit at present seems to be the ability to do some things without the REPL running. If your computer is resource limited or you wish to have a large number of Clojure project open and have auto-complete, find definition and some refactoring available, then LSP would be very useful. I am still trying to find an LSP implementation for Clojure that actually implements the complete LSP specification. The options t have LSP functionality without a REPL I have tried so far include: • clj-kondo-standalone - this is clj-kondo lint tool for environments that dont support running clj-kondo binary (eg. android devices - yes some people run emacs on Android). This is not intended to be a full LSP implementation • anakondo - https://github.com/didibus/anakondo - a early stage static analysis tool that provides LSP features based on clj-kondo - this is very easy to install as an Emacs package and the clj-kondo binary There is also clojure-lsp - https://github.com/snoe/clojure-lsp - this seems fairly complete although I have been unable to get this to work as yet so haven't tested it. Are there any others? Ideally LSP implementations for Clojure in Emacs would be folded into the CIDER orchard, providing a way to do all non-evaluation actions without a REPL and I believe there are no technical barriers to do so, someone just needs to contribute the work.

practicalli-john 2020-05-11T11:49:43.246200Z

One thing to be aware of is that LSP implementations are typically based on static analysis, so the whole code base of a project and its dependencies will need to be evaluated before the LSP functions work. If the static analysis blocks Emacs UI whilst processing, then the user will need to wait for that analysis to complete. I have found analysis can take far longer than starting a REPL for some project. Obviously as LSP implementations mature, then these issues should be resolved. Any feedback and contributions you can give to these project I am sure would be most beneficial in making them more robust and performant.

2020-05-11T12:31:16.246900Z

i didn't think anakondo was lsp-based -- is it?

dpsutton 2020-05-11T12:36:43.247600Z

No it’s not. The only lsp on this list is untested

Snaffu 2020-05-11T14:08:20.248400Z

+1 on clojure-lsp, that is what I've been using. Its seemed the most complete when I was searching a couple months back.

practicalli-john 2020-05-11T14:23:07.250400Z

clj-kondo-standalone is used via LSP, where as clj-kondo is a backend for flycheck. Although as stated it is not trying to be a full LSP implementation

practicalli-john 2020-05-11T16:34:51.266900Z

I have got clojure-lsp to work now, using a similar config used for clj-kondo-standalone. The biggest drawback I have is a very slow startup time for Emacs now, taking over a minute the first time it carried out static analysis over my open projects. Most of my projects are small and have few dependencies, so will investigate why its taking so long. I think its a particular project that is taking up most of the time, that was the case when using anaconda to statically analyse my code. Consecutive restarts of Emacs also take about 30 seconds to start up, which is very noticable compared to the usual 3 seconds. clojure-lsp seems to be at least reviewing all the projects, I assume to check for changes. I assume its not running an analysis from scratch. Considering it takes less than 2 seconds to start a REPL and another couple to evaluate a project, there is a big up front cost to LSP for me compared to running a REPL. If there is anyway to reduce startup time then that would be good to know (apart from closing all the projects I regularly work on) I havent found a compelling reason to include LSP as part of my regular workflow yet, but hope that these small inconvieniences can be ironed out

dpsutton 2020-05-11T16:44:25.267900Z

> Consecutive restarts of Emacs also take about 30 seconds to start up this is wild. lsp-mode has not affected startup for me at all. the lsp process runs in the background and does slow emacs down when first visiting a file from a project

practicalli-john 2020-05-11T17:05:20.268500Z

it was not what I was expecting, so am trying to diagnose over the next couple of weeks.

Snaffu 2020-05-11T17:57:41.271900Z

There was a note, I believe on the main github page regarding the startup times. Going from memory but I think it was something to do with some JSON parsing that is happening behind the scenese. The suggestion was to use Emacs v27 or higher as apparently the JSON parsing was much improved in that release. Sorry, don't remember the details at more fine grained level. I've been running it on 26.3 myself with no issues, but my laptop is new and it was pretty snappy so I didn't dig into it any further.

pesterhazy 2020-05-11T18:01:22.272200Z

@snaffu I think you mean this section https://emacs-lsp.github.io/lsp-mode/page/installation/#performance

pesterhazy 2020-05-11T18:02:44.273300Z

I'm not seeing startup perf problems, but sometimes editing/typing gets very slow, especially (?) when aggressive-indent-mode is active

pesterhazy 2020-05-11T18:03:34.274100Z

I haven't figured out yet what's causing this dramatic slowdowns: sometimes with lsp-mode active it can take seconds for characters to appear on the screen

pesterhazy 2020-05-11T18:07:06.276700Z

I'm now trying the settings suggested in the link above - seems better

pesterhazy 2020-05-11T18:08:23.277700Z

I have a feeling it's related to autocompletion, but not sure

Snaffu 2020-05-11T18:10:41.279500Z

@pesterhazy - Yes that is the comment that I was trying to recall. It was definitely a startup time issue. The issue you mention while typing I have seen on an i5 pc inside a VM that is pretty constrained resources, something like 4G RAM and 2 cores where I was using LSP for Python. I haven't seen this on my other PCs, but they are i7 systems with a lot of cores and RAM so that didn't surprise me. Yeah, I agree with you, I think may be related to auto-complete, that is where I noticed it as well.

pesterhazy 2020-05-11T18:12:22.280400Z

I'm going to disable company-mode. I don't think I want auto-completion anyway, and I've never liked the way it worked in Emacs (perhaps I also just never had it set up correctly)

dpsutton 2020-05-11T18:21:18.281300Z

i remember disabling autocomplete from lsp and using CIDERs

practicalli-john 2020-05-11T20:29:26.284200Z

Thanks @snaffu I have a few projects that have some geojson files in, so if the clojure-clj binary is statically analysing those files it could explain a lot of problems. I had assumed that it would only part clojure files and not json when analysing a project. I have mostly finished with those projects with geojson files, so I will remove them from Emacs and see if it affects startup times.

practicalli-john 2020-05-11T20:31:07.285800Z

@pesterhazy I had issues with Emacs not redrawing the cursor straight away, turned out it was due to the desktop compositor I was using. I disabled it and the lag was fixed instantly and Emacs felt even faster.

practicalli-john 2020-05-11T20:35:03.289100Z

@dpsutton I use a snippet via auto-complete to add the fully qualified namespace when creating a new file. This seems to work with clojure-lsp and anakondo, so thats actually a plus point for LSP for me 🙂 I'll try and stick with LSP during the week, although I'm going to disable it for my live broadcasts at the weekends just so I have one less thing to be concerned about.

hindol 2020-05-12T19:53:58.293100Z

Auto creating the qualified ns at the top for new files work for me using CIDER as well. Did not configure anything.

practicalli-john 2020-05-12T23:01:43.297500Z

The ns snippet was only adding the name of the current namespace when CIDER runs a REPL. With LSP or anakondo the ns snippet works without the need of a running REPL (actions without a REPL was one of the mentioned benefits of LSP that we were discussing)

hindol 2020-05-13T07:28:22.297700Z

Oh yes, that is a key difference. Good point.

hindol 2020-05-13T07:29:07.297900Z

I always leave the REPL running so never noticed that.

dpsutton 2020-05-11T20:53:45.289600Z

for sure! i'd love to watch a few live streams if you have a link that i can watch

practicalli-john 2020-05-11T21:06:54.290800Z

All my videos and live streams are via https://www.youtube.com/c/practicalli I have a years worth of video, mostly done with Emacs/Spacemacs with Clojure if you are stuck for things to do during the pandemic.

👍 2
❤️ 2
bartuka 2020-05-11T23:02:58.292Z

I was looking for a live stream using spacemacs to get a feel how people usually work with vim bindings inside emacs.