-
-
Notifications
You must be signed in to change notification settings - Fork 103
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
Support the same tab completion options as zsh #25
Comments
I don't think there's anything preventing us from implementing all of the git tab completion features that are available in zsh; we based the existing tab completion on git's shell completion code, and given enough time we could port all of it over to gitsh. What other completion features you're missing from zsh? |
I thought of that after opening the issue. As far as I can tell the completion system is just a bit naive. It completes all commands/options listed in help all the time, or remote info in some cases? The zsh completion script is smart about when to complete what options, when to complete remote or local branches, present files, tracked files, indexed files, etc and includes aliases and completes them correctly too. I'd love to port all of that over, and would be willing to work on it myself. |
@alexanderjeurissen I think there are two different issues being discussed here:
I think (1) would be very useful for gitsh users, but (2) is a little more tricky: I'm trying to follow the “principle of least astonishment” with gitsh's interface design, but it's hard to see how to apply that here. As a zsh users, you're surprised that |
@georgebrock I understand that you want easy migration to Gitsh from various terminal emulators. However it would be nice to have more advanced tab completion as |
As a zsh user who does not use the |
I have a similar experience coming from git-sh. It feels git-sh is smarter about the context of the command. I personally don't feel comfortable enough with ruby to start implementation, but would love to help getting this further. Would it be a good start to list some specific situations? Or is the current references to zsh and git-sh enough? (Is this a good issue btw, or is there another more generic issue already?) |
Specifics would be great, pull requests with failing tests would be even better, and pull requests with working code is most ideal. See https://github.com/thoughtbot/gitsh/blob/master/CONTRIBUTING.md for details on how to get the dev environment running locally. Not too much Ruby knowledge is required for this (you'll need RubyGems and Bundler:
Edit it 'completes partial paths' do
with_a_temporary_home_directory do
completer = build_completer(input: 'add ')
Dir.chdir do
FileUtils.mkdir_p(%w(abc def ghi jkl mno))
end
expect(completer.call('a/d/g/j/m')).to include 'abc/def/ghi/jkl/mno'
end
end Then run the test according to CONTRIBUTING.md:
If you want to tackle the Ruby after that, look in |
Thanks for the push into actual coding :) I tried ruby a while back and noticed it costs me a lots of time for small things, so I'll save it for later. Or, at least I'll start with some specific things I'd like to see different. Maybe later or maybe someone else can pick some up. Some auto completion (via tab) wishes:
Often the extra space or slash at the end makes all the difference between fluently continue typing or having to type redundant stuff. |
Perhaps a DSL for expressing completions would be useful, such that we can express:
And @georgebrock how's that for over-engineered? |
I'm not sure what exactly you mean with
|
@mike-burns That could be quite a nice way of expressing it. @lode I'd see |
@georgebrock indeed, than it works perfectly of course. |
This is a really major change, and therefore a big diff. Replaces the Parslet-based parsing expression grammar (PEG) with an RLTK-based context-free grammar (CFG). The `Gitsh::Parser` (which converted text into a AST) and `Gitsh::Transformer` (which converted the AST into useful domain objects) have been replaced with a `Gitsh::Lexer` (which converts text into tokens) and `Gitsh::Parser` (which converts tokens into useful domain objects). Why? ==== Distinguishing between _invalid input_ and _valid but incomplete input_ is really hard with a PEG. There are various papers on improving PEG error reporting, and some support in Parslet for various strategies, but I couldn't find a satisfactory way to accurately work out why parsing failed without making the grammar significantly more complex. We want to add support for various multi-line constructs, which means we need to know if a line is invalid or just waiting for more input. The specific issues I have in mind are: - Support multi-line strings (#31) - Add a `:function` command for defining functions (#35) We also want to improve tab-completion in various ways, which also involves working with very similar types of incomplete input. Most of the enhancements we have in mind will only be possible if we know more exactly what we're completing, and re-using some of the parsing code to understand the input seemed like the most logical approach. Specific issues are: - Support the same tab completion options as zsh (#25) - Add tab completion for options (#80) - Auto complete stash commands (#220) - Tab completion only works for the first command on the line (#261) Note that this commit doesn't implement any of these enhancements, it just makes them more likely to happen in the future. Implementation details ====================== - Introduces equality methods on argument objects, used to testing parser output. - git-prefix correction (i.e. interpreting `git foo` as `foo` when `help.autocorrect` is set) has moved from the Parser to the GitCommand class. - The subshell implementation in this commit is not very good. It will be significantly improved in the next couple of commits, but it seemed too big of a change to roll into this one.
This is a really major change, and therefore a big diff. Replaces the Parslet-based parsing expression grammar (PEG) with an RLTK-based context-free grammar (CFG). The `Gitsh::Parser` (which converted text into a AST) and `Gitsh::Transformer` (which converted the AST into useful domain objects) have been replaced with a `Gitsh::Lexer` (which converts text into tokens) and `Gitsh::Parser` (which converts tokens into useful domain objects). Why? ==== Distinguishing between _invalid input_ and _valid but incomplete input_ is really hard with a PEG. There are various papers on improving PEG error reporting, and some support in Parslet for various strategies, but I couldn't find a satisfactory way to accurately work out why parsing failed without making the grammar significantly more complex. We want to add support for various multi-line constructs, which means we need to know if a line is invalid or just waiting for more input. The specific issues I have in mind are: - Support multi-line strings (#31) - Add a `:function` command for defining functions (#35) We also want to improve tab-completion in various ways, which also involves working with very similar types of incomplete input. Most of the enhancements we have in mind will only be possible if we know more exactly what we're completing, and re-using some of the parsing code to understand the input seemed like the most logical approach. Specific issues are: - Support the same tab completion options as zsh (#25) - Add tab completion for options (#80) - Auto complete stash commands (#220) - Tab completion only works for the first command on the line (#261) Note that this commit doesn't implement any of these enhancements, it just makes them more likely to happen in the future. Implementation details ====================== - Introduces equality methods on argument objects, used to testing parser output. - git-prefix correction (i.e. interpreting `git foo` as `foo` when `help.autocorrect` is set) has moved from the Parser to the GitCommand class. - The subshell implementation in this commit is not very good. It will be significantly improved in the next couple of commits, but it seemed too big of a change to roll into this one.
This is a really major change, and therefore a big diff. Replaces the Parslet-based parsing expression grammar (PEG) with an RLTK-based context-free grammar (CFG). The `Gitsh::Parser` (which converted text into a AST) and `Gitsh::Transformer` (which converted the AST into useful domain objects) have been replaced with a `Gitsh::Lexer` (which converts text into tokens) and `Gitsh::Parser` (which converts tokens into useful domain objects). Why? ==== Distinguishing between _invalid input_ and _valid but incomplete input_ is really hard with a PEG. There are various papers on improving PEG error reporting, and some support in Parslet for various strategies, but I couldn't find a satisfactory way to accurately work out why parsing failed without making the grammar significantly more complex. We want to add support for various multi-line constructs, which means we need to know if a line is invalid or just waiting for more input. The specific issues I have in mind are: - Support multi-line strings (#31) - Add a `:function` command for defining functions (#35) We also want to improve tab-completion in various ways, which also involves working with very similar types of incomplete input. Most of the enhancements we have in mind will only be possible if we know more exactly what we're completing, and re-using some of the parsing code to understand the input seemed like the most logical approach. Specific issues are: - Support the same tab completion options as zsh (#25) - Add tab completion for options (#80) - Auto complete stash commands (#220) - Tab completion only works for the first command on the line (#261) Note that this commit doesn't implement any of these enhancements, it just makes them more likely to happen in the future. Implementation details ====================== - Introduces equality methods on argument objects, used to testing parser output. - git-prefix correction (i.e. interpreting `git foo` as `foo` when `help.autocorrect` is set) has moved from the Parser to the GitCommand class. - The subshell implementation in this commit is not very good. It will be significantly improved in the next couple of commits, but it seemed too big of a change to roll into this one.
This is a really major change, and therefore a big diff. Replaces the Parslet-based parsing expression grammar (PEG) with an RLTK-based context-free grammar (CFG). The `Gitsh::Parser` (which converted text into a AST) and `Gitsh::Transformer` (which converted the AST into useful domain objects) have been replaced with a `Gitsh::Lexer` (which converts text into tokens) and `Gitsh::Parser` (which converts tokens into useful domain objects). Why? ==== Distinguishing between _invalid input_ and _valid but incomplete input_ is really hard with a PEG. There are various papers on improving PEG error reporting, and some support in Parslet for various strategies, but I couldn't find a satisfactory way to accurately work out why parsing failed without making the grammar significantly more complex. We want to add support for various multi-line constructs, which means we need to know if a line is invalid or just waiting for more input. The specific issues I have in mind are: - Support multi-line strings (#31) - Add a `:function` command for defining functions (#35) We also want to improve tab-completion in various ways, which also involves working with very similar types of incomplete input. Most of the enhancements we have in mind will only be possible if we know more exactly what we're completing, and re-using some of the parsing code to understand the input seemed like the most logical approach. Specific issues are: - Support the same tab completion options as zsh (#25) - Add tab completion for options (#80) - Auto complete stash commands (#220) - Tab completion only works for the first command on the line (#261) Note that this commit doesn't implement any of these enhancements, it just makes them more likely to happen in the future. Implementation details ====================== - Introduces equality methods on argument objects, used to testing parser output. - git-prefix correction (i.e. interpreting `git foo` as `foo` when `help.autocorrect` is set) has moved from the Parser to the GitCommand class. - The subshell implementation in this commit is not very good. It will be significantly improved in the next couple of commits, but it seemed too big of a change to roll into this one.
This is a really major change, and therefore a big diff. Replaces the Parslet-based parsing expression grammar (PEG) with an RLTK-based context-free grammar (CFG). The `Gitsh::Parser` (which converted text into a AST) and `Gitsh::Transformer` (which converted the AST into useful domain objects) have been replaced with a `Gitsh::Lexer` (which converts text into tokens) and `Gitsh::Parser` (which converts tokens into useful domain objects). Why? ==== Distinguishing between _invalid input_ and _valid but incomplete input_ is really hard with a PEG. There are various papers on improving PEG error reporting, and some support in Parslet for various strategies, but I couldn't find a satisfactory way to accurately work out why parsing failed without making the grammar significantly more complex. We want to add support for various multi-line constructs, which means we need to know if a line is invalid or just waiting for more input. The specific issues I have in mind are: - Support multi-line strings (#31) - Add a `:function` command for defining functions (#35) We also want to improve tab-completion in various ways, which also involves working with very similar types of incomplete input. Most of the enhancements we have in mind will only be possible if we know more exactly what we're completing, and re-using some of the parsing code to understand the input seemed like the most logical approach. Specific issues are: - Support the same tab completion options as zsh (#25) - Add tab completion for options (#80) - Auto complete stash commands (#220) - Tab completion only works for the first command on the line (#261) Note that this commit doesn't implement any of these enhancements, it just makes them more likely to happen in the future. Implementation details ====================== - Introduces equality methods on argument objects, used to testing parser output. - git-prefix correction (i.e. interpreting `git foo` as `foo` when `help.autocorrect` is set) has moved from the Parser to the GitCommand class. - The subshell implementation in this commit is not very good. It will be significantly improved in the next couple of commits, but it seemed too big of a change to roll into this one.
After the tab completion improvements introduced in #296, #304, #310, #311, #312, #313, I think the tab completion is at least as good as the zsh completion that ships with Git, if not better. Thanks, @mike-burns, for the comment on this issue that inspired the DSL-based approach. There are further specific improvements I'd like to make to tab completion, documented in #314, #315, #316, #317, #318, and #319. Given the recent improvements, and all of those new more-specific issues, I'm going to close this. |
Completion in general is very lacking compared to ZSH, but I'm not sure we can anything about that.
The text was updated successfully, but these errors were encountered: