feat(fish): add gco — smart checkout that cds into worktrees 🌿
If the target branch is already checked out in another worktree, `gco <branch>` cds there instead of erroring with "already used by worktree at". Falls through to plain `git checkout` otherwise.
This commit is contained in:
parent
e43a5eb880
commit
9283643e07
3 changed files with 120 additions and 0 deletions
53
assets/zed/settings.json
Normal file
53
assets/zed/settings.json
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
// Zed settings — tracked in dotfiles, symlinked into ~/.config/zed/settings.json
|
||||
// by home-manager (xdg.configFile in nixos/home/danny/home.nix).
|
||||
//
|
||||
// Because this is a symlink to a nix-store file, editing it from inside Zed
|
||||
// will fail (read-only). Edit THIS file in dotfiles, commit, and rebuild
|
||||
// (`darwin-rebuild switch --flake .`). To see Zed's full default settings,
|
||||
// run `zed: open default settings` from the command palette.
|
||||
{
|
||||
"sticky_scroll": {
|
||||
"enabled": true
|
||||
},
|
||||
"edit_predictions": {
|
||||
"provider": "ollama"
|
||||
},
|
||||
"buffer_font_family": "JetBrains Mono",
|
||||
"cli_default_open_behavior": "existing_window",
|
||||
"project_panel": {
|
||||
"dock": "left"
|
||||
},
|
||||
"outline_panel": {
|
||||
"dock": "left"
|
||||
},
|
||||
"collaboration_panel": {
|
||||
"dock": "left"
|
||||
},
|
||||
"git_panel": {
|
||||
"dock": "left"
|
||||
},
|
||||
"agent": {
|
||||
"dock": "right",
|
||||
"default_model": {
|
||||
"provider": "ollama",
|
||||
"model": "llama3.2:latest"
|
||||
}
|
||||
},
|
||||
"disable_ai": false,
|
||||
"minimap": {
|
||||
"show": "auto"
|
||||
},
|
||||
"telemetry": {
|
||||
"diagnostics": false,
|
||||
"metrics": false
|
||||
},
|
||||
"base_keymap": "VSCode",
|
||||
"vim_mode": true,
|
||||
"ui_font_size": 16,
|
||||
"buffer_font_size": 15,
|
||||
"theme": {
|
||||
"mode": "system",
|
||||
"light": "One Light",
|
||||
"dark": "One Dark"
|
||||
}
|
||||
}
|
||||
|
|
@ -24,6 +24,38 @@
|
|||
|
||||
set fish_greeting 🐟: (set_color yellow; date +%T; set_color green; date --iso-8601 2>/dev/null; or date +%F; set_color normal)
|
||||
|
||||
# gco: smart `git checkout` — if the branch is checked out in another
|
||||
# worktree, cd there instead of failing with "already used by worktree at".
|
||||
function gco --description 'git checkout, but cd into worktree if the branch lives there'
|
||||
if test (count $argv) -eq 0
|
||||
git checkout
|
||||
return $status
|
||||
end
|
||||
|
||||
set -l branch $argv[1]
|
||||
set -l target_ref "refs/heads/$branch"
|
||||
set -l wt_path ""
|
||||
set -l current_wt ""
|
||||
for line in (git worktree list --porcelain 2>/dev/null)
|
||||
switch $line
|
||||
case 'worktree *'
|
||||
set current_wt (string replace -r '^worktree ' "" -- $line)
|
||||
case "branch $target_ref"
|
||||
set wt_path $current_wt
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
set -l here (git rev-parse --show-toplevel 2>/dev/null)
|
||||
if test -n "$wt_path"; and test "$wt_path" != "$here"
|
||||
echo "→ cd $wt_path (branch '$branch' is checked out in another worktree)"
|
||||
cd $wt_path
|
||||
return $status
|
||||
end
|
||||
|
||||
git checkout $argv
|
||||
end
|
||||
|
||||
# Alacritty palette follows macOS appearance; refresh when opening a shell (LaunchAgent also polls).
|
||||
if test (uname -s) = Darwin
|
||||
bash ~/dotfiles/scripts/alacritty-sync-system-theme.sh >/dev/null 2>&1 &
|
||||
|
|
|
|||
|
|
@ -58,6 +58,39 @@
|
|||
end,
|
||||
})
|
||||
|
||||
-- Treesitter highlighting: parser-driven syntax highlighting (richer
|
||||
-- than the regex-based default). Leaving `indent` off — it's still
|
||||
-- buggy in several languages (python, yaml).
|
||||
require'nvim-treesitter.configs'.setup {
|
||||
highlight = { enable = true },
|
||||
}
|
||||
|
||||
-- Sticky scroll: pin enclosing scopes (functions, classes, YAML keys,
|
||||
-- etc.) to the top of the window as you scroll deeper. Same idea as
|
||||
-- Zed/VS Code's "Sticky Scroll". `mode = 'topline'` matches Zed's
|
||||
-- "scrolled past" feel; switch to 'cursor' if you'd rather it track
|
||||
-- the cursor instead of the viewport.
|
||||
require'treesitter-context'.setup {
|
||||
enable = true,
|
||||
max_lines = 5,
|
||||
mode = 'topline',
|
||||
trim_scope = 'outer',
|
||||
}
|
||||
|
||||
-- Fish: expand tabs to spaces. Fish renders raw \t in the commandline
|
||||
-- as the Unicode glyph ␉ (U+2409) and wrap-indents each line to the
|
||||
-- column of the opening quote, which mangles Alt-E multiline edits.
|
||||
-- Using spaces sidesteps the issue entirely.
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "fish",
|
||||
callback = function()
|
||||
vim.opt_local.expandtab = true
|
||||
vim.opt_local.tabstop = 2
|
||||
vim.opt_local.shiftwidth = 2
|
||||
vim.opt_local.softtabstop = 2
|
||||
end,
|
||||
})
|
||||
|
||||
-- Keymaps
|
||||
vim.keymap.set("n", "S", ":%s//g<Left><Left>", { desc = "Replace all" })
|
||||
vim.keymap.set("n", "<leader>w", ":w<CR>", { desc = "Save file" })
|
||||
|
|
@ -73,6 +106,8 @@
|
|||
catppuccin-nvim # theme
|
||||
goyo-vim # write prose
|
||||
limelight-vim # prose paragraph highlighter
|
||||
nvim-treesitter.withAllGrammars # parsers (also makes vim.treesitter.foldexpr work for markdown)
|
||||
nvim-treesitter-context # sticky scroll: pin parent scopes at top of window
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue