.config/nvim/lua/config/util.lua

Sun, 12 Mar 2023 03:18:04 -0500

author
Meredith Howard <mhoward@roomag.org>
date
Sun, 12 Mar 2023 03:18:04 -0500
changeset 1081
59e05e03851d
parent 1078
aa4c1aa529a5
child 1085
c2d11f022cf0
permissions
-rw-r--r--

unlazy indent-blankline.nvim, weird errors

local M = {}

function M.calias(abbrev, expand)
  vim.cmd.cnoreabbrev(
    string.format(
      [[<expr> %s (getcmdtype() == ":" && getcmdline() == "%s") ? "%s" : "%s"]],
      abbrev,
      abbrev,
      expand,
      abbrev
    )
  )
end

function M.autocmd(group, event, pattern, opts)
  if type(opts) == "function" then
    local func = opts
    opts = { callback = function (_)
      func()
    end }
  end

  vim.api.nvim_create_autocmd(
    event,
    vim.tbl_extend("keep", opts, {
      group = group,
      pattern = pattern,
    })
  )
end

return M

mercurial