stevearc / oil.nvim

Neovim file explorer: edit your filesystem like a buffer
MIT License
3.36k stars 91 forks source link

bug: `~` not respected #397

Closed ro0gr closed 1 month ago

ro0gr commented 1 month ago

Did you check the docs and existing issues?

Neovim version (nvim -v)

0.10.0

Operating system/version

MacOS 14.4.1

Describe the bug

Pressing the ~ key does not toggle the case of the letter under cursor.

Please see the ~ in the https://neovim.io/doc/user/change.html#simple-change.

What is the severity of this bug?

minor (annoyance)

Steps To Reproduce

  1. Let's put steps from repro section at /tmp/repro/init.lua
  2. vim /tmp/repro -u /tmp/repro/init.lua
  3. press ~

Actual Result Nothing happens

Expected Behavior

init.lua should become Init.lua. The first letter should become Uppercase.

Directory structure

init.lua

Repro (untouched)

-- save as repro.lua
-- run with nvim -u repro.lua
-- DO NOT change the paths
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "runtime", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "--single-branch",
    "https://github.com/folke/lazy.nvim.git",
    lazypath,
  })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  {
        "stevearc/oil.nvim",
        config = function()
            require("oil").setup({
              -- add any needed settings here
            })
        end,
  },
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here

Did you check the bug with a clean config?

ro0gr commented 1 month ago

Currently I'm not familiar with the codebase. I'd appreciate any reference to where I should start investigation from, and hopefuly fix this.

ro0gr commented 1 month ago

Well, this is caused by the the tcd action mapping, which I was unaware of:

https://github.com/stevearc/oil.nvim/blob/2cb39e838e9dcd8b374f09a3a87a2e5ec9d372f6/lua/oil/config.lua#L70

This overrides vim tilde https://neovim.io/doc/user/change.html#~

ro0gr commented 1 month ago

I've tried to override just a single keymap and leave the rest as is

      keymaps = {
        ['<Leader>t`'] = 'actions.tcd',

Unfortunatelly that doesn't work, and I had to disable all the defaults(use_default_keymaps=false) and redefine all the keymaps again. Is this intentional? Or can we do keymaps merging?

ro0gr commented 1 month ago

Anyways, the problem is solved for me. Closing for now. Thanks for the great plugin!