diff options
| author | Vito G. Graffagnino <vito@graffagnino.xyz> | 2022-07-22 16:42:35 +0100 |
|---|---|---|
| committer | Vito G. Graffagnino <vito@graffagnino.xyz> | 2022-07-22 16:42:35 +0100 |
| commit | fa9ba544bc8c8f4398cd2138841b7d464bb3963a (patch) | |
| tree | ef1c072ec70cc95d3077c6dc10eff73be72366d8 | |
| parent | f6e0aff4356dc2598966657895c777e6bea23d54 (diff) | |
Tidied up dap, and the handlers
| -rw-r--r-- | init.lua | 48 | ||||
| -rw-r--r-- | lua/user/dap.lua | 36 | ||||
| -rw-r--r-- | lua/user/keymaps.lua | 2 | ||||
| -rw-r--r-- | lua/user/lsp/handlers.lua | 8 |
4 files changed, 60 insertions, 34 deletions
@@ -1,24 +1,24 @@ - require "user.options" - require "user.keymaps" - require "user.plugins" - require "user.colorscheme" - require "user.cmp" - require "user.lsp" - require "user.telescope" - require "user.treesitter" - require "user.autopairs" - require "user.autocommands" - require "user.comment" - require "user.dap" - require "user.gitsigns" - require "user.icons" - require "user.illuminate" - require "user.impatient" - require "user.nvim-webdev-icons" - require "user.nvim-tree" - require "user.bufferline" - require "user.lualine" - require "user.toggleterm" - require "user.indentline" - require "user.impatient" - require "user.whichkey" +require "user.options" +require "user.keymaps" +require "user.plugins" +require "user.colorscheme" +require "user.cmp" +require "user.lsp" +require "user.telescope" +require "user.treesitter" +require "user.autopairs" +require "user.autocommands" +require "user.comment" +require "user.dap" +require "user.gitsigns" +require "user.icons" +require "user.illuminate" +require "user.impatient" +require "user.nvim-webdev-icons" +require "user.nvim-tree" +require "user.bufferline" +require "user.lualine" +require "user.toggleterm" +require "user.indentline" +require "user.impatient" +require "user.whichkey" 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) |
