|
@ -5,7 +5,7 @@ return { |
|
|
{ "nvim-telescope/telescope-fzf-native.nvim", build = "make" }, |
|
|
{ "nvim-telescope/telescope-fzf-native.nvim", build = "make" }, |
|
|
"nvim-tree/nvim-web-devicons", |
|
|
"nvim-tree/nvim-web-devicons", |
|
|
"debugloop/telescope-undo.nvim", |
|
|
"debugloop/telescope-undo.nvim", |
|
|
"nvim-telescope/telescope-ui-select.nvim", |
|
|
|
|
|
|
|
|
"nvim-telescope/telescope-ui-select.nvim", |
|
|
}, |
|
|
}, |
|
|
config = function() |
|
|
config = function() |
|
|
local telescope = require("telescope") |
|
|
local telescope = require("telescope") |
|
@ -20,6 +20,7 @@ return { |
|
|
opts = opts or {} |
|
|
opts = opts or {} |
|
|
|
|
|
|
|
|
filepath = vim.fn.expand(filepath) |
|
|
filepath = vim.fn.expand(filepath) |
|
|
|
|
|
---@diagnostic disable-next-line: undefined-field |
|
|
vim.loop.fs_stat(filepath, function(_, stat) |
|
|
vim.loop.fs_stat(filepath, function(_, stat) |
|
|
if not stat then |
|
|
if not stat then |
|
|
return |
|
|
return |
|
@ -36,7 +37,6 @@ return { |
|
|
telescope.setup({ |
|
|
telescope.setup({ |
|
|
defaults = { |
|
|
defaults = { |
|
|
file_sorter = sorters.get_fzy_sorter, |
|
|
file_sorter = sorters.get_fzy_sorter, |
|
|
prompt_prefix = " >", |
|
|
|
|
|
color_devicons = true, |
|
|
color_devicons = true, |
|
|
|
|
|
|
|
|
buffer_previewer_maker = truncate_large_files, |
|
|
buffer_previewer_maker = truncate_large_files, |
|
@ -84,40 +84,41 @@ return { |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}, |
|
|
["ui-select"] = { |
|
|
|
|
|
require("telescope.themes").get_dropdown({}) |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
["ui-select"] = { |
|
|
|
|
|
require("telescope.themes").get_dropdown({}), |
|
|
|
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
telescope.load_extension("fzf") |
|
|
telescope.load_extension("fzf") |
|
|
telescope.load_extension("undo") |
|
|
telescope.load_extension("undo") |
|
|
telescope.load_extension("ui-select") |
|
|
|
|
|
|
|
|
telescope.load_extension("ui-select") |
|
|
|
|
|
|
|
|
local git_branches = function() |
|
|
|
|
|
builtin.git_branches({ |
|
|
|
|
|
attach_mappings = function(_, map) |
|
|
|
|
|
map("i", "<c-d>", actions.git_delete_branch) |
|
|
|
|
|
map("n", "<c-d>", actions.git_delete_branch) |
|
|
|
|
|
return true |
|
|
|
|
|
end, |
|
|
|
|
|
}) |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
-- We cache the results of "git rev-parse" |
|
|
|
|
|
-- Process creation is expensive in Windows, so this reduces latency |
|
|
|
|
|
local is_inside_work_tree = {} |
|
|
|
|
|
|
|
|
|
|
|
local project_files = function() |
|
|
|
|
|
local cwd = vim.fn.getcwd() |
|
|
|
|
|
if is_inside_work_tree[cwd] == nil then |
|
|
|
|
|
vim.fn.system("git rev-parse --is-inside-work-tree") |
|
|
|
|
|
is_inside_work_tree[cwd] = vim.v.shell_error == 0 |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
local find_files = function() |
|
|
|
|
|
local ran, errorMessage = pcall(function() |
|
|
|
|
|
|
|
|
if is_inside_work_tree[cwd] then |
|
|
builtin.git_files({ show_untracked = true, hidden = true }) |
|
|
builtin.git_files({ show_untracked = true, hidden = true }) |
|
|
end) |
|
|
|
|
|
if not ran then |
|
|
|
|
|
builtin.find_files({ hidden = true }) |
|
|
|
|
|
|
|
|
else |
|
|
|
|
|
builtin.find_files({}) |
|
|
end |
|
|
end |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
-- set keymaps |
|
|
-- set keymaps |
|
|
local keymap = vim.keymap -- for conciseness |
|
|
local keymap = vim.keymap -- for conciseness |
|
|
|
|
|
|
|
|
keymap.set("n", "<C-g>", function () builtin.live_grep({ hidden = true }) end, {}) |
|
|
|
|
|
keymap.set("n", "<C-p>", find_files, {}) |
|
|
|
|
|
|
|
|
keymap.set("n", "<C-g>", function() |
|
|
|
|
|
builtin.live_grep({ hidden = true }) |
|
|
|
|
|
end, {}) |
|
|
|
|
|
keymap.set("n", "<C-p>", project_files, {}) |
|
|
|
|
|
|
|
|
keymap.set("n", "<leader>fr", builtin.resume, {}) |
|
|
keymap.set("n", "<leader>fr", builtin.resume, {}) |
|
|
|
|
|
|
|
@ -127,43 +128,42 @@ return { |
|
|
keymap.set("n", "<leader>m", builtin.marks, {}) |
|
|
keymap.set("n", "<leader>m", builtin.marks, {}) |
|
|
keymap.set("n", "<leader>ch", builtin.command_history, {}) |
|
|
keymap.set("n", "<leader>ch", builtin.command_history, {}) |
|
|
|
|
|
|
|
|
keymap.set("n", "<leader>gb", git_branches, {}) |
|
|
|
|
|
|
|
|
|
|
|
keymap.set("n", "<leader>vh", builtin.help_tags, {}) |
|
|
|
|
|
|
|
|
keymap.set("n", "<leader>gb", function() |
|
|
|
|
|
builtin.git_branches({ |
|
|
|
|
|
attach_mappings = function(_, map) |
|
|
|
|
|
map("i", "<c-d>", actions.git_delete_branch) |
|
|
|
|
|
map("n", "<c-d>", actions.git_delete_branch) |
|
|
|
|
|
return true |
|
|
|
|
|
end, |
|
|
|
|
|
}) |
|
|
|
|
|
end, {}) |
|
|
|
|
|
|
|
|
keymap.set("n", "<leader>ds", builtin.lsp_document_symbols, {}) |
|
|
|
|
|
keymap.set("n", "<leader>ws", builtin.lsp_workspace_symbols, {}) |
|
|
|
|
|
keymap.set("n", "<leader>dws", builtin.lsp_dynamic_workspace_symbols, {}) |
|
|
|
|
|
|
|
|
keymap.set("n", "<leader>gc", builtin.git_commits, {}) |
|
|
|
|
|
|
|
|
keymap.set("n", "<leader>gf", function () |
|
|
|
|
|
builtin.grep_string({ |
|
|
|
|
|
search = vim.fn.expand("<cword>"), |
|
|
|
|
|
}) |
|
|
|
|
|
end) |
|
|
|
|
|
|
|
|
keymap.set("n", "<leader>vh", builtin.help_tags, {}) |
|
|
|
|
|
|
|
|
keymap.set("n", "<leader>gF", function () |
|
|
|
|
|
builtin.grep_string({ |
|
|
|
|
|
search = vim.fn.expand("<cWORD>"), |
|
|
|
|
|
}) |
|
|
|
|
|
end) |
|
|
|
|
|
|
|
|
keymap.set("n", "<leader>ds", builtin.lsp_document_symbols, {}) |
|
|
|
|
|
keymap.set("n", "<leader>ws", builtin.lsp_workspace_symbols, {}) |
|
|
|
|
|
keymap.set("n", "<leader>dws", builtin.lsp_dynamic_workspace_symbols, {}) |
|
|
|
|
|
|
|
|
keymap.set("n", "<leader>gD", function () |
|
|
|
|
|
builtin.find_files({ |
|
|
|
|
|
search_file = vim.fn.expand("<cword>"), |
|
|
|
|
|
}) |
|
|
|
|
|
end) |
|
|
|
|
|
|
|
|
keymap.set("n", "<leader>gf", function() |
|
|
|
|
|
builtin.grep_string({ |
|
|
|
|
|
search = vim.fn.expand("<cword>"), |
|
|
|
|
|
}) |
|
|
|
|
|
end) |
|
|
|
|
|
|
|
|
vim.keymap.set("n", "<leader>u", "<cmd>Telescope undo<cr>") |
|
|
|
|
|
|
|
|
keymap.set("n", "<leader>gF", function() |
|
|
|
|
|
builtin.grep_string({ |
|
|
|
|
|
search = vim.fn.expand("<cWORD>"), |
|
|
|
|
|
}) |
|
|
|
|
|
end) |
|
|
|
|
|
|
|
|
local function telescopeDotfiles() |
|
|
|
|
|
|
|
|
keymap.set("n", "<leader>gD", function() |
|
|
builtin.find_files({ |
|
|
builtin.find_files({ |
|
|
prompt_title = "< VimRC >", |
|
|
|
|
|
cwd = vim.fn.expand("~/dotfiles"), |
|
|
|
|
|
hidden = true, |
|
|
|
|
|
|
|
|
search_file = vim.fn.expand("<cword>"), |
|
|
}) |
|
|
}) |
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
vim.api.nvim_create_user_command('TelescopeDotfiles', telescopeDotfiles, {}) |
|
|
|
|
|
|
|
|
end) |
|
|
|
|
|
|
|
|
|
|
|
vim.keymap.set("n", "<leader>u", "<cmd>Telescope undo<cr>") |
|
|
end, |
|
|
end, |
|
|
} |
|
|
} |