From 90c1c6cc822b1836209514c096069b9bbeab63d9 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sun, 1 Dec 2024 12:57:16 +0100 Subject: refactor: use simpler file existence check The vimscript function `getftype` is an easier way to check for file existence compared to vim.uv. --- scripts/docgen.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/docgen.lua b/scripts/docgen.lua index ee275f24..47e2fe28 100644 --- a/scripts/docgen.lua +++ b/scripts/docgen.lua @@ -63,7 +63,7 @@ local function make_section(indentlvl, sep, parts) end local function readfile(path) - assert((uv.fs_stat(path) or {}).type == 'file') + assert(vim.fn.getftype(path) == 'file') return io.open(path):read '*a' end @@ -181,10 +181,10 @@ local function make_lsp_sections() function() local package_json_name = util.path.join(tempdir, config_name .. '.package.json') if docs.package_json then - if not ((uv.fs_stat(package_json_name) or {}).type == 'file') then + if vim.fn.getftype(package_json_name) ~= 'file' then os.execute(string.format('curl -v -L -o %q %q', package_json_name, docs.package_json)) end - if not ((uv.fs_stat(package_json_name) or {}).type == 'file') then + if vim.fn.getftype(package_json_name) ~= 'file' then print(string.format('Failed to download package.json for %q at %q', config_name, docs.package_json)) os.exit(1) return -- cgit v1.2.3-70-g09d2