chrisant996 / clink-flex-prompt

Flex prompt for Clink
MIT License
134 stars 17 forks source link

Show git submodule #42

Closed pablogipi closed 1 year ago

pablogipi commented 1 year ago

At the moment if you go to a folder thta is a git submodule, flex-prompt show the parent repo states/branch instead of the submodule's. Would be gret to have parameter for the git module to get the status/branch from the submodule if present, instead of showing the parent repo.

Thanks.

chrisant996 commented 1 year ago

@pablogipi Can you clarify the request?

  1. Are you asking to use --ignore-submodules=none so that status INCLUDES all submodules?
  2. Are you asking to show status for ONLY the current submodule, when the current working directory is in a submodule?
  3. Are you asking for some other behavior?

If you're just asking for # 1, i.e. add an optional :submodules arg to simply force using --ignore-submodules=none, then that's easy, and I'm adding that.

But if you're asking for # 2, then it quickly gets murky. Git doesn't seem to have a way to do that, so it would have to be 100% custom code. It would require running additional git commands to find all submodules and their respective directories, compare against the current working directory, and filter away modified files that are from a different submodule/repo than the current directory. And it would raise many questions about confusing/quirky situations:

pablogipi commented 1 year ago

Hello Chris. I think Im talking more about the second option.

cmder-powerline-prompt works in this way, it gives preference for submodules when you ire inside it, which is relly really useful. Here is the module for git

We can do a test with option 1 as an starter.

Thanks

chrisant996 commented 1 year ago

That's interesting, because that's the project that was the original source for clink-flex-prompt, and that's mentioned near the top of the README in this repo.

You stated that both the branch status and file status are being shown from the parent.

Are you sure the file status is inaccurate?

I see something a little different:

pablogipi commented 1 year ago

Yes, that is exactly what motivated me to open this issue. When I switched from powerline-prompt to clink-flex-prompt I noticed that in my submodules the branch that was shown was the parent instead of the submodule's branch. Cheers

chrisant996 commented 1 year ago

Ok, what misled me was the statement that "flex-prompt show the parent repo states/branch instead of the submodule's". But it's only the branch info that's inaccurate.

And I see why. I'll make a fix.

pablogipi commented 1 year ago

Thanks Chris!!

chrisant996 commented 1 year ago

When support for worktrees was added, detection of submodules got broken.

pablogipi commented 1 year ago

I'll check scoop to update it in my systems. Thanks for the fix!

pablogipi commented 1 year ago

Tested today and working fine, thanks I was wondering, I think it would be useful to ad an icon besides the usual branch icon in the prompt to add hint that the current path is inside a submodule rather than in a regular git repo. What do you think?

chrisant996 commented 1 year ago

I was wondering, I think it would be useful to ad an icon besides the usual branch icon in the prompt to add hint that the current path is inside a submodule rather than in a regular git repo. What do you think?

Which icon do you suggest?

pablogipi commented 1 year ago

He! Apparently in devicons there is one for submodules:

https://icons8.com/icons/set/git-submodule

image

I think is can go between the git logo and the branch icon.

image

Thanks!

chrisant996 commented 1 year ago

@pablogipi There's been a misunderstanding. Text terminals can't use graphical icon files.

You'd have to look in Nerd Fonts Cheat Sheet for icons that can potentially be available in some customized nerd fonts. Many such icons end up illegible at the small font sizes typically used in terminal windows.

For example, like this:

image

In the screenshot I searched for "submodule" and there are two nerd icons available matching that keyword (searching for "folder" or other keywords may find other potentially suitable icons).

In the screenshot I hovered over the first one, which makes a menu show up for "COPY" options. If you click "Icon" it copies the selected nerd icon character into the clipboard, and then you can paste it into a terminal window.

Here is what that icon actually looks like in Windows Terminal, when using a nerd font that includes that icon (not all nerd fonts include all icons):

image

