m4xshen / hardtime.nvim

Establish good command workflow and quit bad habit
MIT License
1.38k stars 26 forks source link

The nvim . or file name and nvim with lazy package manager #16

Closed directormac closed 1 year ago

directormac commented 1 year ago

Using lazyvim as base

When launching neovim with

nvim . or nvim index.html

Hardtime loads correctly and have issues with remap issues with keys like x, where x is remapped as _x

Launching nvim only and launches the alpha board

nvim

Hardtime loads keys remapped like x is correctly loading but the gk and gj remaps from lazyvim isnt overriden by hardtime.

added hardtime like this

{ "m4xshen/hardtime.nvim", --hardtime practice event = "VeryLazy", dependencies = "neovim/nvim-lspconfig", opts = {}, }, remapped x like this.

map("v", "x", "_x", { noremap = true, silent = true, desc = "Delete character without yanking" })

i just noticed this as i hardly launch nvim with parameters.

m4xshen commented 1 year ago

Please make sure you update it to the lateset version and remove the event = "VeryLazy", which is not needed anymore. See the updated README.

directormac commented 1 year ago

Please make sure you update it to the lateset version and remove the event = "VeryLazy", which is not needed anymore. See the updated README.

I noticed that now! Thank you so much for the awaited fix now only the rebind isn't working ^_^ i just updated few minutes ago.

m4xshen commented 1 year ago

Could you please clarify again what the current issue after updating?

directormac commented 1 year ago

Well its was the same as before on lazyvim i belive the keymap.lua is set afterwards all the plugins have loaded so maybe its conflicting with the reset keys used by hardtime on the resetting keys i removed the x here to reproduce,

if x is removed from resetting keys the remap of x works.

  {
    "m4xshen/hardtime.nvim", --hardtime practice
    dependencies = "neovim/nvim-lspconfig",
    opts = {
      },
    },
  },
local map = require("config.util").map
map("v", "x", "_x", { noremap = true, silent = true, desc = "Delete character without yanking" })
map(
  "n",
  "x", -- Also let's allow 'x' key to delete blank lines in normal mode.
  function()
    if vim.fn.col(".") == 1 then
      local line = vim.fn.getline(".")
      if line:match("^%s*$") then
        vim.api.nvim_feedkeys("dd", "n", false)
        vim.api.nvim_feedkeys("$", "n", false)
      else
        vim.api.nvim_feedkeys('"_x', "n", false)
      end
    else
      vim.api.nvim_feedkeys('"_x', "n", false)
    end
  end,
  { noremap = true, silent = true, desc = "Delete character without yanking" }
)

This is my current workaround

  {
    "m4xshen/hardtime.nvim", --hardtime practice
    dependencies = "neovim/nvim-lspconfig",
    opts = {
      max_time = 2000,
      max_count = 3,
      resetting_keys = {
        ["1"] = { "n", "v" },
        ["2"] = { "n", "v" },
        ["3"] = { "n", "v" },
        ["4"] = { "n", "v" },
        ["5"] = { "n", "v" },
        ["6"] = { "n", "v" },
        ["7"] = { "n", "v" },
        ["8"] = { "n", "v" },
        ["9"] = { "n", "v" },
        ["c"] = { "n" },
        ["C"] = { "n" },
        ["d"] = { "n" },
        -- ["x"] = { "n" },
        ["X"] = { "n" },
        ["y"] = { "n" },
        ["Y"] = { "n" },
        ["p"] = { "n" },
        ["P"] = { "n" },
      },
    },
  },
m4xshen commented 1 year ago

map("v", "x", "_x", { noremap = true, silent = true, desc = "Delete character without yanking" })

I think the right hand side of the map should be "_x. You missed a ".

directormac commented 1 year ago

Yup you are right, i'm expecting the other one for normal mode to work normally where it can delete a blank line. still tho the workaround is fine for me you can close this one! Thanks @m4xshen !