Compare commits

...

6 Commits

4 changed files with 76 additions and 4 deletions

64
lua/plugins/debugger.lua Normal file
View File

@ -0,0 +1,64 @@
return {
'mfussenegger/nvim-dap',
dependencies = {
'igorlfs/nvim-dap-view',
'kbenzie/mason.nvim',
'jay-babu/mason-nvim-dap.nvim',
'theHamsta/nvim-dap-virtual-text',
},
config = function()
local dap = require('dap')
-- Installation
local debug_adapters = {
'codelldb', -- C/C++/Rust/Zig
}
if vim.fn.executable('pip') == 1 then
table.insert(debug_adapters, 'python') -- Python
end
if vim.fn.executable('go') == 1 then
table.insert(debug_adapters, 'delve') -- Go
end
require("mason-nvim-dap").setup({
ensure_installed = debug_adapters,
handlers = {},
})
-- UI plugins
require('dap-view').setup({
winbar = {
sections = {
"console", "watches", "scopes", "exceptions",
"breakpoints", "threads", "repl",
},
-- Must be one of the sections declared above
default_section = "console",
}
})
require('nvim-dap-virtual-text').setup({})
vim.api.nvim_create_autocmd({ "FileType" }, {
pattern = {
'dap-float',
},
callback = function(args)
vim.keymap.set("n", "q", "<C-w>q", { buffer = args.buf })
end,
})
local widgets = require('dap.ui.widgets')
-- Mappings
vim.keymap.set('n', '<F5>', dap.continue)
vim.keymap.set('n', '<F17>', dap.terminate) -- Shift-F5
vim.keymap.set('n', '<F9>', dap.toggle_breakpoint)
vim.keymap.set('n', '<F21>', vim.cmd.DapViewWatch) -- Shift-F9
vim.keymap.set('n', '<F11>', dap.step_into)
vim.keymap.set('n', '<F23>', dap.step_out) -- Shift-F11
vim.keymap.set('n', '<F10>', dap.step_over)
vim.keymap.set('n', '<leader>K', widgets.hover)
end,
}

View File

@ -1,5 +1,6 @@
return { return {
'nvim-treesitter/nvim-treesitter', 'nvim-treesitter/nvim-treesitter',
branch = 'master',
dependencies = { dependencies = {
'nvim-treesitter/nvim-treesitter-textobjects', 'nvim-treesitter/nvim-treesitter-textobjects',
{ 'nvim-treesitter/nvim-treesitter-context', opts = {} }, { 'nvim-treesitter/nvim-treesitter-context', opts = {} },

View File

@ -25,10 +25,17 @@ vim.api.nvim_create_autocmd('BufRead', {
-- Start terminals in insert mode -- Start terminals in insert mode
vim.api.nvim_create_autocmd('TermOpen', { vim.api.nvim_create_autocmd('TermOpen', {
group = group, pattern = 'term://*', group = group,
callback = function() pattern = 'term://*',
vim.cmd.startinsert() callback = function(args)
-- nvim-dap/nvim-dap-view uses terminal buffers in the background which are
-- not visible, don't start insert mode if the dap-type variable exists.
local success, dap_type = pcall(vim.api.nvim_buf_get_var, args.buf, 'dap-type')
if success and dap_type then
return
end end
vim.cmd.startinsert()
end,
}) })
-- Automatically press enter when the terminal process exit successfully -- Automatically press enter when the terminal process exit successfully

View File

@ -78,7 +78,7 @@ vim.opt.splitbelow = true
vim.opt.splitright = true vim.opt.splitright = true
-- Use existing windows and tabs when jumping to errors -- Use existing windows and tabs when jumping to errors
vim.opt.switchbuf = 'usetab' vim.opt.switchbuf = 'usetab,uselast'
-- Automatically write changes to files -- Automatically write changes to files
vim.opt.autowrite = true vim.opt.autowrite = true