config: nvim: rewrite config in lua and use packer as plugin manager

This commit is contained in:
Thomas Preisner 2022-10-13 19:29:40 +02:00
parent 07be5a4e7a
commit 6863d4c2eb
11 changed files with 174 additions and 197 deletions

30
config/nvim/lua/utils.lua Normal file
View file

@ -0,0 +1,30 @@
local M = {}
-- keybinding mapper
function M.map(mode, lhs, rhs, opts)
local options = { noremap = true, silent = true }
if opts then
options = vim.tbl_extend('force', options, opts)
end
vim.api.nvim_set_keymap(mode, lhs, rhs, options)
end
-- simple prompt
function M.prompt(msg, accept_msg, deny_msg)
local answer = vim.fn.input(msg .. ' (YES/no) ')
while(true) do
-- clear vim cmdline before printing anything
vim.cmd('mode')
if answer == 'YES' then
print(accept_msg)
return true
elseif string.lower(answer) == 'no' then
print(deny_msg)
return false
end
-- re-request user input
answer = vim.fn.input('Please retry: ' .. msg .. ' (YES/no) ')
end
end
return M