Add DAP support, and some refactoring, nothing fancy for the DAPs yet, but good enough to use.
This commit is contained in:
parent
905e873d31
commit
0bec36b390
1 changed files with 99 additions and 36 deletions
|
|
@ -1,41 +1,4 @@
|
|||
return {
|
||||
"williamboman/mason.nvim",
|
||||
dependencies = {
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
"neovim/nvim-lspconfig",
|
||||
"WhoIsSethDaniel/mason-tool-installer.nvim",
|
||||
"RubixDev/mason-update-all",
|
||||
},
|
||||
config = function()
|
||||
-- Find all files in lua/language_servers and require them
|
||||
-- We use them to ensure that the servers are installed and configured
|
||||
-- Make sure that the files use the lspconfig naming convention
|
||||
local lua_files_str = vim.fn.globpath(vim.fn.stdpath("config") .. "/lua/language_servers", "*.lua", true)
|
||||
local has_line_breaks = vim.fn.match(lua_files_str, [[\n]]) > -1
|
||||
-- Get an array of all the files in the directory, make sure to account for single file
|
||||
local lua_files = has_line_breaks and vim.fn.split(lua_files_str, "\n") or { lua_files_str }
|
||||
-- Remove path and extension and only keep the filename
|
||||
local server_names = vim.tbl_map(function(file)
|
||||
return vim.fn.fnamemodify(file, ":t:r")
|
||||
end, lua_files)
|
||||
|
||||
-- Create a new table which contains the non-lsp setups for Mason (linters, formatters, etc)
|
||||
-- IMPORTANT: Make sure to leave rust-analyzer out of this list, as it can cause conflicts with rustaceanvim.
|
||||
-- Install rust-analyzer using your systems package manager instead.
|
||||
local mason_installs = vim.list_extend({
|
||||
"clang-format",
|
||||
"cmakelang",
|
||||
-- "luaformater",
|
||||
}, server_names)
|
||||
|
||||
require("mason").setup()
|
||||
require("mason-lspconfig").setup()
|
||||
require("mason-tool-installer").setup({
|
||||
ensure_installed = mason_installs,
|
||||
})
|
||||
require("mason-update-all").setup()
|
||||
|
||||
-- Iterate each server and setup
|
||||
local function setup_lsp(server_names)
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||
local lspconfig = require("lspconfig")
|
||||
for _, server_name in ipairs(server_names) do
|
||||
|
|
@ -67,5 +30,105 @@ return {
|
|||
error("LSP server not found: " .. server_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function setup_dap()
|
||||
local dap = require("dap")
|
||||
local dapui = require("dapui")
|
||||
dapui.setup()
|
||||
|
||||
local dap_signs = {
|
||||
{ "DapBreakpoint", { text = "🛑", texthl = "", linehl = "", numhl = "" } },
|
||||
}
|
||||
|
||||
for _, sign in ipairs(dap_signs) do
|
||||
vim.fn.sign_define(sign[1], sign[2])
|
||||
end
|
||||
|
||||
dap.listeners.after.event_initialized["dapui_config"] = function()
|
||||
dapui.open()
|
||||
end
|
||||
dap.listeners.before.event_terminated["dapui_config"] = function()
|
||||
dapui.close()
|
||||
end
|
||||
dap.listeners.before.event_exited["dapui_config"] = function()
|
||||
dapui.close()
|
||||
end
|
||||
|
||||
require("mason-nvim-dap").setup({
|
||||
handlers = {}
|
||||
})
|
||||
require("nvim-dap-repl-highlights").setup()
|
||||
|
||||
require("utils").add_keymaps({
|
||||
n = {
|
||||
["<leader>dr"] = { cmd = ":lua require(\"dap\").continue()<CR>" },
|
||||
["<leader>db"] = { cmd = ":lua require(\"dap\").toggle_breakpoint()<CR>" },
|
||||
["<leader>ds"] = {
|
||||
cmd = function()
|
||||
dap.disconnect({ terminateDebuggee = true })
|
||||
dap.close()
|
||||
dapui.close()
|
||||
end
|
||||
},
|
||||
["<F10>"] = { cmd = ":lua require(\"dap\").step_over()<CR>" },
|
||||
["<F11>"] = { cmd = ":lua require(\"dap\").step_into()<CR>" },
|
||||
["<F12>"] = { cmd = ":lua require(\"dap\").step_out()<CR>" },
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
return {
|
||||
"williamboman/mason.nvim",
|
||||
dependencies = {
|
||||
-- Mason plugins
|
||||
"WhoIsSethDaniel/mason-tool-installer.nvim",
|
||||
"RubixDev/mason-update-all",
|
||||
|
||||
-- LSP config
|
||||
"neovim/nvim-lspconfig",
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
|
||||
-- DAP
|
||||
"folke/neodev.nvim",
|
||||
"jay-babu/mason-nvim-dap.nvim",
|
||||
"rcarriga/nvim-dap-ui",
|
||||
"mfussenegger/nvim-dap",
|
||||
"nvim-neotest/nvim-nio",
|
||||
"LiadOz/nvim-dap-repl-highlights"
|
||||
},
|
||||
config = function()
|
||||
-- Find all files in lua/language_servers and require them
|
||||
-- We use them to ensure that the servers are installed and configured
|
||||
-- Make sure that the files use the lspconfig naming convention
|
||||
local lua_files_str = vim.fn.globpath(vim.fn.stdpath("config") .. "/lua/language_servers", "*.lua", true)
|
||||
local has_line_breaks = vim.fn.match(lua_files_str, [[\n]]) > -1
|
||||
-- Get an array of all the files in the directory, make sure to account for single file
|
||||
local lua_files = has_line_breaks and vim.fn.split(lua_files_str, "\n") or { lua_files_str }
|
||||
-- Remove path and extension and only keep the filename
|
||||
local server_names = vim.tbl_map(function(file)
|
||||
return vim.fn.fnamemodify(file, ":t:r")
|
||||
end, lua_files)
|
||||
|
||||
-- Create a new table which contains the non-lsp setups for Mason (linters, formatters, etc)
|
||||
-- IMPORTANT: Make sure to leave rust-analyzer out of this list, as it can cause conflicts with rustaceanvim.
|
||||
-- Install rust-analyzer using your systems package manager instead.
|
||||
local mason_installs = vim.list_extend({
|
||||
"clang-format",
|
||||
"cmakelang",
|
||||
"codelldb",
|
||||
"netcoredbg",
|
||||
}, server_names)
|
||||
|
||||
require("mason").setup()
|
||||
require("mason-lspconfig").setup()
|
||||
require("mason-tool-installer").setup({
|
||||
ensure_installed = mason_installs,
|
||||
})
|
||||
|
||||
setup_lsp(server_names)
|
||||
setup_dap()
|
||||
|
||||
require("mason-update-all").setup()
|
||||
end,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue