From 870dc27c24015da50a1bd57fc488de1f55e33010 Mon Sep 17 00:00:00 2001 From: "Christoph J. Scherr" Date: Thu, 21 Sep 2023 15:58:30 +0200 Subject: [PATCH] tried to do debug things --- init.lua | 2 + lua/plex/plugins/coding.lua | 81 +++++++++++++++----- lua/plex/plugins/extras/lang/cpp.lua | 74 ++++++++++++++++++ lua/plex/plugins/extras/lang/rust.lua | 42 ++++++++++ lua/plex/plugins/extras/lang/typescript.lua | 6 +- spell/en.utf-8.add | 21 +++++ spell/en.utf-8.add.spl | Bin 1711 -> 1914 bytes 7 files changed, 202 insertions(+), 24 deletions(-) create mode 100644 lua/plex/plugins/extras/lang/cpp.lua create mode 100644 lua/plex/plugins/extras/lang/rust.lua diff --git a/init.lua b/init.lua index 1498982..7d76f98 100644 --- a/init.lua +++ b/init.lua @@ -15,6 +15,8 @@ require('lazy').setup(vim.tbl_extend('keep', config.user_lazy_opts(), { { import = 'plex.plugins.extras.editor' }, { import = 'plex.plugins.extras.org' }, { 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.python' }, { import = 'plex.plugins.extras.lang.yaml' }, diff --git a/lua/plex/plugins/coding.lua b/lua/plex/plugins/coding.lua index b534fa6..9afb160 100644 --- a/lua/plex/plugins/coding.lua +++ b/lua/plex/plugins/coding.lua @@ -44,11 +44,11 @@ return { }, sources = cmp.config.sources({ { name = 'nvim_lsp', priority = 50 }, - { name = 'path', priority = 40 }, - { name = 'luasnip', priority = 30 }, + { name = 'path', priority = 40 }, + { name = 'luasnip', priority = 30 }, }, { { name = 'buffer', priority = 50, keyword_length = 3 }, - { name = 'emoji', insert = true, priority = 20 }, + { name = 'emoji', insert = true, priority = 20 }, { name = 'tmux', priority = 10, @@ -135,7 +135,7 @@ return { dependencies = { 'rafamadriz/friendly-snippets' }, build = (not jit.os:find('Windows')) and "echo 'jsregexp is optional, so not a big deal if it fails to build'; make install_jsregexp" - or nil, + or nil, -- stylua: ignore keys = { { @@ -205,12 +205,12 @@ return { local plugin = require('lazy.core.config').spec.plugins['mini.surround'] local opts = require('lazy.core.plugin').values(plugin, 'opts', false) local mappings = { - { opts.mappings.add, desc = 'Add 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_left, desc = 'Find left 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.add, desc = 'Add 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_left, desc = 'Find left 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.update_n_lines, desc = 'Update `MiniSurround.config.n_lines`', mode = { 'n', 'x', 'v' } }, } mappings = vim.tbl_filter(function(m) @@ -220,12 +220,12 @@ return { end, opts = { mappings = { - add = 'sa', -- Add surrounding in Normal and Visual modes - delete = 'sd', -- Delete surrounding - find = 'sf', -- Find surrounding (to the right) - find_left = 'sF', -- Find surrounding (to the left) - highlight = 'sh', -- Highlight surrounding - replace = 'cs', -- Replace surrounding + add = 'sa', -- Add surrounding in Normal and Visual modes + delete = 'sd', -- Delete surrounding + find = 'sf', -- Find surrounding (to the right) + find_left = 'sF', -- Find surrounding (to the left) + highlight = 'sh', -- Highlight surrounding + replace = 'cs', -- Replace surrounding update_n_lines = 'su', -- Update `n_lines` }, }, @@ -238,13 +238,13 @@ return { dependencies = { 'JoosepAlviste/nvim-ts-context-commentstring' }, keys = { { 'v', 'gcc', remap = true, silent = true, mode = 'n' }, - { 'v', 'gc', remap = true, silent = true, mode = 'x' }, + { 'v', 'gc', remap = true, silent = true, mode = 'x' }, }, opts = { options = { custom_commentstring = function() return require('ts_context_commentstring.internal').calculate_commentstring() - or vim.bo.commentstring + or vim.bo.commentstring end, }, }, @@ -304,9 +304,9 @@ return { 'AndrewRadev/linediff.vim', cmd = { 'Linediff', 'LinediffAdd' }, keys = { - { 'mdf', ':Linediff', mode = 'x', desc = 'Line diff' }, - { 'mda', ':LinediffAdd', mode = 'x', desc = 'Line diff add' }, - { 'mds', 'LinediffShow', desc = 'Line diff show' }, + { 'mdf', ':Linediff', mode = 'x', desc = 'Line diff' }, + { 'mda', ':LinediffAdd', mode = 'x', desc = 'Line diff add' }, + { 'mds', 'LinediffShow', desc = 'Line diff show' }, { 'mdr', 'LinediffReset', desc = 'Line diff reset' }, }, }, @@ -323,4 +323,43 @@ return { vim.g.dsf_no_mappings = 1 end, }, + + ----------------------------------------------------------------------------- + { + -- TODO: + -- make debugging for C. Cpp, Rust, Python work + 'mfussenegger/nvim-dap', + keys = { + { + 'db', + 'lua require\'dap\'.toggle_breakpoint()', + mode = { 'n', 'x' }, + desc = 'Debugging: Toggle breakpoint', + }, + { + 'db', + 'lua require\'dap\'.continue()', + mode = { 'n', 'x' }, + desc = 'Debugging: Start or continue debug session', + }, + { + 'dsi', + 'lua require\'dap\'.step_into()', + mode = { 'n', 'x' }, + desc = 'Debugging: Step into code', + }, + { + 'dso', + 'lua require\'dap\'.step_over()', + mode = { 'n', 'x' }, + desc = 'Debugging: Step over code', + }, + { + 'dm', + 'lua require\'dap\'.repl.open()', + mode = { 'n', 'x' }, + desc = 'Debugging: Menu', + }, + }, + }, } diff --git a/lua/plex/plugins/extras/lang/cpp.lua b/lua/plex/plugins/extras/lang/cpp.lua new file mode 100644 index 0000000..33cc8be --- /dev/null +++ b/lua/plex/plugins/extras/lang/cpp.lua @@ -0,0 +1,74 @@ +return { + { + 'mfussenegger/nvim-dap', + optional = true, + dependencies = { + 'mfussenegger/nvim-dap-python', + }, + -- stylua: ignore + -- keys = { + -- { 'dPt', function() require('dap-python').test_method() end, desc = 'Debug Method' }, + -- { '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, + }, +} diff --git a/lua/plex/plugins/extras/lang/rust.lua b/lua/plex/plugins/extras/lang/rust.lua new file mode 100644 index 0000000..d3cb0f9 --- /dev/null +++ b/lua/plex/plugins/extras/lang/rust.lua @@ -0,0 +1,42 @@ +return { + { + 'mfussenegger/nvim-dap', + optional = true, + dependencies = { + 'mfussenegger/nvim-dap-python', + }, + -- stylua: ignore + -- keys = { + -- { 'dPt', function() require('dap-python').test_method() end, desc = 'Debug Method' }, + -- { '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, + }, +} diff --git a/lua/plex/plugins/extras/lang/typescript.lua b/lua/plex/plugins/extras/lang/typescript.lua index 8cdd7aa..6415499 100644 --- a/lua/plex/plugins/extras/lang/typescript.lua +++ b/lua/plex/plugins/extras/lang/typescript.lua @@ -25,7 +25,7 @@ return { -- stylua: ignore keys = { { 'co', 'TypescriptOrganizeImports', desc = 'Organize Imports' }, - { 'cR', 'TypescriptRenameFile', desc = 'Rename File' }, + { 'cR', 'TypescriptRenameFile', desc = 'Rename File' }, }, settings = { ---@diagnostic disable: missing-fields @@ -93,8 +93,8 @@ return { -- 💀 Make sure to update this path to point to your installation args = { require('mason-registry') - .get_package('js-debug-adapter') - :get_install_path() .. '/js-debug/src/dapDebugServer.js', + .get_package('js-debug-adapter') + :get_install_path() .. '/js-debug/src/dapDebugServer.js', '${port}', }, }, diff --git a/spell/en.utf-8.add b/spell/en.utf-8.add index 8d4435b..912416b 100644 --- a/spell/en.utf-8.add +++ b/spell/en.utf-8.add @@ -125,3 +125,24 @@ Rustdoc paragraph rustc Klabnik +io +rustbook +Deserialize +deserialisierbaren +SIGTERM +Beendigungsabfrage +SIGKILL +stdout +stderr +Leveln +gedroppt +#ekonstruktor +Dekonstruktor/! +dealloziiert +Dealloziierung +Dealloziieren +vvvv +TODO +vvvv +Structs +nomicon diff --git a/spell/en.utf-8.add.spl b/spell/en.utf-8.add.spl index 7722a966213474fa1e92656509548c793ada8c52..21d15025972eb821535fa66984f17dbd85c240e5 100644 GIT binary patch literal 1914 zcmYjSyN(=16s>!ERtSl}vNnOh5y6OvUE8aUkT7a?i2G5~)9%-7Kjz^8Ik7~7 z`~k=xVOhu@!58=g03k%+yv%f#T7*@WnPv1E=`{TnT&2qme zmgVEBZrW~j*$?Bi-t3-4t{)|lOqSB(?WD$Yz^}x+71b#9wTN@`OcRgu5t^mscI2Uv zV^_$8RRL)tsVt<&yP!twrIQL4o$VG;k`2%tp-~#b%AU2|?{UhD`lA!R?)YWcpB^RE zz>{eWb~Uh`z`7LZM>sz7l#OJ7MO;AM8qXfAD%{lpS8q}sMhO5)C0s=m9BPWqs|k`G zTVk~^SphBS?}Vej_kj_!{Vw0V5|zErk2QH#vele!HL_9${Z+{@%ySBRI9`Te zgQrHmrKp4HnViZU{IK8OHl2`#3Jx%6^3kZ}V2oXysLqf-K+K|LO&@z%BW}jJVqK*c zO?h3ymlZG6g2o9pEX?7GK5qN1g$fH6cii&oOCW{Z)B)q=7$v!nigpb9Tde#QKrDi) z^e!G0W!M0pK?c%`EP%|L$kC;{cpO@kQGs|_JOJ0>2i>?f5B0}nmiTV8JV5=gLc0y* z?$;iuMrofxScX8q4RLV?s9AmwtPj>SOr8x#N!|53bGf*39OrZ9Y^!Lm{yH$G-dQrk z9js|Kc8WjCkawfXZ-DG$EZHlpBOY7lU9j}z_fGo>DjC{tX##oap~6;V$E+YDYG^c2 ziFfdJIYFJ9NsCKpZRJEh<-z;}JFDq^C{JyZm@v4bII5F1V65vPH@SJv2^;avbG6tg?;vC3d>#N&GAmmnt1))a`HSvH8( zs{;tzh+~I6!WcOWR7gM05m<(n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