scry icon indicating copy to clipboard operation
scry copied to clipboard

Completion fails using Emacs and lsp-mode

Open xeals opened this issue 5 years ago • 0 comments

The full backtrace is mostly lsp-mode internals, but the (pretty-printed) gist of it is:

Couldn't parse (LSP::Protocol::NotificationMessage | LSP::Protocol::RequestMessage) from
{
  "jsonrpc": "2.0",
  "method": "textDocument/completion",
  "params": {
    "textDocument": {
      "uri": "file:///home/dev/cls/src/cls/log.cr"
    },
    "position": {
      "line": 3,
      "character": 2
    },
    "context": {
      "triggerKind": 1
    }
  },
  "id": 22
}
at 1:1

where the file is simply, where | is the cursor:

module CLS
  |
end

I thought this was traceable to this line in lsp, as the message doesn't send the triggerCharacter field and that's preventing it from being deserialized:

https://github.com/crystal-lang-tools/lsp/blob/master/src/lsp/protocol/completion_context.cr#L11

Per the specification, triggerCharacter should be nullable:

export interface CompletionContext {
	/**
	 * How the completion was triggered.
	 */
	triggerKind: CompletionTriggerKind;

	/**
	 * The trigger character (a single character) that has trigger code complete.
	 * Is undefined if `triggerKind !== CompletionTriggerKind.TriggerCharacter`
	 */
	triggerCharacter?: string;
}

However, compiling a version with this fix and #174 doesn't seem to help. Stuck on how to further debug at the moment.

xeals avatar Jun 24 '20 12:06 xeals