-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Adding the ability to differentiate builtin plugins when listing #3810
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
Conversation
I'd prefer to have ...or... Right now the version number of internal plugins is somehow useless, since we never update them and so they become superfluous.
We can proceed printing their version number in case they're overwritten by the user. |
Sounds good to me.
wdym exactly? That's possible for the internal plugins? |
We should print the version number in case BTW: |
I see, if it gets overridden, it will be treated as user plugin right? So the version will be printed but the
I don't mind changing it to |
Yes.
I see and yes, we should keep them in sync. |
Yes as in keep it as it is or yes as in change them both to |
|
424aefa
to
d058948
Compare
This is what the latest changes look like. I overrided "comment" with a different version just to see how it acts, seems good to me.
|
d058948
to
e5e07e6
Compare
internal/config/plugin.go
Outdated
@@ -71,7 +71,7 @@ type Plugin struct { | |||
Info *PluginInfo // json file containing info | |||
Srcs []RuntimeFile // lua files | |||
Loaded bool | |||
Default bool // pre-installed plugin | |||
Builtin bool // pre-installed plugin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gofmt
And, what @JoeKar said in #3810 (comment) when advocating for renaming it: "It wouldn't require the additional comment."?
...IMHO Default
is a fine name. But since you guys are eager to rename it, I'm fine with that too.
initlua is built-in? |
It comes with micro, so I guess it is? I am not sure, it's kinda a special case. |
It doesn't come with micro, it is created by the user, isn't it? |
Ah, didn't notice I have an empty init.lua in my config. Okay, if I set What should the version text be? |
Or I can do a special check for initlua when listing the plugin, in that case do we just show |
It neither is built-in nor has a version, so we shouldn't show either? |
e5e07e6
to
b645494
Compare
Something like this now:
|
@@ -665,7 +670,7 @@ func PluginCommand(out io.Writer, cmd string, args []string) { | |||
for _, plugin := range args { | |||
// check if the plugin exists. | |||
for _, p := range Plugins { | |||
if p.Name == plugin && p.Default { | |||
if p.Name == plugin && p.Builtin { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And if this is initlua?
Although, this part is already buggy without this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, I have just updated initlua to be builtin then, should error out now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, is it built-in or not built-in?
We are introducing mess where we could easily avoid it? For example, we could just add an explicit check for "initlua"
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It neither is built-in nor has a version, so we shouldn't show either?
Actually I was thinking the same, but it has an advantage to print its presence:
You see that there might be one more callback routine affecting micro
's behavior.
This we can then request directly within the issue template (when we use the new GitHub template mechanism after micro
's move).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It neither is built-in nor has a version, so we shouldn't show either?
Actually I was thinking the same, but it has an advantage to print its presence: You see that there might be one more callback routine affecting
micro
's behavior.
I thought @dmaluka meant only the version (bracketed) text. If @dmaluka meant the whole entry like you said then I agree with you @JoeKar , I would prefer it being shown and not hidden away from the user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I meant only the bracketed text.
131e8b5
to
d3b42b6
Compare
internal/config/plugin_installer.go
Outdated
@@ -665,7 +670,7 @@ func PluginCommand(out io.Writer, cmd string, args []string) { | |||
for _, plugin := range args { | |||
// check if the plugin exists. | |||
for _, p := range Plugins { | |||
if p.Name == plugin && p.Default { | |||
if (p.Name == plugin && p.Builtin) || p.Name == "initlua" { | |||
fmt.Fprintln(out, "Default plugins cannot be removed, but can be disabled via settings.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are renaming "default" to "built-in" all over the place anyway, don't we update to update this log message as well?
internal/config/plugin_installer.go
Outdated
@@ -665,7 +670,7 @@ func PluginCommand(out io.Writer, cmd string, args []string) { | |||
for _, plugin := range args { | |||
// check if the plugin exists. | |||
for _, p := range Plugins { | |||
if p.Name == plugin && p.Default { | |||
if (p.Name == plugin && p.Builtin) || p.Name == "initlua" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Now, when successfully removing any plugin, micro prints "Default plugins cannot be removed..."
Although the plugin still ends up being successfully removed, thanks to continue
(BTW I'm not sure why we have continue
instead of break
here).
- What about
UpdatePlugins()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Now, when successfully removing any plugin, micro prints "Default plugins cannot be removed..."
Although the plugin still ends up being successfully removed, thanks to
continue
(BTW I'm not sure why we havecontinue
instead ofbreak
here).
yeah but we do print out the plugins we have removed, not the best UI/UX but it works. Trying to not rewrite things unless necessary in the PR to not get sidetracked. I have changed continue
to break
tho.
2. What about
UpdatePlugins()
?
Okay yeah, just updated that as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh god. I was really hoping I wouldn't have to point out the obvious. It prints "Default plugins cannot be removed..." because you for some reason put || p.Name == "initlua"
outside the parentheses.
(And before you rush to move the parentheses, another obvious thing: it is completely pointless to check p.Name == "initlua"
at each iteration of the loop. We can just check plugin == "initlua"
before entering the loop.)
So, now that you changed continue
to break
(which I mentioned just as a side note), without fixing the issue that you've introduced, as a result it not just needlessly says "Default plugins cannot be removed" but also fails to remove any plugins (and honestly says "No plugins removed"). Which you should have noticed if you tested your changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooops, my bad. Got a bit tired and mixed up with similar change in the UpdatePlugins
while splitting the commit into two.
Should be good now.
internal/config/plugin_installer.go
Outdated
@@ -687,7 +692,13 @@ func PluginCommand(out io.Writer, cmd string, args []string) { | |||
plugins := GetInstalledVersions(false) | |||
fmt.Fprintln(out, "The following plugins are currently installed:") | |||
for _, p := range plugins { | |||
fmt.Fprintf(out, "%s (%s)\n", p.Pack().Name, p.Version) | |||
if p.Pack().Name == "initlua" { | |||
fmt.Fprintf(out, "initlua\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: just to keep it in line with the below printfs, we could fmt.Fprintf(out, "%s\n", p.Pack().Name)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
3951d7c
to
4bd40c7
Compare
internal/config/plugin_installer.go
Outdated
// check if the plugin exists. | ||
for _, p := range Plugins { | ||
if p.Name == plugin && p.Builtin { | ||
fmt.Fprintln(out, "Built-in plugins cannot be removed, but can be disabled via settings.") | ||
continue | ||
break |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you really want to change it to break
right away, what about the other continue
below, in the successful case?
And before you rush to change it to break
as well: have you investigated what exactly would be the consequences of these changes? What if there actually are multiple plugins with the same name? We probably don't want to allow that, but do we already prevent that? And if we don't, shouldn't we first of all implement preventing that? (In particular, a special case: we probably want to disallow ~/.config/micro/plug/initlua/
, since the name initlua
is reserved for init.lua
? Do we already do that?)
If you don't want to investigate that now, just leave this continue
alone.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... If you don't want to investigate that now, just leave this continue alone.
It's fine, I reverted the change. I thought it was an innocent change when you pointed it out initially.
And before you rush to change it to break as well: ...
This sounds quite harsh, to be honest. I did something by mistake earlier in this PR (as well as not testing things out) doesn't mean you should put it in this way, twice.
I understand those mistakes are quite dumb, but still, I don't like being talked down to like that. Stating any concerns/questions/corrections plainly is enough.
What if there actually are multiple plugins with the same name?
Anyway yes, we should leave it as continue
then since if an unlikely situation of a plugin that shares the same name as the built in ones, then the user can still be able to remove it.
4bd40c7
to
21edb89
Compare
internal/config/plugin_installer.go
Outdated
if p.Name == plugin && p.Default { | ||
fmt.Fprintln(out, "Default plugins cannot be removed, but can be disabled via settings.") | ||
if p.Name == plugin && p.Builtin { | ||
fmt.Fprintln(out, "Built-in plugins cannot be removed, but can be disabled via settings.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When running -plugin remove comment literate
, this message is printed multiple times, which looks a bit odd IMO.
Why we show a generic error message ? Wouldn't it be better to specify which of the provided plugins are built-in?
Also, it would be helpful to display a clearer message when trying to remove a plugin that isn't installed? e.g. Unknown plugin "asd"
(similar to the behavior of -plugin install asd
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we show a generic error message ? Wouldn't it be better to specify which of the provided plugins are built-in?
Yeah, I can specify the plugin name in the message but it dooesn't really bother me too much since it tells me what plugins are removed at the end anyway.
I can add it, maybe something like "xxxx is a built-in plugin which cannot be removed, but can be disabled via settings."?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can add it, maybe something like "xxxx is a built-in plugin which cannot be removed, but can be disabled via settings."?
Looks good.
Nit: Should "Built-in plugins cannot be removed, but can be disabled via settings." include a period? Looking at other messages in the plugin manager, some have a period and some don't looks it's a bit inconsistent.
Side-quests
-
There are a couple
fmt.Fprintln
calls in plugin_installer.go with an extra space. example -
Enhancing the final output of
-plugin install
* to explicitly list which plugins were installed (similar to-plugin remove
) would be a good idea?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Should "Built-in plugins cannot be removed, but can be disabled via settings." include a period? Looking at other messages in the plugin manager, some have a period and some don't looks it's a bit inconsistent.
One might argue that this message is rather long (while others a rather short), so the period is useful to see that the sentence finally ends...
- There are a couple
fmt.Fprintln
calls in plugin_installer.go with an extra space. example
Fixed in 094b02d
- Enhancing the final output of
-plugin install
* to explicitly list which plugins were installed (similar to-plugin remove
) would be a good idea?
To be fixed, if anyone is willing to.
Currently, it is quite difficult to tell which plugins are built-in and which ones are not when listing. For example:
With this change, it explicitly tells you which ones are builtin, like this