feat: debugging

This commit is contained in:
Klesh Wong 2022-07-30 10:23:07 +08:00
parent efbc1a483a
commit 6cd237d7a7
4 changed files with 63 additions and 3 deletions

View File

@ -84,3 +84,33 @@ keymap(COMMAND, '<C-p>', '<Up>', { noremap = true })
-- keymap(INSERT, '<C-p>', '<Up>', { noremap = true })
vim.g.AutoPairsShortcutToggle = "<leader>ap"
-- search and replace highlighted
keymap(VISUAL, '/', "y/\\V<C-R>=escape(@\",'/\\')<CR><CR>", { noremap = true })
keymap(NORMAL, '<leader>r', ':%s///g<left><left>', { noremap = true })
-- xnoremap <leader>r :s///g<left><left>
-- debugger
local dap_ok, dap = pcall(require, "dap")
if dap_ok then
vim.keymap.set('n', '<leader>db', function() dap.toggle_breakpoint() end)
vim.keymap.set('n', '<leader>dc', function() dap.set_breakpoint(vim.fn.input('Breakpoint condition: ')) end)
vim.keymap.set('n', '<C-k>', function() dap.step_out() end)
vim.keymap.set('n', "<C-l>", function() dap.step_into() end)
vim.keymap.set('n', '<C-j>', function() dap.step_over() end)
vim.keymap.set('n', '<C-h>', function() dap.continue() end)
vim.keymap.set('n', '<leader>dl', function() dap.run_to_cursor() end)
vim.keymap.set('n', '<leader>de', function() dap.terminate() end)
vim.keymap.set('n', '<leader>dB', function() dap.clear_breakpoints() end)
-- vim.keymap.set('n', '<leader>de', function() dap.set_exception_breakpoints({ "all" }) end)
vim.keymap.set('n', '<leader>da', function() require "debugHelper".attach() end)
vim.keymap.set('n', '<leader>dA', function() require "debugHelper".attachToRemote() end)
vim.keymap.set('n', '<leader>dh', function() require "dap.ui.widgets".hover() end)
vim.keymap.set('n', '<leader>d?', function() local w = require "dap.ui.widgets"; w.centered_float(w.scopes) end)
vim.keymap.set('n', '<leader>dk', function() dap.up() end)
vim.keymap.set('n', '<leader>dj', function() dap.down() end)
vim.keymap.set('n', '<leader>dr', function() dap.repl.toggle({}, "vsplit") end)
vim.keymap.set('n', '<leader>tds', ':Telescope dap frames<CR>')
vim.keymap.set('n', '<leader>tdb', ':Telescope dap list_breakpoints<CR>')
end

View File

@ -64,6 +64,12 @@ require("packer").startup(function(use)
"/home/klesh/Projects/klesh/nvim-runscript",
config = function() require("nvim-runscript").setup({}) end
}
-- debugger
use 'mfussenegger/nvim-dap'
use 'leoluz/nvim-dap-go'
use 'nvim-telescope/telescope-dap.nvim'
end)
@ -75,3 +81,4 @@ require("plugins/comment")
require("plugins/tree")
require("plugins/searchinfolder")
require("plugins/treesitter")
require("plugins/debugging")

View File

@ -0,0 +1,25 @@
local dap_go_ok, dap_go = pcall(require, "dap-go")
if dap_go_ok then
dap_go.setup()
end
local dap_ok, dap = pcall(require, "dap")
if dap_ok then
dap.defaults.fallback.terminal_win_cmd = '20split new'
-- vim.fn.sign_define('DapBreakpoint', { text = '🟥', texthl = '', linehl = '', numhl = '' })
-- vim.fn.sign_define('DapBreakpointRejected', { text = '🟦', texthl = '', linehl = '', numhl = '' })
-- vim.fn.sign_define('DapStopped', { text = '⭐️', texthl = '', linehl = '', numhl = '' })
end
-- dap.adapters.node2 = {
-- type = 'executable',
-- command = 'node',
-- args = {os.getenv('HOME') .. '/apps/node/out/src/nodeDebug.js'},
-- }
-- require('dap').set_log_level('INFO')
local telescope_ok, telescope = pcall(require, "telescope")
if telescope_ok then
telescope.load_extension("dap")
end

View File

@ -18,7 +18,7 @@ local language_servers = {
},
diagnostics = {
-- Get the language server to recognize the `vim` global
globals = { 'vim' },
globals = { 'vim', 'root', 'client', 'awesome', 'screen', 'mouse', 'keyboardgrabber', 'mousegrabber' },
},
workspace = {
-- Make the server aware of Neovim runtime files
@ -138,5 +138,3 @@ null_ls.setup({
null_ls.builtins.formatting.gofumpt,
},
})