Skip to content
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

Gstatus: use folds for sections ("Untracked") #1317

Closed
blueyed opened this issue Aug 22, 2019 · 7 comments · May be fixed by #1356
Closed

Gstatus: use folds for sections ("Untracked") #1317

blueyed opened this issue Aug 22, 2019 · 7 comments · May be fixed by #1356

Comments

@blueyed
Copy link
Contributor

blueyed commented Aug 22, 2019

In a "ft=fugitive" Gstatus buffer folding could be used to fold "Untracked" files by default.

This could also be used for the inline diffs then maybe (currently done via =, <, and >).

Or = could be supported to show/hide untracked files also.

But I think folds are a more natural choice here.

@tpope
Copy link
Owner

tpope commented Aug 22, 2019

Fugitive respects status.showUntrackedFiles and provides gI for low effort ignoring. These are Git's solutions to untracked files, I don't think we need to invent new ones.

@tpope tpope closed this as completed Aug 22, 2019
@blueyed
Copy link
Contributor Author

blueyed commented Aug 22, 2019

Given that it uses foldmethod=syntax the change for this is rather trivial - happy to keep it locally, but you might want to consider it:

diff --git i/syntax/fugitive.vim w/syntax/fugitive.vim
index afc0c0b..9f7322d 100644
--- i/syntax/fugitive.vim
+++ w/syntax/fugitive.vim
@@ -26,7 +26,12 @@ syn match fugitiveHash /\<\x\{4,\}\>/ contained
 syn region fugitiveHunk start=/^\%(@@\+ -\)\@=/ end=/^\%([A-Za-z?@]\|$\)\@=/ contains=@fugitiveDiff containedin=@fugitiveSection fold
 
 for s:section in ['Untracked', 'Unstaged', 'Staged']
-  exe 'syn region fugitive' . s:section . 'Section start=/^\%(' . s:section . ' .*(\d\+)$\)\@=/ contains=fugitive' . s:section . 'Heading end=/^$/'
+  if s:section ==# 'Untracked'
+    let fold = ' fold'
+  else
+    let fold = ''
+  endif
+  exe 'syn region fugitive' . s:section . 'Section start=/^\%(' . s:section . ' .*(\d\+)$\)\@=/ contains=fugitive' . s:section . 'Heading end=/^$/'.fold
   exe 'syn match fugitive' . s:section . 'Modifier /^[MADRCU?] / contained containedin=fugitive' . s:section . 'Section'
   exe 'syn cluster fugitiveSection add=fugitive' . s:section . 'Section'
   exe 'syn match fugitive' . s:section . 'Heading /^[A-Z][a-z][^:]*\ze (\d\+)$/ contains=fugitivePreposition contained nextgroup=fugitiveCount skipwhite'

(only used it for Untracked to not mess with inline diffs (with would need to be opened then otherwise automatically (with = etc))

As for my use case: I want to be aware of untracked files in vim-fugitive (rules out status.showUntrackedFiles = "no"), and I also do not want to ignore them (always).
In the shell I use gst with --untracked-files=no, but also have gstu to show them.

Since I have a huge number of them in some repos, this is rather distracting then in vim-fugitive.

Being able to zc them is nice. I might even end up closing the "Untracked" fold then by default.
(I've some special processing for filetype=gitcommit buffers already, where those and unstaged files get folded away already (with git commit -v), so I am used to this kind)

JFI: I am not a heavy user of :Gstatus, but getting my toes wet - due to all the recent niceties there. Thanks a lot! :)

@tpope
Copy link
Owner

tpope commented Sep 1, 2019

So the section you want folded gets a fold attribute, but the others don't? Hard pass.

@blueyed
Copy link
Contributor Author

blueyed commented Sep 26, 2019

It's because other sections use inline diffs:

(only used it for Untracked to not mess with inline diffs (with would need to be opened then otherwise automatically (with = etc))

@blueyed
Copy link
Contributor Author

blueyed commented Sep 26, 2019

It might work better in general if = would also use folds in the first place, i.e. have an intermediate fold level then for the files, and configuring foldlevel to automatically open diffs then by default etc.
=> #1356

@matthewgrossman
Copy link

@blueyed you still using this solution locally? I'm also interested in folding away Untracked as a couple projects I work on generate many artifacts upon make test that aren't tracked/explicitly-ignored (I know, not ideal, but out of my control).

I see the PR open (#1356) but it doesn't look like it's had activity in a bit, wondering if it still works well for you

tpope added a commit that referenced this issue Mar 20, 2021
@tpope
Copy link
Owner

tpope commented Mar 20, 2021

I just removed automatically enabled folding in the status window. Assuming that doesn't ruffle too many feathers then I am fine to add the extra level section of folding since it will only affect those who opt in.

But we should probably make all sections foldable, including Rebasing, Unpulled, and Unpushed.

Gelio pushed a commit to Gelio/vim-fugitive that referenced this issue Mar 24, 2021
tpope added a commit that referenced this issue Feb 5, 2023
Resolves: #2111
References: #1317
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants