openlawlibrary/pygls

Can't make Nvim show completion list

Closed this issue · 5 comments

Hi there,

I'm just playing with Pygls, trying to make an LSP for a custom language and I can't get it to show the list of options with nvim. I have tried this https://github.com/openlawlibrary/pygls/tree/master/examples/hello-world (nvim lua and vim lsp). I've also tried coc-settings but it didn't work. What am I doing wrong?

tombh commented

Hi there,

I think we might need a bit more info to see what's going on here. There are a surprising number of little details to get everything working right, so it's understandable it's not working straight away.

For example, it would be good to know the file extension of the file that you're trying to get the autocomplete to work in. I can't remember if pattern = { "*" } is valid, you may need to be more specific, say pattern = { "*.txt" }. Anyway that's just an example of one of the many details that need to be right to get everything working. So please let us know what you've setup so far. I'm sure it'll help other people in the future, and we may even be able to improve the docs.

Hi Tom!

Thanks for your reply.

When i tried setting it up with LUA and vim-script i just copy paste from the docs so i'll try changing the pattern as you say.The file extension is .gbs and now i'm trying setting it up with coc-settings like this:

"languageserver": {
    "gobstones": {
      "enable": true,
      "pythonPath": "/home/user/Workspace/env/bin/python",
      "command": "/home/user/Workspace/env/bin/python",
      "args": ["/home/user/Workspace/server.py"],
      "filetypes": ["gbs"],
      "initializationOptions": {},
      "trace.server": "verbose",
      "settings": {},
    }
  }

After that i did opened a .gbs file with nvim and run these commands : setfiletype gbs and :CocRestart

I got this record and it seems fine to me, but the pop-up menu does not show any options from the list of items.

DEBUG:pygls.protocol:Notification message received.
DEBUG:pygls.server:Content length: 185
DEBUG:pygls.protocol:Received b'Content-Length: 185\r\n\r\n{"jsonrpc":"2.0","id":5,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///home/user/a.gbs"},"position":{"line":1,"character":1},"context":{"triggerKind":1}}}'
DEBUG:pygls.protocol:Request message received.
INFO:pygls.protocol:Sending data: {"id": 5, "jsonrpc": "2.0", "result": {"isIncomplete": false, "items": [{"label": "world"}, {"label": "friend"}]}}

I'm a little bit confuse about all of this (because i'm clearly a noob :D). Should i give up trying to set this LSP with coc-settings?

tombh commented

How's it going?

Those debug logs look really promising! Pygls is sending a response back to Neovim, so it's just the client that isn't picking it up. I know that at least Nvim's native client (maybe Coc's client too) has a nice command LSPInfo that gives some helpful info about how the LSP client is setup.

Hi @tombh, @fgplastina this issue has been reported on the coc.nvim side and may have already been resolved.

Ah yes, the trigger characters, that tripped me up too when I was first trying this!. Ok, I'll close this then. Thank you.