orbitalquark / textadept-lsp

Language server protocol client module for Textadept.
MIT License
28 stars 9 forks source link

[question] lsp works but hover not working? #9

Closed LollipopFt closed 1 year ago

LollipopFt commented 1 year ago

hi, when i hover over a text nothing appears: image

only when i click Tools > Language Server > Show Hover Information the hover information appears there: image

shouldn't hover information appear when i hover over text, or am i missing a setting? my settings:

buffer.use_tabs = true
buffer.tab_width = 2
buffer.eol_mode = buffer.EOL_LF
view.view_eol = true
view.view_ws = view.WS_VISIBLEALWAYS

require('elastic_tabstops')

require('ctags')
local lsp = require('lsp')
lsp.server_commands.rust = 'rust-analyzer'
require('spellcheck')

textadept and lsp version: 12.0 latest nightly version (as of 16 Jan 2023) does not work at all: lsp server immediately closes with error 101

i have read the rpc logs and there are no errors.

orbitalquark commented 1 year ago

You're right that hover information should appear when you hover over text and hold the mouse stationary for a half-second or so. It works for me on Linux with clangd (C++ language server), so there may be something odd going on on Windows. I don't have a Windows box to test on at the moment, but I'll look into this when I have a chance.

On a side note: the LSP module is currently under heavy development, so there may be some transitory issues. The module was recently updated to support LSP version 3.17.0, which your server may not yet support. I don't know what server error 101 is for Rust.

LollipopFt commented 1 year ago

On nightly version 17 Jan 2023, it shows this error in the [Output Buffer]

textadept\data/modules/lsp/init.lua:664: textadept\data/modules/lsp/init.lua:415: attempt to index a nil value (local 'line')

and shows this in the [LSP] buffer

Starting language server: rust-analyzer
Server exited with status 101

could i see how you set up your clangd server on textadept so i can test to see if it is a server issue or an issue in the lsp module itself? thanks!

by the way, i use eol LF files despite using windows, don't know if that may affect anything.

orbitalquark commented 1 year ago

I think that error means your language server has died.

My clangd configuration as simple as this:

 lsp.server_commands.cpp = 'clangd'
LollipopFt commented 1 year ago

config:

local lsp = require('lsp')
lsp.server_commands.rust = 'rust-analyzer'
lsp.server_commands.c = 'clangd'
lsp.server_commands.cpp = 'clangd'

[Output Buffer] (for both c and cpp files):

textadept\data/modules/lsp/init.lua:664: textadept\data/modules/lsp/init.lua:212: No project root found

for rust file:

textadept\data/modules/lsp/init.lua:664: textadept\data/modules/lsp/init.lua:415: attempt to index a nil value (local 'line')

file structure:

the language servers, both rust (rust-analyzer) and c and cpp (clangd) work in other text editors such as neovim, sublime text, lapce and helix on my computer.

orbitalquark commented 1 year ago

For the "no project root found" error, you need to have a version control directory in the project root folder (you can fake one by creating a .git/ if you want). Textadept needs to know what root directory to pass to the language server.

LollipopFt commented 1 year ago

the language servers now work for c and cpp files, thanks so much! i guess there is something different about the rust server then. (not sure what 'attempt to index a nil value means'). however, there is still no hover functionality for c and cpp and i still have to do Tools > Language Server > Show Hover Information.

orbitalquark commented 1 year ago

The LSP module is trying to read a line of output from the Rust language server, but the Rust language server has probably died, so the line is nil and cannot be worked with. I'll add better error handling for this.

I'll have to investigate hover on Windows when I have access to a Windows box.

LollipopFt commented 1 year ago

sorry for not doing this sooner, forgot to turn on log_rpc.

Starting language server: rust-analyzer
RPC send:
{
  "params": {
    "rootUri": "file:///R:/wgpu_prac",
    "capabilities": {
      "textDocument": {
        "signatureHelp": {
          "signatureInformation": {
            "parameterInformation": {
              "labelOffsetSupport": true
            },
            "activeParameterSupport": true,
            "documentationFormat": ["plaintext"]
          }
        },
        "synchronization": {
          "didSave": true
        },
        "completion": {
          "completionItem": {
            "preselectSupport": true,
            "documentationFormat": ["plaintext"]
          },
          "completionItemKind": {
            "valueSet": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]
          }
        },
        "selectionRange": [],
        "hover": {
          "contentFormat": ["plaintext"]
        },
        "documentSymbol": {
          "symbolKind": {
            "valueSet": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]
          }
        }
      }
    },
    "clientInfo": {
      "version": "Textadept 12.0 alpha",
      "name": "textadept"
    },
    "processId": null
  },
  "id": 1,
  "jsonrpc": "2.0",
  "method": "initialize"
}
Server exited with status 101
orbitalquark commented 1 year ago

The hover issue should be fixed via https://github.com/orbitalquark/textadept/commit/07331016da374fbc2fa5618c4a9232ac76c91920 and will be in the next nightly build. Whenever you choose to update, please also grab the latest LSP module, as a lot of work has been done on it in the meantime.

There's nothing I can do about the Rust language server issue because it's crashing for unknown reasons.