REditorSupport / REditorSupport/languageserver

Problem with neovim builtin LSP (NA in position)

Open
#481 17 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
675
Forks
118
Avg merge
1d 37m
Merged PRs (30d)
11

Description

I'm experiencing a problem while editing R package in neovim using the builtin LSP support.
It might be that it is not languageserver problem, but here is what led me to think that it might be a good idea to report it here:

Every few keystrokes I get the following message:

Error executing lua /usr/share/nvim/runtime/lua/vim/lsp/util.lua:165: attempt to compare number with string

which corresponds to the following code in util.lua:

--- Position is a https://microsoft.github.io/language-server-protocol/specifications/specification-current/#position
--- Returns a zero-indexed column, since set_lines() does the conversion to 1-indexed
local function get_line_byte_from_position(bufnr, position)
  ...
  local col = position.character
  -- When on the first character, we can ignore the difference between byte and
  -- character
  if col > 0 then  -- <- HERE is the problem
  ...

Concretely, in those cases col is a string "NA" which has led me to post it here.
A quick fix is to add if col == "NA" then return -1 end, which at least silents the message, but I was wondering if some code range could have been propagated wrongly.

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

Reproduce the error while editing an R package in Neovim and start at /usr/share/nvim/runtime/lua/vim/lsp/util.lua:165, where position.character is compared with a number. Trace which language-server response supplies the "NA" value and whether the range was propagated incorrectly. Done means the reported edit no longer triggers the error and the position data is handled consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
neovim, r
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 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.