summary refs log tree commit diff
path: root/.vim
diff options
context:
space:
mode:
Diffstat (limited to '.vim')
-rw-r--r--.vim/init.lua12
-rw-r--r--.vim/lua/internal/misc.lua23
2 files changed, 29 insertions, 6 deletions
diff --git a/.vim/init.lua b/.vim/init.lua
index 101f9f9..9ee490d 100644
--- a/.vim/init.lua
+++ b/.vim/init.lua
@@ -295,16 +295,16 @@ autocmd({'TermOpen'}, { pattern = 'term://*',
 -- }}}
 
 -- USER COMMANDS -- {{{
-vim.api.nvim_create_user_command('SortLine', misc.sort_lines,
-  { range = '%', preview = misc.sort_lines, desc = 'sort line' })
 vim.api.nvim_create_user_command('Make', function(opts) require('internal.job').make(opts.fargs) end,
   { nargs = '*', desc = 'run make target' })
 vim.api.nvim_create_user_command('Sh', function(opts) require('internal.job').sh(table.concat(opts.fargs, ' ')) end,
   { nargs = '*', desc = 'run shell command' })
-vim.api.nvim_create_user_command('Grep', function(o) misc.live_grep(table.concat(o.fargs)) end,
-  { nargs = '*', complete = 'file', desc = 'live grep (rg)' })
-vim.api.nvim_create_user_command('Find', function(o) misc.find_files(table.concat(o.fargs)) end,
-  { nargs = '*', complete = 'file', desc = 'find files (fd)' })
+
+require('internal.misc').setup {
+  grep = true,
+  find = true,
+  sortline = true,
+}
 -- }}}
 
 _G.statusline_enable_notifysend = false
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