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

changeset 1078
aa4c1aa529a5
child 1079
b59861305252
new file mode 100644
--- /dev/null
+++ b/.config/nvim/lua/config/commands.lua
@@ -0,0 +1,32 @@
+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