This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # announcements (2)
- # asami (5)
- # babashka (52)
- # beginners (42)
- # biff (3)
- # cljdoc (4)
- # cljsrn (2)
- # clojure (30)
- # clojure-austin (35)
- # clojure-dev (3)
- # clojure-france (11)
- # clojurescript (36)
- # conjure (6)
- # cursive (5)
- # fulcro (33)
- # graalvm (41)
- # lsp (54)
- # malli (1)
- # music (2)
- # off-topic (7)
- # overtone (1)
- # pedestal (5)
- # polylith (2)
- # remote-jobs (1)
- # sci (28)
- # shadow-cljs (38)
- # vim (15)
- # web-security (1)
- # xtdb (8)
By any chance is there a "toy example" LSP implementation in Clojure anyone knows about? clojure-lsp is awesome stuff, but if someone has already published the equivalent of a "hello world" LSP implementation in Clojure, that might be useful to look at.
I was also going to say: clj-kondo, since that has only diagnostics, so fairly easy to understand. There is also this one I've been working on for a DSL in .edn: https://github.com/zen-lang/zen-lsp
And now clojure-lsp has a lsp4clj library you can use to bootstrap your own lsp server, next time I might use that one
OK, I've been trying out this small LSP server: https://github.com/clj-kondo/clj-kondo.lsp
On a freshly-installed Ubuntu 20.04 Linux VM, I installed a recent Temurin/Adoptium JDK 1.8, Homebrew, Leiningen, Babbashka, and probably one or two other things I'm forgetting.
I cloned that repo, and following advice from borkdude, who graciously updated the README, ran the command
bb vscode-server from the root directory of that cloned repo. That created the uberjar and copied it into the vscode-extension directory of my cloned repo.
Then following the project README, I did
cd vscode-extension and then
npm install . There were some warning messages (copied below), but nothing that looked serious, and the result was a subdirectory
node_modules created with about 66 MBytes of files in it.
npm install I saw looked like this:
npm WARN [email protected] license should be a valid SPDX license expression audited 79 packages in 1.093s 4 packages are looking for funding run `npm fund` for details found 2 vulnerabilities (1 moderate, 1 critical) run `npm audit fix` to fix them, or `npm audit` for details
The clj-kondo.lsp README next suggests this: "In VSCode open the project directory and hit
F5 (Start Debugging) to run the
extension. Edit a Clojure file (`.clj`) and you will get diagnostic feedback."
code (which I did from my home directory, not my clone of clj-kondo.lsp, if that makes a difference), opened a directory of a small Clojure project I have (again, not clj-kondo.lsp), opened one of its
.clj files, and typed the
F5 key. VSCode popped up a window with this message: "You don't have an extension for debugging Clojure. Should we find a Clojure extension in the Marketplace?" with buttons "Cancel" and "Find Clojure extension"
I am guessing there is a way to install
clj-kondo.lsp on my local system without publishing it to the VSCode Marketplace. Does anyone know the steps for that?
Sorry, I should probably put all of those steps I've followed into a file that I link to somewhere else, rather than dumping it all in messages here.
So you mean to, in a bash shell, cd to the vscode-extension directory, then run the command
code. By "And then run the project" do you mean to open a folder of some arbitrary Clojure project in VSCode? I tried that with some other Clojure project besides "clj-kondo.lsp", but got same error when pressing F5 as mentioned above.
And in that new window open a random Clojure file which then will activate the lsp server
OK, I did happen across a similar step before on my own where it opened another VSCode window different than the original window, and I had no idea if that was normal or unxpected. Good to know it is what should be happening.
I am happy to write down a more detailed sequence of steps and suggest it in a PR in the clj-kondo.lsp project README, once I think I have a correct sequence of steps.
In the zen-lsp project, it is set up in a way that you have an nREPL server running in debug mode when you start the extension in debug mode and you can just program directly agains that
Part of what I am up against is lack of familiarity with developing extensions for VSCode, as well as learning what LSP is.
I want to port that to clj-kondo.lsp as well, but the code in clj-kondo.lsp is pretty much "done" so I don't have an urgent need to do so
I am considering writing a new LSP server, in Clojure, for a programming language unrelated to Clojure.
Trying to walk with existing code to figure out some of the basics, before I run.
That's what zen-lsp is also doing (although the language is implemented in .edn). But yeah, that should be doable.
You can test your lsp server from emacs as well btw, just use lsp-mode. I've also documented this in zen-lsp
https://p4.org. A niche programming language for programs specifying how network devices like switch ASICs and NICs process data packets.
I just find vscode easier since that gives you that new "popup" window where the extension is running without additional setup
Yep, one of my reasons for looking at LSP is I also want to be able to use it from Emacs. I'm trying VSCode first partly because I suspect that most of the users of the LSP for the language P4 would prefer VSCode over Emacs.
The REPL-into-the-server-under-development is recommended when you want to develop such a server, it's such a time-saver
In clj-kondo.lsp you don't really need to run the uberjar, you could just launch a clojure process which runs the server + a REPL to connect to
Oh, I definitely want to do that, so thanks for the tip. One step at a time. I'm not the quickest at this stuff, but once I figure out how to do it, I tend to write down all of the steps for how to do it AGAIN on a freshly installed system, in case I want to start over.
(or want to point someone else at a working sequence of steps, in detail, leaving little to the imagination)
If you want to improve the docs in clj-kondo.lsp, I'd be happy to receive those improvements
personally i found vscode the hardest to bootstrap the server because it seemed to require a custom client plugin for each language. emacs and vim allow you to very easily say run this command to start the server for this filetype.
Thanks, good to know. I'll keep an eye out for that and perhaps try out Emacs + LSP sooner than I might have otherwise.
Seems weird that VScode would make it trickier than other editors, given that Microsoft started VScode and LSP