Add a command for creating launch.json templates
This commit is contained in:
parent
f2ec081697
commit
2e6646dbb0
1 changed files with 23 additions and 21 deletions
|
|
@ -1,32 +1,34 @@
|
||||||
local utils = require("utils")
|
local utils = require("utils")
|
||||||
local dap = require("dap")
|
local dap = require("dap")
|
||||||
|
|
||||||
--[[
|
|
||||||
.vscode/launch.json:
|
|
||||||
----------------------------
|
|
||||||
{
|
|
||||||
"version": "0.2.0",
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"type": "name_of_adapter",
|
|
||||||
"request": "launch/attach",
|
|
||||||
"name": "Friendly name",
|
|
||||||
"program": "${workspaceFolder}/path/to/executable",
|
|
||||||
"cwd": "${workspaceFolder}",
|
|
||||||
"args": [],
|
|
||||||
"stopOnEntry": false,
|
|
||||||
"environment": []
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
----------------------------
|
|
||||||
]]
|
|
||||||
|
|
||||||
local dir_path = "dap/adapters"
|
local dir_path = "dap/adapters"
|
||||||
utils.foreach(utils.get_file_names_in_dir(dir_path, "*.lua", true), function(adapter)
|
utils.foreach(utils.get_file_names_in_dir(dir_path, "*.lua", true), function(adapter)
|
||||||
dap.adapters[adapter] = require(dir_path .. "/" .. adapter)
|
dap.adapters[adapter] = require(dir_path .. "/" .. adapter)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
vim.api.nvim_create_user_command("LaunchTemplate", function()
|
||||||
|
local template = {
|
||||||
|
'{',
|
||||||
|
' "version": "0.2.0",',
|
||||||
|
' "configurations": [',
|
||||||
|
' {',
|
||||||
|
' "type": "codelldb",',
|
||||||
|
' "request": "launch",',
|
||||||
|
' "name": "Launch",',
|
||||||
|
' "program": "${workspaceFolder}/build/binary",',
|
||||||
|
' "cwd": "${workspaceFolder}",',
|
||||||
|
' "args": [],',
|
||||||
|
' "stopOnEntry": false,',
|
||||||
|
' "environment": []',
|
||||||
|
' }',
|
||||||
|
' ]',
|
||||||
|
'}',
|
||||||
|
}
|
||||||
|
|
||||||
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
|
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, template)
|
||||||
|
end, {})
|
||||||
|
|
||||||
-- Do not define default fallbacks until I have a better way of handling a default selected configuration.
|
-- Do not define default fallbacks until I have a better way of handling a default selected configuration.
|
||||||
-- I never want to be prompted for a configuration, we should have ae serialized active config which is always run unless changed.
|
-- I never want to be prompted for a configuration, we should have ae serialized active config which is always run unless changed.
|
||||||
-- -- Define configurations
|
-- -- Define configurations
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue