~gpanders/dotfiles

c012a30186d80fdbc4aaefbdf6e620bd8f282521 — Gregory Anders a month ago 5861ba8
nvim: phase out Fugitive autocommand

According to the fugitive docs, the Fugitive User autocommand is being
phased out in favor of just checking the result of FugitiveGitDir() on a
BufRead/BufNewFile autocmd.
4 files changed, 18 insertions(+), 5 deletions(-)

D .config/nvim/after/plugin/gitsigns.vim
M .config/nvim/after/plugin/telescope.vim
M .config/nvim/autoload/statusline.vim
A .config/nvim/plugin/gitsigns.vim
D .config/nvim/after/plugin/gitsigns.vim => .config/nvim/after/plugin/gitsigns.vim +0 -1
@@ 1,1 0,0 @@
autocmd User Fugitive ++once lua require("gitsigns").setup()

M .config/nvim/after/plugin/telescope.vim => .config/nvim/after/plugin/telescope.vim +4 -1
@@ 12,5 12,8 @@ nnoremap z= <Cmd>Telescope spell_suggest<CR>
augroup my_telescope
    autocmd!
    autocmd User LspAttached nnoremap <buffer> <Space>t <Cmd>Telescope lsp_dynamic_workspace_symbols<CR>
    autocmd User Fugitive nnoremap <buffer> <Space>f <Cmd>Telescope git_files show_untracked=false<CR>

    if exists('*FugitiveGitDir')
        autocmd BufNewFile,BufRead * if !empty(FugitiveGitDir()) | nnoremap <buffer> <Space>f <Cmd>Telescope git_files show_untracked=false<CR> | endif
    endif
augroup END

M .config/nvim/autoload/statusline.vim => .config/nvim/autoload/statusline.vim +3 -3
@@ 3,8 3,8 @@ function! statusline#git() abort
    return b:gitsigns_head
  end

  if get(g:, 'loaded_fugitive')
    let branch = fugitive#head()
  if exists('*FugitiveHead')
    let branch = FugitiveHead()
    if branch !=# ''
      return branch
    endif


@@ 13,7 13,7 @@ function! statusline#git() abort
endfunction

function! statusline#obsession() abort
  if get(g:, 'loaded_obsession')
  if exists('*ObsessionStatus')
    let s = ObsessionStatus()
    if !empty(s)
      let s .= ' '

A .config/nvim/plugin/gitsigns.vim => .config/nvim/plugin/gitsigns.vim +11 -0
@@ 0,0 1,11 @@
function! s:load()
    if !exists('*FugitiveGitDir') || !empty(FugitiveGitDir())
        lua require("gitsigns").setup()
        autocmd! my_gitsigns
        augroup! my_gitsigns
    end
endfunction

augroup my_gitsigns
    autocmd! BufNewFile,BufRead * call s:load()
augroup END