From 72d448e384249103748ee83b587c45924e4bc44d Mon Sep 17 00:00:00 2001 From: sefidel Date: Thu, 10 Feb 2022 00:24:03 +0900 Subject: Initial commit --- fnl/nvrc/lib/io.fnl | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 fnl/nvrc/lib/io.fnl (limited to 'fnl/nvrc/lib') 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!} -- cgit 1.4.1