ionide / Ionide-vim

F# Vim plugin based on FsAutoComplete and LSP protocol
MIT License
167 stars 20 forks source link

Plug-in crashes when being lazy loaded by vim-plug #31

Closed entropitor closed 2 years ago

entropitor commented 3 years ago

Describe the bug Support being lazy loaded by vim-plug

Error detected while processing /Users/jens/.vim/bundle/Ionide-vim/ftplugin/fsharp.vim:
line   14:
E117: Unknown function: fsharp#getServerConfig
line   66:
E121: Undefined variable: g:fsharp#languageserver_command
E15: Invalid expression: g:fsharp#languageserver_command
line   76:
E121: Undefined variable: g:fsharp#automatic_workspace_init
E15: Invalid expression: g:fsharp#automatic_workspace_init
Error detected while processing CursorMoved Autocommands for "*.fsx":
E117: Unknown function: fsharp#OnCursorMove

To Reproduce Use vim-plug with the following config:

Plug 'autozimu/LanguageClient-neovim', {
    \ 'branch': 'next',
    \ 'for': 'fsharp',
    \ 'tag': '0.1.155',
    \ 'do': 'bash install.sh',
    \ }
Plug 'ionide/Ionide-vim', {
    \ 'for': 'fsharp',
    \ 'do':  'make fsautocomplete',
    \ }

Expected behaviour The plugin working like normal

cannorin commented 3 years ago

Can you provide

I tried adding \ 'for': 'fsharp' to both but I couldn't reproduce it with my environment.

entropitor commented 3 years ago

Hmm, weird. My vimrc are at

https://github.com/entropitor/dotfiles/blob/master/vimrc and https://github.com/entropitor/dotfiles/blob/master/vimrc.bundles

NVIM v0.5.0-nightly-13-gd17e508
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/bin/clang -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNDEBUG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/tmp/neovim-20201106-60977-1290w28/build/config -I/tmp/neovim-20201106-60977-1290w28/src -I/usr/local/include -I/tmp/neovim-20201106-60977-1290w28/deps-build/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include -I/usr/local/opt/gettext/include -I/tmp/neovim-20201106-60977-1290w28/build/src/nvim/auto -I/tmp/neovim-20201106-60977-1290w28/build/include
Compiled by jens@Dinotettix.local

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/Cellar/neovim/HEAD-d17e508/share/nvim"

Run :checkhealth for more info
entropitor commented 3 years ago

Ah @cannorin, it works in my dotfiles because I have this plugin loaded twice, but if you remove vim-polyglot / add fsharp to the list here https://github.com/entropitor/dotfiles/blob/master/vimrc.bundles#L382, it stops working

cannorin commented 2 years ago

I'm closing this because I believe this problem is fixed somewhere in the past. The following .vimrc works without any problem:

"--------------------
"   Basic Settings
"--------------------

set nocompatible

if has("syntax")
  syntax on
endif
filetype plugin on

"-----------
"  Plugins
"-----------

" Here we install the required plugins with vim-plug.
function! s:install()

  " This installs vim-plug automatically when missing.
  " Remove this if .. endif if you don't need this.
  if   empty(glob('~/.vim/autoload/plug.vim'))
  \ || empty(glob('~/.local/share/nvim/site/autoload/plug.vim'))
    silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
        \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
    silent !curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs
        \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
    autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
  endif

  call plug#begin('~/.vim/plugged')

  " On Windows, use 'do': 'powershell -ExecutionPolicy Unrestricted .\install.ps1' instead.
  Plug 'autozimu/LanguageClient-neovim', {
      \ 'for': 'fsharp',
      \ 'branch': 'next',
      \ 'do': 'bash install.sh',
      \ }
  " On Windows, use 'do': 'powershell -ExecutionPolicy Unrestricted .\install.ps1' instead.
  Plug 'ionide/Ionide-vim', {
      \ 'for': 'fsharp',
      \ 'do':  'make fsautocomplete',
      \}

  if has('nvim')
    Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
  else
    Plug 'Shougo/deoplete.nvim'
    Plug 'roxma/nvim-yarp'
    Plug 'roxma/vim-hug-neovim-rpc'
  endif

  call plug#end()
endfunction

" Here we configure deoplete.
" See https://github.com/Shougo/deoplete.nvim and https://github.com/deoplete-plugins/deoplete-lsp for details.
function! s:deoplete()
  let g:deoplete#enable_at_startup = 1
endfunction

" Here we configure LC-neovim.
" See https://github.com/autozimu/LanguageClient-neovim for details.
function! s:lc_neovim()
  nnoremap <silent> xd :call LanguageClient#textDocument_definition()<CR>
  nnoremap <silent> xn :call LanguageClient#textDocument_rename()<CR>
  nnoremap <silent> xf :call LanguageClient#textDocument_formatting()<CR>
  nnoremap <silent> xt :call LanguageClient#textDocument_typeDefinition()<CR>
  nnoremap <silent> xr :call LanguageClient#textDocument_references()<CR>
  nnoremap <silent> xh :call LanguageClient#textDocument_hover()<CR>
  nnoremap <silent> xs :call LanguageClient#textDocument_documentSymbol()<CR>
  nnoremap <silent> xa :call LanguageClient#textDocument_codeAction()<CR>
  nnoremap <silent> xx :call LanguageClient_contextMenu()<CR>
endfunction

" Here we configure Ionide-vim.
function! s:fsharp()
  " Required: for nvim users.
  let g:fsharp#backend = 'languageclient-neovim'

  " If you use project-local fsautocomplete,
  " append 'dotnet', before 'fsautocomplete'.
  let g:fsharp#fsautocomplete_command =
    \ [
    \   'env', 'DOTNET_ROLL_FORWARD=LatestMajor',
    \   'fsautocomplete',
    \   '--background-service-enabled'
    \ ]

  " Recommended: show tooptip when you hold cursor over something for 1s.
  if has('nvim') && exists('*nvim_open_win')
    set updatetime=1000
    augroup FSharpShowTooltip
      autocmd!
      autocmd CursorHold *.fs,*.fsi,*.fsx call fsharp#showTooltip()
    augroup END
  endif

  " Recommended: Paket files are excluded from the project loader.
  let g:fsharp#exclude_project_directories = ['paket-files']
endfunction

" Finally, we call each functions.
call s:install()
call s:fsharp()
call s:deoplete()
call s:lc_neovim()