Giter Site home page Giter Site logo

Comments (17)

niten94 avatar niten94 commented on June 17, 2024 1

A line can usually be added again in bindings.json because a key binding is being tried to be set in a plugin when micro is opened. I think you were trying to delete a line so that nothing would happen when pressing a key, but the action can be set as None so that nothing would happen.

For example, the file would be like this when setting the action of Alt-/ as None:

{
    "Alt-/": "None",
    "Ctrl-F2": "command:toggleBookmark",
    "CtrlShift-F2": "command:clearBookmarks",
    "F2": "command:nextBookmark",
    "Shift-F2": "command:prevBookmark"
}

from micro.

dustdfg avatar dustdfg commented on June 17, 2024 1

Got the OLD file !!!
From WHERE ?
So ?

Because micro at start regenerates that file!

from micro.

JoeKar avatar JoeKar commented on June 17, 2024 1

The bindings for bookmarks were set BY ME NOT by the plugin for a start.

https://github.com/haqk/micro-bookmark/blob/baca5fdd6a6475c3b8f9b1bb08192044ffcfff81/bookmark.lua#L401-L405

The plugin tells me something different...

from micro.

dmaluka avatar dmaluka commented on June 17, 2024 1

As a partial workaround we can (can we?) not to rewrite bindings.json if nothing differs so if bindings weren't changed by plugin, user at least won't see annoying "file is changed"...

Isn't that how it already works? (Unless the last argument to TryBindKey is true, which I also mentioned in #2647, but that's not a very common case.)

from micro.

dustdfg avatar dustdfg commented on June 17, 2024

Micro writes bindings.json before opening anything. So you start micro. Micro starts plugins. Plugins register bindings. Micro rewrites bindings.json. Micro finishes initialization and starts to open file you wanted to open. It looks to already overwritten bindings.json...

You can even delete the line. Open any file but not bindings.json. Close micro. Open bindings.json via vim and see that it was rewritten

The file on disk has changed. Reload file (y,n,esc) is partially solved by #3009 but IIUC only for settings.json

from micro.

bloodofdracula avatar bloodofdracula commented on June 17, 2024

Sorry. I stand my ground.

Start with a small bindings built with vim

Here;

{
"Alt-/": "lua:comment.comment",
"Ctrl-F2": "command:toggleBookmark"
}

:wq!

cat .config/micro/bindings.json shows the file (4 lines) as before.

micro .config/micro/bindings.json

Got msg The file on disk has changed. Reload file (y,n,esc)

Did not reply. Did a cat on another terminal for .config/micro/bindings.json and the file has ALREADY BEEN CHANGED by starting micro. It is.

$ cat .config/micro/bindings.json
{
"Alt-/": "lua:comment.comment",
"Ctrl-F2": "command:toggleBookmark",
"CtrlShift-F2": "command:clearBookmarks",
"F2": "command:nextBookmark",
"F5": "lua:wc.wordCount",
"Shift-F2": "command:prevBookmark"
}

Reply n to micro; Exit micro

micro .config/micro/bindings.json

Got the OLD file !!!

From WHERE ?
So ?

Easy to reproduce.

from micro.

dustdfg avatar dustdfg commented on June 17, 2024

It doesn't open old version. It generates it each time you run micro. You can open ANY file with micro and it will regenerate the bindings file

from micro.

bloodofdracula avatar bloodofdracula commented on June 17, 2024

Sorry you are wrong. THERE IS NO reason fro micro to reinstate configuration lines suppressed by user with the user file at .config/micro/bindings.json

They are user bindings NOT system bindings.

On top micro is adding old user bindings (suppressed by me...).

from micro.

dustdfg avatar dustdfg commented on June 17, 2024

They are the bindings set by plugins.

from micro.

dustdfg avatar dustdfg commented on June 17, 2024

You don't believe me. Just disable your bookmark plugin Ctrl+e and then type> set bookmark off after it you can again edit your file to:

{
"Alt-/": "lua:comment.comment",
"Ctrl-F2": "command:toggleBookmark"
}

Micro won't add the lines that was configured by bookmark plugin

from micro.

bloodofdracula avatar bloodofdracula commented on June 17, 2024

The bindings for bookmarks were set BY ME NOT by the plugin for a start.

From bookmarks plugin page...

How to use:

While editing, press the default key (F11) to set a bookmark at the current line.
You can also use the command toggle_bookmark from the (Ctrl+E) prompt
Press the default key (F10) to loop through all the bookmarks
You can also use the command next_bookmark from the (Ctrl+E) prompt
To remove a bookmark, press the default key again while the cursor is on the bookmarked line

from micro.

bloodofdracula avatar bloodofdracula commented on June 17, 2024

You were right and it is a strange design for configuration files. I did a check within the bookmark plugin before reading your last msg.

    config.TryBindKey("Ctrl-F2", "command:toggleBookmark", false)
config.TryBindKey("CtrlShift-F2", "command:clearBookmarks", false)
config.TryBindKey("F2", "command:nextBookmark", false)
config.TryBindKey("Shift-F2", "command:prevBookmark", false)

In fact I did not know the bindings..and took the same I was using with Sublime-Text...I was convinced I did it.

It can be confusing. If you start like this

micro .config/micro/bindings.json

micro load the old bindings.json (modified using vim) and after loading plugins (and adjusting bindings.json) tell you file has been changed...

If you start like this

micro and after opening .config/micro/bindings.json no msg of course.

Thanks anyway.

from micro.

dmaluka avatar dmaluka commented on June 17, 2024

it is a strange design for configuration files.

Yes, it is. If I was @zyedidia I would design it differently.

But we can't just change it now, since we need to preserve compatibility with existing plugins and so on, so...

Anyway, @niten94 has already mentioned the solution for preventing a plugin from forcing its default binding for a key when there is no user-defined binding: bind this key to None.

from micro.

dustdfg avatar dustdfg commented on June 17, 2024

But we can't just change it now, since we need to preserve compatibility with existing plugins and so on, so...

As a partial workaround we can (can we?) not to rewrite bindings.json if nothing differs so if bindings weren't changed by plugin, user at least won't see annoying "file is changed"...

from micro.

dustdfg avatar dustdfg commented on June 17, 2024

Yeah, you are right it is a last argument of TryBindKey in one of my test plugins

from micro.

bloodofdracula avatar bloodofdracula commented on June 17, 2024

Yes a solution is to bind some keys to None if you do want plugins to populate keys definition (or to change plugins yourself...).
I was using vi (yep..), vim, neovim, emacs, Sublime-Text, gedit, kate NOT a single editor or plugin's editor is changing configuration files during start.
Plugins are offering sometime default key not anything else. You can of course replace the default.
At least emacs has a discovery help..C-h k to discover if a key sequence is used and vim/neovim have plugin(s) to do it.

from micro.

dustdfg avatar dustdfg commented on June 17, 2024

Currently we have `

At least emacs has a discovery help..C-h k to discover if a key sequence is used and vim/neovim have plugin(s) to do it.

Now we have showkey command that do the same

from micro.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.