packages feed

nvim-hs 2.1.0.4 → 2.1.0.5

raw patch · 5 files changed

+54/−51 lines, 5 filesdep ~template-haskell

Dependency ranges changed: template-haskell

Files

README.md view
@@ -3,7 +3,7 @@ Neovim API for Haskell plugins as well as a plugin provider. This library and executable should provide a basis for developing plugins. This package should only contain broadly useful interfaces-to write plugins for neovim in haskell. The design goal is to create+to write plugins for Neovim in haskell. The design goal is to create an easy to use API that avoids most of the boilerplate while still retaining some sense of reliability and type safety. Since Template Haskell is used to generate the neovim bindings and to avoid some of the boilerplate@@ -20,16 +20,12 @@  # How do I start using this? -You need to install a neovim plugin that manages starting of `nvim-hs` plugins.-Just follow the instructions here:-[nvim-hs.vim](https://github.com/neovimhaskell/nvim-hs.vim)--Once you have installed that plugin, you can use `nvim-hs` plugins as you would-normal vim plugins. Every plugin is started as a separate process which should-be fine unless you have a lot of them.+You need to install `nvim-hs.vim`, a plugin that manages starting of `nvim-hs` plugins.+To do that, just follow the instructions outlined [here](https://github.com/neovimhaskell/nvim-hs.vim). -You only have to read on if you want to start "scripting" functions or plugins-yourself in Haskell.+Once you have installed `nvim-hs.vim`, you can use `nvim-hs` plugins as you would+normal vim plugins. Note that every plugin you install is started as a separate process,+which should be fine unless you have a lot of them.  # Scripting with Haskell @@ -40,46 +36,43 @@  2. You need a tiny bit of `vimL` in your runtime path that starts the plugin. -The simplest way to get started is the stack template from this-repository/package inside your neovim configuration folder which-will be described here. (Alternatively, you can manually create a project-and do everything that is explained in `:help nvim-hs.txt` which should be-available if you installed the plugin mentioned in the previous section.)--You need to [install stack](https://docs.haskellstack.org/en/stable/README/)-and have the neovim executable on the path.-(The API code generation calls `nvim --api-info`.)+The simplest way to get started is using the stack template from this+repository/package inside your Neovim configuration folder, but you can also+manually create a project by doing everything that is explained in `:help nvim-hs.txt` +(which should be available if you installed `nvim-hs.vim` as mentioned in the previous section). -Afterwards, you switch to your neovim configuration folder (typically `~/.config/nvim`) and-you have to create your plugin project.+To use that template, you'll first need to [install stack](https://docs.haskellstack.org/en/stable/README/)+and have the Neovim executable on the path (the API code generation calls `nvim --api-info` so it needs access to `nvim`). -> cd ~/.config/nvim+After you've done that, you can run these commands to setup the template (assuming your Neovim configuration folder+is in `$XDG_CONFIG_HOME/nvim`): -> stack new my-nvim-hs https://raw.githubusercontent.com/neovimhaskell/nvim-hs/master/stack-template.hsfiles --bare --omit-packages --ignore-subdirs+```+$ cd $XDG_CONFIG_HOME/nvim+$ stack new my-nvim-hs \+https://raw.githubusercontent.com/neovimhaskell/nvim-hs/master/stack-template.hsfiles \+--bare --omit-packages --ignore-subdirs+``` -If you start neovim now, it will compile the example plugins which may take a+If you start Neovim now, it will compile the example plugins which may take a few minutes. Once it is started you can use the predefined functions from the-template.--> :echo NextRandom()--should print a random number.+template, for example by running `:echo NextRandom()`, which should print a random number.  To start writing your own functions and plugins, read through the files-generated by the template accompanied by the+generated by the template and also check out the [library documentation on hackage](http://hackage.haskell.org/package/nvim-hs).  # Contributing -Documentation, typo fixes and alike will almost always be merged.+Documentation, typo fixes, and the like will almost always be merged.  If you want to bring forward new features or convenience libraries-for interacting with neovim, you should create an issue first. The features+for interacting with Neovim, you should create an issue first. The features of this (cabal) project should be kept small as this helps-reducing the development time. (For some tests it is+reduce the development time. (For some tests it is necessary to issue `cabal install`, so any change to to a module can significantly increase the compilation time.) If your idea solves a general problem, feel free to open an issue in the-library project of nvim-hs:-[nvim-hs-contrib](https://github.com/neovimhaskell/nvim-hs-contrib)+library project of `nvim-hs`, +[`nvim-hs-contrib`](https://github.com/neovimhaskell/nvim-hs-contrib). 
library/Neovim.hs view
@@ -153,11 +153,11 @@ {- $existingplugins The easiest way to start is to use the stack template as described in the @README.md@ of this package. If you initialize it in your neovim configuration-directory (@~/.convig/nvim@ on linux-based systems), it should automatically be-compiled and run with two simple example plugins+directory (@~\/.config\/nvim@ on linux-based systems), it should automatically be+compiled and run with two simple example plugins.  You have to define a haskell project that depends on this package and-contains an executable secion with a main file that looks like this:+contains an executable secion within a main file that looks something like this:  @ import TestPlugin.ExamplePlugin (examplePlugin)@@ -171,8 +171,8 @@ /nvim-hs/ is all about importing and creating plugins. This is done following a concise API. Let's start by making a given plugin available inside our plugin provider. Assuming that we have installed a cabal package that exports-an @examplePlugin@ from the module @TestPlugin.ExamplePlugin@. A minimal-main file would then look like this:+an @examplePlugin@ from the module @TestPlugin.ExamplePlugin@, a minimal+main file would look something like this:  That's all you have to do! Multiple plugins are simply imported and put in a list.
library/Neovim/API/TH.hs view
@@ -63,7 +63,13 @@  import           Prelude +#if MIN_VERSION_template_haskell(2,17,0)+dataD' :: CxtQ -> Name -> [TyVarBndr ()] -> [ConQ] -> [Name] -> DecQ+#else dataD' :: CxtQ -> Name -> [TyVarBndr] -> [ConQ] -> [Name] -> DecQ+#endif+-- XXX This should probably be tied to the proper template haskell version+-- similar to the type signature. #if __GLASGOW_HASKELL__ < 800 dataD' = dataD #elif __GLASGOW_HASKELL__ < 802@@ -74,6 +80,14 @@     dataD cxtQ n tyvarbndrs Nothing conq ((return . return . DerivClause Nothing . map ConT) ns) #endif +#if MIN_VERSION_template_haskell(2,17,0)+plainTV' :: Name -> TyVarBndr Specificity+plainTV' env = PlainTV env SpecifiedSpec+#else+plainTV' :: Name -> TyVarBndr+plainTV' = PlainTV env+#endif+ -- | Generate the API types and functions provided by @nvim --api-info@. -- -- The provided map allows the use of different Haskell types for the types@@ -188,7 +202,7 @@       retType <- let env = (mkName "env")-               in forallT [PlainTV env] (return [])+               in forallT [plainTV' env] (return [])                        . appT ([t|Neovim $(varT env) |])                        . withDeferred                        . apiTypeToHaskellType typeMap $ returnType nf
library/Neovim/Plugin.hs view
@@ -40,7 +40,6 @@ import           Control.Monad                (foldM, void) import           Control.Monad.Trans.Resource hiding (register) import           Data.ByteString              (ByteString)-import           Data.ByteString.UTF8         (toString) import           Data.Foldable                (forM_) import           Data.Map                     (Map) import qualified Data.Map                     as Map@@ -190,11 +189,8 @@    where     freeFun = \case-        Autocmd event _ _ AutocmdOptions{..} -> do-            void . vim_command . unwords $ catMaybes-                    [ Just "autocmd!", acmdGroup-                    , Just (toString event) , Just acmdPattern-                    ]+        Autocmd _ _ _ AutocmdOptions{} -> do+            liftIO $ warningM logger "Free not implemented for autocmds."          Command{} ->             liftIO $ warningM logger "Free not implemented for commands."@@ -203,7 +199,7 @@             liftIO $ warningM logger "Free not implemented for functions."  -    free cfg = const . void . liftIO . runNeovimInternal return cfg . freeFun+    free cfg fd _ = void . runNeovimInternal return cfg $ freeFun fd   registerInGlobalFunctionMap :: FunctionMapEntry -> Neovim env ()@@ -248,7 +244,7 @@            -- ^ Fully applied function to register            -> Neovim env (Maybe (Either (Neovim anyEnv ()) ReleaseKey))            -- ^ A 'ReleaseKey' if the registration worked-addAutocmd event s (opts@AutocmdOptions{..}) f = do+addAutocmd event s (opts@AutocmdOptions{}) f = do     n <- newUniqueFunctionName     fmap snd <$> registerFunctionality (Autocmd event n s opts) (\_ -> toObject <$> f) 
nvim-hs.cabal view
@@ -1,5 +1,5 @@ name:                nvim-hs-version:             2.1.0.4+version:             2.1.0.5 synopsis:            Haskell plugin backend for neovim description:   This package provides a plugin provider for neovim. It allows you to write@@ -117,7 +117,7 @@                       , mtl >= 2.2.1 && < 2.3                       , optparse-applicative                       , time-locale-compat-                      , megaparsec < 9+                      , megaparsec < 10                       , prettyprinter >= 1.2 && < 2                       , prettyprinter-ansi-terminal                       , resourcet >= 1.1.11