Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(shell): use vim.system instead of plenary on nvim 0.10+ #70

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ require("lazy").setup({
init = function ()
vim.g.netrw_nogx = 1 -- disable netrw gx
end,
dependencies = { "nvim-lua/plenary.nvim" },
dependencies = { "nvim-lua/plenary.nvim" }, -- Required for Neovim < 0.10.0
config = true, -- default settings
submodules = false, -- not needed, submodules are required only for tests

Expand Down
11 changes: 9 additions & 2 deletions lua/gx/shell.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
local shell = {}

--- Executes a command via vim.system or plenary.Job
---@param command string
---@param args table
---@return integer,table
function shell.execute(command, args)
-- TODO: This could use vim.system() in 0.10+
local Job = require("plenary.job")
if vim.fn.has("nvim-0.10") == 1 then
local result = vim.system({ command, unpack(args) }):wait()
return result.code, vim.split(result.stdout, "\n")
end

local Job = require("plenary.job")
local result, return_val = Job:new({
command = command,
args = args,
Expand Down