oil.nvim icon indicating copy to clipboard operation
oil.nvim copied to clipboard

bug: Alt+h opens a window in horizontal mode, which was suppose to be done with C-h

Open Barmanji opened this issue 10 months ago • 1 comments

Did you check the docs and existing issues?

  • [x] I have read the docs
  • [x] I have searched the existing issues

Neovim version (nvim -v)

NVIM v0.10.4

Operating system/version

Arch Linux x86_64, Linux 6.6.72-1-lts

Describe the bug

So C-h (control h) opens a windows in horizontal mode while in oil file manager, but I have disabled it. Here's my config.


return {
    "stevearc/oil.nvim",
    -- enabled = false,
    dependencies = { "nvim-tree/nvim-web-devicons" },
    config = function()
        require("oil").setup({
            float = {
                max_width = 120, -- Adjust width
                max_height = 30, -- Adjust height
                border = "rounded", -- Optional: make the border rounded
            },
            default_file_explorer = true, -- start up nvim with oil instead of netrw
            columns = {
                -- "icon",
                -- "permissions",
                -- "size",
                -- "mtime",
            },
            keymaps = {
                ["<A-h>"] = false,
                ["<C-h>"] = false,
                ["<C-c>"] = false, -- prevent from closing Oil as <C-c> is esc key
                ["<M-h>"] = "actions.select_split",
                ["<C-s>"] = { "actions.select", opts = { vertical = true } },
                ["gg"] = { "actions.change_sort", mode = "n" },
                ["q"] = "actions.close",
            },
            delete_to_trash = true,
            view_options = {
                show_hidden = true,
            },
            skip_confirm_for_simple_edits = true,
        })

        -- opens parent dir over current active window
        vim.keymap.set("n", "-", "<CMD>Oil<CR>", { desc = "Open parent directory" })
        -- open parent dir in float window
        vim.keymap.set("n", "<leader>-", require("oil").toggle_float)
        vim.api.nvim_create_autocmd("FileType", {
            pattern = "oil", -- Adjust if Oil uses a specific file type identifier
            callback = function()
                vim.cmd("highlight OilBorder guifg=white guibg=NONE")
                vim.cmd("highlight CursorLineNr guifg=white")
            end,
        })
    end,

}

Now the issue is Alt-H is doing same behavior as C-h, and I don't want either or, C-h is successfully disabled but Alt h isnt.

What is the severity of this bug?

minor (annoyance)

Steps To Reproduce

  1. Copy my config
  2. press Alt-h

Expected Behavior

It will open the current window in horizontal seperation

Directory structure

No response

Repro

-- 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?

  • [x] I have confirmed that the bug reproduces with nvim -u repro.lua using the repro.lua file above.

Barmanji avatar Feb 18 '25 16:02 Barmanji

Oil doesn't bind anything to alt by default. You can confirm this if you want by setting use_default_keymaps = false, which will disable all built-in oil keymaps. I suspect that it is related to some other keymap you have. Try :nmap <A-h> to see if there is anything set.

stevearc avatar Mar 04 '25 23:03 stevearc