aboutsummaryrefslogtreecommitdiff
path: root/fnl/nvrc/lib
diff options
context:
space:
mode:
Diffstat (limited to 'fnl/nvrc/lib')
-rw-r--r--fnl/nvrc/lib/io.fnl31
1 files changed, 31 insertions, 0 deletions
diff --git a/fnl/nvrc/lib/io.fnl b/fnl/nvrc/lib/io.fnl
new file mode 100644
index 0000000..7d20ed7
--- /dev/null
+++ b/fnl/nvrc/lib/io.fnl
@@ -0,0 +1,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!}