Giter VIP home page Giter VIP logo

Comments (8)

vE5li avatar vE5li commented on June 5, 2024 1

Although the snippet I sent earlier was just a random example, I think it also shows a problem I would run into with layers. If I wanted to handle the key 'd' in my layer, I would be unable to trigger a lower binding that is also bound to 'd'

from nvim-libmodal.

Iron-E avatar Iron-E commented on June 5, 2024 1

Apologies if that was vague! I'll try to be more specific. From what I understand, this issue is related to doing something like this:

libmodal.mode.enter('FOO', function()
  vim.api.nvim_input('dd')
end)

…and the mode eats the dd input? (If I'm not understanding that right, please let me know / post a small example and I can help better).

Based on my understanding, the following is a solution:

libmodal.mode.enter('FOO', {
  d = 'norm! dd', -- map 'd' to 'dd'
  f = function() -- map `f` to a function
    vim.api.nvim_command 'norm! dd' -- (or nvim_input)
  end, 
})

There are also some benefits to providing a mapping table like this, such as automatic generation of a mode summary (i.e. press ? to see available mappings). It won't be a great solution if you need to dynamically respond to user actions (i.e. the available mappings aren't predetermined), although this can be somewhat mitigated by using submodes.

from nvim-libmodal.

vE5li avatar vE5li commented on June 5, 2024 1

Thank you for taking the time to elaborate. I think that should cover my use case, especially with the help of submodes (thanks for the hint)

from nvim-libmodal.

Iron-E avatar Iron-E commented on June 5, 2024

Would a :h libmodal-layer help in this case?

from nvim-libmodal.

vE5li avatar vE5li commented on June 5, 2024

Sadly not really. I don't want unrecognized input to be passed through, but rather the ability to trigger other "lower" bindings in a very controlled manner.

from nvim-libmodal.

Iron-E avatar Iron-E commented on June 5, 2024

I see. I'll do some investigation.

from nvim-libmodal.

Iron-E avatar Iron-E commented on June 5, 2024

I had a thought, would something like this work? You can pass a table of possible inputs to the mode and anything which executes there is taken as raw input (and if it doeen't still do that, it's most certainly a bug)

If that doesn't fit your use case I can investigate it further.

from nvim-libmodal.

vE5li avatar vE5li commented on June 5, 2024

I'm sorry but you're going to have to be a bit more specific, I don't really understand how this could solve my issue

from nvim-libmodal.

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.