diff --git a/doc/recipes.md b/doc/recipes.md index b2b875b..59d65a4 100644 --- a/doc/recipes.md +++ b/doc/recipes.md @@ -30,6 +30,27 @@ require("oil").setup({ }) ``` +## Show CWD in the winbar + +```lua +-- Declare a global function to retrieve the current directory +function _G.get_oil_winbar() + local dir = require("oil").get_current_dir() + if dir then + return vim.fn.fnamemodify(dir, ":~") + else + -- If there is no current directory (e.g. over ssh), just show the buffer name + return vim.api.nvim_buf_get_name(0) + end +end + +require("oil").setup({ + win_options = { + winbar = "%!v:lua.get_oil_winbar()", + }, +}) +``` + ## Hide gitignored files and show git tracked hidden files ```lua @@ -88,7 +109,9 @@ require("oil").setup({ local dir = require("oil").get_current_dir(bufnr) local is_dotfile = vim.startswith(name, ".") and name ~= ".." -- if no local directory (e.g. for ssh connections), just hide dotfiles - if not dir then return is_dotfile end + if not dir then + return is_dotfile + end -- dotfiles are considered hidden unless tracked if is_dotfile then return not git_status[dir].tracked[name]