stevearc / oil.nvim

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

feature request: Interaction with Lualine #144

Closed bradlauder closed 1 year ago

bradlauder commented 1 year ago

Did you check existing requests?

Describe the feature

Hello, big fan so far!

I'm new to neovim. Wondering if it would be possible to get the same lualine functionality as when a file is open?

As of right now the git branch section of my lualine disappears inside oil. And also the filename section shows oil://... and it would be nice to have it follow the same pattern configure by lualine (relative, absolute) like netrw does.

image image

Provide background

No response

Additional details

No response

stevearc commented 1 year ago

This is something that would have to be addressed within lualine. Those components are built to check for the directory of the current file, but an oil buffer doesn't have an associated file (and has a url-formatted name like oil:///home/user/). We have chosen to name the buffers this way (instead of the raw directory name like /home/user/) in order to play nice with other file managers. If there is interest, the lualine components could be fairly easily modded to support this by adding a special-case check like

-- Assuming the component gets the current path something like this
local current_file = vim.api.nvim_buf_get_name(0)
-- If this is an oil buffer, use the API to get the current path
if vim.b.filetype == "oil" then
  current_file = require("oil").get_current_dir()
end