Skip to content

Conversation

Neko-Box-Coder
Copy link
Contributor

Currently, it is quite difficult to tell which plugins are built-in and which ones are not when listing. For example:

initlua (0.0.0-unknown)
MicroOmni (0.4.1)
filemanager2 (1.3.0)
gitStatus (0.1.5)
autocomplete_tooltip (0.0.1)
misspell (0.2.0)
quoter (1.0.0)
autoclose (1.0.0)
comment (1.0.0)
diff (1.0.0)
ftoptions (1.0.0)
literate (1.0.0)
status (1.0.0)

With this change, it explicitly tells you which ones are builtin, like this

initlua (built-in) (0.0.0-unknown)
MicroOmni (0.4.1)
filemanager2 (1.3.0)
gitStatus (0.1.5)
autocomplete_tooltip (0.0.1)
misspell (0.2.0)
quoter (1.0.0)
autoclose (built-in) (1.0.0)
comment (built-in) (1.0.0)
diff (built-in) (1.0.0)
ftoptions (built-in) (1.0.0)
literate (built-in) (1.0.0)
status (built-in) (1.0.0)

@JoeKar
Copy link
Collaborator

JoeKar commented Jul 21, 2025

I'd prefer to have (built-in) behind the version number (1.0.0).

...or...

Right now the version number of internal plugins is somehow useless, since we never update them and so they become superfluous.
At this point we could simply stop printing the version number of internal plugins and directly post-fix them with (built-in):

autoclose (built-in)
comment (built-in)
diff (built-in)
ftoptions (built-in)
literate (built-in)
status (built-in)

We can proceed printing their version number in case they're overwritten by the user.

@Neko-Box-Coder
Copy link
Contributor Author

Neko-Box-Coder commented Jul 21, 2025

Right now the version number of internal plugins is somehow useless, since we never update them and so they become superfluous. At this point we could simply stop printing the version number of internal plugins and directly post-fix them with (built-in):

autoclose (built-in)
comment (built-in)
diff (built-in)
ftoptions (built-in)
literate (built-in)
status (built-in)

Sounds good to me.

We can proceed printing their version number in case they're overwritten by the user.

wdym exactly? That's possible for the internal plugins?

@JoeKar
Copy link
Collaborator

JoeKar commented Jul 21, 2025

wdym exactly? That's possible for the internal plugins?

We should print the version number in case ~/.config/micro/plug/comment overwrites the built-in one and the respective flag (Default) isn't set.

BTW:
Isn't Builtin the better flag name than Default?

@Neko-Box-Coder
Copy link
Contributor Author

We should print the version number in case ~/.config/micro/plug/comment overwrites the built-in one and the respective flag (Default) isn't set.

I see, if it gets overridden, it will be treated as user plugin right? So the version will be printed but the (built-in) text won't be there. Unless the built-in version of the plugin also comes up when we do -plugin list, which I don't know, will try that later.

BTW:
Isn't Builtin the better flag name than Default?

I don't mind changing it to Builtin but I am just keeping consistent with plugin.go because Default is used there which gets propagated to the plugin installer

@JoeKar
Copy link
Collaborator

JoeKar commented Jul 21, 2025

I see, if it gets overridden, it will be treated as user plugin right?

Yes.

I don't mind changing it to Builtin but I am just keeping consistent with plugin.go because Default is used there which gets propagated to the plugin installer

I see and yes, we should keep them in sync.

@Neko-Box-Coder
Copy link
Contributor Author

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 Builtin? Can't tell which one you meant 😂

@JoeKar
Copy link
Collaborator

JoeKar commented Jul 22, 2025

Builtin is somehow more self explaining than Default...at least for me. It wouldn't require the additional comment.

@Neko-Box-Coder
Copy link
Contributor Author

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.

❯ ./micro -plugin list
The following plugins are currently installed:
initlua (built-in)
MicroOmni (0.4.1)
comment (1.1.0)
filemanager2 (1.4.0)
gitStatus (0.1.5)
autocomplete_tooltip (0.0.1)
misspell (0.2.0)
quoter (1.0.0)
autoclose (built-in)
diff (built-in)
ftoptions (built-in)
literate (built-in)
status (built-in)

@@ -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
Copy link
Collaborator

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.

@dmaluka
Copy link
Collaborator

dmaluka commented Jul 28, 2025

% ./micro -plugin list
The following plugins are currently installed:
initlua (built-in)
...

initlua is built-in?

@Neko-Box-Coder
Copy link
Contributor Author

initlua is built-in?

It comes with micro, so I guess it is? I am not sure, it's kinda a special case.

@dmaluka
Copy link
Collaborator

dmaluka commented Jul 28, 2025

It doesn't come with micro, it is created by the user, isn't it?

@Neko-Box-Coder
Copy link
Contributor Author

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 Builtin to false, it will show initlua (0.0.0-unknown) instead.

What should the version text be?

@Neko-Box-Coder
Copy link
Contributor Author

Or I can do a special check for initlua when listing the plugin, in that case do we just show initlua?

@dmaluka
Copy link
Collaborator

dmaluka commented Jul 28, 2025

It neither is built-in nor has a version, so we shouldn't show either?

@Neko-Box-Coder
Copy link
Contributor Author

Something like this now:

❯ ./micro -plugin list
The following plugins are currently installed:
initlua
MicroOmni (0.4.1)
filemanager2 (1.4.0)
gitStatus (0.1.5)
autocomplete_tooltip (0.0.1)
misspell (0.2.0)
quoter (1.0.0)
autoclose (built-in)
comment (built-in)
diff (built-in)
ftoptions (built-in)
literate (built-in)
status (built-in)

@@ -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 {
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

Copy link
Collaborator

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"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

Copy link
Collaborator

@JoeKar JoeKar Jul 29, 2025

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).

Copy link
Contributor Author

@Neko-Box-Coder Neko-Box-Coder Jul 29, 2025

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.

Copy link
Collaborator

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.

@Neko-Box-Coder Neko-Box-Coder force-pushed the ShowBuiltinPlugins branch 2 times, most recently from 131e8b5 to d3b42b6 Compare July 29, 2025 18:09
@@ -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.")
Copy link
Collaborator

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?

@@ -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" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

  1. 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).

  1. What about UpdatePlugins()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. 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).

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.

Copy link
Collaborator

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.

Copy link
Contributor Author

@Neko-Box-Coder Neko-Box-Coder Jul 29, 2025

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.

@@ -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")
Copy link
Collaborator

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

@Neko-Box-Coder Neko-Box-Coder force-pushed the ShowBuiltinPlugins branch 2 times, most recently from 3951d7c to 4bd40c7 Compare July 29, 2025 23:26
// 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
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

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.")
Copy link
Contributor

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).

Copy link
Contributor Author

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."?

Copy link
Contributor

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?

Copy link
Collaborator

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...

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.

@dmaluka dmaluka merged commit 7a252f4 into zyedidia:master Aug 20, 2025
6 checks passed
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.

4 participants