This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-11-06
Channels
- # announcements (5)
- # asami (4)
- # babashka (27)
- # beginners (1)
- # calva (4)
- # cider (64)
- # clj-kondo (7)
- # clojure (7)
- # clojure-brasil (3)
- # clojure-europe (41)
- # clojure-france (2)
- # clojure-norway (101)
- # clojure-uk (5)
- # clojurescript (19)
- # cursive (3)
- # datahike (15)
- # datomic (15)
- # events (2)
- # honeysql (11)
- # hyperfiddle (27)
- # introduce-yourself (2)
- # jobs-rus (1)
- # leiningen (8)
- # london-clojurians (1)
- # lsp (175)
- # off-topic (52)
- # overtone (10)
- # portal (15)
- # re-frame (7)
- # reagent (1)
- # releases (1)
- # remote-jobs (2)
- # shadow-cljs (15)
- # sql (5)
This might be off topic here, but I'll give it a shot. I'm using lsp-mode in emacs along with the built-in vscode-langservers-extracted to get CSS lsp features. Any way to make this aware of multiple .css files at once? Right now I can navigate to vars defined in the same css file, but not other files.
never did that, but I feel like it's missing the concept of project to know other css files
Can I configure clojure-lsp so that it serves .cljs
files as well as it serves .clj
files? It’s my #joyride scripts, which are .cljs
. Details in 🧵 ->
If e.g. hover a symbol reset!
in the script. I get a very bare bones and boring hover. The lsp message log looks like so:
[Trace - 12 :02:43 PM] Sending request 'textDocument/hover - (32)'.
Params: {
"textDocument": {
"uri": "file:///Users/pez/.config/joyride/scripts/js_repl.cljs"
},
"position": {
"line": 54,
"character": 13
}
}
[Trace - 12:02:43 PM] Received response 'textDocument/hover - (32)' in 12ms.
Result: {
"range": {
"start": {
"line": 54,
"character": 12
},
"end": {
"line": 54,
"character": 18
}
},
"contents": {
"kind": "markdown",
"value": "
clojure\nreset!\n\n\n----\n\n*[/Users/pez/.config/joyride/scripts/js_repl.cljs](file:///Users/pez/.config/joyride/scripts/js_repl.cljs)*"
}
}
Renaming the file to foo.clj
, the exchange looks like so:
[Trace - 12:03:15 PM] Sending request 'textDocument/hover - (36)'.
Params: {
"textDocument": {
"uri": "file:///Users/pez/.config/joyride/scripts/js_repl.clj"
},
"position": {
"line": 54,
"character": 12
}
}
[Trace - 12:03:15 PM] Received response 'textDocument/hover - (36)' in 13ms.
Result: {
"range": {
"start": {
"line": 54,
"character": 12
},
"end": {
"line": 54,
"character": 18
}
},
"contents": {
"kind": "markdown",
"value": "
clojure\nclojure.core/reset!\n[atom newval]\n\n\nSets the value of atom to newval without regard for the\ncurrent value. Returns newval.\n\n__Examples:__\n\n
clojure\nuser=> (def x (atom 10))\n#'user/x\n\nuser=> @x\n10\n\nuser=> (reset! x 20)\n20\n\nuser=> @x\n20\n\n\n__See also:__\n\n[clojure.core/swap!]()\n\n[clojure.core/compare-and-set!]()\n\n[clojure.core/atom]()\n\n[clojure.core/swap-vals!]()\n\n[clojure.core/reset-vals!]()\n\n----\n\n*[/Users/pez/.m2/repository/org/clojure/clojure/1.11.1/<clojure-1.11.1.jar:clojure/core.clj](jar:file:///Users/pez/.m2/repository/org/clojure/clojure/1.11.1/clojure-1.11.1.jar!/clojure/core.clj)*>"
}
}
If kondo provides that analysis it should work, otherwise it's a bug in clojure-lsp or kondo, but before I'd check if the classpath is correct as most of the time issues like that are related to classpath
Server info says:
"classpath": [
"/Users/pez/.m2/repository/org/clojure/core.specs.alpha/0.2.62/core.specs.alpha-0.2.62.jar",
"src",
"/Users/pez/.m2/repository/org/clojure/spec.alpha/0.3.218/spec.alpha-0.3.218.jar",
"test",
"/Users/pez/.m2/repository/org/clojure/clojure/1.11.1/clojure-1.11.1.jar",
"scripts"
],
that's the problem I guess, a empty deps.edn includes only clojure.core stuff, for cljs you would need to explicit declare that dep
Thanks! That worked. Even if it doesn’t really make sense to add clojurescript deps, since we’re not using ClojureScript. @U04V15CAJ, what’s the recommended config for nbb?
Thinking I could do something like so.
{:project-specs [{:project-path "joyride.edn"
:classpath-cmd ["npx" "nbb" "-e" ",,,"]}]}
@U0ETXRFEW yes, there is nbb.classpath/get-classpath
@U0ETXRFEW if you find some sane default for joyride.edn
, we can open a PR on clojure-lsp to consider that project spec as default if that makes sense
@U04V15CAJ, it’s a bit unclear to me how to populate the classpath from a map like this
{:paths ["src" "scripts"]
:deps {org.clojure/clojurescript {:mvn/version "1.11.54"}}}
No. I could, I guess, but it gets to be a similar problem as having it in deps.edn
. Can I tell nbb to look elsewhere for the config?
I guess you could make a deps.edn with a joyride alias and configure lsp to include the joyride alias
I think a good idea would be to have a joyride.edn
which would add the clojurescript deps via CLI args in the classpath-cmd
of the project spec?
nbb.edn depends on bb FWIW, how else did you think it deals with all the maven stuff, magically re-implement everything in Node.js? ;)
Lately I have been considering to bundle bb with Calva. This could push me over to the yes side of that…
you already include deps.clj which is the ingredient used by bb to do all of this maven stuff
Great. I don’t want to depend on Java either, but bundling bb or a binary deps.clj might be the way.
there is a deps.clj binary but deps.clj is just the clj bash script ported to clojure unless you're going to use tools-deps-native https://github.com/babashka/tools-deps-native
I actually do not care so much what is used. I just want as few dependencies as possible. Joyride is fully usable without any other dependency. I’d like to keep it like that. Here it is OK with a Calva dependency, since it is Calva that wants clojure-lsp to have the classpath.
@UKFSJSM38, does clojure-lsp have a way to resolve classpaths from a deps map?
Maybe the solution is to make Calva check if bb is installed on the classpath. If it isn’t, install it and help the user get it on the PATH. And then the classpath-cmd
in clojure-lsp will use bb if it is installed, otherwise just return whatever is in paths
of joyride.edn
. WDYT?
That's fine but users will still require java, since bb calls deps.clj I think 99% of joyride users will already have it installed though
I'd say just go with deps.clj since you already have it in Calva - this is just for clojure-lsp right?
Calva could expose a command for calculating a classpath given a .edn file and then call deps.clj
deps.clj could also have an option to use tools-deps-native so you can avoid java, but the only thing is, that tools-deps-native I consider an experimental project
what deps.clj could do, given an environment variable DEPS_CLJ_TOOLS_DEPS_NATIVE=true
, it could download (instead of the tools jar) the binary
It’s actually not that easy to call deps.clj from the command line either. First I need to know where it is, and VS Code won’t tell me. 😃
$ tools-deps-native
tools.deps.edn ...
help show this help message
deps output a claspath map from a deps map
create-basis output a basis from a set of deps sources and a set of aliases
root-deps output the root deps.edn
slurp-deps read, canonicalize and output a deps.edn file
user-deps-path output the path to the users deps.edn file
It’s a bit the same there. But I guess Calva can place it in a known place. Same with deps.clj.
$ tools-deps-native deps '{:deps {medley/medley {:mvn/version "1.0.0"}}}'
{:classpath-roots ["/Users/borkdude/.m2/repository/medley/medley/1.0.0/medley-1.0.0.jar" "/Users/borkdude/.m2/repository/org/clojure/clojure/1.7.0/clojure-1.7.0.jar"], :classpath {"/Users/borkdude/.m2/repository/medley/medley/1.0.0/medley-1.0.0.jar" {:lib-name medley/medley}, "/Users/borkdude/.m2/repository/org/clojure/clojure/1.7.0/clojure-1.7.0.jar" {:lib-name org.clojure/clojure}}}
I guess Joyride makes most sense. We are to support a joyride.edn
project spec after all.
tools-deps-native is also designed to be used in conjunction with tools.bbuild: https://github.com/babashka/tools.bbuild tools.build for bb without java :)
It would be nice if I could call tools-deps-native like so:
$ tools-deps-native --deps-file joyride.edn --print-path
And it would print the path how clojure -Spath
prints it.I like to think so. 😃 But it’s a bit awkward to script in a vector of command line args. And to make it compatible across platforms.
first make it work, then improve, it seems like you're asking for premature features
that doesn't make sense to me, I thought you said you wanted to not use bb / java you didn't have to. nbb uses both for resolving deps from nbb.edn
how are you on the command line? I don't get it. Btw, you could write a small JS file as part of joyride's package that you can call from the command line.
Still the problem with how the command line should find the Joyride bin directory. There doesn’t seem to be a clean way to do that.
perhaps we can make an npm package (in squint of course :P) that downloads/caches tools-deps-native and offers a neat JS interface for downloading clojure deps :P
It doesn't have EDN on board currently, but you can do it via https://github.com/jorinvo/edn-data Someone has used this from squint quite recently
you want to do the downloading/caching/etc of tools-deps-native rather using bash and powershell?
We handle the download for deps.clj and clojure-lsp in Calva, so we could do this in Joyride for tools-deps-native too.
then "stub" the scripting part for now with bb or nbb and we can optimize that part later in tools-deps-native perhaps
this is the "pre-mature" part that's probably too early to decide on now unless you're 100% certain you're going the tools-deps-native route
Piping to jet also works ;)
$ tools-deps-native deps '{:paths ["src"] :deps {medley/medley {:mvn/version "1.3.0"}}}' | jet -t ':classpath-roots (str/join ":")'
"src:/Users/borkdude/.m2/repository/medley/medley/1.3.0/medley-1.3.0.jar:/Users/borkdude/.m2/repository/org/clojure/clojure/1.9.0/clojure-1.9.0.jar:/Users/borkdude/.m2/repository/org/clojure/core.specs.alpha/0.1.24/core.specs.alpha-0.1.24.jar:/Users/borkdude/.m2/repository/org/clojure/spec.alpha/0.1.143/spec.alpha-0.1.143.jar"
Don't download it through http://Finder.app, but just using curl
This is with all unsigned binaries, just don't use a GUI to download and unzip them on macOS
The way to solve the GUI problem using the GUI is to right-click the binary and select Open from the context menu. Then click Open in the warning dialog. I think that does something similar to sudo xattr
.
I think only the for the ones that are built-in joyride. ClojureScript, rewrite-clj, promesa, and such.
Four paths to begin with, I think. src
, script
, ~/.config/joyride/src
, and ~/.config/joyride/scripts
.
Though I am thinking joyride.edn could also be used to configure more paths for Joyride, WDYT?
This almost works (if I forget about windows for a moment)
{:project-specs [{:project-path "joyride.edn"
:classpath-cmd ["bash" "-c" "$HOME/binaries/tools-deps-native deps \"`< joyride.edn`\" | jet -t ':classpath-roots (str/join \":\")'"]}]}
What trips things up now is the quotes around the string that jet outputs.Well, this command line works:
$HOME/binaries/tools-deps-native deps "`< joyride.edn`" | jet -t ':classpath-roots (str/join ":") println'
But I don’t get it to work when configuring is as the :classpath-cmd
…I can’t shake the feeling that the interface of tools-deps-native could be a bit less demanding.
I like it the experiment. 😃 Just that for my use case an interface where I could have it read a file and spit out the path would remove the need of binaries and the problem with windows compatibility.
I probably will. Next week. I used up this week’s budget for this in trying and failing to get the command line to work. 😃
Can someone help me get LSP within emacs to work with my emacs files, or understand why it doesn't (so i can blacklist those files)? Here is the message i get when emacs starts, annoyingly this happens on every start i presume because my setup tries to load a project/directory which has a yaml file.
Server yamlls:55671/starting exited (check corresponding stderr buffer for details). Do you want to restart it? (y or n)
If i select Y, i get re-asked the same question until i choose n.
If i check the messages buffer i see that in response to answering "y" i get:
LSP :: Restarting LSP in buffer pipeline.yml
LSP :: Connected to [yamlls:55871/starting /home/drewverlee/devops].
LSP :: yamlls has exited (exited abnormally with code 1)
error in process sentinel: Quit [2 times]
So it seems like a yaml file is trying to be read by LSP, then their is an error in the process. My guess is that lsp can't handle this file properly, maybe cause it's aws yaml or something? I'm not sure how to find out more, if i look at lsp logs i see this related to lsp.
The following clients were selected based on priority: (server-id yamlls, priority 0)
Command "/home/drewverlee/.emacs.d/.cache/lsp/npm/yaml-language-server/bin/yaml-language-server --stdio" is present on the path.
Com
though their is a lot more going on. If i got to the lsp yaml site i see instructions to install the yaml server
npm install -g yaml-language-server
I went ahead did that (i think i already had those packages), and restarted emacs but it had no effect. I assume emacs can find them correctly as i used -g.
My next step is probably to blacklist those yaml files, under the assumption that lsp is just failing because their some special aws yaml. But it would be nice to know for sure. Any ideas?• Just to make sure, that's not related with clojure or clojure-lsp right?
• I agree the yamlls is crashing when starting which is bad
• emacs is probably not finding yaml-language-server in the PATH, one way to test that is start emacs from terminal which should inherit the PATH env, you can check that with (getenv "PATH")
i think
It's not related to clojure. Your right, I'm just so used to asking lsp questions here. -_-.
what have you got lsp-yaml-server-command
set to? From the error, it looks like it's trying to execute /home/drewverlee/.emacs.d/.cache/lsp/npm/yaml-language-server/bin/yaml-language-server
(does that file exist?) How have you installed npm
? Are you using nvm
? That will change where npm install -g
puts it's files. When I install the yaml server lsp-mode seems to run
/usr/bin/npm -g --prefix /var/home/ed/.emacs.d/.cache/lsp/npm/yaml-language-server install yaml-language-server
so maybe you should include the --prefix /home/drewverlee/.emacs.d/.cache/lsp/npm/yaml-language-server/
bit in your manual npm install
??yamls server seems to be broken on my Linux system for Emacs 29.
Running Emacs from a desktop launcher did not have npm on the path, so it was not picked up by Emacs. Adding npm to the path in the .profile
configuration file allowed the server to be installed (manually, via lsp-server-install).
Although yamls is installed it still seems to fail at startup or when opening a .yaml file
LSP :: yamlls has exited (exited abnormally with code 127)
So either an issue with the sever or lsp-mode (or a combination of the two).
It seems I also had issues with yamls with neovim too (I disabled it and used prettierd instead)> I went ahead did that (i think i already had those packages), and restarted emacs but it had no effect. I assume emacs can find them correctly as i used -g.
You're right, the logs show you already had those packages. lsp-mode does that for you "automatically". To see the installation for yourself, uninstall the global, delete the .cache/npm/... binary and visit the yaml again. (calling lsp-install-server
with the universal argument (C-u) also forces a reinstall).
if yamls is broken maybe installing yamllint and enabling yaml-yamllint in flycheck would be good enough?
thanks for the suggestions everyone.