ionide / Ionide-vim

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

g:fsharp#languageserver_command is not defined after installing Ionide-vim #8

Closed panesofglass closed 5 years ago

panesofglass commented 5 years ago

Describe the bug g:fsharp#languageserver_command is not defined after installing Ionide-vim.

To Reproduce Steps to reproduce the behaviour:

  1. Follow instructions to install Ionide-vim
  2. Edit any file with nvim .
  3. See error while nvim opens

Expected behaviour Correctly load a pre-configured variable named g:fsharp#languageserver_command to issue commands to FSAC.

Screenshots

Error detected while processing /home/ryan/.vim/init.vim:
line   42:
E121: Undefined variable: g:fsharp#languageserver_command
E15: Invalid expression: { 'fsharp': g:fsharp#languageserver_command }

Environment (please complete the following information):

panesofglass commented 5 years ago

Looks like the issue could be related to my switch to Vim8's built-in package manager pack/*/start path, the install.fsx places the built package in the wrong place. By changing the path to pack/bundle/start/* in install.fsx, it seems like it should work, but I see the same result.

cannorin commented 5 years ago

I haven't really tested install.fsx so much so it may be not working correctly. I'll investigate it.

cannorin commented 5 years ago

As a workaround for now, you can use Plug or dein.vim and it should work as expected.

cannorin commented 5 years ago

Did you use install.sh for installing?

panesofglass commented 5 years ago

Yes, I used install.sh. I’m not interested in using plug or dein.vim, so I’ll pass for now. Thanks.

cannorin commented 5 years ago

If you've installed to .vim/pack/*/start, it won't work in neovim: try .local/share/nvim/site/pack/*/start instead.

cannorin commented 5 years ago

If not, let me know and I'll set up a new Ubuntu environment and try to figure out why it isn't working.

giulioungaretti commented 5 years ago

@cannorin I have the same issue actually, installing with Plug :D running vim on mac osx! LMK if you'd rather have another issue opened, or just continue here and more importantly if any more details could help you! I'd love to get this working :D

cannorin commented 5 years ago

@giulioungaretti It could be because you added

let g:LanguageClient_serverCommands = {
  \ 'fsharp': g:fsharp#languageserver_command
  \ }

before you installed the plugin by executing :PlugInstall. Adding it after installing should not trigger the error. If it wasn't the case, let me know more details.

giulioungaretti commented 5 years ago

:PlugInstall ✔️

Open vim in ~ get:

Error detected while processing /Users/unga/.vimPlug:
line   23:
E121: Undefined variable: g:fsharp#languageserver_command
Press ENTER or type command to continue

Open a .fs file:

Error detected while processing /Users/unga/.vim/plugged/Ionide-vim/ftplugin/fsharp.vim:
line   12:
FSAC not found. :FSharpUpdateFSAC to download.

Run said command:

E492: Not an editor command: FSharpUpdateFSAC 

Which makes me think it could be related to some PATH issues ?

cannorin commented 5 years ago

Ah, my bad. That's because I placed the existence-checking code before defining commands: https://github.com/ionide/Ionide-vim/blob/master/ftplugin/fsharp.vim#L11

As a workaround, could you try doing :call fsharp#updateFSAC() and see what happens?

panesofglass commented 5 years ago

It's still not working for me. :( I'll continue to try again every so often.

cannorin commented 5 years ago

@panesofglass I'll reproduce your environment and try to find out why it isn't working. Could you provide me the location of Ionide-vim and your .vimrc?

cannorin commented 5 years ago

@giulioungaretti https://github.com/ionide/Ionide-vim/commit/5f4f194bc1d2721156fe0b861371360df40ed527 addressed the problem :FSharpUpdateFSAC is not available. If you have not tried the workaround above, you can instead upgrade Ionide-vim to the latest. I suspect that autoload/fsharp.vim is not correctly loaded, so if my guess is correct it will give you a different error message.

panesofglass commented 5 years ago

@cannorin thank you! On Windows, I'm using ~\AppData\Local\nvim with an init.vim in that folder. On Linux, I'm using ~/.config/nvim with init.vim in that folder. I'm storing my plugins using ~/*/nvim/pack/bundle/start. You can access my vimfiles where I'm trying to use Ionide-vim here. (I should have shared that sooner, come to think of it.)

cannorin commented 5 years ago

@panesofglass

  1. You are using the master branch of LanguageClient-neovim which is very outdated and cannot be used. Switch to the next branch and run install.sh.
  2. I didn't know that plugins are loaded after vimrc/init.vim unless manually sourced (which most plugin managers do), which is the source of this problem. I should restructure the settings flow in order to fix this.
cannorin commented 5 years ago

@giulioungaretti @panesofglass I just created issue-8_languageserver-command-not-defined branch and applied the fix (hopefully) to it. Can you switch to that branch and try it out?

The languageserver configuration is now done automatically and

let g:LanguageClient_serverCommands = {
  \ 'fsharp': g:fsharp#languageserver_command
  \ }

in vimrc/init.vim is not needed anymore.

giulioungaretti commented 5 years ago

@cannorin it works wonderfully with that branch! Tested on wsl2 + mac osx!

cannorin commented 5 years ago

@giulioungaretti Great to hear that!

panesofglass commented 5 years ago

I've updated everything, but I still see the error on both wsl2 and windows. Maybe I missed something?

cannorin commented 5 years ago

@panesofglass Make sure you removed the let g:LanguageClient_serverCommands = ... line from your init.vim as it would be the only source of the "not defined" error.

panesofglass commented 5 years ago

Ah, thanks! I missed that bit. It works great now! By the way, if I wanted to add additional language server commands, would I just not add anything about fsharp?

cannorin commented 5 years ago

Thanks! I'll merge the fix now.

The current implementation of Ionide-vim only adds the F# language server command when editing F# files, so you can just add language server of another languages.

cannorin commented 5 years ago

@panesofglass @giulioungaretti Don't forget to switch back to the master branch (I'll delete the issue branch in few days). Thanks a lot for reporting a bug :joy: