Skip to content

Commit

Permalink
fix(sources-path & configs)!: should use window-local cwd
Browse files Browse the repository at this point in the history
Fix path flickering when switching windows with different local cwd
  • Loading branch information
bekaboo committed Oct 27, 2023
1 parent 36b7cc1 commit d9525ed
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -643,9 +643,9 @@ https://github.com/Bekaboo/dropbar.nvim/assets/76579810/e8c1ac26-0321-4762-9975-
},
sources = {
path = {
---@type string|fun(buf: integer): string
relative_to = function(_)
return vim.fn.getcwd()
---@type string|fun(buf: integer, win: integer): string
relative_to = function(_, win)
return vim.fn.getcwd(vim.api.nvim_win_get_number(win))
end,
---Can be used to filter out files or directories
---based on their name
Expand Down Expand Up @@ -1316,16 +1316,16 @@ each sources.

##### Path

- `opts.sources.path.relative_to`: `string|fun(buf: integer): string`
- `opts.sources.path.relative_to`: `string|fun(buf: integer, win: integer): string`
- The path to use as the root of the relative path
- If a function is provided, it will be called with the current buffer number
as an argument and should return a string to use as the root of the relative
path
- Notice: currently does not support `..` relative paths
- Default:
```lua
function(_)
return vim.fn.getcwd()
function(_, win)
return vim.fn.getcwd(vim.api.nvim_win_get_number(win))
end
```
- `opts.sources.path.filter`: `function(name: string): boolean`
Expand Down
6 changes: 3 additions & 3 deletions doc/dropbar.txt
Original file line number Diff line number Diff line change
Expand Up @@ -716,15 +716,15 @@ of each sources.

PATH *dropbar-configuration-options-sources-path*

- `opts.sources.path.relative_to`: `string|fun(buf: integer): string`
- `opts.sources.path.relative_to`: `string|fun(buf: integer, win: integer): string`
- The path to use as the root of the relative path
- If a function is provided, it will be called with the current buffer
number as an argument and should return a string to use as the root of
the relative path
- Notice: currently does not support `..` relative paths
- Default: >lua
function(_)
return vim.fn.getcwd()
function(_, win)
return vim.fn.getcwd(vim.api.nvim_win_get_number(win))
end
<
- `opts.sources.path.filter`: `function(name: string): boolean`
Expand Down
6 changes: 3 additions & 3 deletions lua/dropbar/configs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -419,9 +419,9 @@ M.opts = {
},
sources = {
path = {
---@type string|fun(buf: integer): string
relative_to = function(_)
return vim.fn.getcwd()
---@type string|fun(buf: integer, win: integer): string
relative_to = function(_, win)
return vim.fn.getcwd(vim.api.nvim_win_get_number(win))
end,
---Can be used to filter out files or directories
---based on their name
Expand Down
2 changes: 1 addition & 1 deletion lua/dropbar/sources/path.lua
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ local function get_symbols(buf, win, _)
and current_path ~= '/'
and current_path
~= vim.fs.normalize(
configs.eval(configs.opts.sources.path.relative_to, buf)
configs.eval(configs.opts.sources.path.relative_to, buf, win)
)
do
table.insert(symbols, 1, convert(current_path, buf, win))
Expand Down

0 comments on commit d9525ed

Please sign in to comment.