Closed Lenbok closed 1 week ago
If anyone wants to play along, here's my emacs nextflow use-package
declaration that attempts to set up this server under both eglot
and lsp-mode
language server clients. (They call via a bash wrapper script nextflow-language-server
that just calls java -jar
on the language server jarfile I downloaded from this repo).
(use-package nextflow-mode
:ensure (nextflow-mode :host github :repo "edmundmiller/nextflow-mode" :branch "master")
:config
(with-eval-after-load 'eglot
(add-to-list 'eglot-server-programs
'(nextflow-mode . ("nextflow-language-server"))))
(with-eval-after-load 'lsp-mode
(defvar lsp-nextflow-server-command '("nextflow-language-server"))
(lsp-register-client
(make-lsp-client
:new-connection (lsp-stdio-connection (lambda () lsp-nextflow-server-command))
:major-modes '(nextflow-mode)
:multi-root t
:server-id 'nextflow-lsp))
(add-to-list 'lsp-language-id-configuration '(nextflow-mode . "nextflow"))
(lsp-consistency-check lsp-nextflow)))
Tagging @edmundmiller since he is also trying to set up the language client for emacs
Ooo!
I've got the lsp-mode download working with the vsix from the other repo. I think we can combine these and make a PR
We could probably use this repo, but it would need CI set up and no guarantee the release numbers stay in sync.
Whatever @bentsherman thinks we should rely on.
We can set up a repo in the nextflow-io org for you to collaborate
In terms of lsp-mode
(which is the "batteries included" emacs language client), I see @edmundmiller has a fork where he's working on adding that (https://github.com/emacs-lsp/lsp-mode/compare/master...edmundmiller:lsp-mode:master). He should be able to open a PR directly against upstream lsp-mode
. (I think it should be able to download the language server jar from this repo's releases rather than the vscode vsix
).
I think rather than needing another repo, what is needed is documentation in this repo on what configuration is required/accepted when using other clients, plus testing/debugging against other language clients (and either fixing issues here or in the repos of those other clients).
Are you saying there is one emacs language client that everyone uses to connect to all language servers?
Yeah, isn't that how all of the editors do it? They have an implementation of a LSP client: for emacs there is a plugin that implements it, vim.lsp.Client
is the native LSP client in Neovim, etc. These clients define how to connect to a server that implements the LSP spec then you tell it where to connect to the server either one that's already running or how to start it up.
I also was trying to get the language server jar
up and running in the Neovim LSP client and got the server running and connected successfully but it didn't provide anything. Formatting/completion/etc. didn't seem to get provided.
In vscode there is a typescript API that you use to connect vscode to the language server from a vscode extension. So there is no central repository for all vscode <-> language server integrations
In emacs there is one language client (eglot
) that is now part of emacs, and there are a couple of alternatives available as external packages (lsp-mode
, lsp-bridge
), but as @mehalter notes, generally you choose a client and use it for pretty much all language servers, and it's usually a small amount of configuration to connect the client to the server for a particular language.
I haven't used the groovy language server that this one is derived from, but it might be worth trying in order to see whether it also has similar difficulties with other clients.
@Lenbok PR to lsp-mode https://github.com/emacs-lsp/lsp-mode/pull/4606 and then all of the config I used to set it up personally https://github.com/edmundmiller/.doom.d/blob/b5ce985a5bc81629ce53b46fc950a6b47d807d24/modules/lang/nextflow/config.el
@edmundmiller are you saying you have it actually working and jumping to definitions etc?
Yep! I was mainly testing for formatting myself 😬
Give it a shot and let me know if anything isn't working!
Search for symbol Look for references Highlighting of imports Jump to definition works. Might need to clean up the imenu attempts I had in Nextflow-mode before. Completions Errors list
@edmundmiller Thanks, I was able to get the server working using your lsp-mode
PR, and it was also the help I needed to get it working under eglot
. It does seem the nextflow language server does not have a working "default" configuration, and so the language client has to send minimal configuration. From my experimentation, it must contain a "nextflow.files.exclude" section, so for eglot
a minimal project config (i.e. .dir-locals.el
) is:
;;; Directory Local Variables
;;; For more information see (info "(emacs) Directory Variables")
((nextflow-mode
(eglot-workspace-configuration
. (:nextflow (:files (:exclude [".git" ".nf-test" "work"]))))))
@bentsherman Would you be able to document the configuration options the server knows about and what the defaults are? (Possibly even give the server a default value for the above files directive).
@Lenbok I think it's listed out in the schema on the vscode repo. I ran
(lsp-generate-settings "~/src/nf-core/vscode-language-nextflow/package.json" 'lsp-nextflow)
And in the neovim setup https://github.com/mason-org/mason-registry/blob/841ceaba936a1f18a927cb40ff303a3e8efd42ac/packages/nextflow-language-server/package.yaml#L20
@edmundmiller Neat, I didn't know about that ability to reverse engineer the server settings from the vscode package.json
. That could come handy in future. Nevertheless, it feels like there should be some documentation as part of this repo that says what those settings are and do (and if there are any others that don't happen to be mentioned there), since in principle language servers are independent of any particular client such as vscode.
Closing in favor of #56
I tried to connect this language server up in emacs, using
lsp-mode
, and communication is established between the client and server fine. However when editing one of the examples in the nextflow-patterns repo, my lsp client sends various messages to the server but nothing of interest comes back.What configuration settings does the language server expect?
e.g., when I trace the server initialization, I get:
but e.g. jump to definition requests come back empty: