Fork me on GitHub
#lsp
<
2022-05-08
>
pinkfrog01:05:08

Is it possible to tell lsp to add the classpath from a alias of my ~/.config/clojure/deps.edn ?

practicalli-johnny15:05:36

I hope LSP would look up alias names added to :source-aliases from the project deps.edn and user level deps.edn files. With aliases in the project deps.edn taking precedence if both deps.edn files contain the exact same alias. I haven't tested this yet though

lassemaatta07:05:16

How does keyword completion in clojure-lsp work (with lsp-mode in emacs)? That is, if I type :foo|<tab> , should I get completion suggestions for suitable keywords found in a) only the current namespace, b) the current namespace + all its require 'd namespaces, or c) the whole project?

lassemaatta07:05:52

backstory: I was comparing the completion functionality of cider and clojure lsp and decided to check how completion works if I remove cider from completion-at-point-functions.

lassemaatta07:05:33

at the moment it feels like completion with just lsp works like the a) case above. But I'm not certain if this is how it's supposed to work or if there's something wrong with my emacs/lsp config.

ericdallo13:05:15

Yes, we had some improvements on keyword completions some time ago andonly a) should work. If you have aliased keywords or namespaces keywords though, clojure-lsp should bring properly as well following the namespace

✔️ 1
pez09:05:53

I notice when creating #joyride scripts, that I have no lookup, etcetera help from clojure-lsp. The scripts are located in .joyride/scripts in the project root. The desired workflow is to be able have the project root open and to author both these scripts and code in my project, with retained clojure-lsp support. Is this possible to configure?

ericdallo13:05:53

What do you mean with lookup help? Go to definition? these clojure files are not related with the project, they are not on the classpath or are source paths, right? even though, basic features like lint and things that doesn't rely on other files should work, do you have a example?

pez14:05:06

Yes, I mean things like documentation, and go to definition. And yes, the files are not part of the project. Linting works. An example is the Joyride Examples directory: https://github.com/BetterThanTomorrow/joyride/tree/master/examples Even if there is no project there, yet. 😃

ericdallo15:05:48

yeah, that's why, without a valid project root, clojure-lsp won't find classpath, if you create a deps.edn or project.clj, it should find a classpath and those features may work

pez15:05:00

It doesn't help creating a deps.edn in the project root. Unless I add the joyride scripts to the classpath there, but that's not an option...

ericdallo15:05:19

You want to find a definition from a cljs file in the scripts folder that is in other file on that scripts folder?

ericdallo15:05:38

if so, yeah, it won't work as clojure-lsp has no idea of those files because they are not on project classpath

pez15:05:58

Adding a deps.edn in the .joyride directory doesn't help either. Unless I open that directory as the project root. But then I can script my project using the Joyride REPL...

ericdallo15:05:56

try adding this config: .lsp/config.edn

{:source-paths #{".joyride/scripts"}}
along with a empty deps.edn on the root

pez15:05:45

Or along with whatever deps.edn/project.clj I might have in a project?

👍 1
pez15:05:06

I take that as a yes. I'll try immediately!

ericdallo15:05:21

just to make sure, is joyride/examples your project root, right?

ericdallo15:05:51

could you share a file/function you were trying that was not working so I can test it as well?

pez15:05:33

Any file in that directory, actually.

ericdallo15:05:31

it does work for me with only a deps.edn if I try to find the definition of .joyride/scripts/ignore_form.cljs:26:11 (promessa.core/do!)

ericdallo15:05:22

documentation as well

ericdallo15:05:28

What I did: created a deps.edn with {} on the project root(`joyride/examples`)

ericdallo15:05:11

(find definition of eu/delete-range! works to on that file)

pez15:05:23

I'm trying with that too. Can't get it to work.

ericdallo15:05:38

could you check server logs?

pez15:05:17

Goto def on eu/... stuff works...

ericdallo15:05:21

so it seems is not everything that is not working :)

ericdallo15:05:35

actually, for me everything seems to work fine creating only that deps.edn file

pez15:05:33

What should I look for in the logs?

ericdallo15:05:29

any classpath not found issues, could you share it here so I can help look for it

pez15:05:31

What does clojure-lsp use as project root uri, for you? For me:

"project-root-uri": "file:///Users/pez/Projects/joyride/examples",

ericdallo15:05:08

oh wait a sec, my project root was file:///Users/pez/Projects/joyride/ probably becuase I imported joyride first

ericdallo15:05:20

let me try with the example, I may have the same issues as you probably

ericdallo15:05:15

alright, confirmed it doesn't work, and I know why

ericdallo15:05:27

find definition or hover of pomessa/* won't work because, in your classpath there is no promessa lib

ericdallo15:05:44

and that's expected, because user deps.edn has nothing regarding that

ericdallo16:05:38

and clojure-lsp won't find definition of z-joylib.editor-utils functions unless you open that file manually, because it's not on any source paths, we can fix it though with that lsp config I mentioned above

pez16:05:43

I have that config. And it makes these internal things work. But clojure core and other external stuff does not...

pez16:05:55

For the reasons you mention.

pez16:05:34

Why doesn't clojure core things work?

ericdallo16:05:46

good question, I can repro that too, even if clojure.core is on classpath checking server logs

pez16:05:43

Would be sweet if we could find a way to tell clojure-lsp about classpath things for this non-project directory, similar to how we can inform about the source path.

ericdallo16:05:34

it's possible overriding :project-specs already

ericdallo16:05:16

I think the issue with core symbols is that for example for this code:

(map :foo []) 
the map is a var-usage from cljs.core, but there is only clojure.core on classpath

ericdallo16:05:49

that's the issue indeed, clojurescript analysis are not available on classpath, if you clojure -Spath you will see no cljs lib is available, that's why clojure-lsp doesn't know about that

pez16:05:00

I see. And can I do something about it? That :project-specs override sounds interesting. 😃

ericdallo16:05:22

you can add cljs lib in that deps.edn and that should be enough

ericdallo16:05:52

or, override the project-specs with a custom classpath command that includes cljs but that sounds a little bit more tricky

pez16:05:58

What I want a recipe that Joyride users can follow. Adding cljs to their project's deps.edn might not be an option.

ericdallo16:05:22

it could be in a joyscript alias, and then add that alias to a :source-aliases clojure-lsp setting

pez16:05:48

Thanks! I'll try this and see where it gets me.

ericdallo16:05:03

It's probably the best way ATM to add support for that , I can't see a way or a setting that better One thing we could do to improve that too is to check for a .joyride/scripts folder and automatically consider it as a source-path, not sure would be that good idea