FractalBoy / perl-language-server

101 stars 12 forks source link

goto defintion not working with ampersand prefix #97

Closed cpakkala closed 2 years ago

cpakkala commented 2 years ago

Using tag 0.897, goto definition works on subroutine calls that are not prefixed with an ampersand:

[DEBUG][2022-05-12 20:04:07] .../lua/vim/lsp.lua:1023 "LSP[perlpls]" "client.request" 1 "textDocument/definition" { position = { character = 0, line = 25 }, textDocument = { uri = "file:///home/blah/lib/perl/perl_test.pl" }} <function 1> 1 [DEBUG][2022-05-12 20:04:07] .../vim/lsp/rpc.lua:347 "rpc.send" { id = 2, jsonrpc = "2.0", method = "textDocument/definition", params = { position = { character = 0, line = 25 }, textDocument = { uri = "file:///home/blah/lib/perl/perl_test.pl" } }} [DEBUG][2022-05-12 20:04:07] .../vim/lsp/rpc.lua:454 "rpc.receive" { id = 2, jsonrpc = "2.0", result = { range = { end = { character = 28, line = 16 }, start = { character = 0, line = 13 } }, uri = "file:///home/blah/lib/perl/perl_test.pl" }}

However, if the call is prefixed with an ampersand:

[DEBUG][2022-05-12 20:05:23] .../lua/vim/lsp.lua:1023 "LSP[perlpls]" "client.request" 1 "textDocument/definition" { position = { character = 4, line = 15 }, textDocument = { uri = "file:///home/blah/lib/perl/perl_test.pl" }} <function 1> 1 [DEBUG][2022-05-12 20:05:23] .../vim/lsp/rpc.lua:347 "rpc.send" { id = 3, jsonrpc = "2.0", method = "textDocument/definition", params = { position = { character = 4, line = 15 }, textDocument = { uri = "file:///home/blah/lib/perl/perl_test.pl" } }} [DEBUG][2022-05-12 20:05:23] .../vim/lsp/rpc.lua:454 "rpc.receive" { id = 3, jsonrpc = "2.0"} [INFO][2022-05-12 20:05:23] ...lsp/handlers.lua:323 "textDocument/definition" "No location found"

I'm not an expert on nvim's LSP interface, but it seems like the debugging statements show the communication between the server and client is fine; it seems to be the server not parsing the text under the cursor correctly.

FractalBoy commented 2 years ago

I think I've seen this myself. I'll have to investigate how PPI parses subroutines with an ampersand in front.

I have also seen an issue when trying to go to the definition of a subroutine reference, aka a subroutine name prefixed with \&, and have been meaning to fix that for a while.

FractalBoy commented 2 years ago

@cpakkala I believe this is fixed in #98. Are you able to test to see if it fixes the issue for you?

cpakkala commented 2 years ago

@cpakkala I believe this is fixed in #98. Are you able to test to see if it fixes the issue for you?

Sorry, took me a couple of days to incorporate this into my nix package builds to test it. Yes, it's working as expected now. Thank you!