Fork me on GitHub
#lsp
<
2021-10-28
>
Yehonathan Sharvit13:10:24

How do we use the add missing require feature in NeoVIM?

ericdallo13:10:59

via code actions

ericdallo13:10:11

you need to check how to access code actions on neoVim

ericdallo13:10:35

clojure-lsp will return a Add missing require code action when it knows it can require that ns/alias

Yehonathan Sharvit13:10:57

What kind of logic clojure-lsp uses to guess it can require that alias?

ericdallo13:10:16

that probably deserves a doc about it but it is:

ericdallo13:10:40

• if it's common known require like string/ io/ edn/ • it's the alias already exists on another namespace of the project • (not available on latest release yet, done last week) it tries to infer the namespace name via alias, check https://github.com/clojure-lsp/clojure-lsp/issues/614

Yehonathan Sharvit13:10:21

Is it possible to tell clojure-lsp to resolve with :refer instead of :as ?

ericdallo13:10:14

nope, refers are harder to find since we need to check all vars on the project, but I have some ideas in mind in the future to offer that as well

ericdallo13:10:26

for now, only known refers works

ericdallo13:10:32

like deftest is testing

Yehonathan Sharvit13:10:56

I think I am asking something simpler than what you have in mind. Let's say I am typing clojure.walk/prewalk and instead of having clojure-lsp generate a (require clojure.walk :as [walk]) I want to generate (require clojure.walk :refer [prewalk]

👍 1
ericdallo13:10:33

we don't have that code action, but seems valid

ericdallo13:10:39

feel free to open an issue about it :)

Yehonathan Sharvit13:10:57

By the way, I really liked your talk at London Clojurians

ericdallo13:10:18

thank you :D

ericdallo01:11:56

https://github.com/clojure-lsp/clojure-lsp/issues/627 I thought you meant you would like a code action to add the require with :refer instead of :as, not a code action to change a :as to :refer 😅

andrea.crotti15:10:50

I'm seeing the error locally (void-variable lsp-ada-project-file) doing a M-x load-file and loading the lsp-ada file directly fixes it, but it's weird that I get that error

andrea.crotti15:10:56

I never used ada either

ericdallo15:10:41

this is probably emacs bad compiled lsp-mode package.

andrea.crotti15:10:23

I just recompiled it today

ericdallo15:10:24

lsp-ada-project-file variable is from lsp-ada.el so it's weird

andrea.crotti15:10:27

well removed and reinstalled

andrea.crotti15:10:32

to get the native JSON support

andrea.crotti15:10:38

I can try to remove the .elc maybe

ericdallo15:10:47

yes, try recompiling again

andrea.crotti15:10:37

yeah removing the elc did the trick