aboutsummaryrefslogtreecommitdiff
path: root/.config/nvim/lua/lsp.lua
diff options
context:
space:
mode:
Diffstat (limited to '.config/nvim/lua/lsp.lua')
-rw-r--r--.config/nvim/lua/lsp.lua76
1 files changed, 75 insertions, 1 deletions
diff --git a/.config/nvim/lua/lsp.lua b/.config/nvim/lua/lsp.lua
index 6fe008e..5e8ddf8 100644
--- a/.config/nvim/lua/lsp.lua
+++ b/.config/nvim/lua/lsp.lua
@@ -281,7 +281,7 @@ require("lspconfig").lua_ls.setup({
};
})
-require('lspconfig').jedi_language_server.setup({})
+require("lspconfig").jedi_language_server.setup({})
local null_ls = require("null-ls")
@@ -307,6 +307,80 @@ null_ls.setup({
};
})
+-- Debugging
+
+local dap, dapui = require("dap"), require("dapui")
+dapui.setup()
+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
+
+dap.adapters.coreclr = {
+ type = "executable";
+ command = "netcoredbg";
+ args = { "--interpreter=vscode" };
+}
+
+vim.g.dotnet_build_project = function()
+ local default_path = vim.fn.getcwd() .. "/"
+ if vim.g["dotnet_last_proj_path"] ~= nil then
+ default_path = vim.g["dotnet_last_proj_path"]
+ end
+ local path = vim.fn.input("Path to your *proj file", default_path, "file")
+ vim.g["dotnet_last_proj_path"] = path
+ local cmd = "dotnet build -c Debug " .. path .. " > /dev/null"
+ print("")
+ print("Cmd to execute: " .. cmd)
+ local f = os.execute(cmd)
+ if f == 0 then
+ print("\nBuild: ✔️ ")
+ else
+ print("\nBuild: ❌ (code: " .. f .. ")")
+ end
+end
+
+vim.g.dotnet_get_dll_path = function()
+ local request = function()
+ return vim.fn.input("Path to dll", vim.fn.getcwd() .. "/bin/Debug/", "file")
+ end
+
+ if vim.g["dotnet_last_dll_path"] == nil then
+ vim.g["dotnet_last_dll_path"] = request()
+ else
+ if vim.fn.confirm("Do you want to change the path to dll?\n" ..
+ vim.g["dotnet_last_dll_path"], "&yes\n&no", 2) == 1 then
+ vim.g["dotnet_last_dll_path"] = request()
+ end
+ end
+
+ return vim.g["dotnet_last_dll_path"]
+end
+
+dap.configurations.cs = {
+ {
+ type = "coreclr";
+ name = "launch - netcoredbg";
+ request = "launch";
+ program = function()
+ if vim.fn.confirm("Should I recompile first?", "&yes\n&no", 2) == 1 then
+ vim.g.dotnet_build_project()
+ end
+ return vim.g.dotnet_get_dll_path()
+ end;
+ };
+ {
+ -- If you get an "Operation not permitted" error using this, try disabling YAMA:
+ -- echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
+ name = "Attach to process";
+ type = "cs";
+ request = "attach";
+ pid = require("dap.utils").pick_process;
+ args = {};
+ };
+}
+
vim.diagnostic.config({
virtual_text = false;
signs = true;