From d364f67eb049a62ad1b93e9e3f842cecb82a5c7e Mon Sep 17 00:00:00 2001 From: shaoyu Date: Wed, 13 Nov 2024 17:28:13 -0500 Subject: [PATCH] Some configuration on t480s --- lazy-lock.json | 3 +- lua/custom/plugins/virtualtext.lua | 42 ++++++++++++++++++++ lua/kickstart/plugins/debug.lua | 62 ++++++++++++++++++++++-------- 3 files changed, 90 insertions(+), 17 deletions(-) create mode 100644 lua/custom/plugins/virtualtext.lua diff --git a/lazy-lock.json b/lazy-lock.json index bfe323ec..e29068a2 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -27,13 +27,12 @@ "nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" }, "nvim-treesitter": { "branch": "master", "commit": "bb06afa3f1111780932b3c5493ad65473ce85f9d" }, "nvim-web-devicons": { "branch": "master", "commit": "19d257cf889f79f4022163c3fbb5e08639077bd8" }, + "onedark.nvim": { "branch": "master", "commit": "67a74c275d1116d575ab25485d1bfa6b2a9c38a6" }, "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" }, "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, "telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, - "themery.nvim": { "branch": "main", "commit": "15c29229e9a25655587462c8c64a62d9aadf0a92" }, "todo-comments.nvim": { "branch": "main", "commit": "ae0a2afb47cf7395dc400e5dc4e05274bf4fb9e0" }, - "tokyonight.nvim": { "branch": "main", "commit": "ce91ba480070c95f40753e4663e32b4632ac6db3" }, "vim-sleuth": { "branch": "master", "commit": "be69bff86754b1aa5adcbb527d7fcd1635a84080" }, "which-key.nvim": { "branch": "main", "commit": "68e37e12913a66b60073906f5d3f14dee0de19f2" } } diff --git a/lua/custom/plugins/virtualtext.lua b/lua/custom/plugins/virtualtext.lua new file mode 100644 index 00000000..f026dad5 --- /dev/null +++ b/lua/custom/plugins/virtualtext.lua @@ -0,0 +1,42 @@ +return { + 'theHamsta/nvim-dap-virtual-text', + dependencies = { + 'hrsh7th/nvim-cmp', + 'mfussenegger/nvim-dap', + 'nvim-treesitter/nvim-treesitter', + }, + require('nvim-dap-virtual-text').setup { + enabled = true, -- enable this plugin (the default) + enabled_commands = true, -- create commands DapVirtualTextEnable, DapVirtualTextDisable, DapVirtualTextToggle, (DapVirtualTextForceRefresh for refreshing when debug adapter did not notify its termination) + highlight_changed_variables = true, -- highlight changed values with NvimDapVirtualTextChanged, else always NvimDapVirtualText + highlight_new_as_changed = false, -- highlight new variables in the same way as changed variables (if highlight_changed_variables) + show_stop_reason = true, -- show stop reason when stopped for exceptions + commented = false, -- prefix virtual text with comment string + only_first_definition = true, -- only show virtual text at first definition (if there are multiple) + all_references = false, -- show virtual text on all all references of the variable (not only definitions) + clear_on_continue = false, -- clear virtual text on "continue" (might cause flickering when stepping) + --- A callback that determines how a variable is displayed or whether it should be omitted + --- @param variable Variable https://microsoft.github.io/debug-adapter-protocol/specification#Types_Variable + --- @param buf number + --- @param stackframe dap.StackFrame https://microsoft.github.io/debug-adapter-protocol/specification#Types_StackFrame + --- @param node userdata tree-sitter node identified as variable definition of reference (see `:h tsnode`) + --- @param options nvim_dap_virtual_text_options Current options for nvim-dap-virtual-text + --- @return string|nil A text how the virtual text should be displayed or nil, if this variable shouldn't be displayed + display_callback = function(variable, buf, stackframe, node, options) + -- by default, strip out new line characters + if options.virt_text_pos == 'inline' then + return ' = ' .. variable.value:gsub('%s+', ' ') + else + return variable.name .. ' = ' .. variable.value:gsub('%s+', ' ') + end + end, + -- position of virtual text, see `:h nvim_buf_set_extmark()`, default tries to inline the virtual text. Use 'eol' to set to end of line + virt_text_pos = vim.fn.has 'nvim-0.10' == 1 and 'inline' or 'eol', + + -- experimental features: + all_frames = false, -- show virtual text for all stack frames not only current. Only works for debugpy on my machine. + virt_lines = false, -- show virtual lines instead of virtual text (will flicker!) + virt_text_win_col = nil, -- position the virtual text at a fixed window column (starting from the first text column) , + -- e.g. 80 to position at column 80, see `:h nvim_buf_set_extmark()` + }, +} diff --git a/lua/kickstart/plugins/debug.lua b/lua/kickstart/plugins/debug.lua index 2226d963..0e19662f 100644 --- a/lua/kickstart/plugins/debug.lua +++ b/lua/kickstart/plugins/debug.lua @@ -66,27 +66,59 @@ return { 'delve', }, } - + --GDB + dap.adapters.cppdbg = { + id = 'cppdbg', + type = 'executable', + command = 'C:/Users/18196/.vscode/extensions/ms-vscode.cpptools-1.23.1-win32-x64/debugAdapters/bin/OpenDebugAD7.exe', + options = { + detached = false, + }, + } + dap.configurations.cpp = { + { + name = 'Launch file', + type = 'cppdbg', + request = 'launch', + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end, + cwd = '${workspaceFolder}', + stopAtEntry = true, + }, + { + name = 'Attach to gdbserver :1234', + type = 'cppdbg', + request = 'launch', + MIMode = 'gdb', + miDebuggerServerAddress = 'localhost:1234', + miDebuggerPath = '/usr/bin/gdb', + cwd = '${workspaceFolder}', + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end, + }, + } -- 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 = '⏏', - }, - }, + -- 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