- added nlua (lua neovim) debug configuration

This commit is contained in:
Erik Mertens
2025-06-26 11:28:50 +02:00
parent f9c8a41cc6
commit bc0e4a1650
8 changed files with 281 additions and 81 deletions

View File

@ -4,14 +4,20 @@
"friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" },
"kanagawa-paper.nvim": { "branch": "master", "commit": "b0df20cca3b7087c06f241983b488190cc8e23af" }, "kanagawa-paper.nvim": { "branch": "master", "commit": "b0df20cca3b7087c06f241983b488190cc8e23af" },
"lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "f54e3c11fc9ebfcfc27e696182b0295b071d0811" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "c4c84f4521d62de595c0d0f718a9a40c1890c8ce" },
"mason-nvim-dap.nvim": { "branch": "main", "commit": "4c2cdc69d69fe00c15ae8648f7e954d99e5de3ea" },
"mason-tool-installer.nvim": { "branch": "main", "commit": "93a9ff9b34c91c0cb0f7de8d5f7e4abce51d8903" }, "mason-tool-installer.nvim": { "branch": "main", "commit": "93a9ff9b34c91c0cb0f7de8d5f7e4abce51d8903" },
"mason.nvim": { "branch": "main", "commit": "8024d64e1330b86044fed4c8494ef3dcd483a67c" }, "mason.nvim": { "branch": "main", "commit": "8024d64e1330b86044fed4c8494ef3dcd483a67c" },
"mini.nvim": { "branch": "main", "commit": "3f5d06a6f710966cb93baaadc4897eeb6d6210e5" }, "mini.nvim": { "branch": "main", "commit": "1b32a3f61f1f649cadc748bd4b7a32b4b4785d29" },
"nvim-lspconfig": { "branch": "master", "commit": "314b35335cc84bc2a085c84c69da955ba22da163" }, "nvim-dap": { "branch": "master", "commit": "2edd6375692d9ac1053d50acfe415c1eb2ba92d0" },
"nvim-dap-ui": { "branch": "master", "commit": "73a26abf4941aa27da59820fd6b028ebcdbcf932" },
"nvim-lspconfig": { "branch": "master", "commit": "5e0e9c00d51fcb7efef0d4c49023f9593b38661e" },
"nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" },
"nvim-rpgle": { "branch": "master", "commit": "8feaf44adf915c1df255920268beec710188df43" },
"nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" },
"nvim-ts-autotag": { "branch": "main", "commit": "a1d526af391f6aebb25a8795cbc05351ed3620b5" }, "nvim-ts-autotag": { "branch": "main", "commit": "a1d526af391f6aebb25a8795cbc05351ed3620b5" },
"nvim-web-devicons": { "branch": "master", "commit": "1fb58cca9aebbc4fd32b086cb413548ce132c127" }, "nvim-web-devicons": { "branch": "master", "commit": "19d6211c78169e78bab372b585b6fb17ad974e82" },
"one-small-step-for-vimkind": { "branch": "main", "commit": "d9f832598e14f3b206b06f5738d02cebede65269" },
"plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" },
"telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, "telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" },
"which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" } "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" }

View File

