Fork me on GitHub
#lsp
<
2021-10-14
>
jumar04:10:19

Can I enable lsp just for one language? I want it for terraform but not for Clojure. I added terraform layer for spacemacs: https://develop.spacemacs.org/layers/+tools/terraform/README.html and installed terraform-lsp. But now it seems that lsp is enabled for clojure files too...

practicalli-johnny05:10:34

You can set the backend to be Cider in the Clojure layer

(clojure :variables clojure-backend 'cider)

practicalli-johnny05:10:17

It seems many Spacemacs layers will use an LSP backend if the LSP layer is added. There should be a variable to set the backend for each layer.

jumar06:10:10

Ok, so basically I need to turn it off for every other language?

practicalli-johnny06:10:01

It depends on the layer, although it seems most layers will default to LSP if the LSP layer is enabled.

tatut07:10:07

I'm getting "too many open files" when I have clojure-lsp open for multiple projects (on macOS Big Sur)

seancorfield07:10:51

My experience with macOS suggests that's an incremental file handle leak in a bunch of software. I typically have to reboot my Mac every 30-60 days to reset that.

seancorfield07:10:29

(! 887)-> uptime
 0:12  up 46 days,  5:30, 36 users, load averages: 2.81 2.57 2.56
and I'm definitely seeing flakiness and slowdowns at this point.

tatut07:10:03

I've recently rebooted, and haven't noticed this issue when not using lsp

seancorfield07:10:43

I typically have LSP running for seven or eight projects, including our monorepo at work which is 118K lines. I have adjusted my open file limit tho' (ages ago).

seancorfield07:10:54

I have ulimit -n 16384 in my ~/.profile

borkdude07:10:57

I have had this issue with clj-kondo once: in that case the problem was that clj-kondo didn't close .jar files. So when you would have a large classpath, you would get this issue.

borkdude07:10:08

@U11SJ6Q0K What editor (plugin) are you using? If in emacs, it might help to disable certain things like watching dirs

tatut07:10:22

yes, using emacs

tatut07:10:20

thanks, I'll try those

ericdallo12:10:55

Oh, never faced this issue before on linux, where the error happens? emacs? clojure-lsp? OS? Also, not sure disabling file watchers would fix this kind of issue

seancorfield15:10:07

macOS (Big Sur, specifically, but I've seen the issue on all versions of macOS -- if you don't raise the ulimit).

👍 1
hugod11:10:00

Hi. I’m trying lsp-clojure with emacs on a large codebase. If I have many open .clj files and switch between git branches with many changed files, then it can take up to a minute for emacs to become responsive again. auto-revert will revert many buffers, and lsp is triggered to do something, and sits at 100% cpu for quite a while. Any ideas on how to find out what it would be doing?

hugod11:10:14

The logs show many messages like :didChange 10873ms

hugod12:10:29

Also seeing Invalid clj-kondo finding. Cannot find position data for {…, :row nil, :col nil, :end-row nil, :end-col nil, ..} messages in the log, but they are not always present if there is a large time logged.

hugod12:10:39

Also :completion 34982ms

ericdallo12:10:24

This probably is the file watcher, could you check if there are didChangeWatchedFiles?

hugod12:10:05

I don’t see any didChangeWatchedFiles

hugod12:10:21

(I have lsp-enable-file-watchers nil in emacs)

hugod12:10:17

Setting :notify-references-on-file-change false seems to make things much better

ericdallo12:10:54

did you have that notify-references-on-file-change as true before? (because ATM it's false by default)

ericdallo12:10:50

but yeah, that could cause that, I think we could try to be more smart on that :thinking_face:

hugod12:10:58

Um, no - I didn’’t have it explicitly configured before.

ericdallo12:10:23

are you using latest clojure-lsp just to make sure?

hugod12:10:47

clojure-lsp --version
clojure-lsp 2021.09.13-22.25.35
clj-kondo 2021.08.07-SNAPSHOT

ericdallo12:10:06

it's a little outdated, could you test with latest?

hugod12:10:51

Looks like that was the latest version in brew. I’ll install directly.

ericdallo12:10:06

you are probably not using oficial clojure-lsp brew tap

ericdallo12:10:35

What I think it's happening is that auto-revert-mode (which I didn't know before) send a lot of didChange request close each other becasue multiple files have changed, and clojure-lsp call kondo for each one of those debouncing by 300ms but for each filename, which actually makes call kondo for each file

ericdallo12:10:12

we could maybe change that to be smarter and try to send all those files in a single kondo call, but that would need some critical refactor

hugod13:10:14

with

clojure-lsp --version
clojure-lsp 2021.09.30-15.28.01
clj-kondo 2021.09.25
setting :notify-references-on-file-change false reduces time to switch branches from over a minute to around 7s.

ericdallo13:10:18

that's odd, are you sure you don't have this flag as true anywhere else? maybe your home config or something?

hugod13:10:12

I don’t have a home config.

hugod13:10:46

fwiw, the log shows running clj-kondo on start-up taks around 60s, and :initialize 97873ms

ericdallo13:10:38

this happens when full analyzing the project, when it's the first time or some deps /kondo config have changed

ericdallo13:10:14

would be possible to have a minimal repro for this issue? That probably would help a lot

hugod13:10:57

I can see if I can find time to write a large project generator, but unlikely to be this week. Thanks for the help - with the config above it seems useable.

ericdallo13:10:35

ok, thanks !

lassemaatta14:10:57

@U0HFRSY0M I wrote this very simple tool (https://github.com/lassemaatta/dummy-project-generator) a while back when trying to debug my performance issues with lsp, perhaps it might be of some use to you