diff options
| author | Thomas Vanbesien <tvanbesi@proton.me> | 2026-05-07 13:21:20 +0200 |
|---|---|---|
| committer | Thomas Vanbesien <tvanbesi@proton.me> | 2026-05-07 13:21:20 +0200 |
| commit | bc2d5e85511d95110bc379226f0ddbb0dd1243a0 (patch) | |
| tree | f2db59074151327abf47c5ce171c7ecdebbcb22e | |
| parent | 0bc002288b984d8ec8123c135456570c78a22da3 (diff) | |
| download | dotfiles-bc2d5e85511d95110bc379226f0ddbb0dd1243a0.tar.gz dotfiles-bc2d5e85511d95110bc379226f0ddbb0dd1243a0.zip | |
fix(nvim): `Dotfiles*` commands check if gitgutter is loaded
| -rw-r--r-- | .config/nvim/plugin/50-dotfiles.lua | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/.config/nvim/plugin/50-dotfiles.lua b/.config/nvim/plugin/50-dotfiles.lua index 122912c..fc48014 100644 --- a/.config/nvim/plugin/50-dotfiles.lua +++ b/.config/nvim/plugin/50-dotfiles.lua @@ -28,9 +28,22 @@ vim.api.nvim_create_autocmd("BufEnter", { end, }) +local function check_gitgutter() + if vim.g.gitgutter_enabled == 1 then + return true + end + vim.notify("GitGutter is not enabled!", vim.log.levels.WARN) + return false +end + vim.api.nvim_create_user_command("DotfilesOn", function() - vim.g.gitgutter_git_args = "--git-dir=" .. vim.env.DOTFILES_DIR .. " --work-tree=" .. vim.env.HOME + if check_gitgutter() then + vim.g.gitgutter_git_args = "--git-dir=" .. vim.env.DOTFILES_DIR .. " --work-tree=" .. vim.env.HOME + end end, { desc = "Activate dotfiles (set git env)" }) + vim.api.nvim_create_user_command("DotfilesOff", function() - vim.g.gitgutter_git_args = "" + if check_gitgutter() then + vim.g.gitgutter_git_args = "" + end end, { desc = "Deactivate dotfiles (unset git env)" }) |
