nvim-hs 0.2.4 → 0.2.5
raw patch · 6 files changed
+79/−62 lines, 6 filesdep +voiddep ~conduit-extra
Dependencies added: void
Dependency ranges changed: conduit-extra
Files
- CHANGELOG.md +7/−0
- README.md +27/−46
- library/Neovim/API/Parser.hs +2/−2
- library/Neovim/Plugin/ConfigHelper/Internal.hs +8/−8
- library/Neovim/RPC/EventHandler.hs +23/−4
- nvim-hs.cabal +12/−2
CHANGELOG.md view
@@ -1,3 +1,10 @@+# 0.2.5++* Older versions of `nvim-hs` may not function if some versions of a+ dependency are used. This version has proper bounds for the dependency and+ should cause a compile time failure if an incompatible version of the+ dependency is used (see #61).+ # 0.2.0 * Replace error code of remote functions to return
README.md view
@@ -11,6 +11,8 @@ [](https://travis-ci.org/neovimhaskell/nvim-hs) [](https://hackage.haskell.org/package/nvim-hs)+[](http://stackage.org/lts/package/nvim-hs)+[](http://stackage.org/nightly/package/nvim-hs) # What do I have to expect if I were to use it now? @@ -57,27 +59,6 @@ > stack new my-nvim-hs https://raw.githubusercontent.com/neovimhaskell/nvim-hs/master/stack-template.hsfiles --bare --omit-packages --ignore-subdirs -Since `nvim-hs` is not yet on stackage, you have to edit the generated-`stack.yaml` file by hand (sorry about that). Replace the packages list with-one containing the current directory and the extra-deps list with a-dependency to nvim-hs. The lines of the file that look like this--```yaml-packages: []--extra-deps: []-```--should become:--```yaml-packages:-- .--extra-deps:-- nvim-hs-0.2.2-```- Now, you have to compile everything. > stack setup@@ -115,7 +96,8 @@ ### Installing a plugin from Hackage Let's take [nvim-hs-ghcid](http://hackage.haskell.org/package/nvim-hs-ghcid)-as an example. Since it is not on stackage, have to declare the dependency+as an example. Let's also pretend, that it's not on stackage. +We have to declare the dependency in the `my-nvim-hs.cabal` file and in the `stack.yaml` file. In the `.cabal` file, add `nvim-hs-ghcid` to the `build-depends` section. It should look like this:@@ -132,28 +114,21 @@ ```yaml extra-deps:-- nvim-hs-0.2.2-- nvim-hs-contrib-0.2.0 - nvim-hs-ghcid-0.2.0 ``` -What is the `nvim-hs-contrib` dependency we had to add there? The plugin we-chose to install had a dependency to a haskell project that is not on-stackage. You have to add these to the stack.yaml file as well, although you-do not necessarily have to add them to the cabal file. This is exactly the-disadvantage of using stack for this. The benefit is that you will have a+If `nvim-hs-ghcid` depended upon any other package that is not on stackage,+you would have to add those dependencies there as well. The output of +`stack build` should tell you which you have to add. You don't have to add+these transitive dependencies to the `build-depends` of the cabal file because+you are not accessing anything from these packages directly.++Adding all these explicit versions seems to be the disadvantage of using stack. +However, the benefit is that you will have a reproducible build in the future and you don't have to hunt down a working-set of version boundariesfor every dependency you have. A little effort now+set of version boundaries for every dependency you have. A little effort now will save you more time later! -Note that I (saep) intend to add `nvim-hs` and `nvim-hs-contrib` to stackage-once I feel I should switch to version 1.0.0. Then, you wouldn't have to-edit the `stack.yaml` for this. If you want to update a dependency/plugin,-you have to manually increment the version number in the stack.yaml file and-possibly fix the compilation errors that arise. If you want a rolling-release for a plugin, follow the instructions for installing a plugin from-git.- To use the plugin, add it to the plugins list of the `nvim.hs` file in `~/.config/nvim`: @@ -173,11 +148,17 @@ } ``` +If you want to update a dependency/plugin,+you have to manually increment the version number in the stack.yaml file and+possibly fix the compilation errors that arise. If you want a rolling+release for a plugin, follow the instructions for installing a plugin from+git. ### Installing a plugin from git This method is best suited for plugins that update a lot and for which you need-the most recent version most of the time. If you don't intend to work on the+the most recent version most of the time. This also works for plugins that do not+have a hackage release. If you don't intend to work on the code of that plugin repository, you can add it to the plugin list of your plugin manager (e.g. [vim-plug](https://github.com/junegunn/vim-plug)). This way, you get updates if you update all your normal vim plugins.@@ -197,24 +178,24 @@ ```yaml packages: - .-- plugged/nvim-hs-ghcid+- plugged/nvim-hs-ghcid # or the appropriate relative path the folder you configured ``` As long as you have the repository in this list, you don't have to specify it as a dependency anywhere else, you still have to add the plugins'-dependencies to the `stack.yaml` file, though. It should look like this:+dependencies to the `stack.yaml` file, though. It chould look like this: ```yaml extra-deps:-- nvim-hs-0.2.2-- nvim-hs-contrib-0.2.0+- some-dependency-0.2.4+- and-another-one-13.8.5.2 ``` Add the plugin to the plugins list in `nvim.hs` in exactly the same way as-described in the previous chapter.+described at the end of the previous chapter. -The downside of this is that your compilation times will be longer the more-plugins you include this way.+The downside of this approach is that your compilation times will be longer the more+plugins you include this way. ### Writing your own functions that you can call from neovim
library/Neovim/API/Parser.hs view
@@ -169,7 +169,7 @@ pSimple :: P.Parser NeovimType-pSimple = SimpleType <$> some (noneOf [',', ')'])+pSimple = SimpleType <$> P.some (noneOf [',', ')']) pArray :: P.Parser NeovimType@@ -178,5 +178,5 @@ pNum :: P.Parser Int-pNum = read <$> (P.try (char ',') *> space *> some (oneOf ['0'..'9']))+pNum = read <$> (P.try (char ',') *> space *> P.some (oneOf ['0'..'9']))
library/Neovim/Plugin/ConfigHelper/Internal.hs view
@@ -81,17 +81,17 @@ -- error messages look like. parseQuickfixItems :: String -> [QuickfixListItem String] parseQuickfixItems s =- case parse (many pQuickfixListItem) "Quickfix parser" s of+ case parse (P.many pQuickfixListItem) "Quickfix parser" s of Right qs -> qs Left _ -> [] pQuickfixListItem :: P.Parser (QuickfixListItem String) pQuickfixListItem = do- _ <- many blankLine+ _ <- P.many blankLine (f,l,c) <- pLocation - void $ many tabOrSpace+ void $ P.many tabOrSpace e <- pSeverity desc <- try pShortDesrciption <|> pLongDescription return $ (quickfixListItem (Right f) (Left l))@@ -109,7 +109,7 @@ pShortDesrciption :: P.Parser String pShortDesrciption = (:) <$> (notFollowedBy blankLine *> anyChar)- <*> anyChar `manyTill` (void (some blankLine) <|> eof)+ <*> anyChar `manyTill` (void (P.some blankLine) <|> eof) pLongDescription :: P.Parser String@@ -123,7 +123,7 @@ blankLine :: P.Parser ()-blankLine = void . try $ many tabOrSpace >> newline+blankLine = void . try $ P.many tabOrSpace >> newline -- | Skip anything until the next location information appears.@@ -135,11 +135,11 @@ -- @\/some\/path\/to\/a\/file.hs:42:88:@ pLocation :: P.Parser (String, Int, Int) pLocation = (,,)- <$> some (noneOf ":\n\t\r") <* char ':'+ <$> P.some (noneOf ":\n\t\r") <* char ':' <*> pInt <* char ':'- <*> pInt <* char ':' <* many tabOrSpace+ <*> pInt <* char ':' <* P.many tabOrSpace pInt :: P.Parser Int-pInt = read <$> some (satisfy isDigit)+pInt = read <$> P.some (satisfy isDigit) -- 1}}}
library/Neovim/RPC/EventHandler.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE LambdaCase #-} {- |@@ -29,7 +30,11 @@ import Control.Monad.Trans.Resource import Data.ByteString (ByteString) import Data.Conduit as C+#if MIN_VERSION_conduit_extra(1,2,2)+import Data.Conduit.Binary (sinkHandleFlush)+#else import Data.Conduit.Binary (sinkHandle)+#endif import qualified Data.Map as Map import Data.Serialize (encode) import System.IO (Handle)@@ -49,7 +54,11 @@ $= eventHandler $$ addCleanup (cleanUpHandle writeableHandle)+#if MIN_VERSION_conduit_extra(1,2,2)+ (sinkHandleFlush writeableHandle)+#else (sinkHandle writeableHandle)+#endif -- | Convenient monad transformer stack for the event handler@@ -70,7 +79,7 @@ forever $ yield =<< atomically' (readTQueue q) -eventHandler :: ConduitM SomeMessage ByteString EventHandler ()+eventHandler :: ConduitM SomeMessage EncodedResponse EventHandler () eventHandler = await >>= \case Nothing -> return () -- i.e. close the conduit -- TODO signal shutdown globally@@ -80,14 +89,24 @@ eventHandler -yield' :: (MonadIO io) => MsgpackRPC.Message -> ConduitM i ByteString io ()+#if MIN_VERSION_conduit_extra(1,2,2)+type EncodedResponse = Flush ByteString+#else+type EncodedResponse = ByteString+#endif++yield' :: (MonadIO io) => MsgpackRPC.Message -> ConduitM i EncodedResponse io () yield' o = do liftIO . debugM "EventHandler" $ "Sending: " ++ show o+#if MIN_VERSION_conduit_extra(1,2,2)+ yield . Chunk . encode $ toObject o+ yield Flush+#else yield . encode $ toObject o-+#endif handleMessage :: (Maybe FunctionCall, Maybe MsgpackRPC.Message)- -> ConduitM i ByteString EventHandler ()+ -> ConduitM i EncodedResponse EventHandler () handleMessage = \case (Just (FunctionCall fn params reply time), _) -> do i <- get
nvim-hs.cabal view
@@ -1,5 +1,5 @@ name: nvim-hs-version: 0.2.4+version: 0.2.5 synopsis: Haskell plugin backend for neovim description: This package provides a plugin provider for neovim. It allows you to write@@ -100,7 +100,16 @@ , cereal , cereal-conduit >= 0.7.3 , conduit- , conduit-extra++ -- sinkHandle flushed after every yield in the releases+ -- [1.1.2, 1.1.17) and in release 1.2.2 an API was added+ -- to flush manually, so any other version probably does+ -- not work unless you set NoBuffering on the handle (see #61)+ -- I think having NoBuffering on TCP-Handles is kind of+ -- ridicilous, so the version range [1.1.17, 1.2.2) is+ -- simply excluded+ , conduit-extra >= 1.1.2 && < 1.1.17 || >= 1.2.2+ , containers , data-default , deepseq >= 1.1 && < 1.5@@ -129,6 +138,7 @@ , transformers , transformers-base , utf8-string+ , void hs-source-dirs: library default-language: Haskell2010 ghc-options: -Wall