stevearc / oil.nvim

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

bug: float win_options not work if change directory #430

Closed icefed closed 4 days ago

icefed commented 1 week ago

Did you check the docs and existing issues?

Neovim version (nvim -v)

0.10.0

Operating system/version

MacOS 14.5

Describe the bug

  {
    "stevearc/oil.nvim",
    dependencies = { "nvim-tree/nvim-web-devicons" },
    -- enabled = false,
    opts = {
      view_options = {
        -- Show files and directories that start with "."
        show_hidden = true,
      },
      delete_to_trash = true,
      float = {
        -- Padding around the floating window
        padding = 2,
        max_width = 90,
        max_height = 0,
        border = "rounded",
        win_options = {
          winblend = 0,
          winhighlight = "NormalFloat:Normal,FloatBorder:Normal",
        },
      },
    },
  },

This is my oil config, I set float win_options: winhighlight = "NormalFloat:Normal,FloatBorder:Normal",, the first time I open Oil float window it works, until I change to another directory(in Oil).

I read the oil code, found the issue caused by https://github.com/stevearc/oil.nvim/blob/65c53dbe4f2140236590a7568a5f22a77d16be39/lua/oil/init.lua#L264-L266

If I remove scope = "local" all fine.

What is the severity of this bug?

minor (annoyance)

Steps To Reproduce

init.lua

local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "https://github.com/folke/lazy.nvim.git",
    "--branch=stable", -- latest stable release
    lazypath,
  })
end
vim.opt.rtp:prepend(lazypath)

vim.g.mapleader = ","

require("lazy").setup({
  {
    "ellisonleao/gruvbox.nvim",
    lazy = false,    -- make sure we load this during startup if it is your main colorscheme
    priority = 1000, -- make sure to load this before all the other start plugins
    config = function()
      require("gruvbox").setup({})
      vim.cmd("colorscheme gruvbox")
    end,
  },
  {
    "stevearc/oil.nvim",
    dependencies = { "nvim-tree/nvim-web-devicons" },
    -- enabled = false,
    opts = {
      view_options = {
        -- Show files and directories that start with "."
        show_hidden = true,
      },
      delete_to_trash = true,
      float = {
        -- Padding around the floating window
        padding = 2,
        max_width = 90,
        max_height = 0,
        border = "rounded",
        win_options = {
          winblend = 0,
          winhighlight = "NormalFloat:Normal,FloatBorder:Normal",
        },
      },
    },
    keys = {
      { "<leader>t",  "",                 desc = "Toggle" },
      { "<leader>tt", ":Oil --float<CR>", desc = "Oil Open parent directory" },
    },
  },
})
  1. open a file in directory
  2. press <leader>tt( open oil in float mode )
  3. choose one folder and press enter (into this folder, winhighlight not work)
  4. choose ../ and press enter (back to parent, winhighlight work)

Expected Behavior

float win_options works if I change directory.

Directory structure

No response

Repro

...

Did you check the bug with a clean config?