Skip to content

Commit 8c719ed

Browse files
authored
Merge pull request #131 from Yagua/fix-file-exist-func
refactor file_exists function
2 parents 3c49a8c + c066035 commit 8c719ed

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

lua/rest-nvim/utils/init.lua

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,7 @@ end
2727
-- file_exists checks if the provided file exists and returns a boolean
2828
-- @param file File to check
2929
M.file_exists = function(file)
30-
file = io.open(file, "rb")
31-
if file then
32-
file:close()
33-
end
34-
return file ~= nil
30+
return vim.fn.filereadable(file) == 1
3531
end
3632

3733
-- read_file Reads all lines from a file and returns the content as a table

0 commit comments

Comments
 (0)