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

lib/plugin: support plugin pinning #119

Merged
merged 3 commits into from
Feb 13, 2017
Merged

lib/plugin: support plugin pinning #119

merged 3 commits into from
Feb 13, 2017

Conversation

jedahan
Copy link
Member

@jedahan jedahan commented Feb 10, 2017

This adds geometry_prompt_plugin_check(), which will be run to determine if we are in a context where it makes sense to display the plugin

A plugin can be pinned by appending a * to skip this check.

How can we could remove the quoting requirement for pins?

GEOMETRY_PROMPT_PLUGINS+=(rustup*)

instead of

GEOMETRY_PROMPT_PLUGINS+=('rustup*')

@jedahan
Copy link
Member Author

jedahan commented Feb 10, 2017

Some alternatives to * at the end

  1. plugin. looks like a typo to me
export GEOMETRY_PROMPT_PLUGINS=(exec_time git node rustup.)
  1. .plugin look like a pin, and less like a typo
export GEOMETRY_PROMPT_PLUGINS=(exec_time git node .rustup)
  1. plugin! looks alarming
export GEOMETRY_PROMPT_PLUGINS=(exec_time git node rustup!)

@jedahan jedahan requested review from desyncr and frm February 10, 2017 21:17
@jedahan jedahan self-assigned this Feb 10, 2017
Copy link
Member

@desyncr desyncr left a comment

Choose a reason for hiding this comment

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

I have no issues with quoting. Using '*' is cool to me.

@desyncr
Copy link
Member

desyncr commented Feb 10, 2017

Watch out for API breaking changes. Either we should be backward compatible or start tagging/versioning.

My concern is with existing custom plugins that might break with a geometry update.

@jedahan
Copy link
Member Author

jedahan commented Feb 11, 2017

One thing I saw zplug do, which I like, is to release a version that prints out deprecation messages, then wait a month, then remove support. We can do that here, though we might be able to get away with just ignoring _check() if it does not exist, which would be backwards compatible.

Copy link
Member

@frm frm left a comment

Choose a reason for hiding this comment

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

Overall looks pretty good to me. Just some notes on the reads and a note on updating the node plugin.

Thanks for taking the time to add checks to the current plugins!

README.md Outdated
@@ -75,6 +76,12 @@ These plugins will load and display on the right prompt. You can check the
documentation and configuration for each specific plugin in the
[plugins](/plugins) directory.

You can pin* a plugin by appending `*` to the end of the name. Geometry will always render the plugin.
Copy link
Member

Choose a reason for hiding this comment

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

I would add a note here on pinning, since when reading this document from the start you don't really get what it is. If I was a new user, I would think "wait, so plugins don't always render? Why not?"

What do you think of just prepending something like "Some plugins only render when you are in a given directory or in the presence of a given file. You can have them always render by pinning the plugin. (...)"?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea, prepended a sentence about pinning

@@ -23,15 +23,15 @@ configuration files.


```sh
GEOMETRY_PROMPT_PLUGINS=(virtualenv docker_machine exec_time git hg)
GEOMETRY_PROMPT_PLUGINS=(virtualenv docker_machine exec_time git hg 'rustup*')
```

*Note: if you're not sure where to put geometry configs, just add them to your `.zshrc`*
Copy link
Member

Choose a reason for hiding this comment

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

For the same reasons as before, if I missed the pinning section, I would be confused with the 'rustup*'. Maybe add a link saying "if you're not sure what's with the * you can read about it here" ? What's your take?

Copy link
Member Author

@jedahan jedahan Feb 12, 2017

Choose a reason for hiding this comment

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

Added a note beneath the current note

# Do nothing if we're not in a repository
[ -d $PWD/.git ] || return 1
}
```
Copy link
Member

Choose a reason for hiding this comment

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

👍 nice example, clear explanation

```sh
GEOMETRY_PROMPT_PLUGINS+=('rustup*')
```

Copy link
Member

Choose a reason for hiding this comment

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

Note about pinning here? Since it is not required the plugin with the *

Copy link
Member Author

Choose a reason for hiding this comment

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

removed the pinning

GEOMETRY_NPM_VERSION="$(npm --version 2> /dev/null)"
echo "$GEOMETRY_NODE_NPM_VERSION $GEOMETRY_NODE_VERSION ($GEOMETRY_NPM_VERSION)"
fi
GEOMETRY_NODE_VERSION="$(node -v 2> /dev/null)"
Copy link
Member

Choose a reason for hiding this comment

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

Just a note: don't forget to update this with the code recently merged from #108

Copy link
Member Author

Choose a reason for hiding this comment

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

Rebased against master, will force push to this PR soon

@frm frm mentioned this pull request Feb 12, 2017
@frm
Copy link
Member

frm commented Feb 12, 2017

I'm good with 'plugin*', don't have any strong feelings on that. None of the other suggestions do it better IMO.

I moved the version discussion to #121 since a lot has been said in different PRs and issues. Might as well have a dedicated issue for that 😄

Jonathan Dahan added 2 commits February 12, 2017 12:58
This adds geometry_prompt_plugin_check(), which
will be run to determine if we are in a context
where it makes sense to display the plugin

A plugin can be pinned by appending a * to skip this check

How can we could remove the quoting requirement for pins?

  GEOMETRY_PROMPT_PLUGINS+=(rustup*)

instead of

  GEOMETRY_PROMPT_PLUGINS+=('rustup*')
@jedahan
Copy link
Member Author

jedahan commented Feb 12, 2017

I really don't like the extra ritual for globbing, this patch proposes +plugin for pinning

@jedahan
Copy link
Member Author

jedahan commented Feb 12, 2017

I also made it backwards compatible in that, if you don't have a check function for a plugin, it just runs render. That way we don't need to version yet.

@frm
Copy link
Member

frm commented Feb 13, 2017

Looking great! @desyncr any takes?

Copy link
Member

@desyncr desyncr left a comment

Choose a reason for hiding this comment

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

Two small things. Should be good to go 👍

README.md Outdated
@@ -75,6 +76,13 @@ These plugins will load and display on the right prompt. You can check the
documentation and configuration for each specific plugin in the
[plugins](/plugins) directory.

Some plugins only render when you are in a given directory or in the presence of a given file.
You can have those plugins always render by pinning a `+` before the name
Copy link
Member

Choose a reason for hiding this comment

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

"before the name" => "before the name:"

```

*Note: if you're not sure where to put geometry configs, just add them to your `.zshrc`*

*Note: the `+` before rustup means the plugin is pinned, and will always render, regardless of context*
Copy link
Member

Choose a reason for hiding this comment

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

"pinned" should like to the "Pinning" section.

@jedahan
Copy link
Member Author

jedahan commented Feb 13, 2017

So, should I squash the three commits, rewrite the commit message, and push? Not sure what's good protocol.

@frm
Copy link
Member

frm commented Feb 13, 2017

Precisely that. Squash, merge, push. Or just change the big green button on GitHub to say "Squash and merge" and hit that.

@jedahan jedahan merged commit 02836c5 into master Feb 13, 2017
@jedahan jedahan deleted the plugin-pinning branch February 13, 2017 17:14
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.

3 participants