@ -20,7 +20,7 @@ require("lazy").setup({
spec = { spec = {
-- import your plugins -- import your plugins
{ import = "plugins" }, { import = "plugins" },
-- "https://git.erik.mertens.digital/erik/nvim-rpgle.git" "https://git.erik.mertens.digital/erik/nvim-rpgle.git"
}, },
-- Configure any other settings here. See the documentation for more details. -- Configure any other settings here. See the documentation for more details.
-- colorscheme that will be used when installing plugins. -- colorscheme that will be used when installing plugins.

View File

@ -5,6 +5,10 @@ return {
version = '1.*', version = '1.*',
cond = function()
return not vim.g.vscode
end,
---@module 'blink.cmp' ---@module 'blink.cmp'
---@type blink.cmp.Config ---@type blink.cmp.Config
opts = { opts = {
@ -46,4 +50,3 @@ return {
}, },
opts_extend = { "sources.default" } opts_extend = { "sources.default" }
} }

177
lua/plugins/debug.lua Normal file
View File

@ -0,0 +1,177 @@
-- debug.lua
--
-- Shows how to use the DAP plugin to debug your code.
--
-- Primarily focused on configuring the debugger for Go, but can
-- be extended to other languages as well. That's why it's called
-- kickstart.nvim and not kitchen-sink.nvim ;)
return {
-- NOTE: Yes, you can install new plugins here!
'mfussenegger/nvim-dap',
-- NOTE: And you can specify dependencies as well
dependencies = {
-- Creates a beautiful debugger UI
'rcarriga/nvim-dap-ui',
-- Required dependency for nvim-dap-ui
'nvim-neotest/nvim-nio',
-- Installs the debug adapters for you
'mason-org/mason.nvim',
'jay-babu/mason-nvim-dap.nvim',
-- Add your own debuggers here
-- 'leoluz/nvim-dap-go',
"jbyuki/one-small-step-for-vimkind"
},
keys = {
-- Basic debugging keymaps, feel free to change to your liking!
{
'<F5>',
function()
require('dap').step_into()
end,
desc = 'Debug: Step Into',
},
{
'<F6>',
function()
require('dap').step_over()
end,
desc = 'Debug: Step Over',
},
{
'<F7>',
function()
require('dap').step_out()
end,
desc = 'Debug: Step Out',
},
{
'<F8>',
function()
require('dap').continue()
end,
desc = 'Debug: Start/Continue',
},
-- Toggle to see last session result. Without this, you can't see session output in case of unhandled exception.
{
'<F9>',
function()
require('dapui').toggle()
end,
desc = 'Debug: See last session result.',
},
{
'<leader>Db',
function()
require('dap').toggle_breakpoint()
end,
desc = '[D]ebug: Toggle [b]reakpoint',
},
{
'<leader>DB',
function()
require('dap').set_breakpoint(vim.fn.input 'Breakpoint condition: ')
end,
desc = '[D]ebug: Set [B]reakpoint condition',
},
{
"<leader>Dl",
function()
require("osv").launch({ port = 8086 })
end,
desc = "[D]ebug [l]aunch"
},
{
"<leader>Dh",
function()
require("dap.ui.widgets").hover()
end,
desc = "[D]ebug [h]over"
}
-- vim.keymap.set('n', '<leader>Dl', function()
-- require "osv".launch({ port = 8086 })
-- end, { noremap = true })
},
config = function()
local dap = require 'dap'
local dapui = require 'dapui'
require('mason-nvim-dap').setup {
-- Makes a best effort to setup the various debuggers with
-- reasonable debug configurations
automatic_installation = true,
-- You can provide additional configuration to the handlers,
-- see mason-nvim-dap README for more information
handlers = {
function(config)
require("mason-nvim-dap").default_setup(config)
end
},
-- You'll need to check that you have the required things installed
-- online, please don't ask me how to install them :)
ensure_installed = {
-- Update this to ensure that you have the debuggers for the langs you want
"firefox_debug_adapter",
"codelldb",
"local-lua-debugger-vscode"
},
}
-- Dap UI setup
-- For more information, see |:help nvim-dap-ui|
dapui.setup {
-- Set icons to characters that are more likely to work in every terminal.
-- Feel free to remove or use ones that you like more! :)
-- Don't feel like these are good choices.
icons = { expanded = '', collapsed = '', current_frame = '*' },
controls = {
icons = {
pause = '',
play = '',
step_into = '',
step_over = '',
step_out = '',
step_back = 'b',
run_last = '▶▶',
terminate = '',
disconnect = '',
},
},
}
-- Change breakpoint icons
vim.api.nvim_set_hl(0, 'DapBreak', { fg = '#e51400' })
vim.api.nvim_set_hl(0, 'DapStop', { fg = '#ffcc00' })
local breakpoint_icons = vim.g.have_nerd_font
and { Breakpoint = '', BreakpointCondition = '', BreakpointRejected = '', LogPoint = '', Stopped = '' }
or { Breakpoint = '', BreakpointCondition = '', BreakpointRejected = '', LogPoint = '', Stopped = '' }
for type, icon in pairs(breakpoint_icons) do
local tp = 'Dap' .. type
local hl = (type == 'Stopped') and 'DapStop' or 'DapBreak'
vim.fn.sign_define(tp, { text = icon, texthl = hl, numhl = hl })
end
dap.listeners.after.event_initialized['dapui_config'] = dapui.open
dap.listeners.before.event_terminated['dapui_config'] = dapui.close
dap.listeners.before.event_exited['dapui_config'] = dapui.close
-- Configure debug adapters
dap.configurations.lua = {
{
type = 'nlua',
request = 'attach',
name = "Attach to running Neovim instance",
}
}
dap.adapters.nlua = function(callback, config)
callback({ type = 'server', host = config.host or "127.0.0.1", port = config.port or 8086 })
end
end,
}

View File

