Skip to content

Commit

Permalink
fix: complete path/file windows adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
ibhagwan committed Feb 4, 2024
1 parent a125fa5 commit 8bf3b5e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
13 changes: 8 additions & 5 deletions lua/fzf-lua/complete.lua
Original file line number Diff line number Diff line change
@@ -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 = {}
Expand Down Expand Up @@ -85,8 +86,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
Expand All @@ -101,12 +102,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
Expand Down
13 changes: 7 additions & 6 deletions lua/fzf-lua/defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
4 changes: 2 additions & 2 deletions lua/fzf-lua/fzf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function M.raw_fzf(contents, fzf_cli_args, opts)
if contents then
if type(contents) == "string" and #contents > 0 then
if opts.silent_fail ~= false then
contents = ("%s || true"):format(contents)
contents = ("%s || " .. utils._if_win("break", "true")):format(contents)
end
FZF_DEFAULT_COMMAND = contents
else
Expand Down Expand Up @@ -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("<Esc>i", true, false, true)]]
.. [[, 'n', true)]])
Expand Down

0 comments on commit 8bf3b5e

Please sign in to comment.