From 38476f668c8cd715b06c2a4d82fe35fc195c00c9 Mon Sep 17 00:00:00 2001 From: Fernando Schauenburg Date: Wed, 28 Sep 2022 23:01:12 +0200 Subject: [PATCH] vim: add feedback for lua executor This is useful when executing lines that produce no output, so I have some confidence that something actually happened when pressing the key bindings. I am printing the message before executing the command because otherwise this feedback would shadow the output of the command being executed (which I am presumably interested in and would serve itself as feedback). --- config/nvim/after/ftplugin/lua.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/config/nvim/after/ftplugin/lua.lua b/config/nvim/after/ftplugin/lua.lua index 9885ba7..a70c29a 100644 --- a/config/nvim/after/ftplugin/lua.lua +++ b/config/nvim/after/ftplugin/lua.lua @@ -3,13 +3,16 @@ vim.bo.tabstop = 2 local buffer = { buffer = true } local exec_current_lua_line = function() - vim.fn.luaeval(vim.fn.getline('.')) + local lineno = vim.fn.line('.') + print('Executing line ' .. lineno) + vim.fn.luaeval(vim.fn.getline(lineno)) end local exec_current_lua_selection = function() local selection = { vim.fn.line('v'), vim.fn.line('.') } local first, last = vim.fn.min(selection), vim.fn.max(selection) local code = vim.fn.join(vim.fn.getline(first, last), '\n') + print('Executing lines ' .. first .. ' to ' .. last) loadstring(code)() end