Skip to content

Commit

Permalink
fix(configs): cannot find winnr (again)
Browse files Browse the repository at this point in the history
  • Loading branch information
bekaboo committed Nov 3, 2023
1 parent 3435bb8 commit 9f86b27
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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`
Expand Down
4 changes: 3 additions & 1 deletion doc/dropbar.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
7 changes: 3 additions & 4 deletions lua/dropbar/configs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9f86b27

Please sign in to comment.