zyedidia / micro

A modern and intuitive terminal-based text editor
https://micro-editor.github.io
MIT License
25.04k stars 1.17k forks source link

How to modify / disable a built-in plugin? #3014

Closed jabbalaci closed 11 months ago

jabbalaci commented 11 months ago

micro has a built-in plugin called "comment", which is very useful but I have an issue with this. I'm playing with a new terminal emulator (wezterm), and according to "> raw", when I press Ctrl-/, it is recognized as Ctrl-_, which is the same as CtrlUnderscore. The comment plugin adds this line:

"CtrlUnderscore": "lua:comment.comment",

However, what I want is this:

"CtrlUnderscore": "lua:comment.comment,CursorDown,StartOfTextToggle",

That is, when I comment a line, I want the cursor to move down 1 line, thus I can comment several lines easily. However, the built-in plugin overwrites my setting each time I launch micro :(

How could this issue be resolved? If the comment plugin didn't register its keybinding, there would be no problem.

jabbalaci commented 11 months ago

In what order are the plugins loaded? First the built-ins, then the custom ones in ~/.config/plug? Are they loaded in alphabetical order?

I tried to make a custom plugin that would overwrite the setting of the built-in plugin "comment":

VERSION = "0.1.0"

local config = import("micro/config")

function init()
    config.TryBindKey("CtrlUnderscore", "lua:comment.comment,CursorDown,StartOfTextToggle", true)
    config.Reload()
end

However, when I check bindings.json, it's not modified :(

Update: Sorry, I made a mistake previously. It actually works!

JoeKar commented 11 months ago

However, what I want is this: "CtrlUnderscore": "lua:comment.comment,CursorDown,StartOfTextToggle",

When I define that in my bindings.json then it isn't overwritten by the comment plugin, because it uses TryBindKey(..., ..., false) so not overwriting user defined bindings.

Update:

Update: Sorry, I made a mistake previously. It actually works!

If this was meant to tell that the issue is obsolete, then please close it. ;)

jabbalaci commented 11 months ago

Thanks for the reply! Now that I tried again, it's not overwritten. Sorry, it can be closed.