diff --git a/nvim/.config/nvim/fnl/dotfiles/util.fnl b/nvim/.config/nvim/fnl/dotfiles/util.fnl index 1998ced..622e74f 100644 --- a/nvim/.config/nvim/fnl/dotfiles/util.fnl +++ b/nvim/.config/nvim/fnl/dotfiles/util.fnl @@ -1,12 +1,18 @@ (local a (require :nfnl.core)) +(fn fn? [x] + (= :function (type x))) + (fn noremap [mode from to opts] (let [map-opts {:noremap true :silent true} - to (.. ":" to :) + to (if (fn? to) + to + (.. ":" to :)) buff-num (a.get opts :buff-num)] (if (or (a.get opts :local?) buff-num) - (vim.api.nvim_buf_set_keymap (or buff-num 0) mode from to map-opts) - (vim.api.nvim_set_keymap mode from to map-opts)))) + (vim.keymap.set mode from to + (a.merge map-opts {:buffer (or buff-num 0)})) + (vim.keymap.set mode from to map-opts)))) (fn nnoremap [from to opts] (noremap :n from to opts)) diff --git a/nvim/.config/nvim/lua/dotfiles/util.lua b/nvim/.config/nvim/lua/dotfiles/util.lua index 1875c99..376c2af 100644 --- a/nvim/.config/nvim/lua/dotfiles/util.lua +++ b/nvim/.config/nvim/lua/dotfiles/util.lua @@ -1,13 +1,21 @@ -- [nfnl] fnl/dotfiles/util.fnl local a = require("nfnl.core") +local function fn_3f(x) + return ("function" == type(x)) +end local function noremap(mode, from, to, opts) local map_opts = {noremap = true, silent = true} - local to0 = (":" .. to .. "") + local to0 + if fn_3f(to) then + to0 = to + else + to0 = (":" .. to .. "") + end local buff_num = a.get(opts, "buff-num") if (a.get(opts, "local?") or buff_num) then - return vim.api.nvim_buf_set_keymap((buff_num or 0), mode, from, to0, map_opts) + return vim.keymap.set(mode, from, to0, a.merge(map_opts, {buffer = (buff_num or 0)})) else - return vim.api.nvim_set_keymap(mode, from, to0, map_opts) + return vim.keymap.set(mode, from, to0, map_opts) end end local function nnoremap(from, to, opts)