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