nvim-telescope / telescope.nvim

Find, Filter, Preview, Pick. All lua, all the time.
MIT License
15.99k stars 836 forks source link

builtin.lsp_code_actions return an error #1302

Closed koopa1338 closed 3 years ago

koopa1338 commented 3 years ago

Description

Error when selecting an code action:

E5108: Error executing lua /usr/local/share/nvim/runtime/lua/vim/lsp/buf.lua:605: command: expected string, got nil

Example of the code action data that vim.lsp.buf.execute_command is receiving by triggering the code actionimplement missing members in a rust file:

{
  data = {
    codeActionParams = {
      context = {
        diagnostics = {}
      },
      range = {
        end = {
          character = 0,
          line = 4
        },
        start = {
          character = 0,
          line = 4
        }
      },
      textDocument = {
        uri = "file:///home/koopa/Projects/russo/src/lib.rs"
      }
    },
    id = "add_impl_missing_members:QuickFix:0"
  },
  kind = "quickfix",
  title = "Implement missing members"
}

Neovim version

NVIM v0.6.0-dev+386-gad1c42a97 Build type: RelWithDebInfo LuaJIT 2.0.5

Operating system and version

Linux Archer 5.14.8-arch1-1

checkhealth telescope

health#gitmessenger#check
========================================================================
  - OK: +job is available to execute Git command
  - OK: Git command `git` is available: git version 2.33.0
  - OK: Floating window is available for popup window

health#lspconfig#check
========================================================================
## Checking language server protocol configuration
  - INFO: tsserver: configuration checked.
  - INFO: html: configuration checked.
  - INFO: jdtls: configuration checked.
  - INFO: gopls: configuration checked.
  - INFO: clangd: configuration checked.
  - INFO: bashls: configuration checked.
  - INFO: ocamlls: configuration checked.
  - INFO: yamlls: configuration checked.
  - INFO: jsonls: configuration checked.
  - INFO: cssls: configuration checked.
  - INFO: dockerls: configuration checked.
  - INFO: texlab: configuration checked.
  - INFO: vimls: configuration checked.
  - INFO: rust_analyzer: configuration checked.
  - INFO: sumneko_lua: configuration checked.
  - INFO: jedi_language_server: configuration checked.

