@@ -19,38 +19,36 @@ module Neovim (
19
19
-- $installation
20
20
21
21
-- * Tutorial
22
+
22
23
-- ** Motivation
23
24
-- $overview
24
- -- ** Combining existing plugins
25
25
-- $existingplugins
26
26
Neovim ,
27
27
neovim ,
28
- NeovimConfig (.. ),
28
+ NeovimConfig (.. ),
29
29
defaultConfig ,
30
30
def ,
31
31
32
-
33
32
-- ** Creating a plugin
34
33
-- $creatingplugins
35
- NeovimPlugin (.. ),
36
- Plugin (.. ),
37
- NvimObject (.. ),
34
+ NeovimPlugin (.. ),
35
+ Plugin (.. ),
36
+ NvimObject (.. ),
38
37
(+:) ,
39
38
Dictionary ,
40
- Object (.. ),
39
+ Object (.. ),
41
40
wrapPlugin ,
42
41
function ,
43
42
function' ,
44
43
command ,
45
44
command' ,
46
45
autocmd ,
47
- Synchronous (.. ),
48
- CommandOption (.. ),
49
- RangeSpecification (.. ),
50
- CommandArguments (.. ),
51
- AutocmdOptions (.. ),
46
+ Synchronous (.. ),
47
+ CommandOption (.. ),
48
+ RangeSpecification (.. ),
49
+ CommandArguments (.. ),
50
+ AutocmdOptions (.. ),
52
51
addAutocmd ,
53
-
54
52
ask ,
55
53
asks ,
56
54
@@ -64,9 +62,10 @@ module Neovim (
64
62
err ,
65
63
errOnInvalidResult ,
66
64
catchNeovimException ,
67
- NeovimException (.. ),
65
+ NeovimException (.. ),
68
66
69
67
-- * Unsorted exports
68
+
70
69
-- This section contains just a bunch of more or less useful functions which
71
70
-- were not introduced in any of the previous sections.
72
71
liftIO ,
@@ -76,62 +75,85 @@ module Neovim (
76
75
docFromObject ,
77
76
Doc ,
78
77
AnsiStyle ,
79
- Pretty (.. ),
78
+ Pretty (.. ),
80
79
putDoc ,
81
80
exceptionToDoc ,
82
- Priority (.. ),
81
+ Priority (.. ),
83
82
module Control.Monad ,
84
83
module Control.Applicative ,
85
84
module Data.Monoid ,
86
85
module Data.Int ,
87
86
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 (.. ))
88
143
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 )
124
144
-- Installation {{{1
145
+
125
146
{- $installation
126
147
127
148
Installation instructions are in the README.md file that comes with the source
128
149
of this package. It is also on the repositories front page.
129
-
130
150
-}
151
+
131
152
-- 1}}}
132
153
133
154
-- Tutorial {{{1
134
155
-- Overview {{{2
156
+
135
157
{- $overview
136
158
An @nvim-hs@ plugin is just a collection of haskell functions that can be
137
159
called from neovim.
@@ -146,12 +168,11 @@ writing a plugin.
146
168
147
169
Since you are reading haddock documentation, you probably want the latter, so
148
170
just keep reading. @:-)@
149
-
150
171
-}
151
172
152
-
153
173
-- 2}}}
154
174
-- Combining Existing Plugins {{{2
175
+
155
176
{- $existingplugins
156
177
The easiest way to start is to use the stack template as described in the
157
178
@README.md@ of this package. If you initialize it in your neovim configuration
@@ -178,27 +199,27 @@ main file would look something like this:
178
199
179
200
That's all you have to do! Multiple plugins are simply imported and put in a
180
201
list.
181
-
182
202
-}
183
203
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:
198
206
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
+ }
199
219
200
220
-- 2}}}
201
221
-- Creating a plugin {{{2
222
+
202
223
{- $creatingplugins
203
224
Creating plugins isn't difficult either. You just have to follow and survive the
204
225
compile time errors of seemingly valid code. This may sound scary, but it is not
@@ -318,10 +339,11 @@ mode:
318
339
319
340
The haddock documentation will now list all the things we have used up until now.
320
341
Afterwards, there is a plugin with state which uses the environment.
321
-
322
342
-}
343
+
323
344
-- 2}}}
324
345
-- Creating a stateful plugin {{{2
346
+
325
347
{- $statefulplugin
326
348
Now that we are a little bit comfortable with the interface provided by /nvim-hs/,
327
349
we 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:
436
458
@
437
459
:call SetNextRandom(42)
438
460
@
439
-
440
461
-}
462
+
441
463
-- 2}}}
442
464
-- Calling remote functions {{{2
465
+
443
466
{- $remote
444
467
Calling remote functions is only possible inside a 'Neovim' context. There are
445
468
a 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.
471
494
472
495
That's pretty much all there is to it.
473
496
-}
497
+
474
498
-- 2}}}
475
499
-- 1}}}
476
500
0 commit comments