This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-02-20
Channels
- # architecture (1)
- # babashka (5)
- # beginners (46)
- # calva (8)
- # cider (12)
- # clj-kondo (2)
- # cljfx (3)
- # clojure (23)
- # clojure-europe (7)
- # clojure-israel (2)
- # clojure-nl (11)
- # clojure-norway (8)
- # clojure-uk (1)
- # clojurescript (27)
- # conjure (2)
- # cursive (50)
- # data-oriented-programming (1)
- # data-science (1)
- # datahike (1)
- # datascript (12)
- # emacs (3)
- # events (1)
- # fulcro (13)
- # lambdaisland (7)
- # leiningen (4)
- # lsp (102)
- # meander (2)
- # off-topic (19)
- # parinfer (3)
- # reveal (8)
- # rewrite-clj (13)
- # shadow-cljs (3)
- # specter (13)
- # tools-deps (6)
- # vim (12)
Hi folks, I often edit .cljc
files with reader conditionals in the ns
:require
block:
(ns my-app.core
(:require
[my-app.foo :as foo]
#?@(:cljs
[[my-app.bar :as bar]])))
This seems to break the add-missing-libspec
action. Should this work, or is it too much of a unique use-case to support?
It's indeed a bug @jkrasnay 😔 Please, open an issue with that minimal repro, clojure-lsp should know how to handle that IMO
I’m trying to create a repro but add-missing-libspec
has seemed to stop working for me at all, even for plain .clj
files. I’ve tried clearing out .lsp/sqlite.db
and restarting but it’s no help. Unfortunately I don’t see any logs under /tmp
either. Any ideas?
Are you running arr-missing-libspec
via code actions or manually executing lsp-clojure-add-missing-libspec
?
you can try lsp-clojure-server-info
and find the log-path
where it will point to the clojure-lsp log path
I’m running Neovim with this mapping from @U0BUV7XSA’s vimrc: nnoremap <silent> cram :call CocRequest('clojure-lsp', 'workspace/executeCommand', {'command': 'add-missing-libspec', 'arguments': [Expand('%:p'), line('.') - 1, col('.') - 1]})<CR>
Not sure how to run the equivalent of lsp-clojure-server-info
in Neovim (that looks like an Emacs command to me). Let me try to figure that one out.
I see, the issue with manually calling the commands is that you need to know if for that ns is supported, that's way I recommend calling code actions instead
I'd suggest using code actions instead of manually calling refactor commands (that may not be available all the time, depending on your code)
@U11EL3P9U knows how to call code actions in vim 🙂
Got it. Yeah, @U11EL3P9U was giving me some help on the #vim channel. add-missing-libspec
wasn’t showing in my code actions either, but now I’ve found the log!
FYI I guess MacOS has some fancy ideas on where to put temp files. My log was in /var/folders/6k/qwsbhrf9291gjy8vs1nyyq7h0000gn/T/clojure-lsp.13565201280854705473.out
yeah, @U0BUV7XSA had the same issue, is like JVM save the log on createTempFile
, not sure there is a better way to improve that without messing with user folders permissions
The problem was that I was trying to resolve str/lower-case
. string/lower-case
resolves fine. Obvious in retrospect 😊
yeah, that's why code actions are more reliable 🙂 If there is any way to add that require/import, it'll return the code action, otherwise not
Out of curiosity, would it then be your advice not to use mappings such as "noremap <silent> cram :call CocRequest('clojure-lsp', 'workspace/executeCommand', {'command': 'add-missing-libspec', 'arguments': [Expand('%:p'), line('.') - 1, col('.') - 1]})<CR>" and only rely upon the codeaction (menu)?
The issue is that add-missing-libspec is a command that will only work if the namespace can be imported otherwise will do nothing. The add-missing-* code actions are already returned if it's confirmed that could be imported, so it's a better UI IMO
cycle privacy is available via code action too, and not make sense call in a non function, but it's your choice, is not a huge difference
true, I'm normally "in" a function when I do crcp
to quickly toggle the privacy. Yes, using a code action would achieve the same 🙂
I'm curious to know if it might be possible to show javadoc on a known Java interop method
i.e., if I press K
(a well-known show me the source binding), then if I'm on a, say for example a .javaMethod
it would pop up and show the javadoc for javaMethod
I have a project that needs aliases to generate the correct dev classpath. As in clojure -A:dev -Spath
@U05094X3J This is what I have in .lsp/config.edn at work:
{:project-specs [{:project-path "deps.edn"
:classpath-cmd ["clojure" "-A:frontend:backend" "-Spath"]}]}
I have a clojurescript project that outputs cljs files (for source maps I think) to a directory nested under the resources
directory of my project. Is there a way to make clojure-lsp ignore this directory? Sometimes when I try to navigate to a var definition, it jumps me to a file under this directory when the preferred file exists under my source directory.
I tried setting ignore-classpath-directories
to true but that didn't seem to solve my problem
Yeah, the ignore-classpath-directories
is exactly for that, but I don't know exactly how it works, it's odd to me that it's a boolean, if true it'll ignore what folders?
@U0BUV7XSA should that be a set of files/folders? otherwise, how that does work?
I'm currently attempting force lsp to start with a fresh late by deleting the sqlite.db file. Maybe it held onto some stuff when I set that ignore-classpath-directories
thing
I am unsure if I've fixed it. I deleted the sqlite.db file, I ran lein clean
on my project (which cleaned up the extra cljs files in resources). I'm not jumping into that directory anymore. We will see if it holds.
Hrm, that might be a bug, we should only save jar analysis in the db, no matter the flag.
@UKFSJSM38 If you look at your classpath, there's basically three types of things in there. A) jar files, B) target directories (`output/:target/`) C) source directories (`src/)`. If you set that flag to true, LSP should only walk the jar files from the classpath (A), if the flag is false, then directories (B) would also be analyzed (but should not be stored) and then (as always) we analyze source-paths
based on settings and independent from classpath source paths (C). I'm guessing we messed up what we store in the db when switching to kondo
So if set that flag to true it'll stop walking that jar files? is that make sence? I think we just need a flag to not check the target directories, right?
Alright, I see the point of the boolean now, I saw that the code ignore directories if true, but that won't ignore source paths that are directories too?
Honestly, true
should be the default behaviour, I just wasn't comfortable changing it before.
I'm trying to explore the https://github.com/furkan3ayraktar/clojure-polylith-realworld-example-app using lsp to navigate between the files. But the navigation works in several cases only after entering manually on the destination file. Should it work without that?
@U05094X3J since it's a project with not default folders src test
, you should configure it
with source-paths
: https://clojure-lsp.github.io/clojure-lsp/settings/
or import the specific project instead of the root, like clojure-polylith-realworld-example-app/rest-api
on the first time you open the project (lsp-mode should prompt for you to chosse the root, then you should choose the subproject if you wanna try this way)
So, those are on the :dev
alias under :extra-paths
and they apear on the classpath generated using clojure -A:dev -Spath
And it has to be on the top-level of deps.edn? I renamed the extra-paths to source-paths on the alias (as there is no top-level source-paths) and got the same result.
no, they are different things, extra-paths
is something you tell clj
what are the extra-paths for your classpath, but clojure-lsp
doesn't know that (or is not smarter enough, not sure that would be possible or could be confusing), so you need to tell clojure-lsp what are the dirs that contains the clojrue code of your project, the default are src
and test
For most common clojure projects, the default is enough, since this project use a different folders arch, you need to specify that
Sorry for missing the file where :source-paths
should go, now everything is working. Thank you!
I wonder if the classpath information (that considers the :extra-path
configuration on deps.edn
) should not be enough for analysis since that is what clj-kondo
uses. I'm sure there is a reason why this is necessary and I just don't know what it is.
Thank you for your work on clojure-lsp, I think is an amazing project!
Nice! Yeah, that something to improve probably, but we need to take care to not mess with already working source-paths, but I agree that should be cool feature to have, for leon projects too checking the project.el Feel free to open a feature request issue :)
Has anyone had any luck using clojure-lsp
with Instaparse? Instaparse appears to define may of its symbols via a macro: defclone
. This appears to confuse clojure-lsp
triggering unresolved-vars
errors. I tried fixing this by adding instaparse.macros/defclone clojure.core/def
under the :lint-as
key in .clj-kondo/config.edn
, but that didn’t work.
If so, the correct way to fix the macro lint error is to configure via clj-kondo indeed with :lint-as
@U050CT4HR past here the exact config
{:lint-as {clojure.test.check.clojure-test/defspec clojure.core/def
clojure.test.check.properties/for-all clojure.core/let
instaparse.macros/defclone clojure.core/def
metaprob.generative-functions/gen clojure.core/fn}}
@U050CT4HR rm -rf .lsp/sqlite* and then re-open the project
@UKFSJSM38 Maybe the crawler should take into account a hash of the clj-kondo config for caching?
@U04V15CAJ That fixed it. Cheers!
I was thinking exactly that @U04V15CAJ, we could hash the clj-config used
@U04V15CAJ By the way, I’m giving clojure-lsp
another go because of your recent video, so thanks for that as well. 👍:skin-tone-2: 🙂
Created this to improve that behavior 🙂 https://github.com/clojure-lsp/clojure-lsp/issues/331
I’m experiencing something a bit strange with completion. In one of the files in my project completion isn’t available before a certain line, but is available after it. The only significant thing about the line in question is that it has a .cljc
reader conditional on it. :thinking_face:
check the lsp-log-io
section: https://emacs-lsp.github.io/lsp-mode/page/troubleshooting/
Thanks. Filed here: https://github.com/clojure-lsp/clojure-lsp/issues/332