By the way, the second icon from the screen shot isn't available in most nerd fonts, and it pastes as the "character not present in font" symbol. This is why it's important to test whether a proposed icon is available in nerd fonts. Also, just because it's available in one nerd font doesn't mean it's available in others. The icons currently used by clink-flex-prompt are available in most nerd fonts; it takes time and effort to find suitable icons and verify them.

Those are the reasons why my response to the suggestion to use a different icon for submodules was to ask "which icon?" Because there are very few options, very little control available, and a lot of verification effort is required. So, while I agree that using another icon could be nice, I definitely need specified suggestions, and ideally the suggestions need to have been verified to be truly viable (i.e. that the icon is legible enough to be recognizable and that the icon is actually present in most nerd fonts).

Also, are you suggesting to show several icons in a row? One for "git", one for "submodule", and one for "branch"? Or are you suggesting to replace the "git" icon with a "submodule" icon? Or are you suggesting to replace the "branch" icon with a "submodule" icon?

pablogipi commented 1 year ago

Yep I know, the links I sent before were for the devicons that are part of the NerdFonts. And yes I agree that some of these icons don't look really good when rendered as fonts. My idea is to have several icons in a row, one for git, then optionally the submodule icon and then the branch icon. The folder icon probably is going to look awkward, even when is the submodule icon.

chrisant996 commented 1 year ago

I was looking for a specific suggestion of a textual Unicode codepoint to use, since that's the only thing that can actually be used. A link to an image file isn't usable.

I would prefer something legible.

In this case, the majority of the work is hunting down possible icons and verifying how widely they're actually available in nerd fonts. That involves many hours, and it's work that others can do just as easily as myself. If you or someone else does the work of finding a suitable icon, then it's pretty quick for me to add code to use it.

chrisant996 commented 1 year ago

NerdFonts recently released a v3 of the fonts and icons.

It's a major change in what icons are available, which Unicode codepoint they're available at, and how wide they are.

The good news is there's a submodule icon and it's double-wide now so it's very legible.

The bad news is:

Ugh.

pablogipi commented 1 year ago

I think is better to stick to v2. Looking at https://www.nerdfonts.com/cheat-sheet I propose any of these ones as good options:

chrisant996 commented 1 year ago

I think is better to stick to v2.

I think you mean supporting v2 is worthwhile. Yes, of course.

But I can't make v3 not exist, and I can't make people not use it, and it has better icons. If you're saying flexprompt shouldn't even add support for v3 at all, then that wouldn't make sense. I'll be adding support for v3, which means making the wizard help figure out which one is being used, so that flexprompt can support both v2 and v3 (obviously not at the same time on a given computer).

Looking at https://www.nerdfonts.com/cheat-sheet I propose any of these ones as good options:

  • nf_md_consolidate
  • nf_md_import
  • nf_md_layers
  • nf_md_pot

I'll take a look at them and their availability, thanks for the suggestions!

pablogipi commented 1 year ago

No, I mean stick to v2 for the submodule icon.

chrisant996 commented 1 year ago

No, I mean stick to v2 for the submodule icon.

Do you recognize the consequences of that proposal? It would mean flexprompt would be incompatible with the current versions of NerdFonts, and people would be unable to use flexprompt (with icons) with NerdFonts anymore. That wouldn't make any sense.

Maybe the meaning of "v2" and "v3" was unclear? It refers to the version of the fonts themselves. A font cannot be "both" v2 and v3. A v2 nerd font and a v3 nerd font have different icons at different Unicode codepoints. If flexprompt "sticks to v2" that means it will not work when using a v3 font, and that is very unacceptable.

As I said, I will make flexprompt support v2 when you use v2, and support v3 when you use v3.

chrisant996 commented 1 year ago

Full support is coming for:

Plus, an option to use color emoji in Windows Terminal for certain icons.

pablogipi commented 1 year ago

Uuuh that's great, thanks for the update!

chrisant996 commented 1 year ago

The combination of Clink v1.4.28 and clink-flex-prompt v0.14 should handle showing an icon for git submodule, and supporting different versions and widths of nerdfonts, and supporting certain color emoji in Windows Terminal.

The new releases have been published.