This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-02-24
Channels
- # announcements (3)
- # babashka (47)
- # beginners (40)
- # biff (21)
- # calva (12)
- # cider (2)
- # clj-kondo (31)
- # cljsrn (8)
- # clojure (14)
- # clojure-berlin (2)
- # clojure-conj (1)
- # clojure-dev (24)
- # clojure-europe (84)
- # clojure-italy (8)
- # clojure-nl (1)
- # clojure-spec (1)
- # clojure-sweden (2)
- # clojure-uk (2)
- # clojurescript (34)
- # clr (3)
- # community-development (1)
- # cursive (14)
- # datalevin (8)
- # datomic (5)
- # defnpodcast (2)
- # dev-tooling (1)
- # etaoin (4)
- # events (3)
- # fulcro (26)
- # graphql (3)
- # honeysql (6)
- # hyperfiddle (45)
- # lsp (40)
- # malli (1)
- # missionary (1)
- # nbb (18)
- # podcasts-discuss (1)
- # reagent (8)
- # reitit (2)
- # releases (2)
- # ring-swagger (1)
- # scittle (78)
- # shadow-cljs (96)
- # vim (7)
- # xtdb (3)
Hi, I am trying to rename all the namespaces in a project and I find that it does break a lot of requires and references. I am using this piece of code:
(->> (all-ns)
(map ns-name)
(map name)
(filter #(s/starts-with? % "datahike."))
#_(mapv #(symbol (s/replace-first (str %) #"datahike." "io.replikativ.datahike.")))
(mapv (fn [ns-str]
(lsp/rename! {:from (symbol ns-str)
:to (symbol (s/replace-first (str ns-str) #"datahike." "io.replikativ.datahike."))})))))
and pieces of code show up like this:
-(s/def ::index #{:datahike.index/hitchhiker-tree :datahike.index/persistent-set})
+(s/def ::index #{:io.replikativ.datahike.index/hi:io.replikativ.datahike.index/persistent-setatahike.index/persistent-setpersistent-set})
or this:
(:require
[clojure.data]
[clojure.walk]
- [datahike.constants :refer [e0 tx0 emax txmax]]
+ [io.replikativ.datahike.constantshike.constants :refer [e0 tx0 emax txmax]]
[datahike.datom :refer [datom datom-tx]]
[datahike.db.interface :as dbi]
- [datahike.index :as di]
+ [io.replikativ.datahike.indexdatahike.index :as di]
I am running it on main branch of https://github.com/replikativ/datahike
that's actually the first time I see someone heavily using lsp/rename!
so curious if works that well :)
I can repro with a simple
(clojure-lsp.api/rename!
{:from (symbol "datahike.constants")
:to (symbol "io.replikativ.datahike.constants")})
Found the bug, kinda hard to find, it actually happens for editor as well and only for cljc files, will create a issue and work on that
Usually it helps to create a deps.edn
with the dependencies from nbb.edn
. Perhaps clojure-lsp can detect nbb.edn
and use bb --config nbb.edn print-deps
to support nbb - cc @UKFSJSM38
I made a nbb project with an nbb.edn file containing :
{:deps {com.rpl/specter {:mvn/version "1.1.4"}
cider/cider-nrepl {:mvn/version "0.30.0"}}}
and was hoping to get completion suggestions via clojure-lsp in neovimI doubt that specter works with nbb currently, but perhaps we can look into making that work
oh that probably explains by current problem then. I tried in include specter but it didn't work. However I do seem to have LSP diagnostics appearing in neovim now 🙂
Thanks @U04V15CAJ! No rush though, I’ll have to head off soon 💤
There is this https://github.com/clojure-lsp/clojure-lsp/issues/1418 regarding that support, one of the ideas was to have a nbb.edn
and a nbb --print-classpath
, I didn't think about bb --config nbb.edn print-deps
but I suppose that would require bb installed besides nbb
hmm one thing that won't work is built-in libraries like promesa... but at least it will work for the deps declared in nbb.edn
@U01TU6MLA69 I looked into specter support and pushed a couple of improvements but didn't get it completely working, maybe some other time
Thanks @U04V15CAJ 🙂
Is the answer to the question: Not at the moment ?
Using nvim-lint to trigger clj-kondo to trigger at least clj-kondo while lsp does not recognize nbb project.
use({
"mfussenegger/nvim-lint",
config = function()
require("lint").linters_by_ft = {
clojure = { "clj-kondo" },
-- ... other linters
}
end,
})
vim.api.nvim_create_autocmd({ "BufWritePost" }, {
callback = function()
require("lint").try_lint()
end,
})