feat(lua): add custom startup picker and snacks configuration
This commit is contained in:
1 parent
393011a521
commit
b4b165fb96
3 files changed
+171
-51
No files matched your search
@@ -16,6 +16,7 @@ return {
|
|||||||
"AstroNvim/astrocore",
|
"AstroNvim/astrocore",
|
||||||
---@type AstroCoreOpts
|
---@type AstroCoreOpts
|
||||||
opts = {
|
opts = {
|
||||||
|
|
||||||
sessions = {
|
sessions = {
|
||||||
-- Configure auto saving
|
-- Configure auto saving
|
||||||
autosave = {
|
autosave = {
|
||||||
@@ -104,6 +105,76 @@ return {
|
|||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
-- Show recent files or git repos on startup
|
||||||
|
startup_picker = {
|
||||||
|
{
|
||||||
|
event = "VimEnter",
|
||||||
|
desc = "Show recent files for git repo or git repos picker on startup",
|
||||||
|
callback = function()
|
||||||
|
-- Skip if opening with arguments (files, directories, stdin)
|
||||||
|
if vim.fn.argc() > 0 then return end
|
||||||
|
|
||||||
|
-- Skip if current buffer has content
|
||||||
|
local lines = vim.api.nvim_buf_get_lines(0, 0, -1, false)
|
||||||
|
if #lines > 1 or (#lines == 1 and lines[1] ~= "") then return end
|
||||||
|
|
||||||
|
-- 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)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
-- vim options can be configured here
|
-- vim options can be configured here
|
||||||
|
|||||||
+47
-51
@@ -1,59 +1,55 @@
|
|||||||
--- Bufferline configuration with AstroNvim integration
|
--- Bufferline configuration with AstroNvim integration
|
||||||
--- Provides enhanced buffer/tab management with diagnostics and custom close handlers
|
--- Overrides and customizations for bufferline.nvim
|
||||||
|
--- Relies on astrocommunity.bars-and-lines.bufferline-nvim for base setup
|
||||||
--- @module plugins.bufferline
|
--- @module plugins.bufferline
|
||||||
|
|
||||||
---@type LazySpec
|
---@type LazySpec
|
||||||
return {
|
return {
|
||||||
"akinsho/bufferline.nvim",
|
"akinsho/bufferline.nvim",
|
||||||
version = "*",
|
opts = {
|
||||||
dependencies = { "nvim-tree/nvim-web-devicons", "AstroNvim/astrocore" },
|
options = {
|
||||||
event = "VeryLazy",
|
mode = "buffers",
|
||||||
config = function()
|
numbers = "none",
|
||||||
local bufferline = require "bufferline"
|
-- Use AstroCore buffer close handler for proper cleanup
|
||||||
local groups = require "bufferline.groups"
|
close_command = function(n) require("astrocore.buffer").close(n) end,
|
||||||
|
right_mouse_command = function(n) require("astrocore.buffer").close(n) end,
|
||||||
bufferline.setup {
|
separator_style = "thick",
|
||||||
options = {
|
indicator = { style = "none", icon = "" },
|
||||||
mode = "buffers",
|
diagnostics = "nvim_lsp",
|
||||||
numbers = "none",
|
diagnostics_indicator = function(_, _, diagnostics_dict)
|
||||||
close_command = function(n) require("astrocore.buffer").close(n) end,
|
local s = " "
|
||||||
right_mouse_command = function(n) require("astrocore.buffer").close(n) end,
|
for e, _ in pairs(diagnostics_dict) do
|
||||||
separator_style = "thick",
|
local sym = e == "error" and " " or (e == "warning" and " " or " ")
|
||||||
indicator = { style = "none", icon = "" },
|
s = s .. sym
|
||||||
diagnostics = "nvim_lsp",
|
end
|
||||||
diagnostics_indicator = function(_, _, diagnostics_dict)
|
return s
|
||||||
local s = " "
|
end,
|
||||||
for e, _ in pairs(diagnostics_dict) do
|
always_show_bufferline = true,
|
||||||
local sym = e == "error" and " " or (e == "warning" and " " or " ")
|
show_buffer_close_icons = true,
|
||||||
s = s .. sym
|
show_close_icon = true,
|
||||||
end
|
modified_icon = "●",
|
||||||
return s
|
buffer_close_icon = "",
|
||||||
end,
|
close_icon = "",
|
||||||
always_show_bufferline = true,
|
left_trunc_marker = "",
|
||||||
show_buffer_close_icons = true,
|
right_trunc_marker = "",
|
||||||
show_close_icon = true,
|
-- Offset for snacks picker to prevent overlap
|
||||||
modified_icon = "●",
|
offsets = {
|
||||||
buffer_close_icon = "",
|
{ filetype = "snacks_picker", text = "", padding = 0 },
|
||||||
close_icon = "",
|
{ filetype = "neo-tree", text = "", padding = 0 },
|
||||||
left_trunc_marker = "",
|
|
||||||
right_trunc_marker = "",
|
|
||||||
offsets = {
|
|
||||||
{ filetype = "snacks_picker", text = "", padding = 0 },
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
highlights = {
|
},
|
||||||
group_label = { fg = "#ffffff", bg = "#423f5a", bold = true },
|
highlights = {
|
||||||
group_separator = { fg = "#585b70" },
|
group_label = { fg = "#ffffff", bg = "#423f5a", bold = true },
|
||||||
buffer_selected = { fg = "#89dceb", bold = true },
|
group_separator = { fg = "#585b70" },
|
||||||
buffer_visible = { fg = "#585b70" },
|
buffer_selected = { fg = "#89dceb", bold = true },
|
||||||
background = { fg = "#585b70" },
|
buffer_visible = { fg = "#585b70" },
|
||||||
hint = { fg = "#94e2d5" },
|
background = { fg = "#585b70" },
|
||||||
hint_selected = { fg = "#94e2d5", bold = true },
|
hint = { fg = "#94e2d5" },
|
||||||
warning = { fg = "#f9e2af" },
|
hint_selected = { fg = "#94e2d5", bold = true },
|
||||||
warning_selected = { fg = "#f9e2af", bold = true },
|
warning = { fg = "#f9e2af" },
|
||||||
error = { fg = "#f38ba8" },
|
warning_selected = { fg = "#f9e2af", bold = true },
|
||||||
error_selected = { fg = "#f38ba8", bold = true },
|
error = { fg = "#f38ba8" },
|
||||||
},
|
error_selected = { fg = "#f38ba8", bold = true },
|
||||||
}
|
},
|
||||||
end,
|
},
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
--- Snacks.nvim configuration
|
||||||
|
--- Overrides and customizations for snacks.nvim features
|
||||||
|
--- Relies on astrocommunity.recipes.telescope-nvim-snacks for base setup
|
||||||
|
--- @module plugins.snacks
|
||||||
|
|
||||||
|
return {
|
||||||
|
"folke/snacks.nvim",
|
||||||
|
opts = {
|
||||||
|
-- Disable dashboard - we use custom startup picker in astrocore.lua
|
||||||
|
dashboard = { enabled = false },
|
||||||
|
|
||||||
|
-- Enable snacks features we use throughout config
|
||||||
|
bigfile = { enabled = true },
|
||||||
|
input = { enabled = true },
|
||||||
|
notifier = { enabled = true },
|
||||||
|
picker = { enabled = true },
|
||||||
|
quickfile = { enabled = true },
|
||||||
|
rename = { enabled = true },
|
||||||
|
scope = { enabled = true },
|
||||||
|
scroll = { enabled = true },
|
||||||
|
statuscolumn = { enabled = true },
|
||||||
|
terminal = { enabled = true },
|
||||||
|
words = { enabled = true },
|
||||||
|
indent = { enabled = true },
|
||||||
|
|
||||||
|
-- Terminal styles
|
||||||
|
styles = {
|
||||||
|
terminal = {
|
||||||
|
bo = { filetype = "snacks_terminal" },
|
||||||
|
wo = {},
|
||||||
|
keys = {
|
||||||
|
q = "hide",
|
||||||
|
term_normal = {
|
||||||
|
"<esc>",
|
||||||
|
function(self)
|
||||||
|
self.esc_timer = self.esc_timer or (vim.uv or vim.loop).new_timer()
|
||||||
|
if self.esc_timer:is_active() then
|
||||||
|
self.esc_timer:stop()
|
||||||
|
vim.cmd("stopinsert")
|
||||||
|
else
|
||||||
|
self.esc_timer:start(200, 0, function() end)
|
||||||
|
return "<esc>"
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
mode = "t",
|
||||||
|
expr = true,
|
||||||
|
desc = "Double escape to normal mode",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
Reference in new issue
Block a user