aboutsummaryrefslogtreecommitdiff
path: root/.config/nvim/lua/cmds.lua
blob: 1426b9902303dba3555fa4b28189019f8ef4a1d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
local M = {}
local fn = vim.fn

local function cabbrev(input, replace)
    local cmd = 'cnoreabbrev <expr> %s v:lua.cmds.command("%s", "%s")'

    vim.cmd(cmd:format(input, input, replace))
end

function M.command(cmd, match)
    if fn.getcmdtype() == ":" and fn.getcmdline():match("^" .. cmd) then
        return match
    else
        return cmd
    end
end

cabbrev("vs", "vert sb")

return M