Skip to content

Commit

Permalink
perf: Lazily require adapter mappings (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
Natr1x authored Apr 19, 2023
1 parent 2b5f8a2 commit 9816e2a
Show file tree
Hide file tree
Showing 15 changed files with 93 additions and 92 deletions.
92 changes: 0 additions & 92 deletions lua/mason-nvim-dap/mappings/adapters.lua

This file was deleted.

4 changes: 4 additions & 0 deletions lua/mason-nvim-dap/mappings/adapters/bash.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
return {
type = 'executable',
command = vim.fn.exepath('bash-debug-adapter'),
}
4 changes: 4 additions & 0 deletions lua/mason-nvim-dap/mappings/adapters/chrome.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
return {
type = 'executable',
command = vim.fn.exepath('chrome-debug-adapter'),
}
14 changes: 14 additions & 0 deletions lua/mason-nvim-dap/mappings/adapters/codelldb.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
local M = {
type = 'server',
port = '${port}',
executable = {
command = vim.fn.exepath('codelldb'),
args = { '--port', '${port}' },
},
}

if vim.fn.has('win32') == 1 then
M.codelldb.executable.detached = false
end

return M
5 changes: 5 additions & 0 deletions lua/mason-nvim-dap/mappings/adapters/coreclr.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
return {
type = 'executable',
command = vim.fn.exepath('netcoredbg'),
args = { '--interpreter=vscode' },
}
12 changes: 12 additions & 0 deletions lua/mason-nvim-dap/mappings/adapters/cppdbg.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
local M = {
id = 'cppdbg',
type = 'executable',
command = vim.fn.exepath('OpenDebugAD7'),
}
if vim.fn.has('win32') == 1 then
M.cppdbg.options = {
detached = false,
}
end

return M
5 changes: 5 additions & 0 deletions lua/mason-nvim-dap/mappings/adapters/dart.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
return {
type = 'executable',
command = vim.fn.exepath('dart-debug-adapter'),
args = { 'flutter' },
}
9 changes: 9 additions & 0 deletions lua/mason-nvim-dap/mappings/adapters/delve.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- https://github.com/mfussenegger/nvim-dap/wiki/Debug-Adapter-installation#go-using-delve-directly
return {
type = 'server',
port = '${port}',
executable = {
command = vim.fn.exepath('dlv'),
args = { 'dap', '-l', '127.0.0.1:${port}' },
},
}
4 changes: 4 additions & 0 deletions lua/mason-nvim-dap/mappings/adapters/firefox.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
return {
type = 'executable',
command = vim.fn.exepath('firefox-debug-adapter'),
}
14 changes: 14 additions & 0 deletions lua/mason-nvim-dap/mappings/adapters/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--- Lazily map debug adapters

local M = {}

local META = {}
function META.__index(table, key)
local adapter = require('mason-nvim-dap.mappings.adapters.' .. key)
table[key] = adapter
return adapter
end

setmetatable(M, META)

return M
5 changes: 5 additions & 0 deletions lua/mason-nvim-dap/mappings/adapters/kotlin.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
return {
type = 'executable',
command = vim.fn.exepath('kotlin-debug-adapter'),
args = { '--interpreter=vscode' },
}
5 changes: 5 additions & 0 deletions lua/mason-nvim-dap/mappings/adapters/mix_task.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
return {
type = 'executable',
command = vim.fn.exepath('elixir-ls-debugger'), -- https://github.com/williamboman/mason.nvim/blob/d97579ccd5689f9c6c365e841ea99c27954112ec/lua/mason-registry/elixir-ls/init.lua#L26
args = {},
}
4 changes: 4 additions & 0 deletions lua/mason-nvim-dap/mappings/adapters/node2.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
return {
type = 'executable',
command = vim.fn.exepath('node-debug2-adapter'),
}
4 changes: 4 additions & 0 deletions lua/mason-nvim-dap/mappings/adapters/php.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
return {
type = 'executable',
command = vim.fn.exepath('php-debug-adapter'),
}
4 changes: 4 additions & 0 deletions lua/mason-nvim-dap/mappings/adapters/python.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
return {
type = 'executable',
command = vim.fn.exepath('debugpy-adapter'),
}

2 comments on commit 9816e2a

@jinzhongjia
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in init.lua, this will cause this:

image

Due to direct require, there is no js adapter by default, but it will still be imported

@jinzhongjia
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested passing a

{
    ensure_installed = {},
    handlers={},
}

to setup, it will trigger this problem stably

Please sign in to comment.