Fork me on GitHub

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


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


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?


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.


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.


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

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?


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?


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: Even if there is no project there, yet. 😃


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


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...


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


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


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...


try adding this config: .lsp/config.edn

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


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

👍 1

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


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


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


Any file in that directory, actually.


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!)


documentation as well


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


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


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


could you check server logs?


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


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


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


What should I look for in the logs?


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


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

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


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


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


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


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


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


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


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


For the reasons you mention.


Why doesn't clojure core things work?


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


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.


it's possible overriding :project-specs already


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


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


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


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


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


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


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


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


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