From f5a1ec1e88a53ee7365c8058503acf49b042a2c7 Mon Sep 17 00:00:00 2001 From: Prad Nukala Date: Sun, 12 Jul 2026 11:18:33 -0400 Subject: [PATCH] feat(plugins): add LSP symbols finder to smart picker --- lua/plugins/astrocore.lua | 6 ++++++ lua/plugins/user.lua | 14 ++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/lua/plugins/astrocore.lua b/lua/plugins/astrocore.lua index 9c00178..719db37 100644 --- a/lua/plugins/astrocore.lua +++ b/lua/plugins/astrocore.lua @@ -226,6 +226,12 @@ return { function() require("snacks").picker.git_files { transform = file_filter } end, desc = "Find files", }, + [""] = { + function() + require("snacks").picker.lsp_symbols { layout = { preset = "vscode", preview = "main" } } + end, + desc = "Find LSP symbols", + }, ["o"] = { function() require("snacks").picker.recent() end, desc = "Find recent files", diff --git a/lua/plugins/user.lua b/lua/plugins/user.lua index 64cfd6a..71bf325 100644 --- a/lua/plugins/user.lua +++ b/lua/plugins/user.lua @@ -25,6 +25,20 @@ for _, source in ipairs { "files", "git_files", "smart", "recent", "buffers" } d } end +-- Smart picker: anchor to the current git repository. `config` runs when +-- the picker opens: cwd becomes the repo root (so the `files` finder scans +-- the whole repo, not just a rooter-chdir'd subdir) and `filter.cwd` drops +-- buffers/recent entries from other repos. Outside a repo, plain cwd +-- behavior is kept. +picker_sources.smart.config = function(opts) + local root = require("snacks").git.get_root() + if root then + opts.cwd = root + opts.filter = vim.tbl_extend("force", opts.filter or {}, { cwd = true }) + end + return opts +end + ---@type LazySpec return { { "sphamba/smear-cursor.nvim", opts = {} },