Skip to content

Commit

Permalink
fix: isdirectory is not necessary
Browse files Browse the repository at this point in the history
The fs_realpath function will return nil if the path doesn't exist.
  • Loading branch information
neandrake committed Dec 21, 2023
1 parent 7455d2c commit af75323
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions lua/persisted/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,8 @@ local function args_path()
-- Use expand() to resolve `~`and use fs_realpath to resolve both '.' and
-- relative paths passed as arguments. Note that argv() will only ever return
-- paths/files passed as arguments and does not include other
-- parameters/arguments.
local dir = vim.loop.fs_realpath(vim.fn.expand(vim.fn.argv(0)))
if dir ~= nil and vim.fn.isdirectory(dir) ~= 0 then
return dir
end
return nil
-- parameters/arguments. fs_realpath() returns nil if the path doesn't exist.
return vim.loop.fs_realpath(vim.fn.expand(vim.fn.argv(0)))
end

---Check any arguments passed to Neovim and verify if they're a directory
Expand Down

0 comments on commit af75323

Please sign in to comment.