From 3b167169864f5fd631a7cb4a67465d3558042870 Mon Sep 17 00:00:00 2001 From: Wynd Date: Sun, 15 Mar 2026 16:19:56 +0200 Subject: [PATCH] Setup DAP (mostly for java), updated some keybinds and fixed possible failure with the auto folding logic --- .../wynd/.config/nvim/after/ftplugin/hurl.lua | 4 + backup/home/wynd/.config/nvim/lazy-lock.json | 166 ++++-------------- .../wynd/.config/nvim/lua/nvwynd/keymaps.lua | 43 ++++- .../.config/nvim/lua/nvwynd/plugins/dap.lua | 5 + .../nvim/lua/nvwynd/plugins/editor.lua | 19 +- .../nvim/lua/nvwynd/plugins/formatting.lua | 11 -- .../.config/nvim/lua/nvwynd/plugins/lsp.lua | 11 +- .../nvim/lua/nvwynd/plugins/treesitter.lua | 45 +++-- .../.config/nvim/lua/nvwynd/plugins/util.lua | 12 -- .../wynd/.config/nvim/queries/java/folds.scm | 5 + 10 files changed, 138 insertions(+), 183 deletions(-) create mode 100644 backup/home/wynd/.config/nvim/after/ftplugin/hurl.lua create mode 100644 backup/home/wynd/.config/nvim/lua/nvwynd/plugins/dap.lua create mode 100644 backup/home/wynd/.config/nvim/queries/java/folds.scm diff --git a/backup/home/wynd/.config/nvim/after/ftplugin/hurl.lua b/backup/home/wynd/.config/nvim/after/ftplugin/hurl.lua new file mode 100644 index 0000000..6e54164 --- /dev/null +++ b/backup/home/wynd/.config/nvim/after/ftplugin/hurl.lua @@ -0,0 +1,4 @@ +local map = vim.keymap.set + +map({ "n" }, "", "HurlRunner", { desc = "Run All requests", buffer = true }) +map({ "n" }, "", "HurlRunnerAt", { desc = "Run Api request", buffer = true }) diff --git a/backup/home/wynd/.config/nvim/lazy-lock.json b/backup/home/wynd/.config/nvim/lazy-lock.json index 4f8eb29..456a02e 100644 --- a/backup/home/wynd/.config/nvim/lazy-lock.json +++ b/backup/home/wynd/.config/nvim/lazy-lock.json @@ -1,134 +1,36 @@ { - "Comment.nvim": { - "branch": "master", - "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" - }, - "blink.cmp": { - "branch": "main", - "commit": "b19413d214068f316c78978b08264ed1c41830ec" - }, - "catppuccin": { - "branch": "main", - "commit": "beaf41a30c26fd7d6c386d383155cbd65dd554cd" - }, - "conform.nvim": { - "branch": "master", - "commit": "5ac2bb57a9096f00ca50e1a3c46020d5930319b8" - }, - "dressing.nvim": { - "branch": "master", - "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" - }, - "fidget.nvim": { - "branch": "main", - "commit": "7fa433a83118a70fe24c1ce88d5f0bd3453c0970" - }, - "friendly-snippets": { - "branch": "main", - "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" - }, - "git-conflict.nvim": { - "branch": "main", - "commit": "4bbfdd92d547d2862a75b4e80afaf30e73f7bbb4" - }, - "hurl.nvim": { - "branch": "main", - "commit": "0e5430d5130fe95fc1b8b015491b50274aa2e796" - }, - "lazy.nvim": { - "branch": "main", - "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" - }, - "lazydev.nvim": { - "branch": "main", - "commit": "5231c62aa83c2f8dc8e7ba957aa77098cda1257d" - }, - "lualine.nvim": { - "branch": "master", - "commit": "47f91c416daef12db467145e16bed5bbfe00add8" - }, - "luvit-meta": { - "branch": "main", - "commit": "0ea4ff636c5bb559ffa78108561d0976f4de9682" - }, - "mini.map": { - "branch": "main", - "commit": "32a3a5d9a7c074dbb0a4a1d5943d09cb8edbab3f" - }, - "neo-tree.nvim": { - "branch": "v3.x", - "commit": "f3df514fff2bdd4318127c40470984137f87b62e" - }, - "nui.nvim": { - "branch": "main", - "commit": "de740991c12411b663994b2860f1a4fd0937c130" - }, - "nvim-colorizer.lua": { - "branch": "master", - "commit": "338409dd8a6ed74767bad3eb5269f1b903ffb3cf" - }, - "nvim-jdtls": { - "branch": "master", - "commit": "77ccaeb422f8c81b647605da5ddb4a7f725cda90" - }, - "nvim-lsp-file-operations": { - "branch": "master", - "commit": "b9c795d3973e8eec22706af14959bc60c579e771" - }, - "nvim-lspconfig": { - "branch": "master", - "commit": "92ee7d42320edfbb81f3cad851314ab197fa324a" - }, - "nvim-notify": { - "branch": "master", - "commit": "8701bece920b38ea289b457f902e2ad184131a5d" - }, - "nvim-surround": { - "branch": "main", - "commit": "1098d7b3c34adcfa7feb3289ee434529abd4afd1" - }, - "nvim-treesitter": { - "branch": "main", - "commit": "d19def46c112c26c17adeef88dd1253cc6d623a1" - }, - "nvim-ts-autotag": { - "branch": "main", - "commit": "c4ca798ab95b316a768d51eaaaee48f64a4a46bc" - }, - "nvim-web-devicons": { - "branch": "master", - "commit": "803353450c374192393f5387b6a0176d0972b848" - }, - "outline.nvim": { - "branch": "main", - "commit": "1967ef50036b0b1eac4977aeede55915a741afe0" - }, - "plenary.nvim": { - "branch": "master", - "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" - }, - "telescope-fzf-native.nvim": { - "branch": "main", - "commit": "6fea601bd2b694c6f2ae08a6c6fab14930c60e2c" - }, - "telescope.nvim": { - "branch": "master", - "commit": "a8c2223ea6b185701090ccb1ebc7f4e41c4c9784" - }, - "todo-comments.nvim": { - "branch": "main", - "commit": "31e3c38ce9b29781e4422fc0322eb0a21f4e8668" - }, - "trouble.nvim": { - "branch": "main", - "commit": "bd67efe408d4816e25e8491cc5ad4088e708a69a" - }, - "vim-cool": { - "branch": "master", - "commit": "9ea940c0d537e55de0de4c0298c04b976960fb12" - }, - "which-key.nvim": { - "branch": "main", - "commit": "3aab2147e74890957785941f0c1ad87d0a44c15a" - } + "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, + "blink.cmp": { "branch": "main", "commit": "b19413d214068f316c78978b08264ed1c41830ec" }, + "catppuccin": { "branch": "main", "commit": "beaf41a30c26fd7d6c386d383155cbd65dd554cd" }, + "conform.nvim": { "branch": "master", "commit": "5ac2bb57a9096f00ca50e1a3c46020d5930319b8" }, + "dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" }, + "fidget.nvim": { "branch": "main", "commit": "7fa433a83118a70fe24c1ce88d5f0bd3453c0970" }, + "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, + "git-conflict.nvim": { "branch": "main", "commit": "4bbfdd92d547d2862a75b4e80afaf30e73f7bbb4" }, + "hurl.nvim": { "branch": "main", "commit": "0e5430d5130fe95fc1b8b015491b50274aa2e796" }, + "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, + "lazydev.nvim": { "branch": "main", "commit": "5231c62aa83c2f8dc8e7ba957aa77098cda1257d" }, + "lualine.nvim": { "branch": "master", "commit": "47f91c416daef12db467145e16bed5bbfe00add8" }, + "luvit-meta": { "branch": "main", "commit": "0ea4ff636c5bb559ffa78108561d0976f4de9682" }, + "mini.map": { "branch": "main", "commit": "32a3a5d9a7c074dbb0a4a1d5943d09cb8edbab3f" }, + "neo-tree.nvim": { "branch": "v3.x", "commit": "f3df514fff2bdd4318127c40470984137f87b62e" }, + "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, + "nvim-colorizer.lua": { "branch": "master", "commit": "338409dd8a6ed74767bad3eb5269f1b903ffb3cf" }, + "nvim-dap": { "branch": "master", "commit": "a9d8cb68ee7184111dc66156c4a2ebabfbe01bc5" }, + "nvim-jdtls": { "branch": "master", "commit": "77ccaeb422f8c81b647605da5ddb4a7f725cda90" }, + "nvim-lsp-file-operations": { "branch": "master", "commit": "b9c795d3973e8eec22706af14959bc60c579e771" }, + "nvim-lspconfig": { "branch": "master", "commit": "92ee7d42320edfbb81f3cad851314ab197fa324a" }, + "nvim-notify": { "branch": "master", "commit": "8701bece920b38ea289b457f902e2ad184131a5d" }, + "nvim-surround": { "branch": "main", "commit": "1098d7b3c34adcfa7feb3289ee434529abd4afd1" }, + "nvim-treesitter": { "branch": "main", "commit": "d19def46c112c26c17adeef88dd1253cc6d623a1" }, + "nvim-ts-autotag": { "branch": "main", "commit": "c4ca798ab95b316a768d51eaaaee48f64a4a46bc" }, + "nvim-web-devicons": { "branch": "master", "commit": "803353450c374192393f5387b6a0176d0972b848" }, + "outline.nvim": { "branch": "main", "commit": "1967ef50036b0b1eac4977aeede55915a741afe0" }, + "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "6fea601bd2b694c6f2ae08a6c6fab14930c60e2c" }, + "telescope.nvim": { "branch": "master", "commit": "a8c2223ea6b185701090ccb1ebc7f4e41c4c9784" }, + "todo-comments.nvim": { "branch": "main", "commit": "31e3c38ce9b29781e4422fc0322eb0a21f4e8668" }, + "trouble.nvim": { "branch": "main", "commit": "bd67efe408d4816e25e8491cc5ad4088e708a69a" }, + "vim-cool": { "branch": "master", "commit": "9ea940c0d537e55de0de4c0298c04b976960fb12" }, + "which-key.nvim": { "branch": "main", "commit": "3aab2147e74890957785941f0c1ad87d0a44c15a" } } diff --git a/backup/home/wynd/.config/nvim/lua/nvwynd/keymaps.lua b/backup/home/wynd/.config/nvim/lua/nvwynd/keymaps.lua index 7b844a3..1edda61 100644 --- a/backup/home/wynd/.config/nvim/lua/nvwynd/keymaps.lua +++ b/backup/home/wynd/.config/nvim/lua/nvwynd/keymaps.lua @@ -1,5 +1,12 @@ local map = vim.keymap.set +local jdtls = require("jdtls") +local dap = require("dap") +local telescope = require("telescope.builtin") +local comment_api = require("Comment.api") +local conform = require("conform") +local outline = require("outline") + -- generic -- prevents selected text we past over to be moved in a registry and override our paste map("x", "p", '"_dP') @@ -7,7 +14,14 @@ map("x", "p", '"_dP') map({ "n", "v", "x" }, "x", '"_d') map({ "n", "v", "x" }, "", '"_x') -- filthy casual save keybind -map({ "n", "i", "v" }, "", "w", { desc = "File Save" }) +map({ "n", "i", "v" }, "", function() + vim.cmd("w") + local has_dap_session = dap.session() ~= nil + -- If jdtls is available and dap is running also run the hotcode swap automatically + if jdtls and has_dap_session then + vim.cmd("JdtUpdateHotcode") + end +end, { desc = "File Save" }) -- easy way to close the current buffer map("n", "", "bd!", { desc = "Close Buffer" }) -- moves the selection up or down using K and J (uppercase) @@ -22,12 +36,12 @@ map("n", "", "cprev", { desc = "Qui[C]kfix Next" }) map("t", "", "") -- telescope -local telescope = require("telescope.builtin") map("n", "ff", telescope.find_files, { desc = "[F]ind [F]iles" }) map("n", "fh", telescope.help_tags, { desc = "[F]ind [H]elp" }) map("n", "fr", telescope.oldfiles, { desc = "[F]ind [R]ecent" }) map("n", "fsb", telescope.current_buffer_fuzzy_find, { desc = "[F]ind [S]tring in current [B]uffer" }) map("n", "fsg", telescope.live_grep, { desc = "[F]ind [S]tring [G]lobal" }) +map("n", "fds", telescope.lsp_dynamic_workspace_symbols, { desc = "[F]ind [D]ynamic [S]ymbols" }) map("n", "fgg", telescope.git_files, { desc = "[F]ind [G]it" }) map("n", "fgs", telescope.git_status, { desc = "[F]ind [G]it [S]tatus" }) map("n", "fgh", telescope.git_stash, { desc = "[F]ind [G]it Stas[H]" }) @@ -54,6 +68,20 @@ map("n", "ws", telescope.lsp_dynamic_workspace_symbols, { desc = "[W]ork map("n", "ds", telescope.lsp_document_symbols, { desc = "[D]ocument [S]ymbols" }) map("n", "rn", vim.lsp.buf.rename, { desc = "[R]e[n]ame" }) +-- dap +map("n", "", function() + dap.continue() +end, { desc = "Run Debug" }) +map("n", "", function() + dap.toggle_breakpoint() +end, { desc = "Toggle Breakpoint" }) +map("n", "", function() + dap.step_over() +end, { desc = "Debug Step Over" }) +map("n", "", function() + dap.step_into() +end, { desc = "Debug Step Into" }) + -- neo-tree map("n", "n", "Neotree toggle", { desc = "Toggle Filetree Window" }) map("n", "e", "Neotree focus", { desc = "Focus Filetree Window" }) @@ -61,9 +89,18 @@ map("n", "e", "Neotree focus", { desc = "Focus Filetree Window" -- minimap map("n", "m", MiniMap.toggle, { desc = "Toggle Minimap" }) +-- outline +map("n", "oo", function() + outline.toggle_outline() +end, { desc = "Toggle Outline" }) + +-- formatting +map("", "", function() + conform.format({ async = true, lsp_fallback = true }) +end, { desc = "Format selection" }) + -- comment -- _ represents the / key here -local comment_api = require("Comment.api") map({ "n", "i" }, "", function() comment_api.toggle.linewise.current() end, { desc = "Toggle Comment" }) diff --git a/backup/home/wynd/.config/nvim/lua/nvwynd/plugins/dap.lua b/backup/home/wynd/.config/nvim/lua/nvwynd/plugins/dap.lua new file mode 100644 index 0000000..27d3438 --- /dev/null +++ b/backup/home/wynd/.config/nvim/lua/nvwynd/plugins/dap.lua @@ -0,0 +1,5 @@ +return { + { + "mfussenegger/nvim-dap", + }, +} diff --git a/backup/home/wynd/.config/nvim/lua/nvwynd/plugins/editor.lua b/backup/home/wynd/.config/nvim/lua/nvwynd/plugins/editor.lua index dbda9ee..91c5e93 100644 --- a/backup/home/wynd/.config/nvim/lua/nvwynd/plugins/editor.lua +++ b/backup/home/wynd/.config/nvim/lua/nvwynd/plugins/editor.lua @@ -8,10 +8,25 @@ return { }, config = function() local telescope = require("telescope") + local actions = require("telescope.actions") + telescope.setup({ extension = { fzf = {}, }, + + pickers = { + buffers = { + mappings = { + i = { + [""] = actions.delete_buffer, + }, + n = { + [""] = actions.delete_buffer, + }, + }, + }, + }, }) telescope.load_extension("fzf") @@ -99,10 +114,6 @@ return { "hedyhli/outline.nvim", lazy = true, cmd = { "Outline", "OutlineOpen" }, - keys = { - { "oo", "Outline", desc = "[O]utline [O]pen" }, - { "of", "OutlineFocus", desc = "[O]utline [F]ocus" }, - }, opts = { outline_window = { width = 20, diff --git a/backup/home/wynd/.config/nvim/lua/nvwynd/plugins/formatting.lua b/backup/home/wynd/.config/nvim/lua/nvwynd/plugins/formatting.lua index adcf70b..e62c28e 100644 --- a/backup/home/wynd/.config/nvim/lua/nvwynd/plugins/formatting.lua +++ b/backup/home/wynd/.config/nvim/lua/nvwynd/plugins/formatting.lua @@ -3,17 +3,6 @@ return { "stevearc/conform.nvim", event = { "BufWritePre" }, cmd = { "ConformInfo" }, - keys = { - { - -- "fc", - "", - function() - require("conform").format({ async = true, lsp_fallback = true }) - end, - mode = "", - desc = "[F]ormat [C]ode inside current buffer", - }, - }, opts = { formatters_by_ft = { lua = { "stylua" }, diff --git a/backup/home/wynd/.config/nvim/lua/nvwynd/plugins/lsp.lua b/backup/home/wynd/.config/nvim/lua/nvwynd/plugins/lsp.lua index b63b8ce..b7575d3 100644 --- a/backup/home/wynd/.config/nvim/lua/nvwynd/plugins/lsp.lua +++ b/backup/home/wynd/.config/nvim/lua/nvwynd/plugins/lsp.lua @@ -79,7 +79,9 @@ return { }, init_options = { - bundles = {}, + bundles = { + "~/.local/lib/com.microsoft.java.debug.plugin-0.53.2.jar", + }, }, }) vim.lsp.enable("jdtls") @@ -208,5 +210,10 @@ return { opts = {}, }, - { "mfussenegger/nvim-jdtls" }, + { + "mfussenegger/nvim-jdtls", + dependencies = { + "mfussenegger/nvim-dap", + }, + }, } diff --git a/backup/home/wynd/.config/nvim/lua/nvwynd/plugins/treesitter.lua b/backup/home/wynd/.config/nvim/lua/nvwynd/plugins/treesitter.lua index 17c91ba..b240fe5 100644 --- a/backup/home/wynd/.config/nvim/lua/nvwynd/plugins/treesitter.lua +++ b/backup/home/wynd/.config/nvim/lua/nvwynd/plugins/treesitter.lua @@ -63,23 +63,24 @@ return { "desktop", }) - local function close_import_fold() + local import_nodes = { + rust = { "use_declaration" }, + java = { "import_declaration" }, + python = { "import_statement", "import_from_statement" }, + } + + local function close_import_fold(args) -- see if there's a parser associated with the current buffer - local ok, parser = pcall(vim.treesitter.get_parser, 0) + local ok, parser = pcall(vim.treesitter.get_parser, args.buf) if not ok then return end - local import_nodes = { - rust = "use_declaration", - java = "import_declaration", - } - local ft = vim.bo.filetype -- check the language of the buffer and the TS node associated with the import section - local target = import_nodes[ft] - if not target then + local targets = import_nodes[ft] + if not targets then return end @@ -88,16 +89,19 @@ return { -- parse all the nodes until finding the import nodes for node in root:iter_children() do - if node:type() == target then - local start_row, _, _, _ = node:range() + for _, target in ipairs(targets) do + if node:type() == target then + local start_row, _, _, _ = node:range() + ---@diagnostic disable: param-type-mismatch - -- close the fold starting with the first line of the chunk - -- the function usage is to avoid some annoying warning because vim.cmd is seen as a table and pcall takes a function - local _, _ = pcall(function() - vim.cmd(start_row + 1 .. "foldclose") - end) + -- force update the folds to exist or something ?, the following pcall can sometimes fail because folds don't yet exist, this fixes it + pcall(vim.cmd, "silent! normal! zx") - break + -- close the fold starting with the first line of the chunk + pcall(vim.cmd, start_row + 1 .. "foldclose") + + return + end end end end @@ -113,10 +117,13 @@ return { -- indentation vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" - - close_import_fold() end, }) + + vim.api.nvim_create_autocmd("FileType", { + pattern = vim.tbl_keys(import_nodes), + callback = close_import_fold, + }) end, }, } diff --git a/backup/home/wynd/.config/nvim/lua/nvwynd/plugins/util.lua b/backup/home/wynd/.config/nvim/lua/nvwynd/plugins/util.lua index 6274c4d..e3c6d8f 100644 --- a/backup/home/wynd/.config/nvim/lua/nvwynd/plugins/util.lua +++ b/backup/home/wynd/.config/nvim/lua/nvwynd/plugins/util.lua @@ -69,18 +69,6 @@ return { prev_panel = "", }, }, - keys = { - -- Run API request - { "", "HurlRunner", desc = "Run All requests" }, - { "a", "HurlRunnerAt", desc = "Run Api request" }, - -- { "te", "HurlRunnerToEntry", desc = "Run Api request to entry" }, - -- { "tE", "HurlRunnerToEnd", desc = "Run Api request from current entry to end" }, - -- { "tm", "HurlToggleMode", desc = "Hurl Toggle Mode" }, - -- { "tv", "HurlVerbose", desc = "Run Api in verbose mode" }, - -- { "tV", "HurlVeryVerbose", desc = "Run Api in very verbose mode" }, - -- Run Hurl request in visual mode - -- { "h", ":HurlRunner", desc = "Hurl Runner", mode = "v" }, - }, }, { diff --git a/backup/home/wynd/.config/nvim/queries/java/folds.scm b/backup/home/wynd/.config/nvim/queries/java/folds.scm new file mode 100644 index 0000000..1fbbeb6 --- /dev/null +++ b/backup/home/wynd/.config/nvim/queries/java/folds.scm @@ -0,0 +1,5 @@ +; extends + +[ + (block_comment) +] @fold