@ -20,7 +20,7 @@ return { -- LSP Configuration & Plugins
map('gd', function() vim.lsp.buf.definition() end, '[G]oto [D]efinition') map('gd', function() vim.lsp.buf.definition() end, '[G]oto [D]efinition')
-- map('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') -- map('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
-- map('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') -- map('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')
map('<leader>D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition') map('<leader>gd', require('telescope.builtin').lsp_type_definitions, '[G]oto Type [D]efinition')
map('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') map('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
map('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') map('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
-- map('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame') -- map('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
@ -34,7 +34,8 @@ return { -- LSP Configuration & Plugins
-- --
-- When you move your cursor, the highlights will be cleared (the second autocommand). -- When you move your cursor, the highlights will be cleared (the second autocommand).
local client = vim.lsp.get_client_by_id(event.data.client_id) local client = vim.lsp.get_client_by_id(event.data.client_id)
if client and client.server_capabilities.documentHighlightProvider then if client and client:supports_method(
vim.lsp.protocol.Methods.textDocument_documentHighlight, event.buf) then
vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
buffer = event.buf, buffer = event.buf,
callback = vim.lsp.buf.document_highlight, callback = vim.lsp.buf.document_highlight,
@ -46,6 +47,13 @@ return { -- LSP Configuration & Plugins
}) })
end end
if client and client:supports_method(
vim.lsp.protocol.Methods.textDocument_documentHighlight, event.buf) then
map('<leader>ti', function()
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({ bufnr = event.buf }))
end, "[T]oggle [I]nlay")
end
-- autoformat -- autoformat
vim.api.nvim_create_autocmd("BufWritePre", { vim.api.nvim_create_autocmd("BufWritePre", {
buffer = event.buf, buffer = event.buf,
@ -84,7 +92,8 @@ return { -- LSP Configuration & Plugins
workspace = { workspace = {
library = { library = {
[vim.fn.expand("$VIMRUNTIME/lua")] = true, [vim.fn.expand("$VIMRUNTIME/lua")] = true,
[vim.fn.stdpath("config") .. "/lua"] = true [vim.fn.stdpath("config") .. "/lua"] = true,
["${3rd}/luv/library"] = true,
} }
} }
}, },

View File

@ -1,10 +1,13 @@
return { return {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
branch = 'master', branch = "master",
lazy = false, lazy = false,
build = ":TSUpdate", build = ":TSUpdate",
event = { "BufRead" }, event = { "BufRead" },
opts = { -- Das Plugin bietet noch diverse weitere Optionen. opts = { -- Das Plugin bietet noch diverse weitere Optionen.
ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc',
'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc', "rust", "vue", "typescript", "css"
},
indent = { enable = true }, -- Automatische Einrückungen mit Tree-sitter indent = { enable = true }, -- Automatische Einrückungen mit Tree-sitter
highlight = { enable = true }, -- Das Syntax-Highlighting einschalten highlight = { enable = true }, -- Das Syntax-Highlighting einschalten
auto_install = true, -- Highlighting-Daten automatisch installieren auto_install = true, -- Highlighting-Daten automatisch installieren

View File

@ -7,6 +7,9 @@ return {
wk.add({ wk.add({
{ "<leader>f", group = "Telescope" } { "<leader>f", group = "Telescope" }
}) })
wk.add({
{ "<leader>D", group = "Debug" }
})
end, end,
keys = { keys = {
{ {

View File

@ -1,4 +1,3 @@
-- Keymaps -- Keymaps
-- Copy -- Copy
vim.api.nvim_set_keymap("n", "<C-v>", '"+gp', { noremap = true }) vim.api.nvim_set_keymap("n", "<C-v>", '"+gp', { noremap = true })
@ -52,16 +51,6 @@ vim.o.laststatus = 3
vim.o.breakindent = true vim.o.breakindent = true
vim.o.showbreak = "=>" vim.o.showbreak = "=>"
-- setup sign symbols
local signs = { Error = "", Warn = "", Hint = "💡", Info = "" }
for type, icon in pairs(signs) do
local hl = "DiagnosticSign" .. type
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
end
-- -- terminal mode -- -- terminal mode
-- if jit.os == "Windows" then -- if jit.os == "Windows" then
-- vim.o.shell = [[C:\Users\mertens\AppData\Local\Programs\Git\bin\bash.exe]] -- vim.o.shell = [[C:\Users\mertens\AppData\Local\Programs\Git\bin\bash.exe]]
@ -69,5 +58,15 @@ end
-- --
-- vim.o.backupdir = "C:\\Users\\mertens\\AppData\\Local\\nvim-data\\backup" -- vim.o.backupdir = "C:\\Users\\mertens\\AppData\\Local\\nvim-data\\backup"
-- end -- end
vim.diagnostic.config({
vim.diagnostic.config({ virtual_lines = { current_line = true } }) severity_sort = true,
signs = {
text = {
[vim.diagnostic.severity.ERROR] = "",
[vim.diagnostic.severity.WARN] = "",
[vim.diagnostic.severity.HINT] = "💡",
[vim.diagnostic.severity.INFO] = "",
}
},
virtual_lines = { current_line = true }
})