Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown stylization of completion documentation throws error (pylsp) #1974

Open
2 tasks done
yutanagano opened this issue Jul 4, 2024 · 0 comments
Open
2 tasks done
Labels
bug Something isn't working

Comments

@yutanagano
Copy link

FAQ

  • I have checked the FAQ and it didn't resolve my problem.

Announcement

Minimal reproducible full config

if has('vim_starting')
  set encoding=utf-8
endif
scriptencoding utf-8

if &compatible
  set nocompatible
endif

let s:plug_dir = expand('/tmp/plugged/vim-plug')
if !filereadable(s:plug_dir .. '/plug.vim')
  execute printf('!curl -fLo %s/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim', s:plug_dir)
end

execute 'set runtimepath+=' . s:plug_dir
call plug#begin(s:plug_dir)
Plug 'hrsh7th/nvim-cmp'
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/vim-vsnip'
Plug 'neovim/nvim-lspconfig'
call plug#end()
PlugInstall | quit

" Setup global configuration. More on configuration below.
lua << EOF
local cmp = require "cmp"
cmp.setup {
  snippet = {
    expand = function(args)
      vim.fn["vsnip#anonymous"](args.body)
    end,
  },
  
  mapping = cmp.mapping.preset.insert({
    ['<CR>'] = cmp.mapping.confirm({ select = true })
  }),

  sources = cmp.config.sources({
    { name = "nvim_lsp" },
    { name = "buffer" },
  }),
}
EOF

lua << EOF
local capabilities = require('cmp_nvim_lsp').default_capabilities()

require'lspconfig'.pylsp.setup {
  capabilities = capabilities,
}
EOF

Description

Firstly thank you to all the maintainers and particularly hrsh7th for all your hard work. Much appreciated.

I discovered today that when using nvim-cmp with pylsp to write Python, scrolling through certain completion options will result in the error stack below. It looks like perhaps some completion options have associated markdown documentation, and its stylization during rendering is failing. I have attached a screenshot of this happening with the minimal config above.

Error executing vim.schedule lua callback: /usr/share/nvim/runtime/lua/vim/lsp/util.lua:1409: attempt to index a
 nil value                                                                                                      
stack traceback:                                                                                                
        /usr/share/nvim/runtime/lua/vim/lsp/util.lua:1409: in function 'stylize_markdown'                       
        /tmp/plugged/vim-plug/nvim-cmp/lua/cmp/view/docs_view.lua:64: in function 'open'                        
        /tmp/plugged/vim-plug/nvim-cmp/lua/cmp/view.lua:292: in function 'callback'                             
        /tmp/plugged/vim-plug/nvim-cmp/lua/cmp/utils/async.lua:138: in function ''                              
        vim/_editor.lua: in function <vim/_editor.lua:0>

image

Steps to reproduce

  1. Ensure the language server pylsp is installed (I installed via dnf on Fedora, you can also install via mason.nvim, pip, conda, or I think also homebrew) (I used pylsp v1.11.0)
  2. Create minimal Python environment (I used python3.11 on Fedora when reproducing issue)
  3. Install Pandas (For me it was pandas==2.2.2)
  4. Activate environment
  5. Open a new python file (e.g. test.py) with nvim using minimal config
  6. Write the following in the file:
import pandas as pd

x = pd.r
  1. Wait until completion options appear, then cycle through options (see screenshot above)
  2. At some point, the error shown above in the screenshot will appear

Expected behavior

I should be able to cycle through completion options without any errors, and any associated documentation with completion options should be rendered properly.

Actual behavior

At certain completion options, the rendering of the associated documentation fails (or at least this is what it looks like).

Additional context

Interestingly I can only reproduce with completions using the pandas package. I have tried cycling through some random completion options on other similar packages with long docstrings like numpy and torch, but so far they seem okay.

@yutanagano yutanagano added the bug Something isn't working label Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant