nvim-autopairs icon indicating copy to clipboard operation
nvim-autopairs copied to clipboard

Completing parens on functions with some Lsp (like phpactor) render an error

Open gbprod opened this issue 3 years ago • 0 comments

Description

When completing a function's parens, it renders an error because item.data is not an array:

Error executing vim.schedule lua callback: ...vim-autopairs/lua/nvim-autopairs/completion/handlers.lua:15: attempt to index field 'data' (a number value)                                                                                                                                   
stack traceback:                                                                                                                                                                                                                                                                            
        ...vim-autopairs/lua/nvim-autopairs/completion/handlers.lua:15: in function 'handler'                                                                                                                                                                                               
        ...art/nvim-autopairs/lua/nvim-autopairs/completion/cmp.lua:70: in function 'callback'                                                                                                                                                                                              
        .../site/pack/packer/start/nvim-cmp/lua/cmp/utils/event.lua:47: in function 'emit'                                                                                                                                                                                                  
        ...re/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/core.lua:468: in function ''                                                                                                                                                                                                     
        vim/_editor.lua: in function <vim/_editor.lua:0>      

It happens using phpactor. It could be fixed with #270.

Mapping bug

verbose imap <cr> :

i  <CR>        * <Lua 675: ~/.local/share/nvim/site/pack/packer/start/nvim-cmp/lua/cmp/utils/keymap.lua:111>                                                                                                                                                                                
                 cmp.utils.keymap.set_map     

Steps to reproduce

Setup phpactor Lsp and complete a function.

Minimal config

-- Approximative configuration '-_-

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',
      {
        'windwp/nvim-autopairs',
      },
      {
         "hrsh7th/nvim-cmp",
      },
      {
         "hrsh7th/cmp-nvim-lsp",
      },
      {
        "gbprod/phpactor.nvim",
        run = require("phpactor.handler.update"),
        requires = { "nvim-lua/plenary.nvim", "neovim/nvim-lspconfig" },
      }
    },
    config = {
      package_root = package_root,
      compile_path = install_path .. '/plugin/packer_compiled.lua',
      display = { non_interactive = true },
    },
  }
end
_G.load_config = function()
  require('nvim-autopairs').setup()

  local cmp = require("cmp")
  cmp.setup({
    sources = {
      { name = "nvim_lsp" },
    },
   })

  require("phpactor").setup({})

  local cmp_autopairs = require("nvim-autopairs.completion.cmp")
  cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done())
end
if vim.fn.isdirectory(install_path) == 0 then
  print("Installing nvim-autopairs 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()]]

gbprod avatar Aug 25 '22 07:08 gbprod