summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua')
-rw-r--r--lua/user/dap.lua36
-rw-r--r--lua/user/keymaps.lua2
-rw-r--r--lua/user/lsp/handlers.lua8
3 files changed, 36 insertions, 10 deletions
diff --git a/lua/user/dap.lua b/lua/user/dap.lua
index b51dfd7..fb95eee 100644
--- a/lua/user/dap.lua
+++ b/lua/user/dap.lua
@@ -13,16 +13,44 @@ if not dap_ui_status_ok then
return
end
-if not dap_install_status_ok then
- return
-end
-
dap_install.setup({
installation_path = vim.fn.stdpath('data') .. "/dapinstall/",
})
dap_install.config("python", {})
+--dap setup
+
+dap.adapters.python = {
+ type = 'executable';
+ command = 'python';
+ args = { '-m', 'debugpy.adapter' };
+}
+dap.configurations.python = {
+ {
+ -- The first three options are required by nvim-dap
+ type = 'python'; -- the type here established the link to the adapter definition: `dap.adapters.python`
+ request = 'launch';
+ name = "Launch file";
+
+ -- Options below are for debugpy, see https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings for supported options
+
+ program = "${file}"; -- This configuration will launch the current file if used.
+ pythonPath = function()
+ -- debugpy supports launching an application with a different interpreter then the one used to launch debugpy itself.
+ -- The code below looks for a `venv` or `.venv` folder in the current directly and uses the python within.
+ -- You could adapt this - to for example use the `VIRTUAL_ENV` environment variable.
+ local cwd = vim.fn.getcwd()
+ if vim.fn.executable(cwd .. '/venv/bin/python') == 1 then
+ return cwd .. '/venv/bin/python'
+ elseif vim.fn.executable(cwd .. '/.venv/bin/python') == 1 then
+ return cwd .. '/.venv/bin/python'
+ else
+ return '/usr/bin/python'
+ end
+ end;
+ },
+}
-- dapui.setup()
dapui.setup({
icons = { expanded = "▾", collapsed = "▸" },
diff --git a/lua/user/keymaps.lua b/lua/user/keymaps.lua
index af377f5..10a8ee8 100644
--- a/lua/user/keymaps.lua
+++ b/lua/user/keymaps.lua
@@ -82,7 +82,7 @@ keymap("n", "<localleader>ro", ":MagmaShowOutput<cr>", opts)
-- LSP --
keymap("n", "<leader>la", "<cmd>lua vim.lsp.buf.code_action()<cr>", opts)
keymap("n", "<leader>ld", "<cmd>Telescope lsp_document_diagnostics<cr>", opts)
-keymap("n", "<leader>lf", "<cmd>lua vim.lsp.buf.formatting()<cr>", opts)
+keymap("n", "<leader>lf", "<cmd>lua vim.lsp.buf.formatting_sync()<cr>", opts)
keymap("n", "<leader>lF", "<cmd>LspToggleAutoFormat<cr>", opts)
keymap("n", "<leader>li", "<cmd>LspInfo<cr>", opts)
keymap("n", "<leader>lI", "<cmd>LspInstallInfo<cr>", opts)
diff --git a/lua/user/lsp/handlers.lua b/lua/user/lsp/handlers.lua
index fc5d7d3..e668ad2 100644
--- a/lua/user/lsp/handlers.lua
+++ b/lua/user/lsp/handlers.lua
@@ -73,16 +73,14 @@ local function lsp_keymaps(bufnr)
vim.api.nvim_buf_set_keymap(bufnr, "n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "<C-k>", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
- -- vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", opts)
+ vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts)
- -- vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>", opts)
- -- vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>f", "<cmd>lua vim.diagnostic.open_float()<CR>", opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "[d", '<cmd>lua vim.diagnostic.goto_prev({ border = "rounded" })<CR>', opts)
- vim.api.nvim_buf_set_keymap(bufnr, "n", "gl", "<cmd>lua vim.lsp.diagnostic.open_float()<CR>", opts)
+ -- vim.api.nvim_buf_set_keymap(bufnr, "n", "gl", "<cmd>lua vim.lsp.diagnostic.open_float()<CR>", opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "gl", "<cmd>lua vim.diagnostic.open_float()<CR>", opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "]d", '<cmd>lua vim.diagnostic.goto_next({ border = "rounded" })<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>q", "<cmd>lua vim.diagnostic.setloclist()<CR>", opts)
- vim.cmd [[ command! Format execute 'lua vim.lsp.buf.formatting()' ]]
+ vim.cmd [[ command! Format execute 'lua vim.lsp.buf.formatting_sync()' ]]
end
M.on_attach = function(client, bufnr)