- Simplify telescope.lua configuration - Streamline trouble.lua diagnostics - Refactor oil.lua file manager - Update harpoon.lua quick file navigation - Clean up indent.lua, lualine.lua, which-key.lua
57 lines
2 KiB
Lua
Executable file
57 lines
2 KiB
Lua
Executable file
return {
|
|
'nvim-telescope/telescope.nvim',
|
|
cmd = 'Telescope',
|
|
keys = {
|
|
{ '<leader>ff', '<cmd>Telescope find_files<CR>', desc = 'Find Files' },
|
|
{ '<leader>fg', '<cmd>Telescope live_grep<CR>', desc = 'Live Grep' },
|
|
{ '<leader>fG', '<cmd>LiveGrepGitRoot<CR>', desc = 'Live Grep Git Root' },
|
|
{ '<leader>fb', '<cmd>Telescope buffers<CR>', desc = 'Buffers' },
|
|
{ '<leader>fh', '<cmd>Telescope help_tags<CR>', desc = 'Help Tags' },
|
|
{ '<leader>fr', '<cmd>Telescope oldfiles<CR>', desc = 'Recent Files' },
|
|
},
|
|
dependencies = {
|
|
'nvim-lua/plenary.nvim',
|
|
{ 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' },
|
|
{ 'nvim-tree/nvim-web-devicons', optional = true },
|
|
},
|
|
config = function()
|
|
local telescope = require('telescope')
|
|
local actions = require('telescope.actions')
|
|
|
|
telescope.setup({
|
|
defaults = {
|
|
sorting_strategy = 'descending',
|
|
layout_strategy = 'flex',
|
|
mappings = {
|
|
i = {
|
|
['<C-u>'] = false,
|
|
['<C-d>'] = false,
|
|
['<CR>'] = function(prompt_bufnr)
|
|
-- close first, then center -- this is the correct order
|
|
actions.select_default(prompt_bufnr)
|
|
vim.cmd('normal! zz')
|
|
end,
|
|
},
|
|
},
|
|
},
|
|
extensions = { fzf = {} },
|
|
})
|
|
|
|
telescope.load_extension('fzf')
|
|
|
|
local function find_git_root()
|
|
local current_file = vim.api.nvim_buf_get_name(0)
|
|
local current_dir = current_file ~= '' and vim.fn.fnamemodify(current_file, ':h') or vim.fn.getcwd()
|
|
local git_root =
|
|
vim.fn.systemlist('git -C ' .. vim.fn.escape(current_dir, ' ') .. ' rev-parse --show-toplevel')[1]
|
|
if vim.v.shell_error ~= 0 then
|
|
return vim.fn.getcwd()
|
|
end
|
|
return git_root
|
|
end
|
|
|
|
vim.api.nvim_create_user_command('LiveGrepGitRoot', function()
|
|
require('telescope.builtin').live_grep({ search_dirs = { find_git_root() } })
|
|
end, { desc = 'Live grep in Git root' })
|
|
end,
|
|
}
|