diff options
author | Matthieu Coudron <teto@users.noreply.github.com> | 2021-02-08 15:49:27 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-08 15:49:27 +0100 |
commit | 00423730b5eddc628a4b996b9e226fe23d7ce1f2 (patch) | |
tree | c7ac1a98a69962ab15f5380a85c4252c3aa096eb /src/nvim/lua/vim.lua | |
parent | 02a3c417945e7b7fc781906a78acbf88bd44c971 (diff) | |
parent | a90a43796a7aef470d33d0d5fc7f2f1d004cc06d (diff) | |
download | rneovim-00423730b5eddc628a4b996b9e226fe23d7ce1f2.tar.gz rneovim-00423730b5eddc628a4b996b9e226fe23d7ce1f2.tar.bz2 rneovim-00423730b5eddc628a4b996b9e226fe23d7ce1f2.zip |
Merge pull request #13843 from teto/notif_provider
[RDY] Notification provider
Diffstat (limited to 'src/nvim/lua/vim.lua')
-rw-r--r-- | src/nvim/lua/vim.lua | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/nvim/lua/vim.lua b/src/nvim/lua/vim.lua index dbf4f6014c..00a4fe26d3 100644 --- a/src/nvim/lua/vim.lua +++ b/src/nvim/lua/vim.lua @@ -39,6 +39,16 @@ assert(vim) vim.inspect = package.loaded['vim.inspect'] assert(vim.inspect) +vim.log = { + levels = { + TRACE = 0; + DEBUG = 1; + INFO = 2; + WARN = 3; + ERROR = 4; + } +} + -- Internal-only until comments in #8107 are addressed. -- Returns: -- {errcode}, {output} @@ -478,6 +488,23 @@ function vim.defer_fn(fn, timeout) return timer end + +--- Notification provider +--- without a runtime, writes to :Messages +-- see :help nvim_notify +--@param msg Content of the notification to show to the user +--@param log_level Optional log level +--@param opts Dictionary with optional options (timeout, etc) +function vim.notify(msg, log_level, _opts) + + if log_level == vim.log.levels.ERROR then + vim.api.nvim_err_writeln(msg) + else + vim.api.nvim_echo(msg) + end +end + + local on_keystroke_callbacks = {} --- Register a lua {fn} with an {id} to be run after every keystroke. |