lsp

:clojure-lsp: Clojure implementation of the Language Server Protocol: https://clojure-lsp.io/
Alex 2021-04-12T01:53:56.047200Z

I've set up a .dir-locals.el for a denylist of files/folders that LSP can ignore. However, LSP still asks if I want to watch ~1500 files (way more than I'm expecting). Does Clojure LSP log which folders/files it thinks it should be watching? I'd love to be able to compare that against my directory structure and see whether I've made an error in my configuration

ericdallo 2021-04-12T12:21:31.051800Z

yes, I confirmed clj-kondo dir is being ignored properly indeed

ericdallo 2021-04-12T12:21:59.052Z

Also, they answered you, the lsp-log logs to a lsp-log buffer, but it just logs the project root dir of the watchers, not the folders itself

ericdallo 2021-04-12T02:05:52.047400Z

that's a config from lsp-mode , clojure-lsp has no control over that, you should check if your lsp-file-watch-ignored-directories or lsp-file-watch-ignored-files are correct

Alex 2021-04-12T02:12:45.047600Z

ah gotcha, thanks Eric. yep I'm setting lsp-file-watch-ignored-directories in dir-locals . just wanted to see if there was a way to verify they were being picked up correctly. here's a snippet in case you see anything that stands out

((nil . ((lsp-file-watch-ignored-directories . ("/\\.git$"
                                                "/resources/public/js$"
                                                "/resources/public/img$"
                                                "/resources/public/css$"
                                                "/node_modules$"
                                                "/functions/node_modules$"
                                                "/functions/compiled$"
                                                "/\\.cpcache$"
                                                "/\\.shadow-cljs$")))))
otherwise i'll keep digging. thanks again!

ericdallo 2021-04-12T02:27:17.047800Z

Yeah, I think you can suggest it on lsp-mode discord or as a issue, a command that would check what dirs would exclude or something

ericdallo 2021-04-12T02:34:20.048Z

@rahx1t it seems lsp-mode already logs it somewhere https://github.com/emacs-lsp/lsp-mode/blob/master/lsp-mode.el#L1732

ericdallo 2021-04-12T02:34:59.048300Z

you can add a (message "---> %s" dirs-to-watch) to check

Alex 2021-04-12T03:00:34.048500Z

woo hoo, that worked well!

Alex 2021-04-12T03:00:52.048700Z

thanks Eric. also had to go through byte-compiling a file for the first time

Alex 2021-04-12T03:01:04.048900Z

but learned a few new things about emacs

ericdallo 2021-04-12T03:01:57.049100Z

haha nice, I think you should suggest that on https://discord.gg/swuxy5AAgT and try to understand where lsp-log is logging on that line

Alex 2021-04-12T03:06:18.049400Z

cool, will do! i think i'll post in #troubleshooting

Alex 2021-04-12T03:06:48.049600Z

haha i've been trying to figure out this lsp files watched issue for a while. turns out clj-kondo has a hidden .cache directory that i didnt know about and that's where most of the watched files were coming from

ericdallo 2021-04-12T03:10:31.049800Z

hum.. we should totally add that folder to lsp-mode default ignore dirs...

ericdallo 2021-04-12T03:10:39.050Z

thanks for pointing that

ericdallo 2021-04-12T03:11:52.050200Z

oh, it seems lsp-mode already ignores that folder: https://github.com/emacs-lsp/lsp-mode/blob/master/lsp-mode.el#L336

ericdallo 2021-04-12T03:12:19.050500Z

it's odd why you needed to add the .clj-kondo/.cache if lsp-mode already ignores the .clj-kondo folder

ericdallo 2021-04-12T03:12:24.050700Z

maybe that is not working as expected?

Alex 2021-04-12T03:28:13.050900Z

hmmm interesting. After adding "/\\.clj-kondo/\\.cache$" to my blocklist, the number of watched files went down from 1500 to 250 I'm using Doom, which is managing my package updates. Looks like my lsp-mode is pretty recent, last commit from 15 days ago Based on this, it does seem like the lsp-mode default ignore dirs is not working but I don't have a great intuition for this stuff 🙂

Alex 2021-04-12T03:33:03.051200Z

I switched from "/\\.clj-kondo/\\.cache$" to "/\\.clj-kondo$" and still seems to be blocking properly

Alex 2021-04-12T03:33:18.051400Z

Let me know if you want me to check anything else

practicalli-john 2021-04-12T16:26:42.057800Z

Is ~/.clojure/.lsp/config.edn a valid location for a clojure-lsp configuration file? That directory also contains an sqlite.db file. I was ~/.lsp/config.edn but that directory has been deleted (I think that was me, but not sure). Should I be using ~/.lsp/config.edn or is ~/.clojure/.lsp/config.edn okay to use (seems a bit tidier, especially as it only has cljfmt configuration in there). If both locations are valid, I assume the ~/.clojure/.lsp/config.edn would take preceedence over the general ~/.lsp/config.edn configuration

ericdallo 2021-04-12T16:32:45.058100Z

no, we don't support any ~/.clojure/.lsp ATM moment

ericdallo 2021-04-12T16:33:17.058300Z

your config whould be on ~/.lsp/config.edn

ericdallo 2021-04-12T16:34:08.058500Z

you probably opened ~/.clojure/deps.edn sometime and plugged lsp there and made ~/.clojure as root what made clojure-lsp create the sqlite file

seancorfield 2021-04-12T16:53:15.058700Z

@jr0cket You get a .lsp folder in any directory that you start an editor that using LSP integration. I keep seeing them popup as new files all over the place because it’s not yet common for new project templates to .gitignore the .lsp/sqlite.db file (and of course no older projects exclude it).

ericdallo 2021-04-12T16:54:13.058900Z

exactly, you can have a ~/.gitignore_global , but this is as common as a .clj-kondo/.cache dir

practicalli-john 2021-04-12T16:57:23.059100Z

Thanks. The strange thing is the configuration in ~/.clojure/.lsp/config.edn seems to work. Either that or lsp stopped annoyingly inserting two line spaces in between comments and keywords at the same I made this change... I'll delete it again and see if I still have that issue. Never a dull moment 🙂

👍 1
ericdallo 2021-04-12T16:59:15.059500Z

this is how we resolve config: https://github.com/clojure-lsp/clojure-lsp/blob/master/src/clojure_lsp/config.clj#L64-L90

👍 1
practicalli-john 2021-04-12T17:03:19.059900Z

I think I will set my XDG_CONFIG_HOME to /.config then /.clojure and /.lsp can both be in /.config along with most of the other user level config... and less likely to get deleted by mistake

ericdallo 2021-04-12T17:04:03.060100Z

yes, It looks valid

borkdude 2021-04-12T17:04:34.060300Z

> exactly, you can have a ~/.gitignore_global , but this is as common as a .clj-kondo/.cache dir Except that clj-kondo won't ever automatically create a .clj-kondo dir anywhere on your system.

👍 1
practicalli-john 2021-04-12T17:16:55.060600Z

I've had a .gitignore_global ever since I started using Git... its seems many people are missing out...