lsp

:clojure-lsp: Clojure implementation of the Language Server Protocol: https://clojure-lsp.io/
anonimitoraf 2020-11-15T08:50:17.031400Z

Is there a way for LSP to infer the list of importable variables/functions from a namespace? Say I have:

(ns my-ns
  (:require [my-other-ns :refer [ <trigger an auto-completion box filled with vars/fns> ]]))

snoe 2020-11-16T16:52:43.032100Z

It's probably possible, bringing the cursor's context into the completion code could work. That'll probably require moving the hairy completion code into its own namespace at that point and some better test coverage.

anonimitoraf 2020-11-18T07:47:20.032300Z

Oh right. That makes sense (on a high-level). I haven't seen the codebase though, but will have a look now

anonimitoraf 2020-11-18T08:03:27.032500Z

@snoe Which LSP capability(?) should I be looking at? Also, which part of the clojure-lsp codebase?

snoe 2020-11-18T16:00:32.033200Z

The latter might be useful because that determines some sort of cursor context.

anonimitoraf 2020-11-19T05:12:16.033400Z

Sweet thanks. I'll have a look later. I'm still amazed that it takes this little code to do stuff using Clojure. I'm willing to bet the JS counterpart of this is 10x more verbose

snoe 2020-11-19T21:03:59.033600Z

well, it's built on a lot of libraries, eclipse's lsp4j and rewrite-clj in particular

snoe 2020-11-19T21:04:13.033800Z

and kondo of course

anonimitoraf 2020-11-19T22:49:07.034Z

I suppose, but so are most JS apps. By the way, my workflow ATM is: • In emacs config, I have

(setq lsp-clojure-server-command '("java"
                                     "-jar"
                                     "path/to/clojure-lsp/target/clojure-lsp-release-20201009T224414-standalone.jar"))
• I change stuff, build the jar via lein uberjar • Restart workspace's clojure LSP session • See changes What's your workflow like?

snoe 2020-11-20T17:42:07.034300Z

@nicdaoraf I launch like this https://github.com/snoe/dotfiles/blob/master/home/.vim/coc-settings.json#L9-L10 There's a repl that launches that you can connect to so you don't have to restart and can just eval anything that's not in main.clj.

snoe 2020-11-20T17:42:26.034600Z

I also use tests a lot because it's still pretty stateful

snoe 2020-11-20T17:42:46.034800Z

so lein test-refresh is very helpful

anonimitoraf 2020-11-21T08:41:45.035Z

> can just eval anything that's not in main.clj. Sorry, but what do you mean by this?

anonimitoraf 2020-11-21T08:42:14.035200Z

And cool, I'll see if I can wrap my head around the tests. Also, stealing stuff from your lein profiles 😛

ericdallo 2020-11-15T15:29:12.031600Z

No, currently there is no such option 😕 But if you have a ns imported with alias in another workspace, example:

(ns a
  (:require [my.c :as c]))
When you write in another namespace:
(ns b)

(c/foo)
with the cursor at the unimported namespace, clojure-lsp will be able to add the required because already know that c/ refer to my.c . You just need to call the lsp-execute-code-action and select add missing namespace