tried to do debug things

This commit is contained in:
Christoph J. Scherr 2023-09-21 15:58:30 +02:00
parent 8aa6183df7
commit 5928954cc9
6 changed files with 202 additions and 24 deletions

View File

@ -15,6 +15,8 @@ require('lazy').setup(vim.tbl_extend('keep', config.user_lazy_opts(), {
{ import = 'plex.plugins.extras.editor' }, { import = 'plex.plugins.extras.editor' },
{ import = 'plex.plugins.extras.org' }, { import = 'plex.plugins.extras.org' },
{ import = 'plex.plugins.extras.lang.go' }, { import = 'plex.plugins.extras.lang.go' },
{ import = 'plex.plugins.extras.lang.cpp' },
{ import = 'plex.plugins.extras.lang.rust' },
{ import = 'plex.plugins.extras.lang.json' }, { import = 'plex.plugins.extras.lang.json' },
{ import = 'plex.plugins.extras.lang.python' }, { import = 'plex.plugins.extras.lang.python' },
{ import = 'plex.plugins.extras.lang.yaml' }, { import = 'plex.plugins.extras.lang.yaml' },

View File

@ -44,11 +44,11 @@ return {
}, },
sources = cmp.config.sources({ sources = cmp.config.sources({
{ name = 'nvim_lsp', priority = 50 }, { name = 'nvim_lsp', priority = 50 },
{ name = 'path', priority = 40 }, { name = 'path', priority = 40 },
{ name = 'luasnip', priority = 30 }, { name = 'luasnip', priority = 30 },
}, { }, {
{ name = 'buffer', priority = 50, keyword_length = 3 }, { name = 'buffer', priority = 50, keyword_length = 3 },
{ name = 'emoji', insert = true, priority = 20 }, { name = 'emoji', insert = true, priority = 20 },
{ {
name = 'tmux', name = 'tmux',
priority = 10, priority = 10,
@ -135,7 +135,7 @@ return {
dependencies = { 'rafamadriz/friendly-snippets' }, dependencies = { 'rafamadriz/friendly-snippets' },
build = (not jit.os:find('Windows')) build = (not jit.os:find('Windows'))
and "echo 'jsregexp is optional, so not a big deal if it fails to build'; make install_jsregexp" and "echo 'jsregexp is optional, so not a big deal if it fails to build'; make install_jsregexp"
or nil, or nil,
-- stylua: ignore -- stylua: ignore
keys = { keys = {
{ {
@ -205,12 +205,12 @@ return {
local plugin = require('lazy.core.config').spec.plugins['mini.surround'] local plugin = require('lazy.core.config').spec.plugins['mini.surround']
local opts = require('lazy.core.plugin').values(plugin, 'opts', false) local opts = require('lazy.core.plugin').values(plugin, 'opts', false)
local mappings = { local mappings = {
{ opts.mappings.add, desc = 'Add surrounding', mode = { 'n', 'x', 'v' } }, { opts.mappings.add, desc = 'Add surrounding', mode = { 'n', 'x', 'v' } },
{ opts.mappings.delete, desc = 'Delete surrounding', mode = { 'n', 'x', 'v' } }, { opts.mappings.delete, desc = 'Delete surrounding', mode = { 'n', 'x', 'v' } },
{ opts.mappings.find, desc = 'Find right surrounding', mode = { 'n', 'x', 'v' } }, { opts.mappings.find, desc = 'Find right surrounding', mode = { 'n', 'x', 'v' } },
{ opts.mappings.find_left, desc = 'Find left surrounding', mode = { 'n', 'x', 'v' } }, { opts.mappings.find_left, desc = 'Find left surrounding', mode = { 'n', 'x', 'v' } },
{ opts.mappings.highlight, desc = 'Highlight surrounding', mode = { 'n', 'x', 'v' } }, { opts.mappings.highlight, desc = 'Highlight surrounding', mode = { 'n', 'x', 'v' } },
{ opts.mappings.replace, desc = 'Replace surrounding', mode = { 'n', 'x', 'v' } }, { opts.mappings.replace, desc = 'Replace surrounding', mode = { 'n', 'x', 'v' } },
{ opts.mappings.update_n_lines, desc = 'Update `MiniSurround.config.n_lines`', mode = { 'n', 'x', 'v' } }, { opts.mappings.update_n_lines, desc = 'Update `MiniSurround.config.n_lines`', mode = { 'n', 'x', 'v' } },
} }
mappings = vim.tbl_filter(function(m) mappings = vim.tbl_filter(function(m)
@ -220,12 +220,12 @@ return {
end, end,
opts = { opts = {
mappings = { mappings = {
add = '<leader>sa', -- Add surrounding in Normal and Visual modes add = '<leader>sa', -- Add surrounding in Normal and Visual modes
delete = '<leader>sd', -- Delete surrounding delete = '<leader>sd', -- Delete surrounding
find = '<leader>sf', -- Find surrounding (to the right) find = '<leader>sf', -- Find surrounding (to the right)
find_left = '<leader>sF', -- Find surrounding (to the left) find_left = '<leader>sF', -- Find surrounding (to the left)
highlight = '<leader>sh', -- Highlight surrounding highlight = '<leader>sh', -- Highlight surrounding
replace = '<leader>cs', -- Replace surrounding replace = '<leader>cs', -- Replace surrounding
update_n_lines = '<leader>su', -- Update `n_lines` update_n_lines = '<leader>su', -- Update `n_lines`
}, },
}, },
@ -238,13 +238,13 @@ return {
dependencies = { 'JoosepAlviste/nvim-ts-context-commentstring' }, dependencies = { 'JoosepAlviste/nvim-ts-context-commentstring' },
keys = { keys = {
{ '<Leader>v', 'gcc', remap = true, silent = true, mode = 'n' }, { '<Leader>v', 'gcc', remap = true, silent = true, mode = 'n' },
{ '<Leader>v', 'gc', remap = true, silent = true, mode = 'x' }, { '<Leader>v', 'gc', remap = true, silent = true, mode = 'x' },
}, },
opts = { opts = {
options = { options = {
custom_commentstring = function() custom_commentstring = function()
return require('ts_context_commentstring.internal').calculate_commentstring() return require('ts_context_commentstring.internal').calculate_commentstring()
or vim.bo.commentstring or vim.bo.commentstring
end, end,
}, },
}, },
@ -304,9 +304,9 @@ return {
'AndrewRadev/linediff.vim', 'AndrewRadev/linediff.vim',
cmd = { 'Linediff', 'LinediffAdd' }, cmd = { 'Linediff', 'LinediffAdd' },
keys = { keys = {
{ '<Leader>mdf', ':Linediff<CR>', mode = 'x', desc = 'Line diff' }, { '<Leader>mdf', ':Linediff<CR>', mode = 'x', desc = 'Line diff' },
{ '<Leader>mda', ':LinediffAdd<CR>', mode = 'x', desc = 'Line diff add' }, { '<Leader>mda', ':LinediffAdd<CR>', mode = 'x', desc = 'Line diff add' },
{ '<Leader>mds', '<cmd>LinediffShow<CR>', desc = 'Line diff show' }, { '<Leader>mds', '<cmd>LinediffShow<CR>', desc = 'Line diff show' },
{ '<Leader>mdr', '<cmd>LinediffReset<CR>', desc = 'Line diff reset' }, { '<Leader>mdr', '<cmd>LinediffReset<CR>', desc = 'Line diff reset' },
}, },
}, },
@ -323,4 +323,43 @@ return {
vim.g.dsf_no_mappings = 1 vim.g.dsf_no_mappings = 1
end, end,
}, },
-----------------------------------------------------------------------------
{
-- TODO:
-- make debugging for C. Cpp, Rust, Python work
'mfussenegger/nvim-dap',
keys = {
{
'<leader>db',
'<cmd>lua require\'dap\'.toggle_breakpoint()<CR>',
mode = { 'n', 'x' },
desc = 'Debugging: Toggle breakpoint',
},
{
'<leader>db',
'<cmd>lua require\'dap\'.continue()<CR>',
mode = { 'n', 'x' },
desc = 'Debugging: Start or continue debug session',
},
{
'<leader>dsi',
'<cmd>lua require\'dap\'.step_into()<CR>',
mode = { 'n', 'x' },
desc = 'Debugging: Step into code',
},
{
'<leader>dso',
'<cmd>lua require\'dap\'.step_over()<CR>',
mode = { 'n', 'x' },
desc = 'Debugging: Step over code',
},
{
'<leader>dm',
'<cmd>lua require\'dap\'.repl.open()<CR>',
mode = { 'n', 'x' },
desc = 'Debugging: Menu',
},
},
},
} }

View File

@ -0,0 +1,74 @@
return {
{
'mfussenegger/nvim-dap',
optional = true,
dependencies = {
'mfussenegger/nvim-dap-python',
},
-- stylua: ignore
-- keys = {
-- { '<leader>dPt', function() require('dap-python').test_method() end, desc = 'Debug Method' },
-- { '<leader>dPc', function() require('dap-python').test_class() end, desc = 'Debug Class' },
-- },
config = function()
local dap = require('dap')
dap.adapters.lldb = {
type = 'executable',
command = '/usr/bin/lldb-vscode', -- adjust as needed, must be absolute path
name = 'lldb'
}
dap.configurations.c= {
{
name = 'Launch',
type = 'lldb',
request = 'launch',
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
cwd = '${workspaceFolder}',
stopOnEntry = false,
args = {},
-- 💀
-- if you change `runInTerminal` to true, you might need to change the yama/ptrace_scope setting:
--
-- echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
--
-- Otherwise you might get the following error:
--
-- Error on launch: Failed to attach to the target process
--
-- But you should be aware of the implications:
-- https://www.kernel.org/doc/html/latest/admin-guide/LSM/Yama.html
-- runInTerminal = false,
},
}
dap.configurations.cpp = {
{
name = 'Launch',
type = 'lldb',
request = 'launch',
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
cwd = '${workspaceFolder}',
stopOnEntry = false,
args = {},
-- 💀
-- if you change `runInTerminal` to true, you might need to change the yama/ptrace_scope setting:
--
-- echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
--
-- Otherwise you might get the following error:
--
-- Error on launch: Failed to attach to the target process
--
-- But you should be aware of the implications:
-- https://www.kernel.org/doc/html/latest/admin-guide/LSM/Yama.html
-- runInTerminal = false,
},
}
end,
},
}

View File

@ -0,0 +1,42 @@
return {
{
'mfussenegger/nvim-dap',
optional = true,
dependencies = {
'mfussenegger/nvim-dap-python',
},
-- stylua: ignore
-- keys = {
-- { '<leader>dPt', function() require('dap-python').test_method() end, desc = 'Debug Method' },
-- { '<leader>dPc', function() require('dap-python').test_class() end, desc = 'Debug Class' },
-- },
config = function()
local dap = require('dap')
dap.configurations.rust = {
{
-- ... the previous config goes here ...,
initCommands = function()
-- Find out where to look for the pretty printer Python module
local rustc_sysroot = vim.fn.trim(vim.fn.system('rustc --print sysroot'))
local script_import = 'command script import "' .. rustc_sysroot .. '/lib/rustlib/etc/lldb_lookup.py"'
local commands_file = rustc_sysroot .. '/lib/rustlib/etc/lldb_commands'
local commands = {}
local file = io.open(commands_file, 'r')
if file then
for line in file:lines() do
table.insert(commands, line)
end
file:close()
end
table.insert(commands, 1, script_import)
return commands
end,
-- ...,
}
}
end,
},
}

View File

@ -25,7 +25,7 @@ return {
-- stylua: ignore -- stylua: ignore
keys = { keys = {
{ '<leader>co', '<cmd>TypescriptOrganizeImports<CR>', desc = 'Organize Imports' }, { '<leader>co', '<cmd>TypescriptOrganizeImports<CR>', desc = 'Organize Imports' },
{ '<leader>cR', '<cmd>TypescriptRenameFile<CR>', desc = 'Rename File' }, { '<leader>cR', '<cmd>TypescriptRenameFile<CR>', desc = 'Rename File' },
}, },
settings = { settings = {
---@diagnostic disable: missing-fields ---@diagnostic disable: missing-fields
@ -93,8 +93,8 @@ return {
-- 💀 Make sure to update this path to point to your installation -- 💀 Make sure to update this path to point to your installation
args = { args = {
require('mason-registry') require('mason-registry')
.get_package('js-debug-adapter') .get_package('js-debug-adapter')
:get_install_path() .. '/js-debug/src/dapDebugServer.js', :get_install_path() .. '/js-debug/src/dapDebugServer.js',
'${port}', '${port}',
}, },
}, },

View File

@ -125,3 +125,24 @@ Rustdoc
paragraph paragraph
rustc rustc
Klabnik Klabnik
io
rustbook
Deserialize
deserialisierbaren
SIGTERM
Beendigungsabfrage
SIGKILL
stdout
stderr
Leveln
gedroppt
#ekonstruktor
Dekonstruktor/!
dealloziiert
Dealloziierung
Dealloziieren
vvvv
TODO
vvvv
Structs
nomicon