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

LSP: textDocument/hover is not working correctly in neovim #87192

Closed
tkgalk opened this issue Jan 14, 2024 · 3 comments
Closed

LSP: textDocument/hover is not working correctly in neovim #87192

tkgalk opened this issue Jan 14, 2024 · 3 comments

Comments

@tkgalk
Copy link

tkgalk commented Jan 14, 2024

Tested versions

System information

Godot v4.2.1.stable - macOS 14.2.1 - Vulkan (Forward+) - integrated Apple M1 Max - Apple M1 Max (10 Threads)

Issue description

LSP seems to (still) be working correctly only in VSCode, as previously discussed in #34523. The issue was closed with "please raise issues in editor extensions repos" but this is a basic LSP feature and does not use any extension, so I'll raise it here.

In neovim the call vim.lsp.buf.hover() is what is used by the editor to call the "show me hover tooltip for this thing under cursor", literally the equivalent of hovering your mouse over something in VSCode. Unfortunately, it seems the LSP isn't responding correctly to textDocument/hover called from other editors than VSCode.

The VSCode extension also uses the same LSP command here.

Which results in this:

Screenshot 2024-01-14 at 21 16 37

However, in Neovim (despite LSP clearly connecting and working, as I have autocompletion, diagnostics, errors and documentation), trying to call textDocument/hover through vim.lsp.buf.hover() just returns "no manual entry for Node". This happens when neovim cannot get anything from LSP server and tries to go for manfiles.

Screenshot 2024-01-14 at 21 17 42

Steps to reproduce

  1. You need a working neovim with LSP connected to Godot (https://www.reddit.com/r/neovim/comments/13ski66/neovim_configuration_for_godot_4_lsp_as_simple_as/ <- I recommend this).
  2. Go to any .gdscript file and verify that LSP is connected with :LspInfo (you should see Godot LSP in there), you should also have autocompletion working now.
  3. Use vim.lsp.buf.hover() when hovering over something like "Node3D", usually the default keybind is Shift+K.
  4. See error.

Minimal reproduction project (MRP)

N/A.

@Rubonnek
Copy link
Member

Rubonnek commented Jan 15, 2024

I use neovim and I'm able to see the Node documentation through the default keybind with v4.2.1.stable.official. My guess is the issue comes from your neovim configuration.

  1. https://www.reddit.com/r/neovim/comments/13ski66/neovim_configuration_for_godot_4_lsp_as_simple_as/ <- I recommend this

For what it's worth, my neovim configuration does not pipe the TCP connection and connects directly to it. I'm currently using the LazyVim setup and in my custom plugin specification, this is what I have related to LSP and GDScript:

  -- add servers through lspconfig
  {
    "neovim/nvim-lspconfig",
    ---@class PluginLspOpts
    opts = {
      -- ---@type lspconfig.options
      servers = {
        gdscript = {}, -- NOTE: To change the port, you need to set an environment variable GDScript_Port to the port number.
      },
    },
  },
  -- add more treesitter parsers
  {
    "nvim-treesitter/nvim-treesitter",
    opts = {
      ensure_installed = {
        "gdscript",
      },
    },
  },

@tkgalk
Copy link
Author

tkgalk commented Jan 15, 2024

Interesting. It does work with fresh LazyVim and this set-up, but not with the pipe approach. Might require more people to test their setups.

Also, connecting directly does work for my set-up too. So the LSP does work, but the documentation should be made more obvious on how to set it up. Currently there is no other way than to Google and find random bits and pieces (that are usually outdated).

I think this could be closed? Potentially moved as a documentation issue?

@Rubonnek
Copy link
Member

It does work with fresh LazyVim and this set-up, but not with the pipe approach. Might require more people to test their setups.

I suppose it doesn't work with the pipe because the client probably expects to receive newlines between the JSONs because it's simulating an stdio connection through the piped TCP connection, but some of those newlines may be missing when viewed through the pipe, instead possibly showing up as null characters, which the client doesn't expect and somehow misses/ignores textDocument/hover. I don't think there's any need to support the piped connection since most LSP clients support a TCP connection which makes further testing unnecessary. I'd argue that those possibly missing newlines is a performance enhancement since it's one byte less that needs to travel through the network stack at that stage of the LSP protocol.

I've opened godotengine/godot-docs#8779 to track this documentation issue.

Closing.

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

No branches or pull requests

3 participants