From 2fba5da98a48fe1d562b6c015dda4a6fb4baccfe Mon Sep 17 00:00:00 2001 From: Jacob McDonnell Date: Wed, 14 Feb 2024 21:24:28 -0500 Subject: Integrated dap nvim with lldb --- .config/nvim/init.vim | 32 +++++++++++--------------- .config/nvim/lua/dap_lldb.lua | 52 +++++++++++++++++-------------------------- 2 files changed, 33 insertions(+), 51 deletions(-) (limited to '.config/nvim') diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index 3503890..7bb71b7 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -58,8 +58,6 @@ map l call plug#begin('~/.local/share/nvim/plugged') Plug 'junegunn/goyo.vim' " Nice for reading Documents Plug 'neoclide/coc.nvim', {'branch': 'release'} " Code Completion -Plug 'ms-jpq/coq_nvim', {'branch': 'coq'} -Plug 'ms-jpq/coq.artifacts', {'branch': 'artifacts'} Plug 'tpope/vim-commentary' " Makes commenting multiple lines easier Plug 'NLKNguyen/papercolor-theme' Plug 'nvim-lua/plenary.nvim' @@ -67,10 +65,12 @@ Plug 'nvim-telescope/telescope.nvim', { 'tag': '0.1.x' } Plug 'ThePrimeagen/harpoon', { 'branch': 'harpoon2' } Plug 'neovim/nvim-lspconfig' Plug 'mfussenegger/nvim-dap' -Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} -Plug 'theHamsta/nvim-dap-virtual-text' +Plug 'rcarriga/nvim-dap-ui' call plug#end() +"Plug 'ms-jpq/coq_nvim', {'branch': 'coq'} +"Plug 'ms-jpq/coq.artifacts', {'branch': 'artifacts'} + let g:coc_global_extensions = [ \ 'coc-html', \ 'coc-java', @@ -87,6 +87,14 @@ lua vim.g.coq_settings = {auto_start = 'shut-up',} lua require("dap_lldb") +" nvim-dap keybinds +map db :lua require("dap").toggle_breakpoint() +map dc :lua require("dap").continue() +map dso :lua require("dap").step_over() +map ds :lua require("dap").step_into() +map dr :lua require("dapui").open({ reset = true }) +map dt :lua require("dapui").toggle() + " Goyo plugin makes text more readable when writing prose: map f :Goyo \| set linebreak @@ -107,20 +115,6 @@ autocmd BufWritePre *.go lua goimports(1000) set t_Co=256 -" ChangeBackground changes the background mode based on macOS's `Appearance` -" setting. We also refresh the statusline colors to reflect the new mode. -function! ChangeBackground() - if system("defaults read -g AppleInterfaceStyle") =~ '^Dark' - set background=dark " for the dark version of the theme - else - set background=light " for the light version of the theme - endif -endfunction - -" initialize the colorscheme for the first run -call ChangeBackground() - -map b :call ChangeBackground() -map d :colorscheme default +set background=light " for the light version of the theme colorscheme PaperColor diff --git a/.config/nvim/lua/dap_lldb.lua b/.config/nvim/lua/dap_lldb.lua index 495fb72..40861d0 100644 --- a/.config/nvim/lua/dap_lldb.lua +++ b/.config/nvim/lua/dap_lldb.lua @@ -1,37 +1,25 @@ -local dap = require('dap') +local dap = require'dap' + +require("dapui").setup() + dap.adapters.lldb = { - type = 'executable', - command = '/usr/bin/lldb-vscode', -- adjust as needed, must be absolute path - name = 'lldb' + type = 'executable', + -- absolute path is important here, otherwise the argument in the `runInTerminal` request will default to $CWD/lldb-vscode + command = '/usr/bin/lldb-vscode', + name = "lldb" } - -local dap = require('dap') 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, - }, + { + 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 = {}, + runInTerminal = true, + }, } -dap.configurations.cpp = dap.configurations.c -require("nvim-dap-virtual-text").setup() -- cgit v1.2.3