changeset 582:8d5873878bb8

Add Cfd command to search files
author zegervdv <zegervdv@me.com>
date Sat, 09 Apr 2022 15:49:54 +0200
parents ea43c828daa1
children d16dddcf165e
files .chezmoitemplates/init.lua
diffstat 1 files changed, 33 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/.chezmoitemplates/init.lua	Fri Apr 01 18:13:18 2022 +0200
+++ b/.chezmoitemplates/init.lua	Sat Apr 09 15:49:54 2022 +0200
@@ -5,9 +5,9 @@
 local execute = vim.api.nvim_command
 local fn = vim.fn
 
-local home = os.getenv('HOME')
+local home = os.getenv 'HOME'
 if home == nil then
-  home = os.getenv('USERPROFILE')
+  home = os.getenv 'USERPROFILE'
 end
 
 -- Bootstrap package manager
@@ -595,22 +595,23 @@
   -- Filetypes
   use { 'lepture/vim-jinja' }
 
-    -- Integration with external tools
-    use {
-      'glacambre/firenvim',
-      run = function() vim.fn['firenvim#install'](0) end,
-      config = function ()
-        vim.g.firenvim_config = {
-          localSettings = {
-            ['.*'] = {
-              takeover = 'never',
-            }
-          }
-        }
-      end,
-    }
-
-  end)
+  -- Integration with external tools
+  use {
+    'glacambre/firenvim',
+    run = function()
+      vim.fn['firenvim#install'](0)
+    end,
+    config = function()
+      vim.g.firenvim_config = {
+        localSettings = {
+          ['.*'] = {
+            takeover = 'never',
+          },
+        },
+      }
+    end,
+  }
+end)
 
 vim.cmd [[ packadd dirbuf.nvim ]]
 
@@ -1005,6 +1006,20 @@
 
 vim.api.nvim_add_user_command('LspRename', LspRename, {})
 
+local fd_quickfix = function(args)
+  local grepprg = vim.opt.grepprg
+  local grepformat = vim.opt.grepformat
+
+  vim.opt.grepprg = 'fd'
+  vim.opt.grepformat = '%f'
+  vim.cmd('execute' .. '"silent! grep! ' .. args.args .. '"')
+  vim.cmd 'copen'
+
+  vim.opt.grepprg = grepprg
+  vim.opt.grepformat = grepformat
+end
+vim.api.nvim_add_user_command('Cfd', fd_quickfix, { nargs = '+', complete = 'file' })
+
 vim.diagnostic.config {
   underline = true,
   update_in_insert = false,