Skip to content

Instantly share code, notes, and snippets.

@CarsonSlovoka
Created July 24, 2026 08:19
Show Gist options
  • Select an option

  • Save CarsonSlovoka/2df33947b47eae7376e2a29df43d81f3 to your computer and use it in GitHub Desktop.

Select an option

Save CarsonSlovoka/2df33947b47eae7376e2a29df43d81f3 to your computer and use it in GitHub Desktop.
nvim -l osv 測試
-- Caution: 這種方式沒有辦法. 因為 osv 不能用 -l 的生命周期. 至少需要用 nvim --headless 的方式來啟動才行
local target = assert(_G.arg[1], [[
Missing Lua script to execute.
Usage:
nvim -l debug-runner.lua <script.lua> [args...]
]])
-- 使用絕對路徑,避免 DAP 的 breakpoint 路徑對不上
target = vim.fn.fnamemodify(target, ":p")
vim.pack.add({ "https://github.com/jbyuki/one-small-step-for-vimkind" })
-- vim.cmd("packadd one-small-step-for-vimkind") -- 也行. 前提是plugin已經有載到相關目錄了: pack/*/opt/{name}
require("osv").launch({
host = "127.0.0.1",
port = 8086,
-- 等待另一個 Neovim 的 DAP client 連線後才繼續
blocking = true,
-- Lua 發生錯誤時自動停下,方便檢查 call stack
break_on_exception = true,
output = true, -- Tip: 如果為false. DapUIrepl 視窗將不會有內容
})
-- 重新整理 arg,讓目標腳本看到的參數與直接使用
-- `nvim -l target.lua ...` 時相同
table.remove(_G.arg, 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment