yegappan / lsp

Language Server Protocol (LSP) plugin for Vim9
MIT License
447 stars 43 forks source link

Definition autocomplete fails to parse markdown #511

Closed jacobwhall closed 2 months ago

jacobwhall commented 2 months ago

Hi there,

I ran into an odd bug today I figured I should file in case others run into something similar. I'm unsure why this started happening.

When autocomplete options are suggested by lsp, and I hit the down arrow to highlight one and see its markdown description, an error is thrown and the markdown is not displayed. Here is the plaintext error as well as a screenshot of this happening:

Error detected while compiling function <SNR>15_AsyncRpcCb[20]..lsp#completion#CompletionResolveReply[1]..<SNR>26_ShowCompletionDocumentation[59]..FileType Autocommands for "*"..function <SNR>9_LoadFTPlugin[18]..script /home/jacob/dotfiles/vim/.vim/pack/downloads/opt/lsp/ftplugin/lspgfm.vim[76]..function <SNR>59_RenderGitHubMarkdownText:
Line   16:
E1048: Item not found in script: ParseMarkdown

Screenshot from 2024-05-15 14-03-38-cropped

It appears that, despite lsp/markdown.vim being imported as md at the top of lspgfm.vim, the md.ParseMarkdown function isn't found when called here:

https://github.com/yegappan/lsp/blob/dfc001ab109cb16ef4379d3d74554158bbebdcc5/ftplugin/lspgfm.vim#L58-L60

I was able to fix this locally by making the following change to ftplugin/lspgfm.vim:

 vim9script

-import autoload 'lsp/markdown.vim' as md
+import autoload '../autoload/lsp/markdown.vim' as md

 # Update the preview window with the github flavored markdown text
 def UpdatePreviewWindowContents(bnr: number, contentList: list<dict<any>>)

With this change, lsp works again as expected.

I am using the most recent commit of lsp (dfc001a), and the most recent version of the vim-enhanced package available on Fedora. I've included the relevant part of my .vimrc, as well as the output of vi --version below.

packadd lsp

call LspOptionsSet({'autoHighlight': v:true, 'noNewlineInCompletion': v:true, 'useTabInCompletion': v:true })

call LspAddServer([{
    name: 'pylsp',
    filetype: ['python'],
    path: '/home/jacob/.miniforge3/bin/pylsp',
    args: ['-v'],
    workspaceConfig: {
        pylsp: {
            plugins: {
                pycodestyle: {
                    maxLineLength: 200,
                },
            }
        }
    },
    debug: true,
}])
Version of VIM
VIM - Vi IMproved 9.1 (2024 Jan 02, compiled May 06 2024 00:00:00)
Included patches: 1-393
Modified by 
Compiled by 
Huge version without GUI.  Features included (+) or not (-):
+acl               +file_in_path      +mouse_urxvt       -tag_any_white
+arabic            +find_in_path      +mouse_xterm       -tcl
+autocmd           +float             +multi_byte        +termguicolors
+autochdir         +folding           +multi_lang        +terminal
-autoservername    -footer            -mzscheme          +terminfo
-balloon_eval      +fork()            +netbeans_intg     +termresponse
+balloon_eval_term +gettext           +num64             +textobjects
-browse            -hangul_input      +packages          +textprop
++builtin_terms    +iconv             +path_extra        +timers
+byte_offset       +insert_expand     +perl/dyn          +title
+channel           +ipv6              +persistent_undo   -toolbar
+cindent           +job               +popupwin          +user_commands
-clientserver      +jumplist          +postscript        +vartabs
-clipboard         +keymap            +printer           +vertsplit
+cmdline_compl     +lambda            +profile           +vim9script
+cmdline_hist      +langmap           -python            +viminfo
+cmdline_info      +libcall           +python3/dyn       +virtualedit
+comments          +linebreak         +quickfix          +visual
+conceal           +lispindent        +reltime           +visualextra
+cryptv            +listcmds          +rightleft         +vreplace
+cscope            +localmap          +ruby/dyn          +wildignore
+cursorbind        +lua/dyn           +scrollbind        +wildmenu
+cursorshape       +menu              +signs             +windows
+dialog_con        +mksession         +smartindent       +writebackup
+diff              +modify_fname      +sodium            -X11
+digraphs          +mouse             -sound             +xattr
-dnd               -mouseshape        +spell             -xfontset
-ebcdic            +mouse_dec         +startuptime       -xim
+emacs_tags        +mouse_gpm         +statusline        -xpm
+eval              -mouse_jsbterm     -sun_workshop      -xsmp
+ex_extra          +mouse_netterm     +syntax            -xterm_clipboard
+extra_search      +mouse_sgr         +tag_binary        -xterm_save
-farsi             -mouse_sysmouse    -tag_old_static    
   system vimrc file: "/etc/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
 3rd user vimrc file: "~/.config/vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Wno-complain-wrong-lang -Werror=format-security -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -DSYS_VIMRC_FILE=/etc/vimrc -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 
Linking: gcc -Wl,--enable-new-dtags -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -specs=/usr/lib/rpm/redhat/redhat-package-notes -L/usr/local/lib -o vim -lm -lselinux -lncurses -lsodium -lacl -lattr -lgpm 

Thanks for your work on this plugin!

ghost commented 2 months ago

https://github.com/yegappan/lsp/issues/508

jacobwhall commented 2 months ago

Oops! Thanks @riskygit I somehow missed that issue.

jacobwhall commented 2 months ago

Closing this issue in favor of that one.