mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-22 08:53:33 +02:00
feat(project): add some fzf-lua keymap (#3666)
- `ctrl-s` search_in_project_files - `ctrl-w` change_working_directory - `ctrl-d` delete_project - `ctrl-r` recent_project_files Co-authored-by: 肖健正 <xiaojianzheng@qq.com>
This commit is contained in:
parent
af5a59be90
commit
f24999fd36
1 changed files with 33 additions and 1 deletions
|
@ -1,11 +1,15 @@
|
||||||
local pick = function()
|
local pick = nil
|
||||||
|
|
||||||
|
pick = function()
|
||||||
if LazyVim.pick.picker.name == "telescope" then
|
if LazyVim.pick.picker.name == "telescope" then
|
||||||
return vim.cmd("Telescope projects")
|
return vim.cmd("Telescope projects")
|
||||||
elseif LazyVim.pick.picker.name == "fzf" then
|
elseif LazyVim.pick.picker.name == "fzf" then
|
||||||
local fzf_lua = require("fzf-lua")
|
local fzf_lua = require("fzf-lua")
|
||||||
|
local project = require("project_nvim.project")
|
||||||
local history = require("project_nvim.utils.history")
|
local history = require("project_nvim.utils.history")
|
||||||
local results = history.get_recent_projects()
|
local results = history.get_recent_projects()
|
||||||
local actions = require("fzf-lua.actions")
|
local actions = require("fzf-lua.actions")
|
||||||
|
|
||||||
fzf_lua.fzf_exec(results, {
|
fzf_lua.fzf_exec(results, {
|
||||||
actions = {
|
actions = {
|
||||||
["default"] = {
|
["default"] = {
|
||||||
|
@ -14,6 +18,34 @@ local pick = function()
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
["ctrl-t"] = actions.file_tabedit,
|
["ctrl-t"] = actions.file_tabedit,
|
||||||
|
["ctrl-s"] = {
|
||||||
|
function(selected)
|
||||||
|
fzf_lua.live_grep({ cwd = selected[1] })
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
["ctrl-r"] = {
|
||||||
|
function(selected)
|
||||||
|
fzf_lua.oldfiles({ cwd = selected[1] })
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
["ctrl-w"] = {
|
||||||
|
function(selected)
|
||||||
|
local path = selected[1]
|
||||||
|
local ok = project.set_pwd(path)
|
||||||
|
if ok then
|
||||||
|
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<Esc>", true, false, true), "n", true)
|
||||||
|
LazyVim.info("Change project dir to " .. path)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
["ctrl-d"] = function(selected)
|
||||||
|
local path = selected[1]
|
||||||
|
local choice = vim.fn.confirm("Delete '" .. path .. "' project? ", "&Yes\n&No")
|
||||||
|
if choice == 1 then
|
||||||
|
history.delete_project({ value = path })
|
||||||
|
end
|
||||||
|
pick()
|
||||||
|
end,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue