Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocomplete of ns doesn't work when there's no alias to it #1352

Closed
ericliou opened this issue Oct 31, 2022 · 5 comments
Closed

Autocomplete of ns doesn't work when there's no alias to it #1352

ericliou opened this issue Oct 31, 2022 · 5 comments
Labels
bug Something isn't working editor Related to clojure-lsp on a text editor
Projects

Comments

@ericliou
Copy link

Describe the bug
In Emacs, when requiring a ns without an alias, autocomplete doesn't seem to work.
Even with an alias, it still fails at some weird cases.

I also tried with the same clojure-lsp server in nvim and it works every time <3. So it looks like the problem is isolated around integration with emacs.

To Reproduce
Steps to reproduce the behavior:

  1. Use the suggested init.el from https://emacs-lsp.github.io/lsp-mode/tutorials/clojure-guide/#basic-configuration
  2. Create a ns foo.car
  3. Create a second ns requiring the first one without alias. e.g.
(ns foo.bar
  (:require [foo.car]))
  1. Try autocompleting with part of the ns "foo.c"
  2. Result: No relevant candidates come back from foo.car. Sometimes it works, when deleting enough characters.

Expected behavior
The relevant autocomplete candidates are shown with or without alias.

Screenshots

new-recording.mp4
Log - client <-> server
[Trace - 02:01:23 am] Received response 'textDocument/completion - (16)' in 25ms.
Result: [
  {
    "label": "foo.bar",
    "kind": 9,
    "data": {
      "unresolved": [
        [
          "documentation",
          {
            "name": "foo.bar",
            "uri": "file:///home/eric/dev/lsp-debug/src/foo/bar.clj",
            "name-row": 1,
            "name-col": 5
          }
        ]
      ]
    }
  }
]
Log - clojure-lsp
No relevant logs

User details (please complete the following information):

  • OS: ArchLinux
  • Editor: emacs
  • Version: clojure-lsp 2022.10.05-16.39.51
    clj-kondo 2022.10.05

Additional context

New Emacs user here, it could be some configuration issue. But the issue was reproduced with a minimal init.el.

@ericliou ericliou added bug Something isn't working editor Related to clojure-lsp on a text editor labels Oct 31, 2022
@ericdallo
Copy link
Member

ericdallo commented Oct 31, 2022

@ericliou I suspect this is a clojure-lsp bug pretty specific to not being able to complete a invalid code foo/ with / being at the end of the file like:

(my-ns)

clojure.string/

The / ☝🏻 is the last char in the file and clojure-lsp doesn't understand that well

(my-ns)

(clojure.string/)

Auto completing after / here works because / is not the last char.

I know is pretty weird, but could you try both and LMK?

@ericdallo ericdallo added this to Low priority in clojure-lsp via automation Oct 31, 2022
@ericdallo ericdallo changed the title Autocomplete doesn't return candidates reliably in emacs Autocomplete doesn't work when last char of the file is a invalid clojrue code (foo/) Oct 31, 2022
@ericliou
Copy link
Author

ericliou commented Oct 31, 2022

Tried with the case where the file ends with closing paren and it didn't work.

Also, with an alias, (:require [foo.car :as c]):
c/ this works reliably, so it makes me believe that / isn't the issue.

So.. I tried something else and it changed the problem a bit.
(setq lsp-completion-no-cache t)

These cases started to autocomplete functions reliably:

  • foo.car
  • (foo.car)

The only issues that are still left are:

  • Without aliasing the ns, (:require [foo.car])
    • I expected fo to autocomplete foo.car, it doesn't
    • (With an alias, (:require [foo.car :as c]), it DOES work.)

These are weird but minor issues that I can live with :)
Thanks for the help.

@ericliou ericliou changed the title Autocomplete doesn't work when last char of the file is a invalid clojrue code (foo/) Autocomplete of ns doesn't work when there's no alias to it Oct 31, 2022
@ericdallo
Copy link
Member

That's weird, this seems to work properly to me, I also have lsp-completion-no-cache enabled but for development purposes.

Peek 2022-10-31 15-32

@ericdallo
Copy link
Member

Uh, I do notice that we doesn't suggest foo.bar on that gif, that would be something to fix on server side, nothing more besides that as I can see

clojure-lsp automation moved this from Low priority to Next release Nov 2, 2022
@ericdallo
Copy link
Member

Fixed on master, available on next release (a couple of days probably)!

@ericdallo ericdallo moved this from Next release to Done in clojure-lsp Nov 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working editor Related to clojure-lsp on a text editor
Projects
Development

No branches or pull requests

2 participants