]> git.gir.st - VimFx.git/blob - extension/lib/api-frame.coffee
Change license to MIT
[VimFx.git] / extension / lib / api-frame.coffee
1 # This file defines VimFx’s config file API, for the frame script.
2
3 messageManager = require('./message-manager')
4
5 createConfigAPI = (vim, onShutdown = module.onShutdown) -> {
6 listen: (message, listener) ->
7 unless typeof message == 'string'
8 throw new Error(
9 "VimFx: The first argument must be a message string. Got: #{message}"
10 )
11 unless typeof listener == 'function'
12 throw new Error(
13 "VimFx: The second argument must be a listener function.
14 Got: #{listener}"
15 )
16 messageManager.listen(message, listener, {
17 prefix: 'config:'
18 onShutdown
19 })
20
21 setHintMatcher: (hintMatcher) ->
22 unless typeof hintMatcher == 'function'
23 throw new Error(
24 "VimFx: A hint matcher must be a function. Got: #{hintMatcher}"
25 )
26 vim.hintMatcher = hintMatcher
27 onShutdown(-> vim.hintMatcher = null)
28
29 getMarkerElement: (id) ->
30 data = vim.state.markerElements[id]
31 return if data then data.element else null
32 }
33
34 module.exports = createConfigAPI
Imprint / Impressum