nvim: scope supports grep

telescope, plenary removed
This commit is contained in:
dogeystamp 2024-09-14 18:47:05 -04:00
parent ea7eb8c056
commit 62b281b68e
Signed by: dogeystamp
GPG Key ID: 7225FE3592EFFA38
6 changed files with 47 additions and 33 deletions

18
.gitmodules vendored
View File

@ -14,15 +14,6 @@
# neovim plugins
################
# prompts
# telescope.vim
[submodule "src/dot_local/share/nvim/site/pack/3pp/start/external_telescope.nvim"]
path = src/dot_local/share/nvim/site/pack/3pp/opt/external_telescope.nvim
url = https://github.com/nvim-telescope/telescope.nvim.git
[submodule "src/dot_local/share/nvim/site/pack/3pp/start/external_plenary.nvim"]
path = src/dot_local/share/nvim/site/pack/3pp/opt/external_plenary.nvim
url = https://github.com/nvim-lua/plenary.nvim.git
# git symbols in the gutter
[submodule "src/dot_local/share/nvim/site/pack/3pp/start/external_vim-gitgutter"]
path = src/dot_local/share/nvim/site/pack/3pp/opt/external_vim-gitgutter
@ -89,18 +80,15 @@
[submodule "src/dot_local/share/nvim/site/pack/3pp/start/external_cmp_luasnip"]
path = src/dot_local/share/nvim/site/pack/3pp/opt/external_cmp_luasnip
url = https://github.com/saadparwaiz1/cmp_luasnip
[submodule "submodule.src/dot_local/bin/external_pyinstantref.path"]
path = src/dot_local/bin/external_pyinstantref
url = https://github.com/dogeystamp/pyinstantref
[submodule "submodule.src/dot_local/bin/external_inkscape-shortcut-manager.path"]
path = src/dot_local/bin/external_inkscape-shortcut-manager
url = https://github.com/dogeystamp/inkscape-shortcut-manager
[submodule "submodule.src/dot_local/share/nvim/site/pack/3pp/start/external_telescope.nvim.path"]
path = src/dot_local/share/nvim/site/pack/3pp/opt/external_telescope.nvim
url = https://github.com/nvim-telescope/telescope.nvim.git
[submodule "submodule.src/dot_local/share/nvim/site/pack/3pp/start/external_plenary.nvim.path"]
path = src/dot_local/share/nvim/site/pack/3pp/opt/external_plenary.nvim
url = https://github.com/nvim-lua/plenary.nvim.git
[submodule "submodule.src/dot_local/share/nvim/site/pack/3pp/start/external_vim-gitgutter.path"]
path = src/dot_local/share/nvim/site/pack/3pp/opt/external_vim-gitgutter
url = https://github.com/airblade/vim-gitgutter.git

View File

@ -16,18 +16,13 @@ local dotprofile, profile_table = confutil.dotprofile, confutil.profile_table
-- bind to copy URL under cursor
keymap("<leader>uu", ":let @+ = expand('<cfile>')<cr>")
-- requires plenary.nvim
vim.cmd.packadd("telescope.nvim")
keymap("<leader>eg", "<cmd>Telescope live_grep<cr>")
keymap("<leader>eh", "<cmd>Telescope help_tags<cr>")
keymap("<leader>eb", "<cmd>Telescope keymaps<cr>")
--------
-- generic brand fuzzy finder
--------
local scope = require("scope")
scope.setup()
keymap("<leader>eg", scope.rg_search)
keymap("<leader>ef", scope.file_finder)
keymap("<leader>em", scope.buffer_list)
keymap("<leader>es", vim.lsp.buf.workspace_symbol)

View File

@ -11,6 +11,7 @@ M = {}
---@param s any Thing to print
---@param pre string? Message that goes before thing
---@diagnostic disable-next-line: unused-function, unused-local
---@deprecated
local function dbg_print(s, pre)
vim.system({ "sh", "-c", string.format("echo '%s' >> /tmp/nvim_scope_log", (pre or "") .. vim.inspect(s)) })
end
@ -41,7 +42,7 @@ function M.scope_fzf(choice_gen, command, scope_opts)
local buf = vim.api.nvim_create_buf(false, true)
if win_mode == "window" then
vim.cmd.buf(buf)
vim.api.nvim_win_set_buf(0, buf)
elseif win_mode == "float" then
vim.api.nvim_open_win(buf, true,
opts.float_opts or { relative = "cursor", width = 40, height = 20, col = 1, row = 1 })
@ -49,8 +50,6 @@ function M.scope_fzf(choice_gen, command, scope_opts)
vim.wo.statusline = "Scope"
vim.cmd("startinsert")
local fzf_opts = opts.fzf_opts or ""
local choice_cmd = ""
@ -97,6 +96,8 @@ function M.scope_fzf(choice_gen, command, scope_opts)
end
end
})
-- HACK: startinsert is broken here if called after input_new()
vim.api.nvim_feedkeys("i", "n", false)
end
--------------------------------
@ -195,14 +196,14 @@ local function input_new(opts, on_confirm)
vim.keymap.set({ "i", "n" }, "<Enter>",
function()
on_confirm(table.concat(vim.api.nvim_buf_get_lines(buf, 0, -1, true), "\n"))
close_win()
on_confirm(table.concat(vim.api.nvim_buf_get_lines(buf, 0, -1, true), "\n"))
end,
map_opts
)
vim.keymap.set({ "i" }, "<C-c>", function ()
on_confirm(nil)
vim.keymap.set({ "i" }, "<C-c>", function()
close_win()
on_confirm(nil)
end, map_opts)
end
@ -234,7 +235,7 @@ function M.buffer_list()
return vim.api.nvim_exec2("ls", { output = true }).output
end,
function(s)
local _, _, bufnr = string.find(s, "^%s*(%d+)")
local bufnr = string.match(s, "^%s*(%d+)")
if bufnr then
vim.cmd.buf(bufnr)
end
@ -242,4 +243,23 @@ function M.buffer_list()
)
end
---Non-live grep
function M.rg_search()
vim.ui.input({ prompt = "Query: " }, function(query)
if not query or query == "" then return end
M.scope_fzf(string.format("rg --with-filename --column --null '%s' .", query), function(sel)
local _, idx_end1, search_str = string.find(sel, "([^\n]*)\n")
local _, idx_end2, file = string.find(sel, "([%g ]*)\0", idx_end1 + 1)
if not file then return end
local line, column = string.match(sel, "(%d+):(%d+)", idx_end2 + 1)
vim.cmd.drop(file)
vim.fn.cursor(tonumber(line), tonumber(column))
local highlight = search_str
if highlight == "" then highlight = query end
end, { fzf_opts = ("--print-query --query '%s'"):format(query) })
end)
end
return M

View File

@ -87,6 +87,19 @@ Group.link("DapUIVariable", groups["@variable"])
Group.link("DapUIValue", groups["@number"])
Group.link("DapUIFloatBorder", groups.FloatBorder)
-- Trouble.nvim
Group.link("TroubleNormal", groups.Normal)
Group.link("TroubleNormalNC", groups.Normal)
-- LSP window borders
-- https://vi.stackexchange.com/a/39075
local _border = "rounded"
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(
vim.lsp.handlers.hover, {
border = _border
}
)
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(
vim.lsp.handlers.signature_help, {
border = _border
}
)
vim.diagnostic.config {
float = { border = _border }
}

@ -1 +0,0 @@
Subproject commit a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683

@ -1 +0,0 @@
Subproject commit 3b1600d0fd5172ad9fae00987362ca0ef3d8895d