diff --git a/init.vim b/init.vim index ab8d7b5..ba7e866 100644 --- a/init.vim +++ b/init.vim @@ -37,6 +37,9 @@ source ~/.config/nvim/plugin-confs/fidget.lua source ~/.config/nvim/plugin-confs/symbols-outline.lua source ~/.config/nvim/plugin-confs/chatgpt.lua source ~/.config/nvim/plugin-confs/nvim-colorizer.lua +source ~/.config/nvim/plugin-confs/nvim-dap-python.lua +source ~/.config/nvim/plugin-confs/nvim-dap-bash.lua +source ~/.config/nvim/plugin-confs/nvim-dap-ui.lua " source ~/.config/nvim/plugin-confs/copilot.lua " source ~/.config/nvim/plugin-confs/lsp-signature.lua " source ~/.config/nvim/plugin-confs/nvim-docs-view.lua @@ -53,7 +56,7 @@ source ~/.config/nvim/plugin-confs/github-theme.lua source ~/.config/nvim/plugin-confs/onedarkpro.lua source ~/.config/nvim/plugin-confs/catppuccin.lua -source ~/.config/nvim/lua/toggle_lsp_diagnostics.lua +" source ~/.config/nvim/lua/toggle_lsp_diagnostics.lua " CUSTOM COMMANDS command! -bang -nargs=? -complete=dir Files diff --git a/keybindings.vim b/keybindings.vim index 72a9de5..7602e52 100644 --- a/keybindings.vim +++ b/keybindings.vim @@ -59,6 +59,7 @@ nnoremap bp :bprev nnoremap ca :lua vim.lsp.buf.code_action() nnoremap cd :Telescope diagnostics +nnoremap cDt :lua require("dapui").toggle() nnoremap cp :vert Copilot panel nnoremap Ci :lua require('chatgpt').edit_with_instructions() nnoremap Cd :ChatGPTRun docstring diff --git a/lua/plugins.lua b/lua/plugins.lua index 9330f1b..9df5c85 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -71,14 +71,12 @@ require('packer').startup(function(use) } } }) - require("copilot.suggestion").toggle_auto_trigger() end, 100) end } use { "zbirenbaum/copilot-cmp", - -- after = { "copilot.lua" }, config = function() require("copilot_cmp").setup({ suggestion = { enabled = false }, @@ -93,43 +91,6 @@ require('packer').startup(function(use) use { 'junegunn/fzf', run = function() vim.fn['fzf#install']() end } - -- use { - -- "lewis6991/hover.nvim", - -- config = function() - -- require("hover").setup { - -- init = function() - -- -- Require providers - -- require("hover.providers.lsp") - -- -- require('hover.providers.gh') - -- -- require('hover.providers.jira') - -- require('hover.providers.man') - -- require('hover.providers.dictionary') - -- end, - -- preview_opts = { - -- border = "rounded" - -- -- border = { - -- -- { "╭", "FloatBorder" }, - -- -- { "─", "FloatBorder" }, - -- -- { "╮", "FloatBorder" }, - -- -- { "│", "FloatBorder" }, - -- -- { "╯", "FloatBorder" }, - -- -- { "─", "FloatBorder" }, - -- -- { "╰", "FloatBorder" }, - -- -- { "│", "FloatBorder" }, - -- -- } - -- }, - -- -- Whether the contents of a currently open hover window should be moved - -- -- to a :h preview-window when pressing the hover keymap. - -- preview_window = false, - -- title = true - -- } - - -- -- Setup keymaps - -- vim.keymap.set("n", "K", require("hover").hover, {desc = "hover.nvim"}) - -- vim.keymap.set("n", "gK", require("hover").hover_select, {desc = "hover.nvim (select)"}) - -- end - -- } - use 'norcalli/nvim-colorizer.lua' use 'jiangmiao/auto-pairs' use 'junegunn/fzf.vim' @@ -171,13 +132,29 @@ require('packer').startup(function(use) end } use { 'jose-elias-alvarez/null-ls.nvim' } - use { 'ksyasuda/lsp_lines.nvim' } + use { 'https://git.sr.ht/~whynothugo/lsp_lines.nvim' } use { 'neovim/nvim-lspconfig' } use { 'onsails/lspkind-nvim' } -- use 'ray-x/lsp_signature.nvim' use { 'rmagatti/goto-preview' } use 'saadparwaiz1/cmp_luasnip' - use 'williamboman/nvim-lsp-installer' + use({ + "jackMort/ChatGPT.nvim", + commit = "24bcca7", + requires = { + "MunifTanjim/nui.nvim", "nvim-lua/plenary.nvim", + "nvim-telescope/telescope.nvim" + } + }) + + use({ + "iamcco/markdown-preview.nvim", + run = function() vim.fn["mkdp#util#install"]() end + }) + + use 'folke/neodev.nvim' + use 'mfussenegger/nvim-dap' + use { "rcarriga/nvim-dap-ui", requires = { "mfussenegger/nvim-dap" } } use { 'Mofiqul/dracula.nvim' } use({ @@ -223,21 +200,5 @@ require('packer').startup(function(use) use { 'olimorris/onedarkpro.nvim' } use { 'projekt0n/github-nvim-theme' } - use({ - "jackMort/ChatGPT.nvim", - commit = "24bcca7", - requires = { - "MunifTanjim/nui.nvim", "nvim-lua/plenary.nvim", - "nvim-telescope/telescope.nvim" - } - }) - - use 'khaveesh/vim-fish-syntax' - use { "catppuccin/nvim", as = "catppuccin" } - - use({ - "iamcco/markdown-preview.nvim", - run = function() vim.fn["mkdp#util#install"]() end - }) end) diff --git a/plugin-confs/lspconfig.lua b/plugin-confs/lspconfig.lua index 14cb9bd..c2c2b2c 100644 --- a/plugin-confs/lspconfig.lua +++ b/plugin-confs/lspconfig.lua @@ -1,8 +1,12 @@ local opts = { noremap = true, silent = true } -vim.api.nvim_set_keymap('n', 'e', 'lua vim.diagnostic.open_float()', opts) -vim.api.nvim_set_keymap('n', '[d', 'lua vim.diagnostic.goto_prev()', opts) -vim.api.nvim_set_keymap('n', ']d', 'lua vim.diagnostic.goto_next()', opts) -vim.api.nvim_set_keymap('n', 'q', 'lua vim.diagnostic.setloclist()', opts) +vim.api.nvim_set_keymap('n', 'e', + 'lua vim.diagnostic.open_float()', opts) +vim.api.nvim_set_keymap('n', '[d', 'lua vim.diagnostic.goto_prev()', + opts) +vim.api.nvim_set_keymap('n', ']d', 'lua vim.diagnostic.goto_next()', + opts) +vim.api.nvim_set_keymap('n', 'q', + 'lua vim.diagnostic.setloclist()', opts) -- Use an on_attach function to only map the following keys -- after the language server attaches to the current buffer @@ -60,20 +64,17 @@ vim.cmd [[autocmd! ColorScheme * highlight FloatBorder guifg=white guibg=#1f2335 -- rounded local border = { - { "╭", "FloatBorder" }, - { "─", "FloatBorder" }, - { "╮", "FloatBorder" }, - { "│", "FloatBorder" }, - { "╯", "FloatBorder" }, - { "─", "FloatBorder" }, - { "╰", "FloatBorder" }, - { "│", "FloatBorder" }, + { "╭", "FloatBorder" }, { "─", "FloatBorder" }, { "╮", "FloatBorder" }, + { "│", "FloatBorder" }, { "╯", "FloatBorder" }, { "─", "FloatBorder" }, + { "╰", "FloatBorder" }, { "│", "FloatBorder" } } - local handlers = { - ["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = border }), - ["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = border }), + ["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, + { border = border }), + ["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers + .signature_help, + { border = border }) } -- local orig_util_open_floating_preview = vim.lsp.util.open_floating_preview @@ -93,7 +94,7 @@ local DEFAULT_SETTINGS = { -- The list icon to use for servers that are pending installation. server_pending = "◍", -- The list icon to use for servers that are not installed. - server_uninstalled = "◍", + server_uninstalled = "◍" }, keymaps = { -- Keymap to expand a server in the UI @@ -105,8 +106,8 @@ local DEFAULT_SETTINGS = { -- Keymap to update all installed servers update_all_servers = "U", -- Keymap to uninstall a server - uninstall_server = "X", - }, + uninstall_server = "X" + } }, -- The directory in which to install all servers. @@ -117,7 +118,7 @@ local DEFAULT_SETTINGS = { -- and is not recommended. -- -- Example: { "--proxy", "https://proxyserver" } - install_args = {}, + install_args = {} }, on_attach = on_attach, handlers = handlers, @@ -128,7 +129,7 @@ local DEFAULT_SETTINGS = { -- Limit for the maximum amount of servers to be installed at the same time. Once this limit is reached, any further -- servers that are requested to be installed will be put in a queue. - max_concurrent_installers = 4, + max_concurrent_installers = 4 } vim.diagnostic.config({ @@ -136,7 +137,7 @@ vim.diagnostic.config({ signs = true, underline = false, update_in_insert = false, - severity_sort = true, + severity_sort = true }) local signs = { Error = " ", Warn = " ", Hint = " ", Info = " " } @@ -155,7 +156,9 @@ function PrintDiagnostics(opts, bufnr, line_nr, client_id) local diagnostic_message = "" for i, diagnostic in ipairs(line_diagnostics) do - diagnostic_message = diagnostic_message .. string.format("%d: %s", i, diagnostic.message or "") + diagnostic_message = diagnostic_message .. + string.format("%d: %s", i, + diagnostic.message or "") print(diagnostic_message) if i ~= #line_diagnostics then diagnostic_message = diagnostic_message .. "\n" @@ -166,24 +169,8 @@ end -- vim.cmd [[ autocmd! CursorHold * lua PrintDiagnostics() ]] -local lsp_installer = require("nvim-lsp-installer") - -- Register a handler that will be called for each installed server when it's ready (i.e. when installation is finished -- or if the server is already installed). -lsp_installer.on_server_ready(function(server) - local opts = {} - - -- (optional) Customize the options passed to the server - -- if server.name == "tsserver" then - -- opts.root_dir = function() ... end - -- end - - -- This setup() function will take the provided server configuration and decorate it with the necessary properties - -- before passing it onwards to lspconfig. - -- Refer to https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md - server:setup(DEFAULT_SETTINGS) -end) - -- local servers = { 'jedi_language_server', 'bashls', 'vimls', 'yamlls', 'dockerls', 'rust_analyzer', 'clangd', 'ansiblels' } -- for _, lsp in pairs(servers) do diff --git a/plugin-confs/lsplines.lua b/plugin-confs/lsplines.lua index ffa8a09..450c266 100644 --- a/plugin-confs/lsplines.lua +++ b/plugin-confs/lsplines.lua @@ -1,5 +1,6 @@ require("lsp_lines").setup() -- Disable virtual_text since it's redundant due to lsp_lines. -vim.diagnostic.config({ - virtual_text = false, -}) +vim.diagnostic.config({ virtual_text = false }) + +vim.keymap.set("", "tl", require("lsp_lines").toggle, + { desc = "Toggle lsp_lines" }) diff --git a/plugin-confs/nvim-dap-bash.lua b/plugin-confs/nvim-dap-bash.lua new file mode 100644 index 0000000..7e5cac8 --- /dev/null +++ b/plugin-confs/nvim-dap-bash.lua @@ -0,0 +1,31 @@ +local dap = require('dap') +dap.adapters.bashdb = { + type = 'executable', + command = vim.fn.stdpath("data") .. + '/mason/packages/bash-debug-adapter/bash-debug-adapter', + name = 'bashdb' +} + +dap.configurations.sh = { + { + type = 'bashdb', + request = 'launch', + name = "Launch file", + showDebugOutput = true, + pathBashdb = vim.fn.stdpath("data") .. + '/mason/packages/bash-debug-adapter/extension/bashdb_dir/bashdb', + pathBashdbLib = vim.fn.stdpath("data") .. + '/mason/packages/bash-debug-adapter/extension/bashdb_dir', + trace = true, + file = "${file}", + program = "${file}", + cwd = '${workspaceFolder}', + pathCat = "cat", + pathBash = "/bin/bash", + pathMkfifo = "mkfifo", + pathPkill = "pkill", + args = {}, + env = {}, + terminalKind = "integrated" + } +} diff --git a/plugin-confs/nvim-dap-python.lua b/plugin-confs/nvim-dap-python.lua new file mode 100644 index 0000000..6600a04 --- /dev/null +++ b/plugin-confs/nvim-dap-python.lua @@ -0,0 +1,48 @@ +local dap = require('dap') +dap.adapters.python = function(cb, config) + if config.request == 'attach' then + ---@diagnostic disable-next-line: undefined-field + local port = (config.connect or config).port + ---@diagnostic disable-next-line: undefined-field + local host = (config.connect or config).host or '127.0.0.1' + cb({ + type = 'server', + port = assert(port, + '`connect.port` is required for a python `attach` configuration'), + host = host, + options = { source_filetype = 'python' } + }) + else + cb({ + type = 'executable', + command = '/home/sudacode/Projects/Python/debugpy/env/bin/python', + args = { '-m', 'debugpy.adapter' }, + options = { source_filetype = 'python' } + }) + end +end +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 .. '/env/bin/python') == 1 then + return cwd .. '/env/bin/python' + elseif vim.fn.executable(cwd .. '/.env/bin/python') == 1 then + return cwd .. '/.env/bin/python' + else + return '/usr/bin/python' + end + end + } +} diff --git a/plugin-confs/nvim-dap-ui.lua b/plugin-confs/nvim-dap-ui.lua new file mode 100644 index 0000000..c5dc318 --- /dev/null +++ b/plugin-confs/nvim-dap-ui.lua @@ -0,0 +1,7 @@ +require("dapui").setup() +-- local dap, dapui = require("dap"), require("dapui") +-- 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