Live grep enhancements
parent
36cb3c2f3b
commit
4f15ba03c8
|
@ -0,0 +1,3 @@
|
|||
This is my neovim config, nothing much to explain.
|
||||
|
||||
It's pretty much documented, so you can check it out.
|
85
nix.vim
85
nix.vim
|
@ -126,27 +126,57 @@ vim.keymap.set('i', '<C-Up>', "<Plug>(copilot-previous)", {})
|
|||
-- Telescope
|
||||
local actions = require("telescope.actions")
|
||||
local fb_actions = require "telescope._extensions.file_browser.actions"
|
||||
-- A helper tool from https://github.com/nvim-telescope/telescope.nvim/issues/2201
|
||||
-- We can select a directory and then grep in it
|
||||
local ts_select_dir_for_grep = function(prompt_bufnr)
|
||||
local action_state = require("telescope.actions.state")
|
||||
local fb = require("telescope").extensions.file_browser
|
||||
local live_grep = require("telescope.builtin").live_grep
|
||||
local current_line = action_state.get_current_line()
|
||||
|
||||
fb.file_browser({
|
||||
files = false,
|
||||
depth = false,
|
||||
attach_mappings = function(prompt_bufnr)
|
||||
require("telescope.actions").select_default:replace(function()
|
||||
local entry_path = action_state.get_selected_entry().Path
|
||||
local dir = entry_path:is_dir() and entry_path or entry_path:parent()
|
||||
local relative = dir:make_relative(vim.fn.getcwd())
|
||||
local absolute = dir:absolute()
|
||||
|
||||
live_grep({
|
||||
results_title = relative .. "/",
|
||||
cwd = absolute,
|
||||
default_text = current_line,
|
||||
})
|
||||
end)
|
||||
|
||||
return true
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
require('telescope').setup{
|
||||
extensions = {
|
||||
file_browser = {
|
||||
theme = "ivy",
|
||||
-- disables netrw and use telescope-file-browser in its place
|
||||
hijack_netrw = true,
|
||||
cwd_to_path = true,
|
||||
grouped = true,
|
||||
hidden = true,
|
||||
files = true,
|
||||
auto_depth = 4,
|
||||
git_status = true,
|
||||
mappings = {
|
||||
["i"] = {
|
||||
["<C-Up>"] = fb_actions.goto_parent_dir
|
||||
extensions = {
|
||||
file_browser = {
|
||||
theme = "ivy",
|
||||
-- disables netrw and use telescope-file-browser in its place
|
||||
hijack_netrw = true,
|
||||
cwd_to_path = true,
|
||||
grouped = true,
|
||||
hidden = true,
|
||||
files = true,
|
||||
auto_depth = 4,
|
||||
git_status = true,
|
||||
mappings = {
|
||||
["i"] = {
|
||||
["<C-Up>"] = fb_actions.goto_parent_dir
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
defaults = {
|
||||
dynamic_preview_title = true,
|
||||
defaults = {
|
||||
dynamic_preview_title = true,
|
||||
mappings = {
|
||||
i = {
|
||||
-- Quit via Esc in insert mode
|
||||
|
@ -154,6 +184,18 @@ defaults = {
|
|||
},
|
||||
},
|
||||
},
|
||||
pickers = {
|
||||
live_grep = {
|
||||
mappings = {
|
||||
i = {
|
||||
["<C-f>"] = ts_select_dir_for_grep,
|
||||
},
|
||||
n = {
|
||||
["<C-f>"] = ts_select_dir_for_grep,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
require("telescope").load_extension "file_browser"
|
||||
|
||||
|
@ -247,12 +289,17 @@ require('lualine').setup(
|
|||
tabline = {
|
||||
lualine_a = {
|
||||
{ 'buffers',
|
||||
show_filename_only = false,
|
||||
symbols = {
|
||||
modified = ' +'
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
-- Couldn't find a sane bufferline formatter
|
||||
lualine_z = {
|
||||
{ 'filename',
|
||||
path = 1
|
||||
}
|
||||
},
|
||||
},
|
||||
sections = {
|
||||
lualine_a = {'mode'},
|
||||
|
|
Loading…
Reference in New Issue