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

fix: remove luajit requirement #512

Merged
merged 1 commit into from
Sep 20, 2024
Merged
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
53 changes: 27 additions & 26 deletions lua/rustaceanvim/dap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -310,32 +310,33 @@ function M.start(args, verbose, callback, on_error)
end
vim.schedule(function()
local executables = {}
for value in output:gmatch('([^\n]*)\n?') do
local is_json, artifact = pcall(vim.fn.json_decode, value)
if not is_json then
goto loop_end
end

-- only process artifact if it's valid json object and it is a compiler artifact
if type(artifact) ~= 'table' or artifact.reason ~= 'compiler-artifact' then
goto loop_end
end

local is_binary = vim.list_contains(artifact.target.crate_types, 'bin')
local is_build_script = vim.list_contains(artifact.target.kind, 'custom-build')
local is_test = ((artifact.profile.test == true) and (artifact.executable ~= nil))
or vim.list_contains(artifact.target.kind, 'test')
-- only add executable to the list if we want a binary debug and it is a binary
-- or if we want a test debug and it is a test
if
(cargo_args[1] == 'build' and is_binary and not is_build_script)
or (cargo_args[1] == 'test' and is_test)
then
table.insert(executables, artifact.executable)
end

::loop_end::
end
vim
.iter(output:gmatch('([^\n]*)\n?'))
---@param value string
:map(function(value)
local is_json, artifact = pcall(vim.fn.json_decode, value)
return is_json, artifact
end)
---@param is_json boolean
:filter(function(is_json, artifact)
-- only process artifact if it's valid json object and it is a compiler artifact
return is_json and type(artifact) == 'table' and artifact.reason == 'compiler-artifact'
end)
---@param artifact table
:each(function(_, artifact)
local is_binary = vim.list_contains(artifact.target.crate_types, 'bin')
local is_build_script = vim.list_contains(artifact.target.kind, 'custom-build')
local is_test = ((artifact.profile.test == true) and (artifact.executable ~= nil))
or vim.list_contains(artifact.target.kind, 'test')
-- only add executable to the list if we want a binary debug and it is a binary
-- or if we want a test debug and it is a test
if
(cargo_args[1] == 'build' and is_binary and not is_build_script)
or (cargo_args[1] == 'test' and is_test)
then
table.insert(executables, artifact.executable)
end
end)
-- only 1 executable is allowed for debugging - error out if zero or many were found
if #executables <= 0 then
on_error('No compilation artifacts found.')
Expand Down
Loading