stevearc / oil.nvim

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

feature request: show somewhere in the buffer what directory I'm currently looking at #377

Closed ptn closed 4 months ago

ptn commented 4 months ago

Did you check existing requests?

Describe the feature

My oil looks like this:

Screenshot 2024-05-16 at 12 33 12

I have no idea what dir that is, having a header that states what directory oil is displaying would be absurdly helpful.

Provide background

No response

What is the significance of this feature?

strongly desired

Additional details

Here's my config:

{
    "stevearc/oil.nvim",
    opts = {
      view_options = {
        show_hidden = true,
      },
      skip_confirm_for_simple_edits = true,
      delete_to_trash = true,
      columns = {
        "permissions",
        "size",
        "mtime",
        "icon",
      },
      keymaps = {
        ["q"] = "actions.close",
        ["^"] = "actions.parent",
        ["gr"] = "actions.refresh",
      },
    },
    dependencies = { "nvim-tree/nvim-web-devicons" },
    cmd = "Oil",
    keys = {
      { "<leader>fd", "<CMD>Oil<CR>", desc = "Open oil on dir of current file" },
      {
        "<leader>fD",
        function()
          require("oil").open(vim.fn.getcwd())
        end,
        desc = "Open oil on git root",
      },
    },
  }
sekerhalithamza commented 4 months ago

I would love to see a feature like this

xzbdmw commented 4 months ago

You can use winbar for that, since there are path information you can get from api

stevearc commented 4 months ago

Winbar is the recommended way to do this. If you're using a statusline plugin they probably have a way to configure the winbar, but with raw Neovim APIs you can do this:

function OilDir() return require("oil").get_current_dir() end
vim.api.nvim_create_autocmd("BufWinEnter", {
  callback = function(ev)
    if vim.bo[ev.buf].filetype == "oil" and vim.api.nvim_get_current_buf() == ev.buf then
      vim.api.nvim_set_option_value("winbar", "%{%v:lua.OilDir()%}", { scope = "local", win = 0 })
    end
  end,
})
ro0gr commented 4 months ago

ctrl+g can be useful as well.