From 437780fdf7e276184d1c5d903090878bf9ba3069 Mon Sep 17 00:00:00 2001 From: Fredrik Averpil Date: Thu, 3 Oct 2024 23:12:46 +0200 Subject: [PATCH] fix: replace vim.system with vim.fn.system --- lua/lint/linters/buf_api_linter.lua | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lua/lint/linters/buf_api_linter.lua b/lua/lint/linters/buf_api_linter.lua index 569fc957..3e78934c 100644 --- a/lua/lint/linters/buf_api_linter.lua +++ b/lua/lint/linters/buf_api_linter.lua @@ -33,11 +33,16 @@ local function descriptor_set_in() -- build the descriptor file. local buf_config_folderpath = vim.fn.fnamemodify(buf_config_filepath, ":h") - local buf_cmd = { "buf", "build", "-o", descriptor_filepath } - local buf_cmd_opts = { cwd = buf_config_folderpath } - local obj = vim.system(buf_cmd, buf_cmd_opts):wait() - if obj.code ~= 0 then - error("Command failed: " .. vim.inspect(buf_cmd) .. "\n" .. obj.stderr) + local buf_cmd = string.format( + "cd %s && buf build -o %s", + vim.fn.shellescape(buf_config_folderpath), + vim.fn.shellescape(descriptor_filepath) + ) + local output = vim.fn.system(buf_cmd) + local exit_code = vim.v.shell_error + + if exit_code ~= 0 then + error("Command failed: " .. buf_cmd .. "\n" .. output) end -- return the argument to be passed to the linter.