about summary refs log tree commit diff
path: root/fnl/nvrc/lib
diff options
context:
space:
mode:
authorsefidel <contact@sefidel.net>2022-02-10 00:24:03 +0900
committersefidel <contact@sefidel.net>2022-02-10 00:24:03 +0900
commit72d448e384249103748ee83b587c45924e4bc44d (patch)
tree2aa05a6aaf8c7aa37a8c278fd2fede6e62ff2218 /fnl/nvrc/lib
downloadnvimrc-72d448e384249103748ee83b587c45924e4bc44d.tar.gz
nvimrc-72d448e384249103748ee83b587c45924e4bc44d.zip
Initial commit
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!}