Created
July 24, 2026 08:19
-
-
Save CarsonSlovoka/2df33947b47eae7376e2a29df43d81f3 to your computer and use it in GitHub Desktop.
nvim -l osv 測試
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- 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