Skip to content

Commit

Permalink
fix: fix absolute paths
Browse files Browse the repository at this point in the history
  • Loading branch information
prichrd committed Mar 19, 2024
1 parent 0cc0828 commit 960ab88
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ require('vwd').get_vwd()

Set the VWD with:
```lua
require('vwd').set_vwd(vwd)
require('vwd').set_vwd(vwd, absolute)
```

Reset the VWD with:
Expand Down
4 changes: 2 additions & 2 deletions doc/vwd.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ COMMANDS
Returns the current VWD.

*vwd-api-set*
`require('vwd').set_vwd(vwd)`
`require('vwd').set_vwd(vwd, absolute)`

Sets the VWD to {vwd}.
Sets the VWD to {vwd}. If the path is absolute, set the boolean to true.

*vwd-api-reset*
`require('vwd').reset_vwd()`
Expand Down
2 changes: 1 addition & 1 deletion lua/telescope/_extensions/vwd/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ local manatee = require("vwd")
M.set_vwd = function(prompt_bufnr)
local action_state = require("telescope.actions.state")
local current_picker = action_state.get_current_picker(prompt_bufnr)
manatee.set_vwd(current_picker.finder.path)
manatee.set_vwd(current_picker.finder.path, true)
end

return M
2 changes: 1 addition & 1 deletion lua/vwd/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ local defaults = {}
local cmd = {
["set"] = function(...)
local args = ...
require("vwd").set_vwd(args[1])
require("vwd").set_vwd(args[1], false)
notify.info("VWD updated to '%s'", require("vwd").get_vwd())
end,
["get"] = function()
Expand Down
9 changes: 7 additions & 2 deletions lua/vwd/store.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@ M._state = {

--- set_vwd sets the VWD.
---@param dir string the directory to set as the VWD.
M.set_vwd = function(dir)
M._state.vwd = vim.fn.resolve(vim.fn.getcwd() .. "/" .. dir)
---@param absolute boolean Wether the provided dir is an absolute path or a CWD relative path.
M.set_vwd = function(dir, absolute)
if absolute then
M._state.vwd = dir
else
M._state.vwd = vim.fn.resolve(vim.fn.getcwd() .. "/" .. dir)
end
end

--- get_vwd gets the currently set VWD.
Expand Down

0 comments on commit 960ab88

Please sign in to comment.