about summary refs log tree commit diff
path: root/fnl/nvrc/lib/io.fnl
blob: 7d20ed71bea6b70729931db0e3095751eff2d5bf (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
26
27
28
29
30
31
(fn cmd! [...] (vim.cmd ...))
(local {: format
        : sub} string)

(fn str? [x]
  (= :string (type x)))

(lambda double-quote [s]
  "Add double quotes at the beginning and end of the string."
  (assert (str? s) "expected string for s")
  (format "\"%s\"" s))

(lambda echo! [s]
  "Print a vim message without any format."
  (cmd! (format "echom %s" (double-quote s))))

(lambda warn! [s]
  "Print a vim message with a warning format."
  (cmd! (format "echohl WarningMsg
                 echom %s
                 echohl None" (double-quote s))))

(lambda err! [s]
  "Print a vim message with an error format."
  (cmd! (format "echohl ErrorMsg
                 echom %s
                 echohl None" (double-quote s))))

{: echo!
 : warn!
 : err!}