Fork me on GitHub
#lsp
<
2023-11-21
>
Noah Bogart15:11:02

funny situation: i type in (set/union a b) and lsp suggests set/union as i type, showing me the docstring. once the whole form is typed, it shows red squiggles because i've not required clojure.set :as set . i use CodeAction to see the pop up that suggests add require '[clojure.set :as set]' . However, until i press that, "show docs at cursor" won't show me the docs for set/union, and "go to definition" doesn't work. if I change it to (clojure.set/union), it still doesn't go to definition or show the docs, while still showing me the docs as I type it in. Is this intended? Is there a way to get lsp to show me this stuff without having to require it first?

ericdallo17:11:05

when you complete set/union it should automatically require the clojure.set, unless your editor doesn't support that capability

daveliepmann16:11:01

I'm using clojure-lsp for ClojureDart. Is it possible for LSP not to give "Unresolved symbol" for vars which are defined later in the file? The cljd dialect doesn't require a var be defined or declared before use.

ericdallo17:11:11

would be tricky I guess to make clj-kondo do that, maybe @U04V15CAJ knows more, but can't you follow the clojure convention of declaring it before?

borkdude17:11:58

yes, this would be possible, but it's currently not there. feel free to post an issue

👍 1
borkdude17:11:26

also please make a repro using a .cljd or .cljc file

borkdude17:11:32

in the issue

daveliepmann17:11:31

Thanks for the quick response guys, I will follow up with a repro. > can't you follow the clojure convention of declaring it before? It feels, I dunno, inelegant or something to let a tool dictate coding style contrary to the dialect.

👍 1
phill17:11:58

It was unclear to me in the #C03A6GE8D32 discussion whether the "forgiven missing declare" is considered a feature or an unflagged error. (But, if we're harrumphing, then it seems inelegant for a dialect to desecrate a foundational principle of the original; perhaps we depend on the linter to help people write code that could be ported back to Clojure.)

borkdude17:11:24

> it seems inelegant for a dialect to desecrate a foundational principle of the original I don't disagree ;)

daveliepmann17:11:32

It might be that I'll change my mind once CLJD has a REPL, but as long as I'm working with https://github.com/Tensegritics/ClojureDart/blob/main/doc/differences.md#lazy-defs and tools (hot-reload and LSP) which can accomodate its goals, I'd like to fully explore the Dart-idiomatic way of doing things.

rgm22:11:46

bit of a bikeshedding question: I've been repurposing the ^:deprecated metadata to provide this helpful little safety reminder when I'm working at the design/get-it-working level. This is neovim/conjure/clojure-lsp. Is the machinery for this accessible and generic enough that something like ^:stub and a floating warning like "HEY DON'T FORGET TO FIX THIS` is straightforward?

borkdude23:11:45

No, :deprecated warning from clj-kondo is a bespoke thing currently

rgm23:11:15

alas. Thanks all the same

borkdude23:11:02

There is a :discouraged-var linter where you can set custom warnings about vars, but this doesn't use var metadata

rgm23:11:18

oh interesting

rgm23:11:57

I'm sure that's good for somewhere else. Right here I think I'm just looking for the code equivalent of a big fluorescent orange traffic cone and this works fine

👍 3
jakemcc15:11:53

If you're using git and don't mind waiting to get yelled at till you go to commit, I've used https://jakemccrary.com/blog/2015/05/31/use-git-pre-commit-hooks-to-stop-unwanted-commits/ very successfully as a way of reminding myself to go back in and finish something