Primera versión funcional del plugin para nRF Connect SDK en LazyVim. Incluye: - setup() con opciones por proyecto y API pública (build, flash) - detect: resolución en runtime de versión NCS, toolchain y board (sin hashes hardcodeados) - exec: wrapper async sobre vim.system + entorno NCS - west: construcción del comando build (--sysbuild, -DCONF_FILE, -DDTC_OVERLAY_FILE, -DCMAKE_EXPORT_COMPILE_COMMANDS=ON) - lsp: symlink de compile_commands.json desde build/<image>/ y LspRestart (clangd solo lo lee al arrancar) - flash: detección de placas vía nrfutil device list + selector - keymaps: <leader>nb (build), <leader>np (pristine), <leader>nf (flash)
54 lines
1.2 KiB
Lua
54 lines
1.2 KiB
Lua
local M = {}
|
|
|
|
--- Envuelve un binario (west, nrfutil...) en el entorno NCS.
|
|
function M.ncs(opts, cmd)
|
|
local full = { "nrfutil", "toolchain-manager", "launch" }
|
|
if opts.ncs_version then
|
|
vim.list_extend(full, { "--ncs-version", opts.ncs_version })
|
|
end
|
|
vim.list_extend(full, { "--" })
|
|
vim.list_extend(full, cmd)
|
|
return full
|
|
end
|
|
|
|
--- Ejecuta async y vuelca la salida a un buffer scratch (no bloquea nvim).
|
|
function M.run_async(cmd, o)
|
|
o = o or {}
|
|
local buf = vim.api.nvim_create_buf(false, true)
|
|
vim.api.nvim_buf_set_name(buf, o.title or "hego://run")
|
|
vim.cmd("botright split")
|
|
vim.api.nvim_win_set_buf(0, buf)
|
|
|
|
local function append(data)
|
|
if not data or data == "" then
|
|
return
|
|
end
|
|
vim.api.nvim_buf_set_lines(buf, -1, -1, false, vim.split(data, "\n", { plain = true }))
|
|
vim.api.nvim_win_set_cursor(0, { vim.api.nvim_buf_line_count(buf), 0 })
|
|
end
|
|
|
|
return vim.system(cmd, {
|
|
cwd = o.cwd,
|
|
text = true,
|
|
stdout = function(_, d)
|
|
vim.schedule(function()
|
|
append(d)
|
|
end)
|
|
end,
|
|
stderr = function(_, d)
|
|
vim.schedule(function()
|
|
append(d)
|
|
end)
|
|
end,
|
|
}, function(obj)
|
|
vim.schedule(function()
|
|
append("\n[hego] exit: " .. tostring(obj.code))
|
|
if o.on_exit then
|
|
o.on_exit(obj)
|
|
end
|
|
end)
|
|
end)
|
|
end
|
|
|
|
return M
|