Giter Club home page Giter Club logo

Comments (6)

nullromo avatar nullromo commented on July 22, 2024 1

Thanks for the reply. Looks like this is a feature missing from neovim that may (eventually) be added: neovim/neovim#15527.

In that case, feel free to close this issue as I feel it's a little too far out of the scope of hardtime at the moment.

from hardtime.nvim.

nullromo avatar nullromo commented on July 22, 2024

I tried adding a custom hint like this

hints = {
    ['xi'] = {
        message = function()
            return 'Use s instead of xi'
        end,
        length = 2,
    },
},

but I can't get it to trigger. I tried with length = 1, length = 2, and length = 3.

Instead of getting my custom message, I just get the same old message. Additionally, I tried adding another hint:

hints = {
    ['xx'] = {
        message = function()
            return 'Do not use x multiple times consecutively'
        end,
        length = 2,
    },
},

but I cannot get this one to trigger either.

from hardtime.nvim.

kang8 avatar kang8 commented on July 22, 2024

This is because x same as dl. So pressing x is equivalent to pressing dl.

When you press xi, it is ultimately interpreted as xdli, which(dli) conforms to the ["[^fFtTlt]" rule, so it matches.

You can use follow script to listener every input key

vim.on_key(function(k)
  local mode = vim.fn.mode()
  if mode == 'i' or mode == 'c' or mode == 'R' then
    return
  end

  local key = vim.fn.keytrans(k)
  vim.notify('k is: ' .. k .. ' , key is: ' .. key, vim.log.levels.WARN, { title = 'test' })
end)

from hardtime.nvim.

nullromo avatar nullromo commented on July 22, 2024

It's weird that x actually "presses" dl rather than just doing the underlying operation. For example, the following hint is kind of amusing:

['dl'] = {
    message = function()
        return 'Use x instead of dl'
    end,
    length = 2,
},

Each time you press x, it tells you to use x instead 🙃

So I guess hardtime.nvim can't actually distinguish which keypresses are "real" user keypresses. When I try your test function, I get the following notifications:

2024-02-02T09:15:03 test WARNING WARN WARNING | test: k is: x , key is: x
2024-02-02T09:15:03 test WARNING WARN WARNING | test: k is: d , key is: d
2024-02-02T09:15:03 hardtime WARNING WARN WARNING | hardtime: Use x instead of dl
2024-02-02T09:15:03 test WARNING WARN WARNING | test: k is: l , key is: l

This just feels like a very strange behavior of neovim to me.

from hardtime.nvim.

m4xshen avatar m4xshen commented on July 22, 2024

@nullromo hardtime.nvim uses vim.on_key function to listen to key input. This behavior is expected based on the docs (see :h vim.on_key)

    {fn} will receive the keys after mappings have been evaluated

I currently haven't found other way to listen to the raw key input.

from hardtime.nvim.

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.