feat: núcleo del plugin NCS (build, flash, LSP)

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)
This commit is contained in:
unai committed 2026-10-10 18:36:16 +02:00
1 parent 03a43a686f
commit a4a5bfe636
8 files changed
+297

No files matched your search

+53
View File
@@ -0,0 +1,53 @@
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