.config/nvim/lua/config/commands.lua

Sat, 11 Mar 2023 21:38:57 -0600

author
Meredith Howard <mhoward@roomag.org>
date
Sat, 11 Mar 2023 21:38:57 -0600
changeset 1078
aa4c1aa529a5
child 1079
b59861305252
permissions
-rw-r--r--

Start porting custom commands to lua

local command = vim.api.nvim_create_user_command
local calias = require("config.util").calias
local cmd = vim.cmd
local fn = vim.fn

command("Hgcd", function()
  local root = fn.systemlist("hg root 2>/dev/null")[1]
  if vim.v.shell_error == 0 then
    cmd.cd(root)
  end
end, {})

command("Gcd", function()
  local root = fn.systemlist("git rev-parse --show-toplevel 2>/dev/null")[1]
  if vim.v.shell_error == 0 then
    cmd.cd(root)
  end
end, {})

calias("Q", "q")
calias("Qa", "qa")
calias("W", "w")
calias("grep", "Grep")

calias("gcd", "Gcd")
calias("hgcd", "Hgcd")

-- Switch these to default to stay in one window + buffer
calias("doc", "ViewDoc!")
calias("help", "ViewDocHelp!")
calias("man", "ViewDocMan!")
calias("perldoc", "ViewDocPerl!")

mercurial