feat(plugins): add URL picker and today‑modified file finder, replace Supermaven with NeoCodeium
This commit is contained in:
1 parent
8a76b9c4f5
commit
8f78c67019
4 files changed
+105
-70
No files matched your search
@@ -54,6 +54,58 @@ local function find_files_by_extension()
|
||||
}
|
||||
end
|
||||
|
||||
-- <C-f>x: every URL in the current buffer, in file order; confirm hands the
|
||||
-- URL to vim.ui.open (xdg-open). Reuses astrocore's url_matcher so the
|
||||
-- picker agrees with the highlighturl feature about what counts as a URL.
|
||||
local function find_buffer_urls()
|
||||
local buf = vim.api.nvim_get_current_buf()
|
||||
local re = vim.regex(require("astrocore").url_matcher)
|
||||
local items = {}
|
||||
for lnum, line in ipairs(vim.api.nvim_buf_get_lines(buf, 0, -1, false)) do
|
||||
local offset = 0
|
||||
while offset < #line do
|
||||
-- match_str returns 0-indexed byte offsets relative to the substring
|
||||
local s, e = re:match_str(line:sub(offset + 1))
|
||||
if not s then break end
|
||||
local url = line:sub(offset + s + 1, offset + e)
|
||||
items[#items + 1] = { text = url, url = url, buf = buf, pos = { lnum, offset + s }, lnum = lnum }
|
||||
offset = offset + e
|
||||
end
|
||||
end
|
||||
if #items == 0 then
|
||||
vim.notify("No URLs found in buffer", vim.log.levels.WARN)
|
||||
return
|
||||
end
|
||||
require("snacks").picker {
|
||||
title = "Buffer URLs",
|
||||
items = items,
|
||||
format = function(item)
|
||||
return {
|
||||
{ ("%4d "):format(item.lnum), "SnacksPickerRow" },
|
||||
{ item.url, "SnacksPickerLink" },
|
||||
}
|
||||
end,
|
||||
confirm = function(picker, item)
|
||||
picker:close()
|
||||
if not item then return end
|
||||
vim.ui.open(item.url)
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
-- <C-f>m: files under the git root whose mtime is today (local midnight
|
||||
-- onward). fd's --changed-within accepts a YYYY-MM-DD date as "since".
|
||||
local function find_files_modified_today()
|
||||
local snacks = require "snacks"
|
||||
snacks.picker.files {
|
||||
title = "Modified today",
|
||||
cwd = snacks.git.get_root() or vim.uv.cwd(),
|
||||
cmd = "fd",
|
||||
args = { "--changed-within", os.date "%Y-%m-%d" },
|
||||
transform = file_filter,
|
||||
}
|
||||
end
|
||||
|
||||
return {
|
||||
"AstroNvim/astrocore",
|
||||
---@type AstroCoreOpts
|
||||
@@ -323,6 +375,10 @@ return {
|
||||
function() require("config.templates").pick() end,
|
||||
desc = "Find templates",
|
||||
},
|
||||
-- NOTE: <C-m> and <CR> are likewise the same key, so Enter in normal
|
||||
-- mode runs overseer. Buffers with their own <CR> (quickfix, help,
|
||||
-- neo-tree, overseer's task list) keep theirs via buffer-local maps.
|
||||
["<C-m>"] = { "<Cmd>OverseerRun<CR>", desc = "Run overseer task" },
|
||||
["<C-f>w"] = {
|
||||
function() require("fff").live_grep() end,
|
||||
desc = "Live grep",
|
||||
@@ -340,8 +396,12 @@ return {
|
||||
desc = "Find files (cwd)",
|
||||
},
|
||||
["<C-f>m"] = {
|
||||
function() require("fff").find_files { title = "Git Modified", query = "git:modified " } end,
|
||||
desc = "Find git-modified files",
|
||||
find_files_modified_today,
|
||||
desc = "Find files modified today",
|
||||
},
|
||||
["<C-f>x"] = {
|
||||
find_buffer_urls,
|
||||
desc = "Find URLs in buffer (open in browser)",
|
||||
},
|
||||
["<C-f>r"] = {
|
||||
function() require("fff").resume() end,
|
||||
@@ -421,7 +481,7 @@ return {
|
||||
function() require("config.picker").with_trouble "diagnostics" end,
|
||||
desc = "Search diagnostics (<C-t> sends to Trouble)",
|
||||
},
|
||||
["<C-a><C-s>"] = { "<Cmd>SupermavenToggle<CR>", desc = "Toggle Supermaven" },
|
||||
["<C-a><C-s>"] = { "<Cmd>NeoCodeium toggle<CR>", desc = "Toggle NeoCodeium" },
|
||||
|
||||
-- <Leader>u toggles are mapped through Snacks.toggle in
|
||||
-- config.toggles (called from polish.lua) so which-key renders their
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
-- Native supermaven source for blink.cmp (mirrors the astrocommunity blink-copilot pattern).
|
||||
-- Inline ghost text + <C-l> accept come from `astrocommunity.completion.supermaven-nvim`;
|
||||
-- this additionally surfaces supermaven suggestions in the blink menu so <Tab>/<CR> work.
|
||||
return {
|
||||
"Huijiro/blink-cmp-supermaven",
|
||||
lazy = true,
|
||||
specs = {
|
||||
{
|
||||
"saghen/blink.cmp",
|
||||
optional = true,
|
||||
opts = {
|
||||
sources = {
|
||||
default = { "supermaven" },
|
||||
providers = {
|
||||
supermaven = {
|
||||
name = "supermaven",
|
||||
module = "blink-cmp-supermaven",
|
||||
score_offset = 100,
|
||||
async = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
-- AI ghost-text completion via NeoCodeium (Windsurf/Codeium). Replaces
|
||||
-- supermaven. Suggestions render as virtual text only; blink.cmp keeps its
|
||||
-- own menu (ghost_text stays disabled in AstroNvim's blink spec).
|
||||
--
|
||||
-- Disabled in python buffers and under the LeetCode work directory. Both are
|
||||
-- evaluated by neocodeium on InsertEnter, and `:NeoCodeium enable_buffer`
|
||||
-- still overrides them per buffer.
|
||||
local leetcode_dir = vim.fn.expand "~/Developer/github.com/prdlk/leetcode/work/"
|
||||
|
||||
local function is_leetcode_buffer(bufnr)
|
||||
local name = vim.api.nvim_buf_get_name(bufnr)
|
||||
return name:sub(1, #leetcode_dir) == leetcode_dir
|
||||
end
|
||||
|
||||
-- Insert-mode keys that act on a visible suggestion and otherwise keep their
|
||||
-- native meaning (<C-h> backspace, <C-w> delete word).
|
||||
local function when_visible(action, fallback)
|
||||
return function()
|
||||
local neocodeium = require "neocodeium"
|
||||
if neocodeium.visible() then
|
||||
neocodeium[action]()
|
||||
return ""
|
||||
end
|
||||
return fallback
|
||||
end
|
||||
end
|
||||
|
||||
return {
|
||||
"monkoose/neocodeium",
|
||||
event = "VeryLazy",
|
||||
cmd = "NeoCodeium",
|
||||
opts = {
|
||||
log_level = "warn",
|
||||
filetypes = { python = false },
|
||||
filter = function(bufnr) return not is_leetcode_buffer(bufnr) end,
|
||||
},
|
||||
keys = {
|
||||
{ "<C-l>", when_visible("accept", "<C-l>"), mode = "i", expr = true, desc = "Accept AI suggestion" },
|
||||
{ "<C-w>", when_visible("accept_word", "<C-w>"), mode = "i", expr = true, desc = "Accept AI suggestion word" },
|
||||
{ "<C-h>", when_visible("clear", "<C-h>"), mode = "i", expr = true, desc = "Clear AI suggestion" },
|
||||
},
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
-- Disable supermaven in buffers under the LeetCode work directory, and
|
||||
-- re-enable it when leaving them.
|
||||
--
|
||||
-- Note: supermaven's built-in `condition` option is one-way — its BufEnter
|
||||
-- listener gates the restart branch on `vim.g.SUPERMAVEN_DISABLED`, which
|
||||
-- `api.stop()` itself sets, so once auto-stopped it never comes back. This
|
||||
-- autocmd owns both directions instead. `vim.g.supermaven_leetcode_stopped`
|
||||
-- distinguishes our auto-stop from a manual :SupermavenStop, which stays off.
|
||||
local leetcode_dir = vim.fn.expand "~/Developer/github.com/prdlk/leetcode/work/"
|
||||
|
||||
local function is_leetcode_buffer()
|
||||
local name = vim.api.nvim_buf_get_name(0)
|
||||
return name:sub(1, #leetcode_dir) == leetcode_dir
|
||||
end
|
||||
|
||||
local function sync()
|
||||
local api = require "supermaven-nvim.api"
|
||||
if is_leetcode_buffer() then
|
||||
if api.is_running() then
|
||||
api.stop()
|
||||
vim.g.supermaven_leetcode_stopped = true
|
||||
end
|
||||
elseif vim.g.supermaven_leetcode_stopped and not api.is_running() then
|
||||
vim.g.supermaven_leetcode_stopped = nil
|
||||
api.start()
|
||||
end
|
||||
end
|
||||
|
||||
return {
|
||||
"supermaven-inc/supermaven-nvim",
|
||||
optional = true,
|
||||
config = function(_, opts)
|
||||
require("supermaven-nvim").setup(opts)
|
||||
vim.api.nvim_create_autocmd("BufEnter", {
|
||||
group = vim.api.nvim_create_augroup("supermaven_leetcode", { clear = true }),
|
||||
desc = "Toggle supermaven off in LeetCode solution buffers",
|
||||
callback = sync,
|
||||
})
|
||||
sync() -- plugin loads on VeryLazy; cover the buffer we're already sitting in
|
||||
end,
|
||||
}
|
||||
Reference in new issue
Block a user