Fork me on GitHub
#lsp
<
2022-04-20
>
wilcov10:04:19

Hello, i'm having some issues with neovim and clojure-lsp, specifically with autocompletion. Hopyfully somebody has an idea how to fix this. When i include a lib with an lias symbol it doesn't seem to recognize the relevant namespace when i try to use some of it's functions. Instead it suggests all the clojure function from the stdlib. I.e.

((ns test
  (:require [io.pedestal.http :as http]))

(def test
  (http/
;; this would suggest functions like -, +, abs, and etc
But then when i would close the expression with a function that doesn't exist lsp would recognize the namespace doesn't have the function. i.e.
(def test
  (http/thisdoesntexist))
;; lsp recognizes that the 'thisdoesntexist' function isn't valid
Then when i remove the function and a try a function that actually exists, it does suggest the correct functions. i.e.
(def test
  (http/st))
;; lsp now suggests the correct functions, i.e. start and stop.
But if i would define another variable that uses the http namespace, it again shows the incorrect functions. I've attached a couple of screenshots to help show what i mean. Fwiw i'm using the following software & versions:
clojure-lsp 2022.04.18-00.59.32
clj-kondo 2022.04.09-SNAPSHOT


openjdk 18 2022-03-22
OpenJDK Runtime Environment Homebrew (build 18+0)
OpenJDK 64-Bit Server VM Homebrew (build 18+0, mixed mode, sharing)

NVIM v0.7.0

ericdallo11:04:55

2 things to check: • Try with parens correctly balanced: (http/ ) not sure that would result on correct results • Check what server is sending to client, check this section: https://clojure-lsp.io/troubleshooting/#client-server-log

wilcov11:04:26

Hi @UKFSJSM38 thanks for your reply. When trying with the parens balanced it does work properly. (i.e. first (def testvar ()) and if i then insert the http/ it gives the proper suggestions. So it seems this is more of an user error than anything else. It's probably best fixed with a plugin that automatically closes parens for me or something like that. Thanks for your help :)

ericdallo11:04:04

Yes, a paredit or something like that would help, I think we could improve on clojure-lsp side, not sure how hard would be since we would not have rewrite-clj nodes correctly because of that code

snoe13:04:30

in clojure-lsp i think we should 1) be notifying the client and not running commands if a command is run against an unparsed ns. i run into this with rename that has a high probability of turning the buffer to garbage. 2) write tests against unparseable code. typically buffers open fine, then a change happens that accidentally kills a paren. so the db has an old version of the code and we return edits based on that.

ericdallo14:04:29

we do have some tests that test unparseable code, clj-kondo has multiple support for that and analysis is a thing that keeps working, but I think rewrite-clj doesn't support that

snoe14:04:17

ime diagnostics keep working, but I'm not sure that analysis does.

ericdallo14:04:14

yeah, a test for that on completion makes total sense anyway