jaredly / jaredly/reason-language-server

unqualified completions not working in NeoVim

Open
#408 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
OCaml
Stars
649
Forks
85
PR merge metrics
No merged PRs in 30d

Description

using neovim with LanguageClient, and for some reason autocompleting `Pervasives.int_of` works but simply `int_of` does not work.

LanguageClient is triggering `'textDocument/completion'` with characterposition
* 0 for "int_of"
* 11 for "Pervasives.int_of"

As far I've been able to tell a character offset of 0 would lead to `PartialParser.findCompletable` returning `Nothing`.

Shouldn't this complete modules and everything opened?

EDIT:
BuckleScript 7.1.1 ( Using OCaml:4.06.1+BS )

EDIT 2: log output that lead me to believe character 0 is the problem here
```
{"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":0,"line":7},"textDocument":{"uri":"file:///home/hesxenon/projects/powermaze/src/App.re"}},"id":10}
[server] Got a method textDocument/completion
[server] processing took 0.0109672546387ms
Nothing completable found :/
Sending response {"id": 10, "jsonrpc": "2.0", "result": []}
```
vs
```
{"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":5,"line":7},"textDocument":{"uri":"file:///home/hesxenon/projects/powermaze/src/App.re"}},"id":12}
[server] Got a method textDocument/completion
[server] processing took 0.00715255737305ms
Opens folkz > 0
Package opens Pervasives Powermaze Powermaze
Package opens Pervasives Powermaze Powermaze
FINDING docs for module Impl(/home/hesxenon/projects/powermaze/node_modules/bs-platform/lib/ocaml/pervasives.cmti, /home/hesxenon/projects/powermaze/node_modules/bs-platform/lib/ocaml/pervasives.mli)
FINDING /home/hesxenon/projects/powermaze/node_modules/bs-platform/lib/ocaml/pervasives.cmti src /home/hesxenon/projects/powermaze/node_modules/bs-platform/lib/ocaml/pervasives.mli
FINDING docs for module Impl(/home/hesxenon/projects/powermaze/lib/bs/Powermaze.cmt, nil)
FINDING /home/hesxenon/projects/powermaze/lib/bs/Powermaze.cmt src
FINDING docs for module Impl(/home/hesxenon/projects/powermaze/lib/bs/Powermaze.cmt, nil)
FINDING /home/hesxenon/projects/powermaze/lib/bs/Powermaze.cmt src
Opens nows 3 file:///home/hesxenon/projects/powermaze/node_modules/bs-platform/lib/ocaml/pervasives.mli file:///home/hesxenon/projects/powermaze/lib/bs/Powermaze.cmt file:///home/hesxenon/projects/powermaze/lib/bs/Powermaze.cmt
---------------- LOCAL VAL
- Completing in file:///home/hesxenon/projects/powermaze/node_modules/bs-platform/lib/ocaml/pervasives.mli
-- not capitalized
- Completing in file:///home/hesxenon/projects/powermaze/lib/bs/Powermaze.cmt
-- not capitalized
- Completing in file:///home/hesxenon/projects/powermaze/lib/bs/Powermaze.cmt
-- not capitalized
Sending response {"id": 12, "jsonrpc": "2.0", "result": [{"label": "int_of_float", "kind": 12, "detail": "float => int", "documentation": "Truncate the given floating-point number to an integer. The result is unspecified if the argument is `nan` or falls outside the range of representable integers.\n\n\n\nfile:///home/hesxenon/projects/powermaze/node_modules/bs-platform/lib/ocaml/pervasives.mli:612"}, {"label": "int_of_char", "kind": 12, "detail": "char => int", "documentation": "Return the ASCII code of the argument.\n\n\n\nfile:///home/hesxenon/projects/powermaze/node_modules/bs-platform/lib/ocaml/pervasives.mli:683"}, {"label": "int_of_string_opt", "kind": 12, "detail": "string => option(int)", "documentation": "Same as `int_of_string`, but returns `None` instead of raising.\n\nSince: 4.05\n\nfile:///home/hesxenon/projects/powermaze/node_modules/bs-platform/lib/ocaml/pervasives.mli:748"}, {"label": "int_of_string", "kind": 12, "detail": "string => int", "documentation": "Convert the given string to an integer. The string is read in decimal \\(by default, or if the string begins with `0u`\\), in hexadecimal \\(if it begins with `0x` or `0X`\\), in octal \\(if it begins with `0o` or `0O`\\), or in binary \\(if it begins with `0b` or `0B`\\).\n\nThe `0u` prefix reads the input as an unsigned integer in the range `[0, 2*max_int+1]`. If the input exceeds max_int it is converted to the signed integer `min_int + input - max_int - 1`.\n\nThe `_` \\(underscore\\) character can appear anywhere in the string and is ignored. Raise `Failure \"int_of_string\"` if the given string is not a valid representation of an integer, or if the integer represented exceeds the range of integers representable in type `int`.\n\n\n\nfile:///home/hesxenon/projects/powermaze/node_modules/bs-platform/lib/ocaml/pervasives.mli:729"}]}
```

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at PartialParser.findCompletable and the textDocument/completion handling shown in the logs. Reproduce the difference between `int_of` and `Pervasives.int_of` in NeoVim with LanguageClient, then verify that unqualified completions include opened modules and other expected symbols.

Written by the indexing model from the issue text.

Assessment

Tech stack
neovim, ocaml
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.