From 62b281b68e2f3b31c661707100ee83576a74e9bf Mon Sep 17 00:00:00 2001 From: dogeystamp Date: Sat, 14 Sep 2024 18:47:05 -0400 Subject: [PATCH] nvim: scope supports grep telescope, plenary removed --- .gitmodules | 18 ++-------- src/dot_config/nvim/lua/init.lua | 7 +--- src/dot_config/nvim/lua/scope.lua | 34 +++++++++++++++---- src/dot_config/nvim/lua/theme.lua | 19 +++++++++-- .../site/pack/3pp/opt/external_plenary.nvim | 1 - .../site/pack/3pp/opt/external_telescope.nvim | 1 - 6 files changed, 47 insertions(+), 33 deletions(-) delete mode 160000 src/dot_local/share/nvim/site/pack/3pp/opt/external_plenary.nvim delete mode 160000 src/dot_local/share/nvim/site/pack/3pp/opt/external_telescope.nvim diff --git a/.gitmodules b/.gitmodules index d3f70d1..c28f15a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -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 diff --git a/src/dot_config/nvim/lua/init.lua b/src/dot_config/nvim/lua/init.lua index cfbb319..05ba3ed 100644 --- a/src/dot_config/nvim/lua/init.lua +++ b/src/dot_config/nvim/lua/init.lua @@ -16,18 +16,13 @@ local dotprofile, profile_table = confutil.dotprofile, confutil.profile_table -- bind to copy URL under cursor keymap("uu", ":let @+ = expand('')") --- requires plenary.nvim -vim.cmd.packadd("telescope.nvim") -keymap("eg", "Telescope live_grep") -keymap("eh", "Telescope help_tags") -keymap("eb", "Telescope keymaps") - -------- -- generic brand fuzzy finder -------- local scope = require("scope") scope.setup() +keymap("eg", scope.rg_search) keymap("ef", scope.file_finder) keymap("em", scope.buffer_list) keymap("es", vim.lsp.buf.workspace_symbol) diff --git a/src/dot_config/nvim/lua/scope.lua b/src/dot_config/nvim/lua/scope.lua index fd8f803..1d8b2fb 100644 --- a/src/dot_config/nvim/lua/scope.lua +++ b/src/dot_config/nvim/lua/scope.lua @@ -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" }, "", 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" }, "", function () - on_confirm(nil) + vim.keymap.set({ "i" }, "", 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 diff --git a/src/dot_config/nvim/lua/theme.lua b/src/dot_config/nvim/lua/theme.lua index 722345a..5dfe1e6 100644 --- a/src/dot_config/nvim/lua/theme.lua +++ b/src/dot_config/nvim/lua/theme.lua @@ -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 } +} diff --git a/src/dot_local/share/nvim/site/pack/3pp/opt/external_plenary.nvim b/src/dot_local/share/nvim/site/pack/3pp/opt/external_plenary.nvim deleted file mode 160000 index a3e3bc8..0000000 --- a/src/dot_local/share/nvim/site/pack/3pp/opt/external_plenary.nvim +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683 diff --git a/src/dot_local/share/nvim/site/pack/3pp/opt/external_telescope.nvim b/src/dot_local/share/nvim/site/pack/3pp/opt/external_telescope.nvim deleted file mode 160000 index 3b1600d..0000000 --- a/src/dot_local/share/nvim/site/pack/3pp/opt/external_telescope.nvim +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3b1600d0fd5172ad9fae00987362ca0ef3d8895d