health#nvim_treesitter#check
========================================================================
## Installation
  - OK: `tree-sitter` found  0.20.0 (parser generator, only needed for :TSInstallFromGrammar)
  - OK: `node` found v16.10.0 (only needed for :TSInstallFromGrammar)
  - OK: `git` executable found.
  - OK: `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl" }
  - OK: Neovim was compiled with tree-sitter runtime ABI version 13 (required >=13). Parsers must be compatible with runtime ABI.

## Parser/Features H L F I J
  - gdscript       ✓ ✓ . . ✓ 
  - beancount      ✓ . ✓ . . 
  - python         ✓ ✓ ✓ ✓ ✓ 
  - sparql         ✓ ✓ ✓ ✓ ✓ 
  - comment        ✓ . . . . 
  - lua            ✓ ✓ ✓ ✓ ✓ 
  - ocaml          ✓ ✓ ✓ . ✓ 
  - go             ✓ ✓ ✓ ✓ ✓ 
  - ql             ✓ ✓ . ✓ ✓ 
  - glsl           ✓ ✓ ✓ ✓ ✓ 
  - json           ✓ ✓ ✓ ✓ . 
  - jsdoc          ✓ . . . . 
  - ledger         ✓ . ✓ ✓ ✓ 
  - php            ✓ ✓ ✓ ✓ ✓ 
  - clojure        ✓ ✓ ✓ . ✓ 
  - supercollider  ✓ ✓ ✓ ✓ ✓ 
  - heex           ✓ . ✓ ✓ ✓ 
  - typescript     ✓ ✓ ✓ ✓ ✓ 
  - fennel         ✓ ✓ . . ✓ 
  - query          ✓ ✓ ✓ ✓ ✓ 
  - cpp            ✓ ✓ ✓ ✓ ✓ 
  - vue            ✓ . ✓ . ✓ 
  - latex          ✓ . ✓ . ✓ 
  - rst            ✓ ✓ . . ✓ 
  - css            ✓ . ✓ ✓ ✓ 
  - glimmer        ✓ . . . . 
  - erlang         . . . . . 
  - regex          ✓ . . . . 
  - svelte         ✓ . ✓ ✓ ✓ 
  - c              ✓ ✓ ✓ ✓ ✓ 
  - fortran        ✓ . ✓ ✓ . 
  - teal           ✓ ✓ ✓ ✓ ✓ 
  - java           ✓ ✓ . ✓ ✓ 
  - hjson          ✓ ✓ ✓ ✓ ✓ 
  - gomod          ✓ . . . . 
  - dart           ✓ ✓ . ✓ ✓ 
  - verilog        ✓ ✓ ✓ . ✓ 
  - bash           ✓ ✓ ✓ . ✓ 
  - yaml           ✓ ✓ ✓ ✓ ✓ 
  - pioasm         ✓ . . . ✓ 
  - json5          ✓ . . . ✓ 
  - vim            ✓ ✓ . . ✓ 
  - julia          ✓ ✓ ✓ ✓ ✓ 
  - cmake          ✓ . ✓ . . 
  - zig            ✓ . ✓ ✓ ✓ 
  - bibtex         ✓ . ✓ ✓ . 
  - turtle         ✓ ✓ ✓ ✓ ✓ 
  - r              ✓ ✓ . . . 
  - toml           ✓ ✓ ✓ ✓ ✓ 
  - devicetree     ✓ ✓ ✓ ✓ ✓ 
  - godotResource  ✓ ✓ ✓ . . 
  - tsx            ✓ ✓ ✓ ✓ ✓ 
  - yang           ✓ . ✓ . . 
  - commonlisp     ✓ ✓ ✓ . . 
  - surface        ✓ . ✓ ✓ ✓ 
  - swift          . . . . . 
  - dot            ✓ . . . ✓ 
  - javascript     ✓ ✓ ✓ ✓ ✓ 
  - ocaml_interface✓ ✓ ✓ . ✓ 
  - elixir         ✓ ✓ ✓ ✓ ✓ 
  - cuda           ✓ ✓ ✓ ✓ ✓ 
  - elm            . . . . . 
  - c_sharp        ✓ ✓ ✓ . ✓ 
  - kotlin         ✓ . . . ✓ 
  - ruby           ✓ ✓ ✓ ✓ ✓ 
  - fish           ✓ ✓ ✓ ✓ ✓ 
  - ocamllex       ✓ . . . ✓ 
  - scala          ✓ . ✓ . ✓ 
  - dockerfile     ✓ . . . ✓ 
  - rust           ✓ ✓ ✓ ✓ ✓ 
  - haskell        ✓ . . . ✓ 
  - perl           ✓ . . . . 
  - tlaplus        ✓ . ✓ . ✓ 
  - jsonc          ✓ ✓ ✓ ✓ ✓ 
  - html           ✓ ✓ ✓ ✓ ✓ 
  - graphql        ✓ . . ✓ ✓ 
  - scss           ✓ . . ✓ . 
  - nix            ✓ ✓ ✓ . ✓ 
  - hcl            ✓ . ✓ ✓ ✓ 

 Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
         +) multiple parsers found, only one will be used
         x) errors found in the query, try to run :TSUpdate {lang}

health#targets#check
========================================================================
  - OK: No conflicting mappings found

health#telescope#check
========================================================================
## Checking for required plugins
  - OK: plenary installed.
  - OK: nvim-treesitter installed.

## Checking external dependencies
  - OK: rg: found ripgrep 13.0.0
  - OK: fd: found fd 8.2.1

## ===== Installed extensions =====

## Telescope Extension: `project`
  - INFO: No healthcheck provided

health#lsp#check
========================================================================
## Checking language server client configuration
  - INFO: LSP log level : WARN
  - INFO: Log path: /home/koopa/.cache/nvim/lsp.log
  - INFO: Log size: 26487 KB

health#nvim#check
========================================================================
## Configuration
  - OK: no issues found

## Performance
  - OK: Build type: RelWithDebInfo

## Remote Plugins
  - OK: Up to date

## terminal
  - INFO: key_backspace (kbs) terminfo entry: key_backspace=^H
  - INFO: key_dc (kdch1) terminfo entry: key_dc=\E[3~
  - INFO: $COLORTERM='truecolor'

health#provider#check
========================================================================
## Clipboard (optional)
  - OK: Clipboard tool found: xclip

## Python 2 provider (optional)
  - INFO: `g:python_host_prog` is not set.  Searching for python2 in the environment.
  - INFO: Executable: /usr/bin/python2
  - INFO: Python version: 2.7.18
  - INFO: pynvim version: 0.4.3
  - OK: Latest pynvim is installed.

## Python 3 provider (optional)
  - INFO: `g:python3_host_prog` is not set.  Searching for python3 in the environment.
  - INFO: Executable: /usr/bin/python3
  - INFO: Python version: 3.9.7
  - INFO: pynvim version: 0.4.3
  - OK: Latest pynvim is installed.

## Python virtualenv
  - OK: no $VIRTUAL_ENV

## Ruby provider (optional)
  - INFO: Ruby: ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux]
  - WARNING: `neovim-ruby-host` not found.
    - ADVICE:
      - Run `gem install neovim` to ensure the neovim RubyGem is installed.
      - Run `gem environment` to ensure the gem bin directory is in $PATH.
      - If you are using rvm/rbenv/chruby, try "rehashing".
      - See :help |g:ruby_host_prog| for non-standard gem installations.

## Node.js provider (optional)
  - INFO: Node.js: v16.10.0
  - INFO: Nvim node.js host: /usr/lib/node_modules/neovim/bin/cli.js
  - OK: Latest "neovim" npm/yarn package is installed: 4.10.0

## Perl provider (optional)
  - ERROR: perl provider error:
    - ADVICE:
      - "Neovim::Ext" cpan module is not installed

health#treesitter#check
========================================================================
## Checking treesitter configuration
  - INFO: Runtime ABI version : 13
  - OK: Loaded parser for bash: ABI version 13
  - OK: Loaded parser for beancount: ABI version 13
  - OK: Loaded parser for bibtex: ABI version 13
  - OK: Loaded parser for c: ABI version 13
  - OK: Loaded parser for c_sharp: ABI version 13
  - OK: Loaded parser for clojure: ABI version 13
  - OK: Loaded parser for cmake: ABI version 13
  - OK: Loaded parser for comment: ABI version 13
  - OK: Loaded parser for commonlisp: ABI version 13
  - OK: Loaded parser for cpp: ABI version 13
  - OK: Loaded parser for css: ABI version 13
  - OK: Loaded parser for cuda: ABI version 13
  - OK: Loaded parser for dart: ABI version 13
  - OK: Loaded parser for devicetree: ABI version 13
  - OK: Loaded parser for dockerfile: ABI version 13
  - OK: Loaded parser for dot: ABI version 13
  - OK: Loaded parser for elixir: ABI version 13
  - OK: Loaded parser for elm: ABI version 13
  - OK: Loaded parser for erlang: ABI version 13
  - OK: Loaded parser for fennel: ABI version 13
  - OK: Loaded parser for fish: ABI version 13
  - OK: Loaded parser for fortran: ABI version 13
  - OK: Loaded parser for gdscript: ABI version 13
  - OK: Loaded parser for glimmer: ABI version 13
  - OK: Loaded parser for glsl: ABI version 13
  - OK: Loaded parser for go: ABI version 13
  - OK: Loaded parser for godotResource: ABI version 13
  - OK: Loaded parser for gomod: ABI version 13
  - OK: Loaded parser for graphql: ABI version 13
  - OK: Loaded parser for haskell: ABI version 13
  - OK: Loaded parser for hcl: ABI version 13
  - OK: Loaded parser for heex: ABI version 13
  - OK: Loaded parser for hjson: ABI version 13
  - OK: Loaded parser for html: ABI version 13
  - OK: Loaded parser for java: ABI version 13
  - OK: Loaded parser for javascript: ABI version 13
  - OK: Loaded parser for jsdoc: ABI version 13
  - OK: Loaded parser for json: ABI version 13
  - OK: Loaded parser for json5: ABI version 13
  - OK: Loaded parser for jsonc: ABI version 13
  - OK: Loaded parser for julia: ABI version 13
  - OK: Loaded parser for kotlin: ABI version 13
  - OK: Loaded parser for latex: ABI version 13
  - OK: Loaded parser for ledger: ABI version 13
  - OK: Loaded parser for lua: ABI version 13
  - OK: Loaded parser for nix: ABI version 13
  - OK: Loaded parser for ocaml: ABI version 13
  - OK: Loaded parser for ocaml_interface: ABI version 13
  - OK: Loaded parser for ocamllex: ABI version 13
  - OK: Loaded parser for perl: ABI version 13
  - OK: Loaded parser for php: ABI version 13
  - OK: Loaded parser for pioasm: ABI version 13
  - OK: Loaded parser for python: ABI version 13
  - OK: Loaded parser for ql: ABI version 13
  - OK: Loaded parser for query: ABI version 13
  - OK: Loaded parser for r: ABI version 13
  - OK: Loaded parser for regex: ABI version 13
  - OK: Loaded parser for rst: ABI version 13
  - OK: Loaded parser for ruby: ABI version 13
  - OK: Loaded parser for rust: ABI version 13
  - OK: Loaded parser for scala: ABI version 13
  - OK: Loaded parser for scss: ABI version 13
  - OK: Loaded parser for sparql: ABI version 13
  - OK: Loaded parser for supercollider: ABI version 13
  - OK: Loaded parser for surface: ABI version 13
  - OK: Loaded parser for svelte: ABI version 13
  - OK: Loaded parser for swift: ABI version 13
  - OK: Loaded parser for teal: ABI version 13
  - OK: Loaded parser for tlaplus: ABI version 13
  - OK: Loaded parser for toml: ABI version 13
  - OK: Loaded parser for tsx: ABI version 13
  - OK: Loaded parser for turtle: ABI version 13
  - OK: Loaded parser for typescript: ABI version 13
  - OK: Loaded parser for verilog: ABI version 13
  - OK: Loaded parser for vim: ABI version 13
  - OK: Loaded parser for vue: ABI version 13
  - OK: Loaded parser for yaml: ABI version 13
  - OK: Loaded parser for yang: ABI version 13
  - OK: Loaded parser for zig: ABI version 13
  - OK: Loaded parser for c: ABI version 13

Steps to reproduce

  1. nvim -nu minimal.lua test.rs
  2. create a struct
    struct Test {}
  3. :lua require('telescope.builtin').lsp_code_actions()
  4. select code action (e.g. Generate impl for Test)

Expected behavior

The correct code action should be executed

Actual behavior

Error with message:

E5108: Error executing lua /usr/local/share/nvim/runtime/lua/vim/lsp/buf.lua:605: command: expected string, got nil
stack traceback:
    /usr/local/share/nvim/runtime/lua/vim/lsp/buf.lua:605: in function 'execute_command'
    ...acker/start/telescope.nvim/lua/telescope/builtin/lsp.lua:278: in function 'execute_action'
    ...acker/start/telescope.nvim/lua/telescope/builtin/lsp.lua:304: in function 'run_replace_or_original'
    ...packer/start/telescope.nvim/lua/telescope/actions/mt.lua:30: in function 'key_func'
    ...k/packer/start/telescope.nvim/lua/telescope/mappings.lua:226: in function 'execute_keymap'
    [string ":lua"]:1: in main chunk

Minimal config

vim.cmd [[set runtimepath=$VIMRUNTIME]]
vim.cmd [[set packpath=/tmp/nvim/site]]
local package_root = '/tmp/nvim/site/pack'
local install_path = package_root .. '/packer/start/packer.nvim'
local function load_plugins()
  require('packer').startup {
    {
      'wbthomason/packer.nvim',
      'neovim/nvim-lspconfig',
      {
        'nvim-telescope/telescope.nvim',
        requires = {
          'nvim-lua/plenary.nvim',
          { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make' },
        },
      },
      -- ADD PLUGINS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
    },
    config = {
      package_root = package_root,
      compile_path = install_path .. '/plugin/packer_compiled.lua',
      display = { non_interactive = true },
    },
  }
end
_G.load_config = function()
  require('telescope').setup()
  require('telescope').load_extension('fzf')
  -- ADD INIT.LUA SETTINGS THAT ARE _NECESSARY_ FOR REPRODUCING THE ISSUE
end
if vim.fn.isdirectory(install_path) == 0 then
  print("Installing Telescope and dependencies.")
  vim.fn.system { 'git', 'clone', '--depth=1', 'https://github.com/wbthomason/packer.nvim', install_path }
end
load_plugins()
require('packer').sync()
vim.cmd [[autocmd User PackerComplete ++once echo "Ready!" | lua load_config()]]

local nvim_lsp = require('lspconfig')
-- lsp config
local custom_attach = function()
    vim.bo.omnifunc = "v:lua.vim.lsp.omnifunc"
end

local servers = {
    rust_analyzer = {},
}

local capabilities = vim.lsp.protocol.make_client_capabilities()

for server, config in pairs(servers) do
    config.on_attach = custom_attach
    config.capabilities = capabilities
    nvim_lsp[server].setup(config)
end
ten3roberts commented 3 years ago

I can confirm this problem occurs for me as well using code actions with rust-analyzer.

The issue does not occur when using the C# Omnisharp-roslyn server. There results are as expected.

koopa1338 commented 3 years ago

The sumneko language server also works. Im currently not at home, but could test some more but I dont think that the rust-analyzer is the issue here as the vim.lsp.buf.code_action() call works just fine.

Conni2461 commented 3 years ago

I can reproduce. It worked last friday, for me. I will look at it in the next couple of days.

Thanks for reporting :)

Conni2461 commented 3 years ago

Took me a day longer. I am sorry for that. Anyone has time to test https://github.com/nvim-telescope/telescope.nvim/pull/1311

It works for me with that PR

koopa1338 commented 3 years ago

@Conni2461 tested your PR and can confirm that it fixes the issue.