summaryrefslogtreecommitdiff
path: root/fnl/config/util.fnl
blob: 7665a57a8285c7dc32eeef4e4b377fbb29fedd2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
;; Utility functions.
(module util {autoload {a aniseed.core nvim aniseed.nvim}})

(defn prequire [name]
      (let [(ok? plugin) (pcall require name)]
        (if ok?
            plugin
            (vim.notify (.. "Could not load config: " plugin)
                        vim.log.levels.WARN))))

(defn setup [plugin config]
      (let [plugin (prequire plugin)]
        (plugin.setup config)))

(defn telescope-ext [ext fun opts]
      (let [telescope (prequire :telescope)
            themes (prequire :telescope.themes)
            theme (. opts :theme)]
        ((. (. (. telescope :extensions) ext) fun) ((. themes theme) opts))))

(defn telescope-builtin [builtin opts]
      (let [telescope (prequire :telescope.builtin)
            themes (prequire :telescope.themes)
            theme (. opts :theme)]
        ((. telescope builtin) ((. themes theme) opts))))