diff --git a/lua/fzf-lua/complete.lua b/lua/fzf-lua/complete.lua index b73a09c9..99bcff5a 100644 --- a/lua/fzf-lua/complete.lua +++ b/lua/fzf-lua/complete.lua @@ -1,5 +1,6 @@ local core = require "fzf-lua.core" local path = require "fzf-lua.path" +local utils = require "fzf-lua.utils" local config = require "fzf-lua.config" local M = {} @@ -45,7 +46,7 @@ end -- set the cwd and prompt top the top level directory and -- the leftover match to the input query local set_cmp_opts_path = function(opts) - local match = "[^%s\"']*" + local match = "[^%s'" .. utils._if_win([[\/]], [[\]]) .. "]*" local line = vim.api.nvim_get_current_line() local col = vim.api.nvim_win_get_cursor(0)[2] + 1 local before = col > 1 and line:sub(1, col - 1):reverse():match(match):reverse() or "" @@ -56,6 +57,7 @@ local set_cmp_opts_path = function(opts) after = line:sub(col):match(match) or "" end opts._cwd, opts.cwd, opts.query = find_toplevel_cwd(before .. after, nil, nil) + print("_cwd", opts._cwd, "cwd", opts.cwd, "q", opts.query) opts.prompt = opts._cwd if not opts.prompt then opts.prompt = "." @@ -85,8 +87,8 @@ M.path = function(opts) return "fdfind" elseif vim.fn.executable("fd") == 1 then return "fd" - elseif vim.fn.executable("rg") == 1 then - return "rg --files" + elseif utils.__IS_WINDOWS then + return "dir /s/b" else return [[find ! -path '.' ! -path '*/\.git/*' -printf '%P\n']] end @@ -101,12 +103,14 @@ M.file = function(opts) if not opts then return end opts.cmp_is_file = true opts.cmd = opts.cmd or (function() - if vim.fn.executable("rg") == 1 then - return "rg --files" - elseif vim.fn.executable("fdfind") == 1 then + if vim.fn.executable("fdfind") == 1 then return "fdfind --type f --exclude .git" elseif vim.fn.executable("fd") == 1 then return "fd --type f --exclude .git" + elseif vim.fn.executable("rg") == 1 then + return "rg --files" + elseif utils.__IS_WINDOWS then + return "dir /s/b" else return [[find -type f ! -path '*/\.git/*' -printf '%P\n']] end diff --git a/lua/fzf-lua/defaults.lua b/lua/fzf-lua/defaults.lua index 5a7a4c1a..9cab6238 100644 --- a/lua/fzf-lua/defaults.lua +++ b/lua/fzf-lua/defaults.lua @@ -908,12 +908,13 @@ M.defaults.dap = { } M.defaults.complete_path = { - cmd = nil, -- default: auto detect fd|rg|find - file_icons = false, - git_icons = false, - color_icons = true, - fzf_opts = { ["--no-multi"] = true }, - actions = { ["default"] = actions.complete }, + cmd = nil, -- default: auto detect fd|rg|find + file_icons = false, + git_icons = false, + color_icons = true, + multiprocess = true, + fzf_opts = { ["--no-multi"] = true }, + actions = { ["default"] = actions.complete }, } M.defaults.complete_file = { diff --git a/lua/fzf-lua/fzf.lua b/lua/fzf-lua/fzf.lua index 33fd0dc9..87c826a0 100644 --- a/lua/fzf-lua/fzf.lua +++ b/lua/fzf-lua/fzf.lua @@ -304,7 +304,7 @@ function M.raw_fzf(contents, fzf_cli_args, opts) -- This "retires" 'actions.ensure_insert_mode' and solves the -- issue of calling an fzf-lua mapping from insert mode (#429) - if vim.fn.has("nvim-0.6") == 1 then + if vim.fn.has("nvim-0.6") == 1 and vim.api.nvim_get_mode().mode ~= "i" then vim.cmd([[noautocmd lua vim.api.nvim_feedkeys(]] .. [[vim.api.nvim_replace_termcodes("i", true, false, true)]] .. [[, 'n', true)]])