Setup DAP (mostly for java), updated some keybinds and fixed possible failure with the auto folding logic

master
Wynd 2026-03-15 16:19:56 +02:00
parent d15b6100c0
commit 3b16716986
10 changed files with 138 additions and 183 deletions

View File

@ -0,0 +1,4 @@
local map = vim.keymap.set
map({ "n" }, "<F5>", "<cmd>HurlRunner<CR>", { desc = "Run All requests", buffer = true })
map({ "n" }, "<F6>", "<cmd>HurlRunnerAt<CR>", { desc = "Run Api request", buffer = true })

View File

@ -1,134 +1,36 @@
{ {
"Comment.nvim": { "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" },
"branch": "master", "blink.cmp": { "branch": "main", "commit": "b19413d214068f316c78978b08264ed1c41830ec" },
"commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" "catppuccin": { "branch": "main", "commit": "beaf41a30c26fd7d6c386d383155cbd65dd554cd" },
}, "conform.nvim": { "branch": "master", "commit": "5ac2bb57a9096f00ca50e1a3c46020d5930319b8" },
"blink.cmp": { "dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" },
"branch": "main", "fidget.nvim": { "branch": "main", "commit": "7fa433a83118a70fe24c1ce88d5f0bd3453c0970" },
"commit": "b19413d214068f316c78978b08264ed1c41830ec" "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" },
}, "git-conflict.nvim": { "branch": "main", "commit": "4bbfdd92d547d2862a75b4e80afaf30e73f7bbb4" },
"catppuccin": { "hurl.nvim": { "branch": "main", "commit": "0e5430d5130fe95fc1b8b015491b50274aa2e796" },
"branch": "main", "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" },
"commit": "beaf41a30c26fd7d6c386d383155cbd65dd554cd" "lazydev.nvim": { "branch": "main", "commit": "5231c62aa83c2f8dc8e7ba957aa77098cda1257d" },
}, "lualine.nvim": { "branch": "master", "commit": "47f91c416daef12db467145e16bed5bbfe00add8" },
"conform.nvim": { "luvit-meta": { "branch": "main", "commit": "0ea4ff636c5bb559ffa78108561d0976f4de9682" },
"branch": "master", "mini.map": { "branch": "main", "commit": "32a3a5d9a7c074dbb0a4a1d5943d09cb8edbab3f" },
"commit": "5ac2bb57a9096f00ca50e1a3c46020d5930319b8" "neo-tree.nvim": { "branch": "v3.x", "commit": "f3df514fff2bdd4318127c40470984137f87b62e" },
}, "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" },
"dressing.nvim": { "nvim-colorizer.lua": { "branch": "master", "commit": "338409dd8a6ed74767bad3eb5269f1b903ffb3cf" },
"branch": "master", "nvim-dap": { "branch": "master", "commit": "a9d8cb68ee7184111dc66156c4a2ebabfbe01bc5" },
"commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" "nvim-jdtls": { "branch": "master", "commit": "77ccaeb422f8c81b647605da5ddb4a7f725cda90" },
}, "nvim-lsp-file-operations": { "branch": "master", "commit": "b9c795d3973e8eec22706af14959bc60c579e771" },
"fidget.nvim": { "nvim-lspconfig": { "branch": "master", "commit": "92ee7d42320edfbb81f3cad851314ab197fa324a" },
"branch": "main", "nvim-notify": { "branch": "master", "commit": "8701bece920b38ea289b457f902e2ad184131a5d" },
"commit": "7fa433a83118a70fe24c1ce88d5f0bd3453c0970" "nvim-surround": { "branch": "main", "commit": "1098d7b3c34adcfa7feb3289ee434529abd4afd1" },
}, "nvim-treesitter": { "branch": "main", "commit": "d19def46c112c26c17adeef88dd1253cc6d623a1" },
"friendly-snippets": { "nvim-ts-autotag": { "branch": "main", "commit": "c4ca798ab95b316a768d51eaaaee48f64a4a46bc" },
"branch": "main", "nvim-web-devicons": { "branch": "master", "commit": "803353450c374192393f5387b6a0176d0972b848" },
"commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" "outline.nvim": { "branch": "main", "commit": "1967ef50036b0b1eac4977aeede55915a741afe0" },
}, "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" },
"git-conflict.nvim": { "telescope-fzf-native.nvim": { "branch": "main", "commit": "6fea601bd2b694c6f2ae08a6c6fab14930c60e2c" },
"branch": "main", "telescope.nvim": { "branch": "master", "commit": "a8c2223ea6b185701090ccb1ebc7f4e41c4c9784" },
"commit": "4bbfdd92d547d2862a75b4e80afaf30e73f7bbb4" "todo-comments.nvim": { "branch": "main", "commit": "31e3c38ce9b29781e4422fc0322eb0a21f4e8668" },
}, "trouble.nvim": { "branch": "main", "commit": "bd67efe408d4816e25e8491cc5ad4088e708a69a" },
"hurl.nvim": { "vim-cool": { "branch": "master", "commit": "9ea940c0d537e55de0de4c0298c04b976960fb12" },
"branch": "main", "which-key.nvim": { "branch": "main", "commit": "3aab2147e74890957785941f0c1ad87d0a44c15a" }
"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"
}
} }

