~xerool/fennel-ls

3 3

Completions in lsp-mode

Details
Message ID
<87zfwydqfw.fsf@gmail.com>
DKIM signature
pass
Download raw message
Can someone please help me debug completions in Emacs? I'm using
lsp-mode (not eglot). Matter of fact can someone confirm that the
completions do work in Eglot, I'm not sure if the culprit is lsp-mode or
the server.

This is how I'm setting it up:

config.el:

```
(lsp-register-client
   (make-lsp-client
     :new-connection (lsp-stdio-connection "fennel-ls")
     :activation-fn (lsp-activate-on "fennel")
     :server-id 'fennel-ls
     :initialization-options #'fennel-ls-init-options))

(defun fennel-ls-init-options ()
    (let* ((lsp-cfg-dir (concat (projectile-project-root) "/.lsp/"))
            (cfg-file (expand-file-name "fennel-ls.json" lsp-cfg-dir))
            (json-object-type 'plist))
    (when (file-exists-p cfg-file)
        (json-read-file cfg-file))))
```
fennel-ls-init-options basically expects a file in the project dir root
with the settings. I have them set like so:

.lsp/fennel-ls.json
```
{
    "fennel-ls": {
        "checks": {
            "unused-definition": true,
            "unknown-module-field": true
        },
        "extra-globals": "cfg_dir awesome root client screen"}
}
```

Now, what I expect is to when `lsp-completion-at-point` gets triggered,
it would show some candidates, but nothing is there. I've tried
different combinations of "fennel-path", and still failed to get it to
work. Any thoughts on that? Thank you.
Details
Message ID
<87zfwxjpw8.fsf@hagelb.org>
In-Reply-To
<87zfwydqfw.fsf@gmail.com> (view parent)
DKIM signature
pass
Download raw message
Ag <agzam.ibragimov@gmail.com> writes:

> Can someone please help me debug completions in Emacs? I'm using
> lsp-mode (not eglot). Matter of fact can someone confirm that the
> completions do work in Eglot, I'm not sure if the culprit is lsp-mode or
> the server.

Completions work fine in the latest stable version of Eglot. However,
there was some newer issue with the eglot version from git that made it
incompatible with fennel-ls completions. It's possible lsp-mode has a
similar bug? I don't remember the details but maybe someone else who was
on the user-group call over the weekend can say.

-Phil
Details
Message ID
<avQ7m_ksdlQxj6j5B-XUz0eNn8jap0ahK8zwbmZMWGduKDtEsp5lzEc1IRJPRw_dgCvowlXwHwqJaG79TFYZRD_RnkbuWwWgUUPD3zNyx4Y=@protonmail.com>
In-Reply-To
<87zfwydqfw.fsf@gmail.com> (view parent)
DKIM signature
pass
Download raw message
Ag <agzam.ibragimov@gmail.com> writes:
> Can someone please help me debug completions in Emacs? I'm using
> lsp-mode (not eglot). Matter of fact can someone confirm that the
> completions do work in Eglot, I'm not sure if the culprit is lsp-mode or
> the server.

The fennel-ls server should be able to provide completions, so it's
strange that you're not getting any. One potential explanation would be
if fennel-ls isn't running. To check this: does it show diagnostics
when you have a compiler error? If you put a '~' character into a
fennel source file, does the message "invalid character: ~" appear?

In the user group, someone else was also having trouble with
completions. In their case, they were able to see completions in most
cases, but not when completing fields of tables/modules. We determined
that the problem was with a bleeding edge version of eglot, so it's
unlikely that you're hitting the same root cause.

> Now, what I expect is to when `lsp-completion-at-point` gets triggered,
> it would show some candidates, but nothing is there. I've tried
> different combinations of "fennel-path", and still failed to get it to
> work. Any thoughts on that? Thank you.

If you're sure fennel-ls is running, but lsp-mode isn't showing
completions, we may need to look deeper. From [this page][1], lsp-mode
seems to have a way to show the communication between lsp-mode and the
server, by setting `lsp-log-io` to `t`, attempting a completion, then
using `lsp-workspace-show-log`. See if fennel-ls is receiving a
completion request, and if it isresponding with completions as expected.

If fennel-ls is responding with completions but lsp-mode isn't showing
any, there's a change I plan to make to fennel-ls anyway that will
hopefully solve the issue: Right now, fennel-ls uses the `insertText`
field for each completion, which the protocol technically allows, but
discourages. To fix the eglot issue, I plan on switching it to use
`textEdit` instead, which is the way the protocol recommends. If the
problem stems from lsp-mode misinterpreting fennel-ls' messages,
perhaps these planned changes could solve the problem.

- XeroOl

[1]: https://emacs-lsp.github.io/lsp-mode/page/troubleshooting/
Details
Message ID
<87v87jph26.fsf@gmail.com>
In-Reply-To
<avQ7m_ksdlQxj6j5B-XUz0eNn8jap0ahK8zwbmZMWGduKDtEsp5lzEc1IRJPRw_dgCvowlXwHwqJaG79TFYZRD_RnkbuWwWgUUPD3zNyx4Y=@protonmail.com> (view parent)
DKIM signature
pass
Download raw message
XeroOl <xerool@protonmail.com> writes:

> Ag <agzam.ibragimov@gmail.com> writes:
>> Can someone please help me debug completions in Emacs? I'm using
>> lsp-mode (not eglot). Matter of fact can someone confirm that the
>> completions do work in Eglot, I'm not sure if the culprit is lsp-mode or
>> the server.
>
> The fennel-ls server should be able to provide completions, so it's
> strange that you're not getting any. One potential explanation would be
> if fennel-ls isn't running. To check this: does it show diagnostics
> when you have a compiler error? If you put a '~' character into a
> fennel source file, does the message "invalid character: ~" appear?

No, I'm pretty confident that the fennel-ls is properly connected and is working. I know that because when I change
"extra-globals" list and restart the session it affects the client - it stops complaining about unknown globals for
things added to the list. Also unused definitions are getting picked up and I goto-definition also works. Yet there's
something not quite right with the completions.
Reply to thread Export thread (mbox)