feat(plugins): add fff fuzzy finder and supermaven LeetCode toggle plugins
This commit is contained in:
1 parent
8f49f66837
commit
779e081d80
30 files changed
+221
No files matched your search
@@ -0,0 +1,18 @@
|
||||
--- fff.nvim: rust-backed fuzzy file finder and live grep with frecency
|
||||
--- Backs the <C-f> file/grep bindings in plugins/astrocore.lua. Honours
|
||||
--- .gitignore plus per-repo .ignore files; the config.ignore_patterns
|
||||
--- snacks filter does not apply here (snacks remains for non-file sources:
|
||||
--- diagnostics, lines, LSP symbols, recent, projects, templates).
|
||||
--- @module plugins.fff
|
||||
|
||||
return {
|
||||
"dmtrKovalenko/fff",
|
||||
build = function()
|
||||
-- downloads a prebuilt binary or falls back to cargo build
|
||||
require("fff.download").download_or_build_binary()
|
||||
end,
|
||||
lazy = false, -- the plugin lazy-initialises itself
|
||||
opts = {
|
||||
lazy_sync = true,
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
-- Disable supermaven in JavaScript/Python buffers whose comments contain a
|
||||
-- LeetCode problem URL (solution files), 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 function is_leetcode_buffer()
|
||||
local buf = vim.api.nvim_get_current_buf()
|
||||
local ft = vim.bo[buf].filetype
|
||||
local name = vim.api.nvim_buf_get_name(buf)
|
||||
local comment_pat
|
||||
if ft == "javascript" or ft == "javascriptreact" or name:match "%.[mc]?jsx?$" then
|
||||
comment_pat = "^%s*[/*]"
|
||||
elseif ft == "python" or name:match "%.py$" then
|
||||
comment_pat = "^%s*[#\"']"
|
||||
else
|
||||
return false
|
||||
end
|
||||
-- The URL lives in the header comment block; scanning the top of the file is enough.
|
||||
for _, line in ipairs(vim.api.nvim_buf_get_lines(buf, 0, 200, false)) do
|
||||
if line:find "leetcode%.com/problems/" and line:match(comment_pat) then return true end
|
||||
end
|
||||
return false
|
||||
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