1 # This file defines VimFx’s config file API, for the frame script.
3 messageManager = require('./message-manager')
5 createConfigAPI = (vim, onShutdown = module.onShutdown) -> {
6 listen: (message, listener) ->
7 unless typeof message == 'string'
9 "VimFx: The first argument must be a message string. Got: #{message}"
11 unless typeof listener == 'function'
13 "VimFx: The second argument must be a listener function.
16 messageManager.listen(message, listener, {
21 setHintMatcher: (hintMatcher) ->
22 unless typeof hintMatcher == 'function'
24 "VimFx: A hint matcher must be a function. Got: #{hintMatcher}"
26 vim.hintMatcher = hintMatcher
27 onShutdown(-> vim.hintMatcher = null)
29 getMarkerElement: (id) ->
30 data = vim.state.markerElements[id]
31 return if data then data.element else null
34 module.exports = createConfigAPI