diff --git a/README.md b/README.md index 0d2f7e2e..ae059806 100644 --- a/README.md +++ b/README.md @@ -645,7 +645,9 @@ https://github.com/Bekaboo/dropbar.nvim/assets/76579810/e8c1ac26-0321-4762-9975- path = { ---@type string|fun(buf: integer, win: integer): string relative_to = function(_, win) - return vim.fn.getcwd(vim.api.nvim_win_get_number(win)) + -- Workaround for Vim:E5002: Cannot find window number + local ok, cwd = pcall(vim.fn.getcwd, win) + return ok and cwd or vim.fn.getcwd() end, ---Can be used to filter out files or directories ---based on their name @@ -1325,7 +1327,9 @@ each sources. - Default: ```lua function(_, win) - return vim.fn.getcwd(vim.api.nvim_win_get_number(win)) + -- Workaround for Vim:E5002: Cannot find window number + local ok, cwd = pcall(vim.fn.getcwd, win) + return ok and cwd or vim.fn.getcwd() end ``` - `opts.sources.path.filter`: `function(name: string): boolean` diff --git a/doc/dropbar.txt b/doc/dropbar.txt index 6588f8cd..5bf7d635 100644 --- a/doc/dropbar.txt +++ b/doc/dropbar.txt @@ -724,7 +724,9 @@ PATH *dropbar-configuration-options-sources-path* - Notice: currently does not support `..` relative paths - Default: >lua function(_, win) - return vim.fn.getcwd(vim.api.nvim_win_get_number(win)) + -- Workaround for Vim:E5002: Cannot find window number + local ok, cwd = pcall(vim.fn.getcwd, win) + return ok and cwd or vim.fn.getcwd() end < - `opts.sources.path.filter`: `function(name: string): boolean` diff --git a/lua/dropbar/configs.lua b/lua/dropbar/configs.lua index 463c7ef6..93a78b0c 100644 --- a/lua/dropbar/configs.lua +++ b/lua/dropbar/configs.lua @@ -421,10 +421,9 @@ M.opts = { path = { ---@type string|fun(buf: integer, win: integer): string relative_to = function(_, win) - local winnr = vim.api.nvim_win_is_valid(win) - and vim.api.nvim_win_get_number(win) - or nil - return vim.fn.getcwd(winnr) + -- Workaround for Vim:E5002: Cannot find window number + local ok, cwd = pcall(vim.fn.getcwd, win) + return ok and cwd or vim.fn.getcwd() end, ---Can be used to filter out files or directories ---based on their name