@@ -19,38 +19,36 @@ module Neovim (
1919 -- $installation
2020
2121 -- * Tutorial
22+
2223 -- ** Motivation
2324 -- $overview
24- -- ** Combining existing plugins
2525 -- $existingplugins
2626 Neovim ,
2727 neovim ,
28- NeovimConfig (.. ),
28+ NeovimConfig (.. ),
2929 defaultConfig ,
3030 def ,
3131
32-
3332 -- ** Creating a plugin
3433 -- $creatingplugins
35- NeovimPlugin (.. ),
36- Plugin (.. ),
37- NvimObject (.. ),
34+ NeovimPlugin (.. ),
35+ Plugin (.. ),
36+ NvimObject (.. ),
3837 (+:) ,
3938 Dictionary ,
40- Object (.. ),
39+ Object (.. ),
4140 wrapPlugin ,
4241 function ,
4342 function' ,
4443 command ,
4544 command' ,
4645 autocmd ,
47- Synchronous (.. ),
48- CommandOption (.. ),
49- RangeSpecification (.. ),
50- CommandArguments (.. ),
51- AutocmdOptions (.. ),
46+ Synchronous (.. ),
47+ CommandOption (.. ),
48+ RangeSpecification (.. ),
49+ CommandArguments (.. ),
50+ AutocmdOptions (.. ),
5251 addAutocmd ,
53-
5452 ask ,
5553 asks ,
5654
@@ -64,9 +62,10 @@ module Neovim (
6462 err ,
6563 errOnInvalidResult ,
6664 catchNeovimException ,
67- NeovimException (.. ),
65+ NeovimException (.. ),
6866
6967 -- * Unsorted exports
68+
7069 -- This section contains just a bunch of more or less useful functions which
7170 -- were not introduced in any of the previous sections.
7271 liftIO ,
@@ -76,62 +75,85 @@ module Neovim (
7675 docFromObject ,
7776 Doc ,
7877 AnsiStyle ,
79- Pretty (.. ),
78+ Pretty (.. ),
8079 putDoc ,
8180 exceptionToDoc ,
82- Priority (.. ),
81+ Priority (.. ),
8382 module Control.Monad ,
8483 module Control.Applicative ,
8584 module Data.Monoid ,
8685 module Data.Int ,
8786 module Data.Word ,
87+ ) where
88+
89+ import Control.Applicative
90+ import Control.Monad (void )
91+ import Control.Monad.IO.Class (liftIO )
92+ import Data.Default (def )
93+ import Data.Int (Int16 , Int32 , Int64 , Int8 )
94+ import Data.MessagePack (Object (.. ))
95+ import Data.Monoid
96+ import Data.Word (Word , Word16 , Word32 , Word8 )
97+ import Neovim.API.TH (
98+ autocmd ,
99+ command ,
100+ command' ,
101+ function ,
102+ function' ,
103+ )
104+ import Neovim.Classes (
105+ AnsiStyle ,
106+ Dictionary ,
107+ Doc ,
108+ NvimObject (.. ),
109+ Pretty (.. ),
110+ docFromObject ,
111+ docToObject ,
112+ (+:) ,
113+ )
114+ import Neovim.Config (NeovimConfig (.. ))
115+ import Neovim.Context (
116+ Neovim ,
117+ NeovimException (.. ),
118+ ask ,
119+ asks ,
120+ err ,
121+ errOnInvalidResult ,
122+ exceptionToDoc ,
123+ )
124+ import Neovim.Exceptions (catchNeovimException )
125+ import Neovim.Main (neovim )
126+ import Neovim.Plugin (addAutocmd )
127+ import Neovim.Plugin.Classes (
128+ AutocmdOptions (.. ),
129+ CommandArguments (.. ),
130+ CommandOption (CmdBang , CmdCount , CmdRange , CmdRegister , CmdSync ),
131+ RangeSpecification (.. ),
132+ Synchronous (.. ),
133+ )
134+ import Neovim.Plugin.Internal (
135+ NeovimPlugin (.. ),
136+ Plugin (.. ),
137+ wrapPlugin ,
138+ )
139+ import Neovim.RPC.FunctionCall (wait , wait' )
140+ import Neovim.Util (unlessM , whenM )
141+ import Prettyprinter.Render.Terminal (putDoc )
142+ import System.Log.Logger (Priority (.. ))
88143
89- ) where
90-
91- import Control.Applicative
92- import Control.Monad (void )
93- import Control.Monad.IO.Class (liftIO )
94- import Data.Default (def )
95- import Data.Int (Int16 , Int32 , Int64 , Int8 )
96- import Data.MessagePack (Object (.. ))
97- import Data.Monoid
98- import Data.Word (Word , Word16 , Word32 , Word8 )
99- import Neovim.API.TH (autocmd , command , command' ,
100- function , function' )
101- import Neovim.Classes (Dictionary , NvimObject (.. ),
102- Doc , AnsiStyle , Pretty (.. ),
103- docFromObject , docToObject , (+:) )
104- import Neovim.Config (NeovimConfig (.. ))
105- import Neovim.Context (Neovim ,
106- NeovimException (.. ),
107- exceptionToDoc ,
108- ask , asks , err ,
109- errOnInvalidResult )
110- import Neovim.Main (neovim )
111- import Neovim.Exceptions (catchNeovimException )
112- import Neovim.Plugin (addAutocmd )
113- import Neovim.Plugin.Classes (AutocmdOptions (.. ),
114- CommandArguments (.. ),
115- CommandOption (CmdBang , CmdCount , CmdRange , CmdRegister , CmdSync ),
116- RangeSpecification (.. ),
117- Synchronous (.. ))
118- import Neovim.Plugin.Internal (NeovimPlugin (.. ), Plugin (.. ),
119- wrapPlugin )
120- import Neovim.RPC.FunctionCall (wait , wait' )
121- import Neovim.Util (unlessM , whenM )
122- import System.Log.Logger (Priority (.. ))
123- import Prettyprinter.Render.Terminal (putDoc )
124144-- Installation {{{1
145+
125146{- $installation
126147
127148Installation instructions are in the README.md file that comes with the source
128149of this package. It is also on the repositories front page.
129-
130150-}
151+
131152-- 1}}}
132153
133154-- Tutorial {{{1
134155-- Overview {{{2
156+
135157{- $overview
136158An @nvim-hs@ plugin is just a collection of haskell functions that can be
137159called from neovim.
@@ -146,12 +168,11 @@ writing a plugin.
146168
147169Since you are reading haddock documentation, you probably want the latter, so
148170just keep reading. @:-)@
149-
150171-}
151172
152-
153173-- 2}}}
154174-- Combining Existing Plugins {{{2
175+
155176{- $existingplugins
156177The easiest way to start is to use the stack template as described in the
157178@README.md@ of this package. If you initialize it in your neovim configuration
@@ -178,27 +199,27 @@ main file would look something like this:
178199
179200That's all you have to do! Multiple plugins are simply imported and put in a
180201list.
181-
182202-}
183203
184- -- | Default configuration options for /nvim-hs/. If you want to keep the
185- -- default plugins enabled, you can define your config like this:
186- --
187- -- @
188- -- main = 'neovim' 'defaultConfig'
189- -- { plugins = plugins defaultConfig ++ myPlugins
190- -- }
191- -- @
192- --
193- defaultConfig :: NeovimConfig
194- defaultConfig = Config
195- { plugins = []
196- , logOptions = Nothing
197- }
204+ {- | Default configuration options for /nvim-hs/. If you want to keep the
205+ default plugins enabled, you can define your config like this:
198206
207+ @
208+ main = 'neovim' 'defaultConfig'
209+ { plugins = plugins defaultConfig ++ myPlugins
210+ }
211+ @
212+ -}
213+ defaultConfig :: NeovimConfig
214+ defaultConfig =
215+ Config
216+ { plugins = []
217+ , logOptions = Nothing
218+ }
199219
200220-- 2}}}
201221-- Creating a plugin {{{2
222+
202223{- $creatingplugins
203224Creating plugins isn't difficult either. You just have to follow and survive the
204225compile time errors of seemingly valid code. This may sound scary, but it is not
@@ -318,10 +339,11 @@ mode:
318339
319340The haddock documentation will now list all the things we have used up until now.
320341Afterwards, there is a plugin with state which uses the environment.
321-
322342-}
343+
323344-- 2}}}
324345-- Creating a stateful plugin {{{2
346+
325347{- $statefulplugin
326348Now that we are a little bit comfortable with the interface provided by /nvim-hs/,
327349we can start to write a more complicated plugin. Let's create a random number
@@ -436,10 +458,11 @@ You can also cheat and pretend you know the next number:
436458@
437459:call SetNextRandom(42)
438460@
439-
440461-}
462+
441463-- 2}}}
442464-- Calling remote functions {{{2
465+
443466{- $remote
444467Calling remote functions is only possible inside a 'Neovim' context. There are
445468a few patterns of return values for the available functions. Let's start with
@@ -471,6 +494,7 @@ message to neovim which the user immediately notices.
471494
472495That's pretty much all there is to it.
473496-}
497+
474498-- 2}}}
475499-- 1}}}
476500
0 commit comments