-
-
Notifications
You must be signed in to change notification settings - Fork 915
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(options): add setting to enable git integration for custom worktrees #2092
feat(options): add setting to enable git integration for custom worktrees #2092
Conversation
…s in custom worktree
…n `find_worktree()`
Use the following
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome! Thanks so much! I'll play around with it and hopefully get a new minor release tagged in the coming days :)
* feat(options): add setting to enable git integration for custom worktrees * fix(autocmds): add additional check for AstroGitFile to see if file is in custom worktree * refactor(autocmds): extract `in_worktree()` to custom utility function `find_worktree()` * feat(mappings): allow toggle lazygit to automatically load git worktrees if available * chore(mappings): cleanup redundant toggle lazygit mapping
* feat(options): add setting to enable git integration for custom worktrees * fix(autocmds): add additional check for AstroGitFile to see if file is in custom worktree * refactor(autocmds): extract `in_worktree()` to custom utility function `find_worktree()` * feat(mappings): allow toggle lazygit to automatically load git worktrees if available * chore(mappings): cleanup redundant toggle lazygit mapping
@Subjective I did a slight cleanup on nightly so just let me know if I accidentally broke anything :) |
@Subjective do you think you could also make a PR on the documentation to add a new recipe page regarding git working trees? It could give a slight introduction to them and what they are and then describe in more details how to set them up and use them :) Also for reals, thanks again for this contribution. This is a super great new feature!!! |
…ng trees (#2092) * feat(options): add setting to enable git integration for custom worktrees * fix(autocmds): add additional check for AstroGitFile to see if file is in custom worktree * refactor(autocmds): extract `in_worktree()` to custom utility function `find_worktree()` * feat(mappings): allow toggle lazygit to automatically load git worktrees if available * chore(mappings): cleanup redundant toggle lazygit mapping
* fix(utils): load treesitter when making notifications * fix(treesitter): ensure markdown treesitter parser * feat: add `vim.g.git_worktrees` to enable usage of detached git working trees (#2092) * feat(options): add setting to enable git integration for custom worktrees * fix(autocmds): add additional check for AstroGitFile to see if file is in custom worktree * refactor(autocmds): extract `in_worktree()` to custom utility function `find_worktree()` * feat(mappings): allow toggle lazygit to automatically load git worktrees if available * chore(mappings): cleanup redundant toggle lazygit mapping * refactor: clean up implementation of git worktrees * fix(ui): notifications appearing on top in unintended situations (#2093) * fix(ui): notifications appearing on top in unintended situations * fix(ui): increase notification zindex to 175 Co-authored-by: Micah Halter <micah@mehalter.com> --------- Co-authored-by: Micah Halter <micah@mehalter.com> * feat: include tables for all map modes in `mappings` and `lsp.mappings` * chore: use `vim.ui.open` if it's available * fix(utils): set cursor in a better position (#2094) * fix: disable `lua_ls` formatting with Neoconf * fix(lsp): hacky fix for neoconf lazy loading * fix(heirline): improve lualine integration with statusline * refactor: simplify notification formatting implementation * fix(utils): update `is_available` to use the correct lazy API * chore(snapshot): update lazy_snapshot --------- Co-authored-by: Josh <56745535+Subjective@users.noreply.github.com> Co-authored-by: Tiago Muniz de Araujo <tiagomuniz130@gmail.com>
…ng trees (#2092) * feat(options): add setting to enable git integration for custom worktrees * fix(autocmds): add additional check for AstroGitFile to see if file is in custom worktree * refactor(autocmds): extract `in_worktree()` to custom utility function `find_worktree()` * feat(mappings): allow toggle lazygit to automatically load git worktrees if available * chore(mappings): cleanup redundant toggle lazygit mapping
…ng trees (AstroNvim#2092) * feat(options): add setting to enable git integration for custom worktrees * fix(autocmds): add additional check for AstroGitFile to see if file is in custom worktree * refactor(autocmds): extract `in_worktree()` to custom utility function `find_worktree()` * feat(mappings): allow toggle lazygit to automatically load git worktrees if available * chore(mappings): cleanup redundant toggle lazygit mapping
Many users (myself included) like tracking their dotfiles in bare git repos which rely on setting a custom worktree to work. Unfortunately, this also means that while editing dotfiles, it's not possible to see git diffs in the gutter or open lazygit in the correct repository as without a
.git
folder it is difficult to know whether a file is being tracked by a bare repo or not.This PR adds git integration when editing files within custom worktrees, allowing toggleterm and gitsigns gutter highlighting to work as you would expect them to. It also fixes the AstroGitFile event to trigger when a file within a custom worktree is opened, allowing plugins like gitsigns to propely lazy load.
This functionality is opt-in, so those who don't rely on custom worktrees won't notice anything.
To enable it, set the global option git_worktrees to an array-like table, where each entry represents a worktree with entries
toplevel
andgitdir
. This mirrors a similar configuration option in gitsigns (lewis6991/gitsigns.nvim/pull/600). For example, if you have a bare git repo located at ~/.cfg, you can enable git integration for it by setting the following in the AstroNvim global options table: