CHORE: CLeaned up neovim config
This commit is contained in:
@@ -6,6 +6,7 @@ font-size = 14
|
||||
scrollback-limit = 10000
|
||||
macos-titlebar-style = transparent
|
||||
macos-titlebar-proxy-icon = hidden
|
||||
macos-option-as-alt = true
|
||||
title = " "
|
||||
background-opacity = 0.90
|
||||
background-blur = 64
|
||||
|
||||
@@ -12,6 +12,7 @@ vim.lsp.config('lua_ls', {
|
||||
},
|
||||
})
|
||||
vim.lsp.config('vtsls', {
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
typescript = {
|
||||
updateImportsOnFileMove = { enabled = 'always' },
|
||||
@@ -36,5 +37,5 @@ vim.lsp.enable({
|
||||
'cssls',
|
||||
'html',
|
||||
'gopls',
|
||||
'pylsp'
|
||||
'pylsp',
|
||||
})
|
||||
|
||||
@@ -8,3 +8,4 @@ require('DarthMooMancer.plugins.mason')
|
||||
require('DarthMooMancer.plugins.snacks')
|
||||
require('DarthMooMancer.plugins.trouble')
|
||||
require('DarthMooMancer.plugins.conform')
|
||||
require('DarthMooMancer.plugins.mason-conform')
|
||||
|
||||
@@ -8,11 +8,9 @@ require('conform').setup({
|
||||
typescript = { 'prettier', stop_after_first = true },
|
||||
json = { 'prettier' },
|
||||
html = { 'prettier' },
|
||||
go = { 'goimports' },
|
||||
c = { 'clang-format' },
|
||||
cpp = { 'clang-format' },
|
||||
css = { 'csskit' },
|
||||
dart = { 'dart_format', lsp_format = 'fallback' },
|
||||
python = { 'autopep8' },
|
||||
['_'] = { 'trim_whitespace' },
|
||||
},
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
vim.pack.add({
|
||||
{ src = 'https://github.com/b0o/incline.nvim' },
|
||||
{ src = 'https://github.com/SmiteshP/nvim-navic' },
|
||||
})
|
||||
|
||||
local helpers = require('incline.helpers')
|
||||
local navic = require('nvim-navic')
|
||||
local devicons = require('nvim-web-devicons')
|
||||
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
group = vim.api.nvim_create_augroup('UserNavicAttach', { clear = true }),
|
||||
callback = function(args)
|
||||
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
||||
if client and client.server_capabilities.documentSymbolProvider then
|
||||
navic.attach(client, args.buf)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
require('incline').setup({
|
||||
window = {
|
||||
padding = 0,
|
||||
margin = { horizontal = 0, vertical = 0 },
|
||||
},
|
||||
ignore = {
|
||||
floating_wins = false,
|
||||
wintypes = function(winid, wintype)
|
||||
-- Check if snacks.zen is active anywhere in this tabpage
|
||||
for _, w in ipairs(vim.api.nvim_tabpage_list_wins(0)) do
|
||||
if vim.w[w].snacks_main then
|
||||
return true -- Hide from ALL windows during Zen mode
|
||||
end
|
||||
end
|
||||
|
||||
-- Default incline behavior (ignore non-normal windows)
|
||||
return wintype ~= ''
|
||||
end,
|
||||
},
|
||||
render = function(props)
|
||||
-- 1. Count normal splits in the current tabpage
|
||||
local wins = vim.api.nvim_tabpage_list_wins(0)
|
||||
local normal_splits = 0
|
||||
|
||||
for _, win in ipairs(wins) do
|
||||
-- Also check for snacks.zen here as an immediate guard
|
||||
if vim.w[win].snacks_main then
|
||||
return ''
|
||||
end
|
||||
|
||||
local config = vim.api.nvim_win_get_config(win)
|
||||
if config.relative == '' then
|
||||
normal_splits = normal_splits + 1
|
||||
end
|
||||
end
|
||||
|
||||
-- Hide if 2 or fewer normal splits are open (requires 3+)
|
||||
if normal_splits <= 2 then
|
||||
return ''
|
||||
end
|
||||
|
||||
-- 2. Build the visual statusline
|
||||
local filename =
|
||||
vim.fn.fnamemodify(vim.api.nvim_buf_get_name(props.buf), ':t')
|
||||
if filename == '' then
|
||||
filename = '[No Name]'
|
||||
end
|
||||
|
||||
local ft_icon, ft_color = devicons.get_icon_color(filename)
|
||||
local modified = vim.bo[props.buf].modified
|
||||
|
||||
local res = {
|
||||
ft_icon and {
|
||||
' ',
|
||||
ft_icon,
|
||||
' ',
|
||||
guibg = ft_color,
|
||||
guifg = helpers.contrast_color(ft_color),
|
||||
} or '',
|
||||
' ',
|
||||
{ filename, gui = modified and 'bold,italic' or 'bold' },
|
||||
guibg = 'none',
|
||||
}
|
||||
|
||||
if props.focused then
|
||||
for _, item in ipairs(navic.get_data(props.buf) or {}) do
|
||||
table.insert(res, {
|
||||
{ ' > ', group = 'NavicSeparator' },
|
||||
{ item.icon, group = 'NavicIcons' .. item.type },
|
||||
{ item.name, group = 'NavicText' },
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
table.insert(res, ' ')
|
||||
return res
|
||||
end,
|
||||
})
|
||||
@@ -0,0 +1,6 @@
|
||||
vim.pack.add({
|
||||
{ src = 'https://git.moomancer.xyz/DarthMooMancer/mason-conform.nvim.git' },
|
||||
})
|
||||
require('mason-conform').setup({
|
||||
ignore_install = {},
|
||||
})
|
||||
@@ -1,14 +1,13 @@
|
||||
vim.pack.add({
|
||||
{
|
||||
src = 'https://github.com/nvim-mini/mini.nvim.git',
|
||||
version = vim.version.range('*')
|
||||
}
|
||||
version = vim.version.range('*'),
|
||||
},
|
||||
})
|
||||
|
||||
local hipatterns = require('mini.hipatterns')
|
||||
hipatterns.setup({
|
||||
highlighters = {
|
||||
-- Highlight standalone 'FIXME', 'HACK', 'TODO', 'NOTE'
|
||||
fixme = {
|
||||
pattern = '%f[%w]()FIXME()%f[%W]',
|
||||
group = 'MiniHipatternsFixme',
|
||||
@@ -31,4 +30,4 @@ hipatterns.setup({
|
||||
})
|
||||
|
||||
require('mini.pairs').setup()
|
||||
-- require('mini.icons').setup()
|
||||
require('mini.surround').setup()
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
vim.pack.add({
|
||||
{ src = 'https://github.com/folke/noice.nvim' },
|
||||
{ src = 'https://github.com/MunifTanjim/nui.nvim' },
|
||||
})
|
||||
|
||||
require('noice').setup({
|
||||
lsp = {
|
||||
override = {
|
||||
['vim.lsp.util.convert_input_to_markdown_lines'] = true,
|
||||
['vim.lsp.util.stylize_markdown'] = true,
|
||||
},
|
||||
},
|
||||
presets = {
|
||||
bottom_search = true, -- use a classic bottom cmdline for search
|
||||
command_palette = true, -- position the cmdline and popupmenu together
|
||||
long_message_to_split = true, -- long messages will be sent to a split
|
||||
inc_rename = false, -- enables an input dialog for inc-rename.nvim
|
||||
lsp_doc_border = false, -- add a border to hover docs and signature help
|
||||
},
|
||||
})
|
||||
@@ -1,25 +0,0 @@
|
||||
vim.pack.add({
|
||||
'https://github.com/sphamba/smear-cursor.nvim',
|
||||
})
|
||||
|
||||
-- require('smear_cursor').setup({
|
||||
-- matrix_pixel_threshold = 0.5,
|
||||
-- stiffness = 0.8, -- 0.6 [0, 1]
|
||||
-- trailing_stiffness = 0.6, -- 0.45 [0, 1]
|
||||
-- stiffness_insert_mode = 0.7, -- 0.5 [0, 1]
|
||||
-- trailing_stiffness_insert_mode = 0.7, -- 0.5 [0, 1]
|
||||
-- damping = 0.95, -- 0.85 [0, 1]
|
||||
-- damping_insert_mode = 0.95, -- 0.9 [0, 1]
|
||||
-- distance_stop_animating = 0.5, -- 0.1 > 0
|
||||
-- time_interval = 7,
|
||||
-- })
|
||||
--
|
||||
require('smear_cursor').setup({
|
||||
stiffness = 0.8, -- 0.6 [0, 1]
|
||||
trailing_stiffness = 0.6, -- 0.45 [0, 1]
|
||||
stiffness_insert_mode = 0.7, -- 0.5 [0, 1]
|
||||
trailing_stiffness_insert_mode = 0.7, -- 0.5 [0, 1]
|
||||
damping = 0.95, -- 0.85 [0, 1]
|
||||
damping_insert_mode = 0.95, -- 0.9 [0, 1]
|
||||
distance_stop_animating = 0.5, -- 0.1 > 0
|
||||
})
|
||||
@@ -1,16 +0,0 @@
|
||||
vim.pack.add({
|
||||
{
|
||||
src = 'https://github.com/blackhat-7/vellum.nvim',
|
||||
},
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd('FileType', {
|
||||
pattern = 'markdown',
|
||||
once = true,
|
||||
callback = function()
|
||||
local ok, vellum = pcall(require, 'vellum')
|
||||
if ok then
|
||||
vellum.setup({})
|
||||
end
|
||||
end,
|
||||
})
|
||||
@@ -1,34 +1,28 @@
|
||||
local D = require('nvim-web-devicons')
|
||||
local a, S = vim.api, vim.diagnostic.severity
|
||||
local now = (vim.uv or vim.loop).now
|
||||
local C = a.nvim_get_current_buf
|
||||
local D, a, S = require('nvim-web-devicons'), vim.api, vim.diagnostic.severity
|
||||
local now, cur = (vim.uv or vim.loop).now, a.nvim_get_current_buf
|
||||
local function cn(c)
|
||||
return c.name
|
||||
end
|
||||
local R = function()
|
||||
vim.cmd.redrawstatus()
|
||||
end
|
||||
local T, JOB = {}, nil
|
||||
local IV, LAST = 750, 0
|
||||
local T, JOB, LAST = {}, nil, 0
|
||||
|
||||
local function snap(bb)
|
||||
local nm = ' %F'
|
||||
local i, hl = D.get_icon(a.nvim_buf_get_name(bb), nil, { default = true })
|
||||
if i then
|
||||
nm = ' %#' .. hl .. '#' .. i .. ' %*%F'
|
||||
end
|
||||
local x = vim.diagnostic.count(bb)
|
||||
local function snap(b)
|
||||
local i, hl = D.get_icon(a.nvim_buf_get_name(b), nil, { default = true })
|
||||
local nm = i and ('%#' .. hl .. '#' .. i .. ' %*%t') or ' %t'
|
||||
local x = vim.diagnostic.count(b)
|
||||
local e, w, h = x[S.ERROR] or 0, x[S.WARN] or 0, x[S.HINT] or 0
|
||||
local dg = (e > 0 and ('%#DiagnosticError#E' .. e .. '%* ') or '')
|
||||
.. (w > 0 and ('%#DiagnosticWarn#W' .. w .. '%* ') or '')
|
||||
.. (h > 0 and ('%#DiagnosticHint#H' .. h .. '%* ') or '')
|
||||
local cs = vim.lsp.get_clients({ bufnr = bb })
|
||||
local dg = (e > 0 and '%#DiagnosticError#E' .. e .. '%* ' or '')
|
||||
.. (w > 0 and '%#DiagnosticWarn#W' .. w .. '%* ' or '')
|
||||
.. (h > 0 and '%#DiagnosticHint#H' .. h .. '%* ' or '')
|
||||
local cs = vim.lsp.get_clients({ bufnr = b })
|
||||
local rd = #cs > 0 and (' ' .. table.concat(vim.tbl_map(cn, cs), '/') .. ' ') or ''
|
||||
return nm .. '%m%r %=' .. dg, rd
|
||||
end
|
||||
|
||||
local function touch(bb, redraw)
|
||||
vim.b[bb].d = true
|
||||
local function touch(b, redraw)
|
||||
vim.b[b].d = true
|
||||
if redraw then
|
||||
R()
|
||||
end
|
||||
@@ -44,7 +38,7 @@ local function sync(force)
|
||||
break
|
||||
end
|
||||
end
|
||||
if JOB ~= prev and (force or now() - LAST >= IV) then
|
||||
if JOB ~= prev and (force or now() - LAST >= 750) then
|
||||
LAST = now()
|
||||
R()
|
||||
end
|
||||
@@ -59,8 +53,9 @@ au({ 'BufEnter', 'BufFilePost' }, function(e)
|
||||
touch(e.buf, true)
|
||||
end)
|
||||
au('DiagnosticChanged', function(e)
|
||||
touch(e.buf, e.buf == C())
|
||||
touch(e.buf, e.buf == cur())
|
||||
end)
|
||||
au('FocusGained', R)
|
||||
au({ 'LspAttach', 'LspDetach' }, function(e)
|
||||
if e.event == 'LspDetach' then
|
||||
T[e.data.client_id] = nil
|
||||
@@ -69,27 +64,26 @@ au({ 'LspAttach', 'LspDetach' }, function(e)
|
||||
touch(e.buf, true)
|
||||
end)
|
||||
au('LspProgress', function(e)
|
||||
local v = e.data.params.value
|
||||
local id, tk = e.data.client_id, e.data.params.token or 'default'
|
||||
local v, id, tk = e.data.params.value, e.data.client_id, e.data.params.token or 'default'
|
||||
T[id] = T[id] or {}
|
||||
if v.kind == 'end' or (v.kind == 'report' and v.percentage == 100) then
|
||||
T[id][tk] = nil
|
||||
sync(true)
|
||||
else
|
||||
local title = (v.title and v.title ~= '') and v.title or nil
|
||||
local msg = (v.message and v.message ~= '') and v.message or nil
|
||||
T[id][tk] = (title and msg and (title .. ' ' .. msg)) or title or msg or 'Loading...'
|
||||
local title = (v.title and v.title ~= '') and v.title
|
||||
local msg = (v.message and v.message ~= '') and v.message
|
||||
T[id][tk] = (title and msg and title .. ' ' .. msg) or title or msg or 'Loading...'
|
||||
sync()
|
||||
end
|
||||
end)
|
||||
au('FocusGained', R)
|
||||
|
||||
function _G.Status()
|
||||
local v = vim.b
|
||||
local buf = vim.g.statusline_winid and a.nvim_win_get_buf(vim.g.statusline_winid) or a.nvim_get_current_buf()
|
||||
local v = vim.b[buf]
|
||||
if not v.h or v.d then
|
||||
v.h, v.r = snap(C())
|
||||
v.h, v.r = snap(buf)
|
||||
v.stl, v.d = v.h .. v.r, nil
|
||||
end
|
||||
return JOB and (v.h .. '%#DiagnosticInfo#' .. JOB .. '%* ') or v.stl
|
||||
return JOB and (v.h .. '%#DiagnosticInfo#' .. JOB .. '%*') or v.stl
|
||||
end
|
||||
vim.opt.statusline = '%!v:lua.Status()'
|
||||
|
||||
@@ -13,10 +13,6 @@
|
||||
"rev": "721a75b9a0c2eb1fb811d34507708ee315cb04eb",
|
||||
"src": "https://github.com/m4xshen/hardtime.nvim"
|
||||
},
|
||||
"incline.nvim": {
|
||||
"rev": "debd628e9395f7a9da57bdc31ce75ca6b40a880b",
|
||||
"src": "https://github.com/b0o/incline.nvim"
|
||||
},
|
||||
"kanso.nvim": {
|
||||
"rev": "1afbbb449aa0254823dbe1932e3cbb51886ff9fe",
|
||||
"src": "https://github.com/webhooked/kanso.nvim"
|
||||
@@ -25,8 +21,12 @@
|
||||
"rev": "a6307fa340ed7c0d96f5c567afc8c991aad94ce0",
|
||||
"src": "https://github.com/brianhuster/live-preview.nvim"
|
||||
},
|
||||
"mason-conform.nvim": {
|
||||
"rev": "132a3d0630de4bdb80e96ccd62b740fcf5754bdc",
|
||||
"src": "https://git.moomancer.xyz/DarthMooMancer/mason-conform.nvim.git"
|
||||
},
|
||||
"mason-lspconfig.nvim": {
|
||||
"rev": "b3298993d55fa194279b5eb9dbfb3a43da65cadf",
|
||||
"rev": "e17625cdc8c2650787467398e02c5d63a2cde966",
|
||||
"src": "https://github.com/mason-org/mason-lspconfig.nvim"
|
||||
},
|
||||
"mason.nvim": {
|
||||
@@ -38,22 +38,10 @@
|
||||
"src": "https://github.com/nvim-mini/mini.nvim.git",
|
||||
"version": ">=0.0.0"
|
||||
},
|
||||
"noice.nvim": {
|
||||
"rev": "7bfd942445fb63089b59f97ca487d605e715f155",
|
||||
"src": "https://github.com/folke/noice.nvim"
|
||||
},
|
||||
"nui.nvim": {
|
||||
"rev": "10fc361835c856ba4233ef5ea135b919bf3dce97",
|
||||
"src": "https://github.com/MunifTanjim/nui.nvim"
|
||||
},
|
||||
"nvim-lspconfig": {
|
||||
"rev": "910f0c4d46aa186641518395bc7e6fffb4d23baf",
|
||||
"rev": "c59fc922f718fa055f69f5f3bc888f23211571eb",
|
||||
"src": "https://github.com/neovim/nvim-lspconfig"
|
||||
},
|
||||
"nvim-navic": {
|
||||
"rev": "455808fd0fae06e6d70fadfd61432275db8f34ce",
|
||||
"src": "https://github.com/SmiteshP/nvim-navic"
|
||||
},
|
||||
"nvim-tmux-navigation": {
|
||||
"rev": "4898c98702954439233fdaf764c39636681e2861",
|
||||
"src": "https://github.com/alexghergh/nvim-tmux-navigation"
|
||||
@@ -74,10 +62,6 @@
|
||||
"rev": "2b30e36fade3272081f7166bc0ec614b0b7da1c9",
|
||||
"src": "https://git.moomancer.xyz/DarthMooMancer/polydev.git"
|
||||
},
|
||||
"smear-cursor.nvim": {
|
||||
"rev": "f6cb57c342268177f719acc3968b9d8de3ecc969",
|
||||
"src": "https://github.com/sphamba/smear-cursor.nvim"
|
||||
},
|
||||
"snacks.nvim": {
|
||||
"rev": "882c996cf28183f4d63640de0b4c02ec886d01f2",
|
||||
"src": "https://github.com/folke/snacks.nvim"
|
||||
@@ -85,10 +69,6 @@
|
||||
"trouble.nvim": {
|
||||
"rev": "bd67efe408d4816e25e8491cc5ad4088e708a69a",
|
||||
"src": "https://github.com/folke/trouble.nvim"
|
||||
},
|
||||
"vellum.nvim": {
|
||||
"rev": "c9a8665c5d306bf56c6df89896fed8bfaf3110b3",
|
||||
"src": "https://github.com/blackhat-7/vellum.nvim"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,62 +1,182 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# 1. Get active tmux sessions
|
||||
sessions=$(tmux list-sessions -F "#S" 2>/dev/null)
|
||||
# Ensure Homebrew and standard paths are accessible inside fzf's preview subshell
|
||||
export PATH="/opt/homebrew/bin:/usr/local/bin:$HOME/.local/bin:$PATH"
|
||||
|
||||
# 2. Get directories from key work paths
|
||||
dirs=$(find ~ ~/.config ~/Projects ~/dotfiles ~/personal \
|
||||
-mindepth 1 -maxdepth 4 \
|
||||
\( -name ".git" -o -name "node_modules" -o -name ".cache" -o -name "Library" \) -prune \
|
||||
-o -type d -print 2>/dev/null)
|
||||
# Tabs definition
|
||||
TABS=("All" "Projects" "Dotfiles" "Blank Session")
|
||||
TOTAL=${#TABS[@]}
|
||||
ACTIVE_TAB=0
|
||||
|
||||
# 3. Dynamic Previewer (Tree view for folders, Window list for sessions)
|
||||
# Terminal Palette Colors for the Tab Header (Ghostty palette 12 and 8)
|
||||
CLR_ACTIVE=$(printf '\033[1;38;5;12m')
|
||||
CLR_INACTIVE=$(printf '\033[38;5;8m')
|
||||
CLR_RESET=$(printf '\033[0m')
|
||||
|
||||
# Dynamic Previewer (Restored exact working structure from your original script)
|
||||
preview_cmd='
|
||||
if [ -d {} ]; then
|
||||
if command -v eza &>/dev/null; then
|
||||
eza --tree --level=2 --icons --color=always {}
|
||||
elif command -v tree &>/dev/null; then
|
||||
tree -C -L 2 {}
|
||||
if [ "{}" = "[Create Blank Session in ~]" ]; then
|
||||
echo "Will spawn an empty session in ~/"
|
||||
elif [ -d {} ]; then
|
||||
if command -v eza >/dev/null 2>&1; then
|
||||
eza --tree --level=2 --icons --color=always --git-ignore -I "node_modules|build|dist|target|.cache" {}
|
||||
elif command -v tree >/dev/null 2>&1; then
|
||||
tree -C -L 2 --gitignore -I "node_modules|build|dist|target|.cache" {}
|
||||
else
|
||||
ls -la --color=always {}
|
||||
fi
|
||||
else
|
||||
tmux list-windows -t {} 2>/dev/null
|
||||
tmux list-windows -t {} 2>/dev/null || echo "Session or path: {}"
|
||||
fi'
|
||||
|
||||
# 4. Kanagawa Wave Themed FZF Selector
|
||||
selected=$(printf "%s\n%s" "$sessions" "$dirs" | grep -v '^$' | fzf \
|
||||
get_projects() {
|
||||
if command -v fd &>/dev/null; then
|
||||
[ -d "$HOME/Projects" ] && fd --type d --max-depth 2 . "$HOME/Projects" 2>/dev/null | sed 's:/*$::'
|
||||
[ -d "$HOME/personal/Projects" ] && fd --type d --min-depth 2 --max-depth 2 . "$HOME/personal/Projects" 2>/dev/null | sed 's:/*$::'
|
||||
else
|
||||
if [ -d "$HOME/Projects" ]; then
|
||||
find "$HOME/Projects" -mindepth 1 -maxdepth 2 \
|
||||
\( -name ".git" -o -name "node_modules" -o -name "build" -o -name ".cache" \) -prune \
|
||||
-o -type d -print 2>/dev/null | sed 's:/*$::'
|
||||
fi
|
||||
if [ -d "$HOME/personal/Projects" ]; then
|
||||
find "$HOME/personal/Projects" -mindepth 2 -maxdepth 2 \
|
||||
\( -name ".git" -o -name "node_modules" -o -name "build" -o -name ".cache" \) -prune \
|
||||
-o -type d -print 2>/dev/null | sed 's:/*$::'
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
get_dotfiles() {
|
||||
if command -v fd &>/dev/null; then
|
||||
# 1. Standard ~/.config/<app>
|
||||
[ -d "$HOME/.config" ] && fd --type d --max-depth 1 . "$HOME/.config" 2>/dev/null | sed 's:/*$::'
|
||||
|
||||
# 2. ~/dotfiles direct packages (e.g. ~/dotfiles/nvim, ~/dotfiles/tmux)
|
||||
# and stow structures (e.g. ~/dotfiles/nvim/.config/nvim or ~/dotfiles/.config/*)
|
||||
if [ -d "$HOME/dotfiles" ]; then
|
||||
# Top-level dotfile modules (depth 1)
|
||||
fd --type d --max-depth 1 . "$HOME/dotfiles" 2>/dev/null | sed 's:/*$::'
|
||||
|
||||
# Unhide and drill down specifically into any .config folders inside dotfiles
|
||||
fd --type d --hidden --no-ignore --max-depth 4 \
|
||||
--full-path '.*/\.config/[^/]+$' "$HOME/dotfiles" 2>/dev/null | sed 's:/*$::'
|
||||
fi
|
||||
else
|
||||
# Fallback using find
|
||||
if [ -d "$HOME/.config" ]; then
|
||||
find "$HOME/.config" -mindepth 1 -maxdepth 1 -type d 2>/dev/null | sed 's:/*$::'
|
||||
fi
|
||||
if [ -d "$HOME/dotfiles" ]; then
|
||||
# Dotfiles packages + nested .config targets up to 4 levels deep
|
||||
find "$HOME/dotfiles" -mindepth 1 -maxdepth 4 \
|
||||
\( -name ".git" -o -name "node_modules" -o -name ".cache" \) -prune \
|
||||
-o -type d -print 2>/dev/null | grep -E '(dotfiles/[^/]+$|/\.config/[^/]+$)' | sed 's:/*$::'
|
||||
fi
|
||||
fi | sort -u
|
||||
}
|
||||
|
||||
get_items_for_tab() {
|
||||
local tab_idx=$1
|
||||
case "$tab_idx" in
|
||||
1) # Projects only
|
||||
get_projects
|
||||
;;
|
||||
2) # Dotfiles only
|
||||
get_dotfiles
|
||||
;;
|
||||
3) # Blank Session
|
||||
echo "[Create Blank Session in ~]"
|
||||
;;
|
||||
*) # All: tmux sessions + projects + dotfiles + top-level home dirs
|
||||
tmux list-sessions -F "#S" 2>/dev/null
|
||||
get_projects
|
||||
get_dotfiles
|
||||
find "$HOME" -maxdepth 1 -mindepth 1 -type d ! -name "Library" 2>/dev/null | sed 's:/*$::'
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
render_header() {
|
||||
local active=$1
|
||||
local out=""
|
||||
for i in "${!TABS[@]}"; do
|
||||
local name="${TABS[$i]}"
|
||||
if [ "$i" -eq "$active" ]; then
|
||||
out+="${CLR_ACTIVE}[▶ ${name}]${CLR_RESET} "
|
||||
else
|
||||
out+="${CLR_INACTIVE} ${name} ${CLR_RESET} "
|
||||
fi
|
||||
done
|
||||
printf "%s\n" "$out"
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# Tab Navigation Loop
|
||||
# ---------------------------------------------------------
|
||||
selected=""
|
||||
while true; do
|
||||
fzf_output=$( { render_header "$ACTIVE_TAB"; get_items_for_tab "$ACTIVE_TAB" | grep -v '^$'; } | fzf \
|
||||
--ansi \
|
||||
--header-lines=1 \
|
||||
--expect=tab,btab \
|
||||
--layout=reverse \
|
||||
--border=rounded \
|
||||
--margin=1 \
|
||||
--padding=1 \
|
||||
--margin=15 \
|
||||
--padding=0 \
|
||||
--height=100% \
|
||||
--prompt=" " \
|
||||
--color="bg:#1F1F28,bg+:#223249,fg:#DCD7BA,fg+:#DCD7BA" \
|
||||
--color="hl:#2D4F67,hl+:#7E9CD8,prompt:#957FB8,pointer:#7E9CD8" \
|
||||
--color="info:#98BB6C,spinner:#957FB8,header:#7AA89F,border:#54546D" \
|
||||
--color="marker:#98BB6C" \
|
||||
--color="bg:#090E13,bg+:#22262D,fg:#c5c9c7,fg+:#ffffff" \
|
||||
--color="hl:#7fb4ca,hl+:#7fb4ca,prompt:#7fb4ca,pointer:#22262D" \
|
||||
--color="info:#5C6066,spinner:#5C6066,header:#5C6066,border:#2d3139" \
|
||||
--color="label:#7fb4ca" \
|
||||
--preview="$preview_cmd" \
|
||||
--preview-window="right:55%:border-left")
|
||||
|
||||
# Exit if fzf was cancelled
|
||||
fzf_status=$?
|
||||
# Cancelled via Escape or Ctrl-C
|
||||
[[ $fzf_status -ne 0 && $fzf_status -ne 1 ]] && exit 0
|
||||
|
||||
key=$(echo "$fzf_output" | head -n 1)
|
||||
selection=$(echo "$fzf_output" | tail -n +2)
|
||||
|
||||
if [ "$key" = "tab" ]; then
|
||||
ACTIVE_TAB=$(( (ACTIVE_TAB + 1) % TOTAL ))
|
||||
elif [ "$key" = "btab" ]; then
|
||||
ACTIVE_TAB=$(( (ACTIVE_TAB - 1 + TOTAL) % TOTAL ))
|
||||
else
|
||||
selected="$selection"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
[[ -z "$selected" ]] && exit 0
|
||||
|
||||
# 5. Handle Session Creation / Switching
|
||||
if [[ -d "$selected" ]]; then
|
||||
# Selection is a DIRECTORY -> Create session named after folder
|
||||
session_name=$(basename "$selected" | tr '.: ' '_')
|
||||
# Strip trailing slash if present
|
||||
selected="${selected%/}"
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# Handle Session Creation / Switching
|
||||
# ---------------------------------------------------------
|
||||
if [[ "$selected" == "[Create Blank Session in ~]" ]]; then
|
||||
idx=1
|
||||
while tmux has-session -t "=blank-$idx" 2>/dev/null; do
|
||||
((idx++))
|
||||
done
|
||||
session_name="blank-$idx"
|
||||
tmux new-session -d -s "$session_name" -c "$HOME"
|
||||
elif [[ -d "$selected" ]]; then
|
||||
session_name=$(basename "$selected" | tr '.: ' '_')
|
||||
if ! tmux has-session -t "=$session_name" 2>/dev/null; then
|
||||
tmux new-session -d -s "$session_name" -c "$selected"
|
||||
fi
|
||||
else
|
||||
# Selection is an EXISTING SESSION -> Connect directly
|
||||
session_name="$selected"
|
||||
fi
|
||||
|
||||
# 6. Attach or Switch
|
||||
if [[ -z "$TMUX" ]]; then
|
||||
exec tmux attach-session -t "$session_name"
|
||||
else
|
||||
tmux switch-client -t "$session_name"
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user