vim.keymap.set('n', '<leader>R', vim.lsp.buf.rename)
vim.keymap.set('n', '<leader>k', vim.lsp.buf.hover)
vim.keymap.set('n', '<leader>K', vim.diagnostic.open_float)
+
vim.keymap.set('n', '<leader>d',
function()
if vim.g.visible_diagnostics then
end
end
)
+
+-- live grep in git repo, or fall back to current repo
+vim.keymap.set('n', '<leader>F',
+ function()
+ local function is_git_repo()
+ vim.fn.system("git rev-parse --is-inside-work-tree")
+
+ return vim.v.shell_error == 0
+ end
+
+ local function get_git_root()
+ local dot_git_path = vim.fn.finddir(".git", ".;")
+ return vim.fn.fnamemodify(dot_git_path, ":h")
+ end
+
+ local opts = {}
+
+ if is_git_repo() then
+ opts = {
+ cwd = get_git_root(),
+ }
+ end
+
+ require("telescope.builtin").live_grep(opts)
+ end
+)
+
+vim.keymap.set('n', '<leader>f',
+ function()
+ local function is_git_repo()
+ vim.fn.system("git rev-parse --is-inside-work-tree")
+ return vim.v.shell_error == 0
+ end
+ local function get_git_root()
+ local dot_git_path = vim.fn.finddir(".git", ".;")
+ return vim.fn.fnamemodify(dot_git_path, ":h")
+ end
+ local opts = {}
+ if is_git_repo() then
+ opts = {
+ cwd = get_git_root(),
+ }
+ end
+ require("telescope.builtin").find_files(opts)
+ end
+)
return {
{
'nvim-telescope/telescope.nvim',
- dependencies = { 'nvim-lua/plenary.nvim' },
+ lazy = false,
+ dependencies = {
+ 'nvim-lua/plenary.nvim',
+ {
+ 'nvim-telescope/telescope-fzf-native.nvim',
+ build = {
+ 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build' }
+ },
+ },
keys = {
- { '<leader>f', '<CMD>Telescope git_files<CR>' },
- { '<leader>F', '<CMD>Telescope find_files<CR>' },
- { '<leader><C-f>', '<CMD>Telescope live_grep<CR>' },
{ '<leader>b', '<CMD>Telescope buffers<CR>' },
{ '<leader><C-r>', '<CMD>Telescope command_history<CR>' },
{ '<leader>D', '<CMD>Telescope diagnostics<CR>' },
layout_config = {
height = 0.9,
width = 0.9,
- }
+ },
+ mappings = {
+ i = { ["<ESC>"] = require('telescope.actions').close },
+ },
},
pickers = {},
- extensions = {},
+ extensions = {
+ fzf = {
+ fuzzy = true,
+ override_generic_sorter = true,
+ override_file_sorter = true,
+ case_mode = 'smart_case',
+ }
+ },
}
+
+ require('telescope').load_extension('fzf')
end
},
}