summary refs log tree commit diff
path: root/.vim/lua
diff options
context:
space:
mode:
authorRobert Günzler <r@gnzler.io>2022-12-02 18:26:44 +0100
committerRobert Günzler <r@gnzler.io>2022-12-02 18:29:42 +0100
commit46f2f2c0bba2f588e2f8648b2d2063ce85090ad0 (patch)
treec0c08fe916add737e3cc1f67cff88ea982ec5f10 /.vim/lua
parent6d7c8da2ee4380d1104423ec66a651c9b138868d (diff)
vim/misc: add a setup func to setup userfuncs
Diffstat (limited to '.vim/lua')
-rw-r--r--.vim/lua/internal/misc.lua23
1 files changed, 23 insertions, 0 deletions
diff --git a/.vim/lua/internal/misc.lua b/.vim/lua/internal/misc.lua
index a3045f4..b7d1a06 100644
--- a/.vim/lua/internal/misc.lua
+++ b/.vim/lua/internal/misc.lua
@@ -204,4 +204,27 @@ function M.link_preview()
   )
 end
 
+function M.setup(opts)
+  if opts.sortline then
+    vim.api.nvim_create_user_command('SortLine', M.sort_lines,
+      { desc = 'sort line', range = '%', preview = M.sort_lines })
+  end
+  if opts.grep then
+    vim.api.nvim_create_user_command('Grep', function(o) M.live_grep(table.concat(o.fargs)) end,
+      {
+        desc = 'live grep (rg)',
+        nargs = '*',
+        complete = 'dir',
+      })
+  end
+  if opts.find then
+    vim.api.nvim_create_user_command('Find', function(o) M.find_files(table.concat(o.fargs)) end,
+      {
+        desc = 'find files (fd)',
+        nargs = '*',
+        complete = 'dir',
+      })
+  end
+end
+
 return M