refactor(lua): reformat and clean up Lua configuration files

This commit is contained in:
Prad Nukala committed 2025-10-24 09:34:24 -04:00
1 parent b4b165fb96
commit 54444c9f33
7 files changed
+771 -825

No files matched your search

+22 -65
View File
@@ -16,7 +16,7 @@ return {
"AstroNvim/astrocore",
---@type AstroCoreOpts
opts = {
sessions = {
-- Configure auto saving
autosave = {
@@ -86,9 +86,15 @@ return {
local filepath = vim.fn.expand "%:p"
local filename = vim.fn.expand "%:t"
-- If no file is open, show Nvim only
-- If no file is open, try to show just the repo name
if filename == "" then
vim.opt.titlestring = "Nvim"
local cwd = vim.fn.getcwd()
local github_match = cwd:match "github%.com/([^/]+/[^/]+)"
if github_match then
vim.opt.titlestring = github_match
else
vim.opt.titlestring = "Nvim"
end
return
end
@@ -96,8 +102,8 @@ return {
local github_match = filepath:match "github%.com/([^/]+/[^/]+)"
if github_match then
-- Format: filename (org/repo) | Nvim
vim.opt.titlestring = string.format("%s (%s) | Nvim", filename, github_match)
-- Format: filename | org/repo
vim.opt.titlestring = string.format("%s | %s", filename, github_match)
else
-- Fallback: filename | Nvim
vim.opt.titlestring = string.format("%s | Nvim", filename)
@@ -105,13 +111,13 @@ return {
end,
},
},
-- Show recent files or git repos on startup
-- Show smart picker on startup
startup_picker = {
{
event = "VimEnter",
desc = "Show recent files for git repo or git repos picker on startup",
desc = "Show smart picker on startup",
callback = function()
-- Skip if opening with arguments (files, directories, stdin)
-- Skip if opening with arguments
if vim.fn.argc() > 0 then return end
-- Skip if current buffer has content
@@ -120,58 +126,8 @@ return {
-- Delay to ensure everything is loaded
vim.defer_fn(function()
-- Check if we're in a git repo
local git_dir = vim.fn.systemlist("git rev-parse --git-dir 2>/dev/null")[1]
local is_git_repo = vim.v.shell_error == 0 and git_dir ~= nil and git_dir ~= ""
if is_git_repo then
-- In a git repo: show recent files
require("snacks").picker.recent()
else
-- Not in a git repo: show git repos using ghq
if vim.fn.executable "ghq" == 1 then
-- Get list of repos from ghq
local repos = vim.fn.systemlist "ghq list --full-path"
if #repos > 0 then
-- Build items list with formatted display
local items = {}
for _, repo_path in ipairs(repos) do
-- Extract org/repo from path
local display = repo_path:match "github%.com/([^/]+/[^/]+)" or vim.fn.fnamemodify(repo_path, ":t")
table.insert(items, {
text = display,
path = repo_path,
})
end
-- Use snacks picker to show repos
require("snacks").picker({
title = "Git Repositories",
layout = { preview = false },
items = items,
format = function(item)
return { { item.text } }
end,
confirm = function(picker, item)
picker:close()
-- Change to the selected repo directory
vim.cmd("cd " .. item.path)
-- Show recent files from the new directory
vim.defer_fn(function()
require("snacks").picker.recent()
end, 50)
end,
})
else
-- Fallback to recent files if no repos found
require("snacks").picker.recent()
end
else
-- ghq not available, just show recent files
require("snacks").picker.recent()
end
end
end, 10)
require("snacks").picker.smart()
end, 50)
end,
},
},
@@ -511,10 +467,10 @@ return {
},
-- AI/Assistant mappings (Claude Code)
["<C-a>"] = { nil, desc = "AI/Claude Code" },
["<C-a><C-a>"] = { function() _G.claude_at_root("ClaudeCode")() end, desc = "Toggle Claude" },
["<C-a>f"] = { function() _G.claude_at_root("ClaudeCodeFocus")() end, desc = "Focus Claude" },
["<C-a>C"] = { function() _G.claude_at_root("ClaudeCode --resume")() end, desc = "Resume Claude" },
["<C-a>c"] = { function() _G.claude_at_root("ClaudeCode --continue")() end, desc = "Continue Claude" },
["<C-a><C-a>"] = { function() _G.claude_at_root "ClaudeCode"() end, desc = "Toggle Claude" },
["<C-a>f"] = { function() _G.claude_at_root "ClaudeCodeFocus"() end, desc = "Focus Claude" },
["<C-a>C"] = { function() _G.claude_at_root "ClaudeCode --resume"() end, desc = "Resume Claude" },
["<C-a>c"] = { function() _G.claude_at_root "ClaudeCode --continue"() end, desc = "Continue Claude" },
["<C-a>m"] = { "<cmd>ClaudeCodeSelectModel<cr>", desc = "Select Claude model" },
["<C-a>b"] = { "<cmd>ClaudeCodeAdd %<cr>", desc = "Add current buffer" },
["<C-a>y"] = { "<cmd>ClaudeCodeDiffAccept<cr>", desc = "Accept diff" },
@@ -575,7 +531,8 @@ return {
},
["<leader>ua"] = {
function() require("snacks").toggle.animate():toggle() end,
desc = "Toggle Animations", },
desc = "Toggle Animations",
},
["<leader>uS"] = {
function() require("snacks").toggle.scroll():toggle() end,
desc = "Toggle Smooth Scroll",