Browse Source

feat: finished DAP integration

- NOTE: docs are missing in `docs/modules.md`
my-config
NTBBloodbath 3 years ago
parent
commit
eea5291a71
No known key found for this signature in database GPG Key ID: 18D6730BC846AAC5
  1. 18
      lua/doom/core/config/init.lua
  2. 4
      lua/doom/core/init.lua

18
lua/doom/core/config/init.lua

@ -450,26 +450,22 @@ end
--
-- @param langs The list of languages in the doomrc
M.install_dap_clients = function(langs)
-- TODO: finish the integration, see notes below
-- selene: allow(undefined_variable)
if packer_plugins and packer_plugins["dap-install"] and packer_plugins["dap-install"].loaded then
-- NOTE: this doesn't work as lspinstall one, we will need to find other
-- way to get the installed clients in a Lua table
local installed_clients = require("dap-install.tools.tool_list").list_debuggers()
if packer_plugins and packer_plugins["DAPInstall.nvim"] and packer_plugins["DAPInstall.nvim"].loaded then
local installed_clients = require("dap-install.api.debuggers").get_installed_debuggers()
-- NOTE: not all the clients follows the 'language_dbg' standard and this
-- can give some problems to us
local available_clients = vim.tbl_keys(require("dap-install.debuggers_list").debuggers)
-- can give some problems to us (maybe?)
local available_clients = vim.tbl_keys(require("dap-install.api.debuggers").get_debuggers())
for _, lang in ipairs(langs) do
local lang_str = lang
lang = lang:gsub("%s+%+lsp", ""):gsub("%s+%+debug", "")
-- If the +debug flag exists and the language server is not installed yet
-- If the +debug flag exists and the language client is not installed yet
if lang_str:find("%+debug") and (not utils.has_value(installed_clients, lang .. "_dbg")) then
-- Try to install the server only if there is a server available for
-- Try to install the client only if there is a client available for
-- the language, oterwise raise a warning
if utils.has_value(available_clients, lang) then
if utils.has_value(available_clients, lang .. "_dbg") then
require("dap-install.tools.tool_install").install_debugger(lang .. "_dbg")
else
log.warn(

4
lua/doom/core/init.lua

@ -28,6 +28,10 @@ for i = 1, #core_modules, 1 do
require("doom.core.config").install_servers(
require("doom.core.config.doomrc").load_doomrc().langs
)
-- Automatically install language DAP clients
require("doom.core.config").install_dap_clients(
require("doom.core.config.doomrc").load_doomrc().langs
)
end
end
end

Loading…
Cancel
Save