neovimhaskell / nvim-hs

Neovim API for Haskell plugins as well as the plugin provider
Other
267 stars 18 forks source link

Better plugin discovery #51

Closed teto closed 7 years ago

teto commented 7 years ago

The way to install haskell plugins is not as smooth as it is for python for instance where you just drop your .py files in rplugin/python{3}/ and then UpdateRemotePlugins will send a "specs" request over msgpack-rpc. The python host returns a string that is used to register commands/functions in .local/share/nvim/rplugin.vim .

I am a beginner in haskell so I might be wrong but I don't think the previous mechanism is available for haskell ?! Else I would like to volunteer (as a way to improve my haskell skills). Is that redundant with https://github.com/neovimhaskell/nvim-hs/issues/41 ?

justinmk commented 7 years ago

Maybe see how @garyburd approached it for the go-client.

saep commented 7 years ago

There is actually an open ticket for this: #27

I'll take a closer look this weekend, especially with respect to the go-client linked here.

Just for a short heads up, I can say this:

Issue #41 is just a general architectural design idea and implementing it would make compiler errors more cryptic, but give plugin authors a little more flexibility. It is not relevant for this problem, though.

I have only written 4 plugins or so and they simply reside as Haskell files in ~/.config/nvim/lib/ while I develop them. I only have to manually add 2 lines to my ~/.config/nvim/nvim.hs"config" file for each plugin I use [Example in hackage documentation](http://hackage.haskell.org/package/nvim-hs-0.1.0/docs/Neovim.html#g:7). The default setup will mark compiler errors in the quickfix list automatically when I save any file in that directory (if it is referenced from thenvim.hs` file), so I think that this is as smooth as it gets. But if I am mistaken, I'll happily make it smoother. Getting the setup running smoothly is the problem and I think that the wiki here could be a perfect place to describe a few setups. On the top of my head, I can think of these basic setups:

Spontaneously, I would think that creating a stack project template could be the best general solution which can be beginner friendly if you accompany it with some simple documentation. You would then manage the plugins as you would manage plain haskell libraries with the flexiblity of stack's dependency management. The automatic plugin discovery is possible, but I do not think it is worth spending time on it. It will be very magical for the end-user and a pain to debug once you have issues with it. Having plugins be proper haskell projects isn't too much effort and being a little explicit about the plugins you use can be very helpful.

Writing about this really helps to give rise to new ideas. :-)

A stack project template for plugin authors is probably also a good idea.

If you can't wait to try something out, feel free to do so. I'm happy to help, although my response times may be a bit long.

teto commented 7 years ago

You describe the plugin installation process from the haskell point of view but what about the classic vim plugin installation process ? when I install my plugins with vim-plug, I expect UpdateRemotePlugins to work out of the box as it does for python/ruby (ie. have the haskell host register autocommands/functiosn for plugins in rplugin/haskell) . If I can make my laptop great again (i.e., boot on its hard drive), I will try to come up with sthg.

saep commented 7 years ago

So you want to drop this in your init.vim file and have it work?

Plug 'saep/nvim-hs-ghcid', { 'for': ['haskell']}

I can think of a way to make this work, but I'm not sure it would scale.

I could make it work in a way that you only have to add two things to the nvim.hs "config" file. The other necessary files could be edited automatically.

import Neovim

import qualified Neovim.Ghcid as Ghcid

main :: IO ()
main = neovim defaultConfig
    { plugins = plugins defaultConfig ++ [ Ghcid.plugin ]
    }

One could add a flavor of this plugin manager that could auto-generate this file, though.

The design idea to include plugins for the current version of nvim-hs is as follows: Plugins are just plain Haskell libraries. To use one, you add the dependency and edit your nvim.hs "config" file to include the plugin. The way you manage the dependency is completely up to the user.

The simplest and messiest approach is this.

cabal install nvim-hs nvim-hs-ghcid

Put the config above to ~/.config/nvim.hs. Done.

For additional plugins:

cabal install name-of-another-plugin

Adjust the config above to include the plugin.

If you manage your Haskell plugins as a Haskell project, you have to add the plugins as dependencies to the project as you would with any other haskell project. The benefit of this approach is, that you can just copy/clone your project to another computer and install every plugin with stack build or whatever you prefer.

My idea was to create a stack template and write a step-by-step tutorial for the latter approach.

saep commented 7 years ago

Busy weekend, I'll probably get to it in a few days.

saep commented 7 years ago

I updated the README with two ways of installing plugins. The stack template contains documented example code and sets up almost everything you need.

Feel free to bring up any ideas or criticism you might have.

saep commented 7 years ago

Since there hasn't been any feedback in over 3 months and the README has grown significantly, I'll close this here.