Skip to content

Commit

Permalink
feat(shell): use vim.system instead of plenary on nvim 0.10+ (#70)
Browse files Browse the repository at this point in the history
Plenary isn't a required dependency after 0.10
  • Loading branch information
jarviliam authored Sep 11, 2024
1 parent 2806091 commit cc70d11
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
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

0 comments on commit cc70d11

Please sign in to comment.