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

WIP Completion for fish #829

Merged
merged 1 commit into from Sep 6, 2018
Merged

Conversation

scorphus
Copy link
Contributor

@scorphus scorphus commented Aug 26, 2018

WIP – Please do not merge yet

I'm submitting this PR in its early stage to get some preliminar feedbacks and reviews, which are more than welcome.

  • Completion function and command line parser reviewed
  • Documentation added
  • Tested by another Fish user

@kovidgoyal
Copy link
Owner

I'm not familiar with fish so I cannot comment on that part of it. In general the way completion is supposed to work is that the shell should send a list of words each separated from the next by a newline upto the word the cursor is currently on. If the cursor is not on a word (i.e. it is after a psace) there should be two newlines at the end. You can change this scheme as you like by implementing an appropriate input_parser in complete.py for your shell.

kitty then responds by printing out a shell script on stdout that is evaled by the shell to set the completions.

After you have implemented this scheme you should also add some instructions to docs/index.rst about how to enable the completions in fish, just as there are for bash and zsh.

@scorphus
Copy link
Contributor Author

Great! Looks like I'm on track.

Fish's completion works quite differently from Bash and Zsh. I've integrated many other tools to Fish in the past so I'll hopefully end up with a decent, working completion.

Thanks for your initial review, @kovidgoyal 👍 I'll finish this ASAP (on my free time, of course).

@skorokithakis
Copy link
Contributor

As a fish user, I would love it if this got merged.

@scorphus
Copy link
Contributor Author

scorphus commented Sep 5, 2018

Me too, @skorokithakis! I think I'll have some free time tonight to advance on this! Stay tuned 😃

@scorphus
Copy link
Contributor Author

scorphus commented Sep 5, 2018

@kovidgoyal, Please review again. Would you like a test and feedback from another Fish user?

BTW, @skorokithakis, did you have the chance to test this?

Thanks!

@@ -86,6 +94,11 @@ def bash_input_parser(data):
return words, new_word


@input_parser
def fish_input_parser(data):
return data.rstrip().splitlines(), True
Copy link
Owner

@kovidgoyal kovidgoyal Sep 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not look right to me. new_word should be True only if the cursor is after a space.

For example:

kitty +kitt<cursor>

should have new_word False, while

kitty +kitten <cursor>

should have new_word True

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thing is that completions work quite differently in Fish than in other command line shells. As Fish interprets and filters the completions suggestions, there's no need to work on completing the current partial token. Only if we're doing something really tricky with the partial token. In that sense, kitty +complete fish will always receive complete tokens.

@kovidgoyal kovidgoyal merged commit 1b7244f into kovidgoyal:master Sep 6, 2018
@scorphus scorphus deleted the fish-completion branch September 6, 2018 08:42
@kovidgoyal
Copy link
Owner

OK as I said I dont know anything about fish -- so that was just a comment based on the other shells. In any case I have merged, since even if it does not work perfectly it is better than nothing.

@scorphus
Copy link
Contributor Author

scorphus commented Sep 6, 2018

Great! I'll ask my dear friend @wpjunior to test it and post his feedback!

No problem :-) I just wanted to explain that. I should have done this in the commit message – will do so the next time ;-)

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 this pull request may close these issues.

None yet

3 participants