Module: Rvim::Lua::Notify

Defined in:
lib/rvim/lua/notify.rb

Overview

vim.notify(msg, [level], [opts]): forward a Lua plugin’s notification to the editor’s status line. Level is one of vim.log.levels but for v3.0 we just stringify and route to status_message regardless of level.

Constant Summary collapse

LEVELS =
{ 0 => 'TRACE', 1 => 'DEBUG', 2 => 'INFO', 3 => 'WARN', 4 => 'ERROR' }.freeze

Class Method Summary collapse

Class Method Details

.install(state, editor, _runtime) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rvim/lua/notify.rb', line 13

def install(state, editor, _runtime)
  state.function 'vim.notify' do |msg, level, _opts|
    tag = LEVELS[level&.to_i]
    editor.status_message = tag ? "[#{tag}] #{msg}" : msg.to_s
  end

  # vim.log.levels — used by plugins to pass severity to vim.notify.
  state.eval(<<~LUA)
    vim.log = { levels = { TRACE = 0, DEBUG = 1, INFO = 2, WARN = 3, ERROR = 4 } }
  LUA
end