View File

@ -1,5 +1,12 @@
local map = vim.keymap.set 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 -- generic
-- prevents selected text we past over to be moved in a registry and override our paste -- prevents selected text we past over to be moved in a registry and override our paste
map("x", "p", '"_dP') map("x", "p", '"_dP')
@ -7,7 +14,14 @@ map("x", "p", '"_dP')
map({ "n", "v", "x" }, "x", '"_d') map({ "n", "v", "x" }, "x", '"_d')
map({ "n", "v", "x" }, "<Del>", '"_x') map({ "n", "v", "x" }, "<Del>", '"_x')
-- filthy casual save keybind -- filthy casual save keybind
map({ "n", "i", "v" }, "<C-s>", "<cmd>w<cr>", { desc = "File Save" }) map({ "n", "i", "v" }, "<C-s>", 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 -- easy way to close the current buffer
map("n", "<C-X>", "<cmd>bd!<cr>", { desc = "Close Buffer" }) map("n", "<C-X>", "<cmd>bd!<cr>", { desc = "Close Buffer" })
-- moves the selection up or down using K and J (uppercase) -- moves the selection up or down using K and J (uppercase)
@ -22,12 +36,12 @@ map("n", "<M-Up>", "<cmd>cprev<cr>", { desc = "Qui[C]kfix Next" })
map("t", "<ESC>", "<C-\\><C-n>") map("t", "<ESC>", "<C-\\><C-n>")
-- telescope -- telescope
local telescope = require("telescope.builtin")
map("n", "<leader>ff", telescope.find_files, { desc = "[F]ind [F]iles" }) map("n", "<leader>ff", telescope.find_files, { desc = "[F]ind [F]iles" })
map("n", "<leader>fh", telescope.help_tags, { desc = "[F]ind [H]elp" }) map("n", "<leader>fh", telescope.help_tags, { desc = "[F]ind [H]elp" })
map("n", "<leader>fr", telescope.oldfiles, { desc = "[F]ind [R]ecent" }) map("n", "<leader>fr", telescope.oldfiles, { desc = "[F]ind [R]ecent" })
map("n", "<leader>fsb", telescope.current_buffer_fuzzy_find, { desc = "[F]ind [S]tring in current [B]uffer" }) map("n", "<leader>fsb", telescope.current_buffer_fuzzy_find, { desc = "[F]ind [S]tring in current [B]uffer" })
map("n", "<leader>fsg", telescope.live_grep, { desc = "[F]ind [S]tring [G]lobal" }) map("n", "<leader>fsg", telescope.live_grep, { desc = "[F]ind [S]tring [G]lobal" })
map("n", "<leader>fds", telescope.lsp_dynamic_workspace_symbols, { desc = "[F]ind [D]ynamic [S]ymbols" })
map("n", "<leader>fgg", telescope.git_files, { desc = "[F]ind [G]it" }) map("n", "<leader>fgg", telescope.git_files, { desc = "[F]ind [G]it" })
map("n", "<leader>fgs", telescope.git_status, { desc = "[F]ind [G]it [S]tatus" }) map("n", "<leader>fgs", telescope.git_status, { desc = "[F]ind [G]it [S]tatus" })
map("n", "<leader>fgh", telescope.git_stash, { desc = "[F]ind [G]it Stas[H]" }) map("n", "<leader>fgh", telescope.git_stash, { desc = "[F]ind [G]it Stas[H]" })
@ -54,6 +68,20 @@ map("n", "<leader>ws", telescope.lsp_dynamic_workspace_symbols, { desc = "[W]ork
map("n", "<leader>ds", telescope.lsp_document_symbols, { desc = "[D]ocument [S]ymbols" }) map("n", "<leader>ds", telescope.lsp_document_symbols, { desc = "[D]ocument [S]ymbols" })
map("n", "<leader>rn", vim.lsp.buf.rename, { desc = "[R]e[n]ame" }) map("n", "<leader>rn", vim.lsp.buf.rename, { desc = "[R]e[n]ame" })
-- dap
map("n", "<F5>", function()
dap.continue()
end, { desc = "Run Debug" })
map("n", "<C-b>", function()
dap.toggle_breakpoint()
end, { desc = "Toggle Breakpoint" })
map("n", "<F6>", function()
dap.step_over()
end, { desc = "Debug Step Over" })
map("n", "<F7>", function()
dap.step_into()
end, { desc = "Debug Step Into" })
-- neo-tree -- neo-tree
map("n", "<leader>n", "<cmd>Neotree toggle<cr>", { desc = "Toggle Filetree Window" }) map("n", "<leader>n", "<cmd>Neotree toggle<cr>", { desc = "Toggle Filetree Window" })
map("n", "<leader>e", "<cmd>Neotree focus<cr>", { desc = "Focus Filetree Window" }) map("n", "<leader>e", "<cmd>Neotree focus<cr>", { desc = "Focus Filetree Window" })
@ -61,9 +89,18 @@ map("n", "<leader>e", "<cmd>Neotree focus<cr>", { desc = "Focus Filetree Window"
-- minimap -- minimap
map("n", "<leader>m", MiniMap.toggle, { desc = "Toggle Minimap" }) map("n", "<leader>m", MiniMap.toggle, { desc = "Toggle Minimap" })
-- outline
map("n", "<leader>oo", function()
outline.toggle_outline()
end, { desc = "Toggle Outline" })
-- formatting
map("", "<C-f>", function()
conform.format({ async = true, lsp_fallback = true })
end, { desc = "Format selection" })
-- comment -- comment
-- _ represents the / key here -- _ represents the / key here
local comment_api = require("Comment.api")
map({ "n", "i" }, "<C-_>", function() map({ "n", "i" }, "<C-_>", function()
comment_api.toggle.linewise.current() comment_api.toggle.linewise.current()
end, { desc = "Toggle Comment" }) end, { desc = "Toggle Comment" })

View File

@ -0,0 +1,5 @@
return {
{
"mfussenegger/nvim-dap",
},
}

View File

@ -8,10 +8,25 @@ return {
}, },
config = function() config = function()
local telescope = require("telescope") local telescope = require("telescope")
local actions = require("telescope.actions")
telescope.setup({ telescope.setup({
extension = { extension = {
fzf = {}, fzf = {},
}, },
pickers = {
buffers = {
mappings = {
i = {
["<C-d>"] = actions.delete_buffer,
},
n = {
["<C-d>"] = actions.delete_buffer,
},
},
},
},
}) })
telescope.load_extension("fzf") telescope.load_extension("fzf")
@ -99,10 +114,6 @@ return {
"hedyhli/outline.nvim", "hedyhli/outline.nvim",
lazy = true, lazy = true,
cmd = { "Outline", "OutlineOpen" }, cmd = { "Outline", "OutlineOpen" },
keys = {
{ "<leader>oo", "<cmd>Outline<CR>", desc = "[O]utline [O]pen" },
{ "<leader>of", "<cmd>OutlineFocus<CR>", desc = "[O]utline [F]ocus" },
},
opts = { opts = {
outline_window = { outline_window = {
width = 20, width = 20,

View File

@ -3,17 +3,6 @@ return {
"stevearc/conform.nvim", "stevearc/conform.nvim",
event = { "BufWritePre" }, event = { "BufWritePre" },
cmd = { "ConformInfo" }, cmd = { "ConformInfo" },
keys = {
{
-- "<leader>fc",
"<C-f>",
function()
require("conform").format({ async = true, lsp_fallback = true })
end,
mode = "",
desc = "[F]ormat [C]ode inside current buffer",
},
},
opts = { opts = {
formatters_by_ft = { formatters_by_ft = {
lua = { "stylua" }, lua = { "stylua" },

View File

@ -79,7 +79,9 @@ return {
}, },
init_options = { init_options = {
bundles = {}, bundles = {
"~/.local/lib/com.microsoft.java.debug.plugin-0.53.2.jar",
},
}, },
}) })
vim.lsp.enable("jdtls") vim.lsp.enable("jdtls")
@ -208,5 +210,10 @@ return {
opts = {}, opts = {},
}, },
{ "mfussenegger/nvim-jdtls" }, {
"mfussenegger/nvim-jdtls",
dependencies = {
"mfussenegger/nvim-dap",
},
},
} }

View File

@ -63,23 +63,24 @@ return {
"desktop", "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 -- 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 if not ok then
return return
end end
local import_nodes = {
rust = "use_declaration",
java = "import_declaration",
}
local ft = vim.bo.filetype local ft = vim.bo.filetype
-- check the language of the buffer and the TS node associated with the import section -- check the language of the buffer and the TS node associated with the import section
local target = import_nodes[ft] local targets = import_nodes[ft]
if not target then if not targets then
return return
end end
@ -88,16 +89,19 @@ return {
-- parse all the nodes until finding the import nodes -- parse all the nodes until finding the import nodes
for node in root:iter_children() do for node in root:iter_children() do
if node:type() == target then for _, target in ipairs(targets) do
local start_row, _, _, _ = node:range() 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 -- force update the folds to exist or something ?, the following pcall can sometimes fail because folds don't yet exist, this fixes it
-- the function usage is to avoid some annoying warning because vim.cmd is seen as a table and pcall takes a function pcall(vim.cmd, "silent! normal! zx")
local _, _ = pcall(function()
vim.cmd(start_row + 1 .. "foldclose")
end)
break -- close the fold starting with the first line of the chunk
pcall(vim.cmd, start_row + 1 .. "foldclose")
return
end
end end
end end
end end
@ -113,10 +117,13 @@ return {
-- indentation -- indentation
vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
close_import_fold()
end, end,
}) })
vim.api.nvim_create_autocmd("FileType", {
pattern = vim.tbl_keys(import_nodes),
callback = close_import_fold,
})
end, end,
}, },
} }

View File

@ -69,18 +69,6 @@ return {
prev_panel = "<C-p>", prev_panel = "<C-p>",
}, },
}, },
keys = {
-- Run API request
{ "<F5>", "<cmd>HurlRunner<CR>", desc = "Run All requests" },
{ "<F5>a", "<cmd>HurlRunnerAt<CR>", desc = "Run Api request" },
-- { "<leader>te", "<cmd>HurlRunnerToEntry<CR>", desc = "Run Api request to entry" },
-- { "<leader>tE", "<cmd>HurlRunnerToEnd<CR>", desc = "Run Api request from current entry to end" },
-- { "<leader>tm", "<cmd>HurlToggleMode<CR>", desc = "Hurl Toggle Mode" },
-- { "<leader>tv", "<cmd>HurlVerbose<CR>", desc = "Run Api in verbose mode" },
-- { "<leader>tV", "<cmd>HurlVeryVerbose<CR>", desc = "Run Api in very verbose mode" },
-- Run Hurl request in visual mode
-- { "<leader>h", ":HurlRunner<CR>", desc = "Hurl Runner", mode = "v" },
},
}, },
{ {

View File

@ -0,0 +1,5 @@
; extends
[
(block_comment)
] @fold