Skip to content

The server shuts down when I close the editor #486

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

Closed
shiroyasha opened this issue May 17, 2024 · 13 comments
Closed

The server shuts down when I close the editor #486

shiroyasha opened this issue May 17, 2024 · 13 comments

Comments

@shiroyasha
Copy link

I'm starting a standalone language server with:

NEXTLS_SPITFIRE_ENABLED=1 ./next_ls --port 12000

and connect to it via Neovim.

Everything works as expected. However, as I close the editor, the server shuts down.

Let me know if I can help in any other way, e.g. by providing version numbers, operating system, etc..

@mhanberg
Copy link
Collaborator

This is expected

@mhanberg mhanberg closed this as not planned Won't fix, can't repro, duplicate, stale May 17, 2024
@mhanberg
Copy link
Collaborator

Are you using the TCP adapter for a special reason?

@shiroyasha
Copy link
Author

shiroyasha commented May 17, 2024

This is expected

Oh, I see, sorry for not checking the documentation first. My mistake.

Are you using the TCP adapter for a special reason?

Two reasons:

  1. My typical workflow is to open vim, edit some files, close vim, and commit. But, I'm seeing some delays in starting up the language server. As a workaround I'm looking into having an up-and-running language server where my vim instance can attach fast.

  2. The rest of my project is running inside of Docker containers during development, and I would love to move the language server inside of a container as well. This is just an experiment so far, which is also not going great as I'm stuck on a problem that I don't know how to further debug https://elixirforum.com/t/running-elixir-lsp-in-docker/63618 😅

@mhanberg
Copy link
Collaborator

How long are these delays?

The TCP mode is not meant to be used by multiple editors or editing sessions, it's mostly meant to for easy testing during development of Next LS.

Regarding that Elixir Forum post, I noticed that your downloaded the linux arm binary. Is that correct? What is your host OS?

@shiroyasha
Copy link
Author

Around 15-20 seconds. Not a huge problem, but it would be nice if I could eliminate it.

I have a short screencast that demonstrates this behaviour.

go-to-definition-delay-lt-10mb.mov

Sorry for the awful video quality, GitHub limited me to 10mb, so I exported it is as 480p. I still have the original, and can upload it to Youtube if it helps.


The TCP mode is not meant to be used by multiple editors or editing sessions, it's mostly meant to for easy testing during development of Next LS.

Clear. I was experimenting with something that was not meant for regular usage 😅

Regarding that Elixir Forum post, I noticed that your downloaded the linux arm binary. Is that correct? What is your host OS?

It should be the correct one, I think. I'm running inside of an UTM based virtual machine on a Mac Studio 2.

$ uname -a
Linux dev 5.15.0-102-generic #112-Ubuntu SMP Tue Mar 5 16:49:56 UTC 2024 aarch64 aarch64 aarch64 GNU/Linux

Thank you for taking time to look into this. I fully understand that I'm doing something a bit exotic, which does not fall into the regular, everyday, usage of next-ls.

@mhanberg
Copy link
Collaborator

Around 15-20 seconds. Not a huge problem, but it would be nice if I could eliminate it.

I have a short screencast that demonstrates this behaviour.

Left pane: Opening a feature test with Vim, and pressing continuously gd to execute "go to definition".
Right page: tail -f .elixir-tools/next-ls.log

so, definitions shouldn't work inside of test files (its a current limitation of test files), so i am surprised to see that jump work at all.

From what I saw, the server booted up pretty quickly, the textDocument/publishDiagnostics notifications comes once your app has compiled or credo has finished running.

Also, based on looking at your config, are you using Elixir LS and Next LS? that might explain why it was able to jump at all (I can't remember how Elixir LS works inside test files).

Can you try your test again but opening a normal file inside lib?

@mhanberg mhanberg mentioned this issue May 17, 2024
@mhanberg
Copy link
Collaborator

Ignore that other issue i opened 😅

@shiroyasha
Copy link
Author

shiroyasha commented May 17, 2024

Heh, interesting, I also didn't know that go-to-definition should not work in test files.

Here are some further experiments:

  1. I've disabled elixir_ls in my vimfiles: https://github.com/shiroyasha/neovimfiles/blob/master/lua/shiroyasha/plugins/lsp/elixir.lua#L15.

  2. I've tested it from the lib folder. There, it is super fast, it is able to jump in a second of opening a file.

go-to-def-lib.mov
  1. I've tested the jump from the test file, it was still working, but same as before with a 20 second delay.

The good news is that the original performance problem is non-existent as I was basing my judgment mostly on test files. One thing that still puzzles me is how does the jump still working even after I've removed the elixir_ls config. 🤔


Edit: Just to be sure that it is not elixir-ls, I've also commented out this line https://github.com/shiroyasha/neovimfiles/blob/master/lua/shiroyasha/plugins/lsp/elixir.lua#L2

@shiroyasha
Copy link
Author

I dig a bit deeper, and looked into the database.

Screenshot 2024-05-17 at 23 17 34

Given that there is no mention of the test directory, or the support module in the nextls.db, it must mean that I'm still using ElixirLS for that jump after all.


Out of curiosity, what is the root problem that prevents nextls from collecting references in the test directory?

@mhanberg
Copy link
Collaborator

Edit: Just to be sure that it is not elixir-ls, I've also commented out this line https://github.com/shiroyasha/neovimfiles/blob/master/lua/shiroyasha/plugins/lsp/elixir.lua#L2

Elixir LS is enabled by default, so you have to disable it for it to turn off.

Out of curiosity, what is the root problem that prevents nextls from collecting references in the test directory?

Tests are scripts and are not compiled. The way Next LS builds its index is via compiler tracers.

Also, some test code (often in test/support) is only compiled in the test environment, but we compile your project in the dev environment.

@shiroyasha
Copy link
Author

Thank you for your detailed responses regarding the language server behavior. I would really like to have the goto definition functionality inside of tests, if it is possible in any way.

Would you be open to continuing this conversation in a dedicated github discussion? I would be happy to contribute or prototype some ideas to explore this further. Of course, if it is not a planned feature, I understand that as well.

@mhanberg
Copy link
Collaborator

There are two open issues related to test files.

#90

#84

I think I might have an idea with how to accomplish definition/references and will post about it in that issue.

@shiroyasha
Copy link
Author

Sounds great! Thank you for investing time & energy into this 🙇‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants