Compare commits
19 Commits
Author | SHA1 | Date | |
---|---|---|---|
2b3bd6c013 | |||
31c40573db | |||
9cc5d3df50 | |||
6761d8efc8 | |||
0d05715411 | |||
dd5a5fb4cd | |||
9f98b0a01e | |||
b74db85447 | |||
c155b2e965 | |||
6a07e6522a | |||
26254487fb | |||
f9697cbf17 | |||
7eac9a854b | |||
4947802191 | |||
60d472a569 | |||
252197f659 | |||
e29ad4a14e | |||
1b34b481c8 | |||
bedeb66fa9 |
@ -179,17 +179,17 @@ return {
|
||||
"<cmd>Telescope buffers sort_mru=true sort_lastused=true<cr>",
|
||||
desc = "Switch Buffer",
|
||||
},
|
||||
{ "<leader>/", LazyVim.telescope("live_grep"), desc = "Grep (Root Dir)" },
|
||||
{ "<leader>/", LazyVim.pick("live_grep"), desc = "Grep (Root Dir)" },
|
||||
{ "<leader>:", "<cmd>Telescope command_history<cr>", desc = "Command History" },
|
||||
{ "<leader><space>", LazyVim.telescope("files"), desc = "Find Files (Root Dir)" },
|
||||
{ "<leader><space>", LazyVim.pick("auto"), desc = "Find Files (Root Dir)" },
|
||||
-- find
|
||||
{ "<leader>fb", "<cmd>Telescope buffers sort_mru=true sort_lastused=true<cr>", desc = "Buffers" },
|
||||
{ "<leader>fc", LazyVim.telescope.config_files(), desc = "Find Config File" },
|
||||
{ "<leader>ff", LazyVim.telescope("files"), desc = "Find Files (Root Dir)" },
|
||||
{ "<leader>fF", LazyVim.telescope("files", { cwd = false }), desc = "Find Files (cwd)" },
|
||||
{ "<leader>fc", LazyVim.pick.config_files(), desc = "Find Config File" },
|
||||
{ "<leader>ff", LazyVim.pick("auto"), desc = "Find Files (Root Dir)" },
|
||||
{ "<leader>fF", LazyVim.pick("auto", { root = false }), desc = "Find Files (cwd)" },
|
||||
{ "<leader>fg", "<cmd>Telescope git_files<cr>", desc = "Find Files (git-files)" },
|
||||
{ "<leader>fr", "<cmd>Telescope oldfiles<cr>", desc = "Recent" },
|
||||
{ "<leader>fR", LazyVim.telescope("oldfiles", { cwd = vim.uv.cwd() }), desc = "Recent (cwd)" },
|
||||
{ "<leader>fR", LazyVim.pick("oldfiles"), desc = "Recent (cwd)" },
|
||||
-- git
|
||||
{ "<leader>gc", "<cmd>Telescope git_commits<CR>", desc = "Commits" },
|
||||
{ "<leader>gs", "<cmd>Telescope git_status<CR>", desc = "Status" },
|
||||
@ -201,8 +201,8 @@ return {
|
||||
{ "<leader>sC", "<cmd>Telescope commands<cr>", desc = "Commands" },
|
||||
{ "<leader>sd", "<cmd>Telescope diagnostics bufnr=0<cr>", desc = "Document Diagnostics" },
|
||||
{ "<leader>sD", "<cmd>Telescope diagnostics<cr>", desc = "Workspace Diagnostics" },
|
||||
{ "<leader>sg", LazyVim.telescope("live_grep"), desc = "Grep (Root Dir)" },
|
||||
{ "<leader>sG", LazyVim.telescope("live_grep", { cwd = false }), desc = "Grep (cwd)" },
|
||||
{ "<leader>sg", LazyVim.pick("live_grep"), desc = "Grep (Root Dir)" },
|
||||
{ "<leader>sG", LazyVim.pick("live_grep", { root = false }), desc = "Grep (cwd)" },
|
||||
{ "<leader>sh", "<cmd>Telescope help_tags<cr>", desc = "Help Pages" },
|
||||
{ "<leader>sH", "<cmd>Telescope highlights<cr>", desc = "Search Highlight Groups" },
|
||||
{ "<leader>sj", "<cmd>Telescope jumplist<cr>", desc = "Jumplist" },
|
||||
@ -213,11 +213,11 @@ return {
|
||||
{ "<leader>so", "<cmd>Telescope vim_options<cr>", desc = "Options" },
|
||||
{ "<leader>sR", "<cmd>Telescope resume<cr>", desc = "Resume" },
|
||||
{ "<leader>sq", "<cmd>Telescope quickfix<cr>", desc = "Quickfix List" },
|
||||
{ "<leader>sw", LazyVim.telescope("grep_string", { word_match = "-w" }), desc = "Word (Root Dir)" },
|
||||
{ "<leader>sW", LazyVim.telescope("grep_string", { cwd = false, word_match = "-w" }), desc = "Word (cwd)" },
|
||||
{ "<leader>sw", LazyVim.telescope("grep_string"), mode = "v", desc = "Selection (Root Dir)" },
|
||||
{ "<leader>sW", LazyVim.telescope("grep_string", { cwd = false }), mode = "v", desc = "Selection (cwd)" },
|
||||
{ "<leader>uC", LazyVim.telescope("colorscheme", { enable_preview = true }), desc = "Colorscheme with Preview" },
|
||||
{ "<leader>sw", LazyVim.pick("grep_string", { word_match = "-w" }), desc = "Word (Root Dir)" },
|
||||
{ "<leader>sW", LazyVim.pick("grep_string", { root = false, word_match = "-w" }), desc = "Word (cwd)" },
|
||||
{ "<leader>sw", LazyVim.pick("grep_string"), mode = "v", desc = "Selection (Root Dir)" },
|
||||
{ "<leader>sW", LazyVim.pick("grep_string", { root = false }), mode = "v", desc = "Selection (cwd)" },
|
||||
{ "<leader>uC", LazyVim.pick("colorscheme", { enable_preview = true }), desc = "Colorscheme with Preview" },
|
||||
{
|
||||
"<leader>ss",
|
||||
function()
|
||||
@ -246,12 +246,12 @@ return {
|
||||
local find_files_no_ignore = function()
|
||||
local action_state = require("telescope.actions.state")
|
||||
local line = action_state.get_current_line()
|
||||
LazyVim.telescope("find_files", { no_ignore = true, default_text = line })()
|
||||
LazyVim.pick("find_files", { no_ignore = true, default_text = line })()
|
||||
end
|
||||
local find_files_with_hidden = function()
|
||||
local action_state = require("telescope.actions.state")
|
||||
local line = action_state.get_current_line()
|
||||
LazyVim.telescope("find_files", { hidden = true, default_text = line })()
|
||||
LazyVim.pick("find_files", { hidden = true, default_text = line })()
|
||||
end
|
||||
|
||||
return {
|
||||
|
195
lua/lazyvim/plugins/extras/editor/fzf.lua
Normal file
195
lua/lazyvim/plugins/extras/editor/fzf.lua
Normal file
@ -0,0 +1,195 @@
|
||||
---@class FzfLuaOpts: lazyvim.util.pick.Opts
|
||||
---@field cmd string?
|
||||
|
||||
LazyVim.pick.commands = {
|
||||
files = "files",
|
||||
}
|
||||
|
||||
---@param command string
|
||||
---@param opts? FzfLuaOpts
|
||||
LazyVim.pick._open = function(command, opts)
|
||||
opts = opts or {}
|
||||
if opts.cmd == nil and command == "git_files" and opts.show_untracked then
|
||||
opts.cmd = "git ls-files --exclude-standard --cached --others"
|
||||
end
|
||||
return require("fzf-lua")[command](opts)
|
||||
end
|
||||
|
||||
local function symbols_filter(entry, ctx)
|
||||
ctx.symbols_filter = ctx.symbols_filter or require("lazyvim.config").get_kind_filter(ctx.bufnr)
|
||||
return vim.tbl_contains(ctx.symbols_filter, entry.kind)
|
||||
end
|
||||
|
||||
return {
|
||||
{
|
||||
"nvim-telescope/telescope.nvim",
|
||||
enabled = false,
|
||||
},
|
||||
{
|
||||
"ibhagwan/fzf-lua",
|
||||
event = "VeryLazy",
|
||||
opts = function(_, opts)
|
||||
local config = require("fzf-lua.config")
|
||||
local actions = require("fzf-lua.actions")
|
||||
|
||||
-- Quickfix
|
||||
config.defaults.keymap.fzf["ctrl-q"] = "select-all+accept"
|
||||
config.defaults.keymap.builtin["<c-f>"] = "preview-page-down"
|
||||
config.defaults.keymap.builtin["<c-b>"] = "preview-page-up"
|
||||
|
||||
-- Trouble
|
||||
config.defaults.actions.files["ctrl-t"] = require("trouble.sources.fzf").actions.open
|
||||
|
||||
-- Toggle root dir / cwd
|
||||
config.defaults.actions.files["ctrl-r"] = function(_, ctx)
|
||||
local o = vim.deepcopy(ctx.__call_opts)
|
||||
o.root = o.root == false
|
||||
o.cwd = nil
|
||||
o.buf = ctx.__CTX.bufnr
|
||||
LazyVim.pick.open(ctx.__INFO.cmd, o)
|
||||
end
|
||||
config.defaults.actions.files["alt-c"] = config.defaults.actions.files["ctrl-r"]
|
||||
|
||||
-- use the same prompt for all
|
||||
local defaults = require("fzf-lua.profiles.default-title")
|
||||
local function fix(t)
|
||||
t.prompt = t.prompt ~= nil and " " or nil
|
||||
for _, v in pairs(t) do
|
||||
if type(v) == "table" then
|
||||
fix(v)
|
||||
end
|
||||
end
|
||||
end
|
||||
fix(defaults)
|
||||
|
||||
vim.api.nvim_set_hl(0, "FzfLuaPath", { link = "Directory", default = true })
|
||||
|
||||
return vim.tbl_deep_extend("force", opts, defaults, {
|
||||
fzf_colors = true,
|
||||
files = {
|
||||
cwd_prompt = false,
|
||||
actions = {
|
||||
["alt-i"] = { actions.toggle_ignore },
|
||||
["alt-h"] = { actions.toggle_hidden },
|
||||
},
|
||||
},
|
||||
grep = {
|
||||
formatter = "path.hl",
|
||||
actions = {
|
||||
["alt-i"] = { actions.toggle_ignore },
|
||||
["alt-h"] = { actions.toggle_hidden },
|
||||
},
|
||||
},
|
||||
formatters = {
|
||||
path = {
|
||||
hl = {
|
||||
_to = function()
|
||||
local _, escseq = require("fzf-lua.utils").ansi_from_hl("FzfLuaPath", "foo")
|
||||
return [[
|
||||
return function(s, _, m)
|
||||
return "]] .. (escseq or "") .. [["
|
||||
.. s .. m.utils.ansi_escseq.clear
|
||||
end
|
||||
]]
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
end,
|
||||
keys = {
|
||||
{ "<esc>", "<cmd>close<cr>", ft = "fzf", mode = "t", nowait = true },
|
||||
{ "<c-j>", "<Down>", ft = "fzf", mode = "t", nowait = true },
|
||||
{ "<c-k>", "<Up>", ft = "fzf", mode = "t", nowait = true },
|
||||
{
|
||||
"<leader>,",
|
||||
"<cmd>FzfLua buffers sort_mru=true sort_lastused=true<cr>",
|
||||
desc = "Switch Buffer",
|
||||
},
|
||||
{ "<leader>/", LazyVim.pick("live_grep"), desc = "Grep (Root Dir)" },
|
||||
{ "<leader>:", "<cmd>FzfLua command_history<cr>", desc = "Command History" },
|
||||
{ "<leader><space>", LazyVim.pick("auto"), desc = "Find Files (Root Dir)" },
|
||||
-- find
|
||||
{ "<leader>fb", "<cmd>FzfLua buffers sort_mru=true sort_lastused=true<cr>", desc = "Buffers" },
|
||||
{ "<leader>fc", LazyVim.pick.config_files(), desc = "Find Config File" },
|
||||
{ "<leader>ff", LazyVim.pick("auto"), desc = "Find Files (Root Dir)" },
|
||||
{ "<leader>fF", LazyVim.pick("auto", { root = false }), desc = "Find Files (cwd)" },
|
||||
{ "<leader>fg", "<cmd>FzfLua git_files<cr>", desc = "Find Files (git-files)" },
|
||||
{ "<leader>fr", "<cmd>FzfLua oldfiles<cr>", desc = "Recent" },
|
||||
{ "<leader>fR", LazyVim.pick("oldfiles", { root = false }), desc = "Recent (cwd)" },
|
||||
-- git
|
||||
{ "<leader>gc", "<cmd>FzfLua git_commits<CR>", desc = "Commits" },
|
||||
{ "<leader>gs", "<cmd>FzfLua git_status<CR>", desc = "Status" },
|
||||
-- search
|
||||
{ '<leader>s"', "<cmd>FzfLua registers<cr>", desc = "Registers" },
|
||||
{ "<leader>sa", "<cmd>FzfLua autocmds<cr>", desc = "Auto Commands" },
|
||||
{ "<leader>sb", "<cmd>FzfLua grep_curbuf<cr>", desc = "Buffer" },
|
||||
{ "<leader>sc", "<cmd>FzfLua command_history<cr>", desc = "Command History" },
|
||||
{ "<leader>sC", "<cmd>FzfLua commands<cr>", desc = "Commands" },
|
||||
{ "<leader>sd", "<cmd>FzfLua diagnostics_document<cr>", desc = "Document Diagnostics" },
|
||||
{ "<leader>sD", "<cmd>FzfLua diagnostics_workspace<cr>", desc = "Workspace Diagnostics" },
|
||||
{ "<leader>sg", LazyVim.pick("live_grep"), desc = "Grep (Root Dir)" },
|
||||
{ "<leader>sG", LazyVim.pick("live_grep", { root = false }), desc = "Grep (cwd)" },
|
||||
{ "<leader>sh", "<cmd>FzfLua help_tags<cr>", desc = "Help Pages" },
|
||||
{ "<leader>sH", "<cmd>FzfLua highlights<cr>", desc = "Search Highlight Groups" },
|
||||
{ "<leader>sj", "<cmd>FzfLua jumps<cr>", desc = "Jumplist" },
|
||||
{ "<leader>sk", "<cmd>FzfLua keymaps<cr>", desc = "Key Maps" },
|
||||
{ "<leader>sl", "<cmd>FzfLua loclist<cr>", desc = "Location List" },
|
||||
{ "<leader>sM", "<cmd>FzfLua man_pages<cr>", desc = "Man Pages" },
|
||||
{ "<leader>sm", "<cmd>FzfLua marks<cr>", desc = "Jump to Mark" },
|
||||
{ "<leader>sR", "<cmd>FzfLua resume<cr>", desc = "Resume" },
|
||||
{ "<leader>sq", "<cmd>FzfLua quickfix<cr>", desc = "Quickfix List" },
|
||||
{ "<leader>sw", LazyVim.pick("grep_cword"), desc = "Word (Root Dir)" },
|
||||
{ "<leader>sW", LazyVim.pick("grep_cword", { root = false }), desc = "Word (cwd)" },
|
||||
{ "<leader>sw", LazyVim.pick("grep_visual"), mode = "v", desc = "Selection (Root Dir)" },
|
||||
{ "<leader>sW", LazyVim.pick("grep_visual", { root = false }), mode = "v", desc = "Selection (cwd)" },
|
||||
{ "<leader>uC", LazyVim.pick("colorschemes"), desc = "Colorscheme with Preview" },
|
||||
{
|
||||
"<leader>ss",
|
||||
function()
|
||||
require("fzf-lua").lsp_document_symbols({
|
||||
regex_filter = symbols_filter,
|
||||
})
|
||||
end,
|
||||
desc = "Goto Symbol",
|
||||
},
|
||||
{
|
||||
"<leader>sS",
|
||||
function()
|
||||
require("fzf-lua").lsp_dynamic_workspace_symbols({
|
||||
regex_filter = symbols_filter,
|
||||
})
|
||||
end,
|
||||
desc = "Goto Symbol (Workspace)",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
"folke/todo-comments.nvim",
|
||||
optional = true,
|
||||
-- stylua: ignore
|
||||
keys = {
|
||||
{ "<leader>st", function() require("todo-comments.fzf").todo() end, desc = "Todo" },
|
||||
{ "<leader>sT", function () require("todo-comments.fzf").todo({ keywords = { "TODO", "FIX", "FIXME" } }) end, desc = "Todo/Fix/Fixme" },
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
opts = function()
|
||||
local Keys = require("lazyvim.plugins.lsp.keymaps").get()
|
||||
vim.list_extend(Keys, {
|
||||
{
|
||||
"gd",
|
||||
"<cmd>FzfLua lsp_definitions jump_to_single_result=true<cr>",
|
||||
desc = "Goto Definition",
|
||||
has = "definition",
|
||||
},
|
||||
{ "gr", "<cmd>FzfLua lsp_references jump_to_single_result=true<cr>", desc = "References", nowait = true },
|
||||
{ "gI", "<cmd>FzfLua lsp_implementations jump_to_single_result=true<cr>", desc = "Goto Implementation" },
|
||||
{ "gy", "<cmd>FzfLua lsp_typedefs jump_to_single_result=true<cr>", desc = "Goto T[y]pe Definition" },
|
||||
})
|
||||
end,
|
||||
},
|
||||
}
|
@ -343,11 +343,11 @@ return {
|
||||
header = vim.split(logo, "\n"),
|
||||
-- stylua: ignore
|
||||
center = {
|
||||
{ action = LazyVim.telescope("files"), desc = " Find File", icon = " ", key = "f" },
|
||||
{ action = LazyVim.pick(), desc = " Find File", icon = " ", key = "f" },
|
||||
{ action = "ene | startinsert", desc = " New File", icon = " ", key = "n" },
|
||||
{ action = "Telescope oldfiles", desc = " Recent Files", icon = " ", key = "r" },
|
||||
{ action = "Telescope live_grep", desc = " Find Text", icon = " ", key = "g" },
|
||||
{ action = [[lua LazyVim.telescope.config_files()()]], desc = " Config", icon = " ", key = "c" },
|
||||
{ action = LazyVim.pick("oldfiles"), desc = " Recent Files", icon = " ", key = "r" },
|
||||
{ action = LazyVim.pick("live_grep"), desc = " Find Text", icon = " ", key = "g" },
|
||||
{ action = LazyVim.pick.config_files(), desc = " Config", icon = " ", key = "c" },
|
||||
{ action = 'lua require("persistence").load()', desc = " Restore Session", icon = " ", key = "s" },
|
||||
{ action = "LazyExtras", desc = " Lazy Extras", icon = " ", key = "x" },
|
||||
{ action = "Lazy", desc = " Lazy", icon = " ", key = "l" },
|
||||
|
@ -17,6 +17,7 @@ local LazyUtil = require("lazy.core.util")
|
||||
---@field json lazyvim.util.json
|
||||
---@field lualine lazyvim.util.lualine
|
||||
---@field mini lazyvim.util.mini
|
||||
---@field pick lazyvim.util.pick
|
||||
---@field cmp lazyvim.util.cmp
|
||||
local M = {}
|
||||
|
||||
@ -281,4 +282,5 @@ function M.memoize(fn)
|
||||
return cache[key]
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
72
lua/lazyvim/util/pick.lua
Normal file
72
lua/lazyvim/util/pick.lua
Normal file
@ -0,0 +1,72 @@
|
||||
---@class lazyvim.util.pick
|
||||
---@overload fun(command:string, opts?:lazyvim.util.pick.Opts): fun()
|
||||
local M = setmetatable({}, {
|
||||
__call = function(m, ...)
|
||||
return m.wrap(...)
|
||||
end,
|
||||
})
|
||||
|
||||
---@class lazyvim.util.pick.Opts: table<string, any>
|
||||
---@field root? boolean
|
||||
---@field cwd? string
|
||||
---@field buf? number
|
||||
---@field show_untracked? boolean
|
||||
|
||||
---@type table<string, string>
|
||||
M.commands = {
|
||||
files = "find_files",
|
||||
}
|
||||
|
||||
---@param command? string
|
||||
---@param opts? lazyvim.util.pick.Opts
|
||||
function M.open(command, opts)
|
||||
command = command or "auto"
|
||||
opts = opts or {}
|
||||
|
||||
opts = vim.deepcopy(opts)
|
||||
|
||||
if type(opts.cwd) == "boolean" then
|
||||
LazyVim.warn("LazyVim.pick: opts.cwd should be a string or nil")
|
||||
opts.cwd = nil
|
||||
end
|
||||
|
||||
if not opts.cwd and opts.root ~= false then
|
||||
opts.cwd = LazyVim.root({ buf = opts.buf })
|
||||
end
|
||||
|
||||
local cwd = opts.cwd or vim.uv.cwd()
|
||||
if command == "auto" then
|
||||
command = "files"
|
||||
if
|
||||
vim.uv.fs_stat(cwd .. "/.git")
|
||||
and not vim.uv.fs_stat(cwd .. "/.ignore")
|
||||
and not vim.uv.fs_stat(cwd .. "/.rgignore")
|
||||
then
|
||||
command = "git_files"
|
||||
opts.show_untracked = opts.show_untracked ~= false
|
||||
end
|
||||
end
|
||||
command = M.commands[command] or command
|
||||
M._open(command, opts)
|
||||
end
|
||||
|
||||
---@param command? string
|
||||
---@param opts? lazyvim.util.pick.Opts
|
||||
function M.wrap(command, opts)
|
||||
opts = opts or {}
|
||||
return function()
|
||||
M.open(command, vim.deepcopy(opts))
|
||||
end
|
||||
end
|
||||
|
||||
---@param command string
|
||||
---@param opts? lazyvim.util.pick.Opts
|
||||
function M._open(command, opts)
|
||||
return LazyVim.telescope.open(command, opts)
|
||||
end
|
||||
|
||||
function M.config_files()
|
||||
return M.wrap("files", { cwd = vim.fn.stdpath("config") })
|
||||
end
|
||||
|
||||
return M
|
@ -168,13 +168,14 @@ end
|
||||
-- * lsp root_dir
|
||||
-- * root pattern of filename of the current buffer
|
||||
-- * root pattern of cwd
|
||||
---@param opts? {normalize?:boolean}
|
||||
---@param opts? {normalize?:boolean, buf?:number}
|
||||
---@return string
|
||||
function M.get(opts)
|
||||
local buf = vim.api.nvim_get_current_buf()
|
||||
opts = opts or {}
|
||||
local buf = opts.buf or vim.api.nvim_get_current_buf()
|
||||
local ret = M.cache[buf]
|
||||
if not ret then
|
||||
local roots = M.detect({ all = false })
|
||||
local roots = M.detect({ all = false, buf = buf })
|
||||
ret = roots[1] and roots[1].paths[1] or vim.uv.cwd()
|
||||
M.cache[buf] = ret
|
||||
end
|
||||
|
@ -1,9 +1,5 @@
|
||||
---@class lazyvim.util.telescope.opts
|
||||
---@field cwd? string|boolean
|
||||
---@field show_untracked? boolean
|
||||
|
||||
---@class lazyvim.util.telescope
|
||||
---@overload fun(builtin:string, opts?:lazyvim.util.telescope.opts)
|
||||
---@overload fun(builtin:string, opts?:lazyvim.util.pick.Opts)
|
||||
local M = setmetatable({}, {
|
||||
__call = function(m, ...)
|
||||
return m.telescope(...)
|
||||
@ -14,50 +10,39 @@ local M = setmetatable({}, {
|
||||
-- cwd will default to lazyvim.util.get_root
|
||||
-- for `files`, git_files or find_files will be chosen depending on .git
|
||||
---@param builtin string
|
||||
---@param opts? lazyvim.util.telescope.opts
|
||||
function M.telescope(builtin, opts)
|
||||
local params = { builtin = builtin, opts = opts }
|
||||
return function()
|
||||
builtin = params.builtin
|
||||
opts = params.opts
|
||||
opts = vim.tbl_deep_extend("force", { cwd = LazyVim.root() }, opts or {}) --[[@as lazyvim.util.telescope.opts]]
|
||||
if builtin == "files" then
|
||||
if
|
||||
vim.uv.fs_stat((opts.cwd or vim.uv.cwd()) .. "/.git")
|
||||
and not vim.uv.fs_stat((opts.cwd or vim.uv.cwd()) .. "/.ignore")
|
||||
and not vim.uv.fs_stat((opts.cwd or vim.uv.cwd()) .. "/.rgignore")
|
||||
then
|
||||
if opts.show_untracked == nil then
|
||||
opts.show_untracked = true
|
||||
end
|
||||
builtin = "git_files"
|
||||
else
|
||||
builtin = "find_files"
|
||||
end
|
||||
---@param opts? lazyvim.util.pick.Opts
|
||||
function M.open(builtin, opts)
|
||||
opts = opts or {}
|
||||
if opts.cwd and opts.cwd ~= vim.uv.cwd() then
|
||||
local function open_cwd_dir()
|
||||
local action_state = require("telescope.actions.state")
|
||||
local line = action_state.get_current_line()
|
||||
LazyVim.pick.open(
|
||||
builtin,
|
||||
vim.tbl_deep_extend("force", {}, opts or {}, {
|
||||
root = false,
|
||||
default_text = line,
|
||||
})
|
||||
)
|
||||
end
|
||||
if opts.cwd and opts.cwd ~= vim.uv.cwd() then
|
||||
local function open_cwd_dir()
|
||||
local action_state = require("telescope.actions.state")
|
||||
local line = action_state.get_current_line()
|
||||
M.telescope(
|
||||
params.builtin,
|
||||
vim.tbl_deep_extend("force", {}, params.opts or {}, { cwd = false, default_text = line })
|
||||
)()
|
||||
end
|
||||
---@diagnostic disable-next-line: inject-field
|
||||
opts.attach_mappings = function(_, map)
|
||||
-- opts.desc is overridden by telescope, until it's changed there is this fix
|
||||
map("i", "<a-c>", open_cwd_dir, { desc = "Open cwd Directory" })
|
||||
return true
|
||||
end
|
||||
---@diagnostic disable-next-line: inject-field
|
||||
opts.attach_mappings = function(_, map)
|
||||
-- opts.desc is overridden by telescope, until it's changed there is this fix
|
||||
map("i", "<a-c>", open_cwd_dir, { desc = "Open cwd Directory" })
|
||||
return true
|
||||
end
|
||||
|
||||
require("telescope.builtin")[builtin](opts)
|
||||
end
|
||||
|
||||
require("telescope.builtin")[builtin](opts)
|
||||
end
|
||||
|
||||
M.telescope = function(...)
|
||||
LazyVim.deprecate("LazyVim.telescope", "LazyVim.pick")
|
||||
return LazyVim.pick.wrap(...)
|
||||
end
|
||||
|
||||
function M.config_files()
|
||||
return LazyVim.telescope("find_files", { cwd = vim.fn.stdpath("config") })
|
||||
return LazyVim.pick.config_files()
|
||||
end
|
||||
|
||||
return M
|
||||
|
Reference in New Issue
Block a user