This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-09-22
Channels
- # announcements (2)
- # asami (123)
- # aws (17)
- # babashka (77)
- # babashka-sci-dev (23)
- # beginners (48)
- # biff (6)
- # calva (35)
- # cider (16)
- # clj-on-windows (1)
- # clj-yaml (19)
- # clojure (36)
- # clojure-europe (78)
- # clojure-nl (5)
- # clojure-norway (8)
- # clojure-poland (3)
- # clojure-uk (16)
- # clojurescript (17)
- # cursive (6)
- # datahike (3)
- # datalevin (26)
- # duct (7)
- # emacs (41)
- # events (2)
- # fulcro (7)
- # graphql (5)
- # honeysql (13)
- # juxt (3)
- # kaocha (7)
- # lsp (5)
- # malli (12)
- # off-topic (14)
- # pathom (3)
- # portal (1)
- # rdf (9)
- # reitit (3)
- # remote-jobs (2)
- # shadow-cljs (37)
- # spacemacs (5)
- # tools-build (1)
- # tools-deps (20)
- # xtdb (2)
Hello, my eglot starts multiple lsp-servers. One for each major mode.
When I open the first .clj
file in my project, eglot starts a server:
[eglot] Connected! Server `EGLOT (clj/clojure-mode)' now managing `clojure-mode' buffers in project `clj'.
After that, when I open the first .cljc
file, eglot starts another server:
[eglot] Connected! Server `EGLOT (clj/clojurec-mode)' now managing `clojurec-mode' buffers in project `clj'.
Same for .cljs
files.
Any ideas, how to configure eglot to use a single clojure-lsp
server for all clojure modes (`clojure-mode`, clojurescript-mode
, clojurec-mode
,...) when files are opened in the same project?I don't know anything about eglot unfortunately, but the key is make sure eglot is sending the correct project root to clojure-lsp, lsp-mode has the workspace concept, eglot should have something similar
It does send the correct project root. Problem is that it sends the same project root to multiple clojure-lsp instances. One for each of clojure-mode
, clojurec-mode
and clojurescript-mod
. 😞
Oh, that's weird, never saw that with lsp-mode, so not sure why that is happening for eglot :(
I suspect, egot has a mapping of major mode to lsp server command. And since we are using multiple major modes for Clojure, this happens.
lsp-mode does the same, it has a mapping that triggers lsp
after entering in a major mode, this is correct, but what lsp-mode does is check if that buffer/file is associated to a running workspace
You may be interested on https://clojurians.slack.com/archives/CPABC1H61/p1664137536766069
How can I see all the function names I have in a buffer at once? Or all the functions in a project? If I have a docstring in them would I be able to see those along with them (or other information about them)?
You can use consult-imenu
to get a list of all functions in the current buffer and jump to them.
And consult-imenu-multi
for all functions for all buffers in the current project.
This is just one way to do it.
Yay! Thank you.
anyone now how you can get cider to start shadow, I can get it to work with connect but would quite like the figwheel experience where I just connect, how ever with shadow I get this "error shadow-cljs has not been started yet!"
definitively but first have to ask if something have been already done. Was looking at cider recently which detect a bb.edn file.
Here's a start, if you want to give it a shot yourself:
(let ((default-directory "~/dev/borkdude/blog")
(options (s-split "\n"
(s-trim
(shell-command-to-string "bb tasks")))))
(completing-read "which task?" options))
The strings need some cleaning, though :)You might be interested in projectile-run-shell-command-in-root
to list tasks relative to the current project root, rather than in a specific directory.
There is also project-compile
which is similar and built-in. And both commands project-/projectile-compile have autocomplete.
when you're done with this, feel free to post the elisp snippet to the babashka wiki
Is it possible to see a clj buffer in emacs in a ‘collapsed’ way… one line per defn or def and so on? I would be able to quickly see what’s in a buffer as well as the ordering is so.
Yes! 🙂
I see the list in the minibuffer in a different order… I would love to see them vertically stacked in a buffer in the order they actually appear (but maybe I’m using imenu differently).
Oh yes! That’s perfect!
even shows the first line and args. I should be able to create something that would show the second line of each form, then, if I have docstrings, I’d be even more set.
Hi!
I want to use replace-regexp-in-region
, but can't figure out how match a literal period in a regex.
Help please?
Specifically, I want to be able to mark a region around "desired input" below, and get "desired output":
Desired input:
Sentence one. Sentence two. Sentence three.
Desired output:
Sentence one.
Sentence two.
Sentence three.
I tried this, which didn't do what I wanted:
(defun teod/tryit ()
(interactive)
(replace-regexp-in-region "\\.\ " ".\n"))
reading https://www.gnu.org/software/emacs/manual/html_node/elisp/Regexp-Special.html now
M-x re-builder
is useful for experimenting with regex in emacs. emacs regex syntax is slightly weird.
I ended up going a different route:
(defun teod/one-line-per-sentence ()
(interactive)
(let* ((s (delete-and-extract-region (mark) (point)))
(s2 (s-replace ". " ".\n" s)))
(insert s2)))
I thought I had it working with replace-regexp-in-region
, but it just behaved weirdly.Not relevant for your original question but you can check if the region is actually "active" instead of using (point)
and (mark)
.
I always use something like this in my functions that have to take a region:
(defun py2json (start end)
"Read region in Python syntax and convert to json."
(interactive
(if (or (use-region-p) (not transient-mark-mode))
(prog1 (list (region-beginning) (region-end))
(deactivate-mark))
(user-error "No region")))
....