Skip to content

Client capability configuration gets ignored. (Fixed on linked branch) #2318

Description

@rymdbar

How are you using the lua-language-server?

Other

Which OS are you using?

Linux

What is the issue affecting?

Other

Expected Behaviour

With lua-language-server's README.md documenting support for

↪ Go to definition

one could expect calling :ALEGoToDefinition from an editor using vim-ale to move the cursor to the definition as it does with other language servers. Or to be more technical, one could expect that jsonrpc method calls like the following:

{
  "method":"textDocument/definition",
  "jsonrpc":"2.0",
  "id":3,
  "params":{
    "textDocument":{
      "uri":"file:///tmp/luals/hello.lua"
    },
    "position":{
      "character":1,
      "line":4
    }
  }
}

would get resonses similar to:

{
  "jsonrpc":"2.0",
  "id":3,
  "result":[
    {
      "uri":"file:///tmp/luals/hello.lua",
      "range":{
        "start":{
          "line":0,
          "character":9
        },
        "end":{
          "line":0,
          "character":14
        }
      }
    }
  ]
}

Actual Behaviour

The textDocument/definition calls do not get any response at all. The language server appears to still be running, as e.g. typing text does show responses to textDocument/completion calls even after the failed textDocument/definition calls.

Reproduction steps

  1. Create the file hello.lua with the following contents:
function hello()
   print "Hi there"
end

hello()
  1. Open the file with vim, configured to use lua-language-server through ale:
augroup lua
  autocmd FileType lua let b:ale_linters = { 'lua': [ 'lua_language_server', 'cspell', 'luac', 'luacheck', 'selene' ] }
augroup END
let g:ale_lua_language_server_executable = $HOME . '/.vim/luals/bin/wrapper'

For additional debug, use this wrapper script to save all jsonrpc communication to the two text files:

#!/bin/sh -eu

_in='/tmp/langserv2vim'; _out='/tmp/vim2langserv'
_langserv=~/.vim/luals/bin/lua-language-server

tee "$_out" | "$_langserv" --loglevel=trace "$@" | tee "$_in"

unset _in _out _langserv

Additional Notes

Releases 3.6.25, 3.7.0 and 3.7.3 have been showing this issue. I have not tested any other versions.

At time of reporting, I unfortunately do not have sufficient understanding of the Language Server Protocol Specification to be able to debug this any further, and have so far not looked at the lua-language-server source code. edit: Analysis and fix available below.

Log File

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions