improved debugging, auto-switch to correct ft, add treesitter for both fasm and nasm
MHVO2C7QN3N7SPO4UQ2U4G4BF3DOOZXK4MTGAJWBWKO5WYVPMCVAC dap.adapters["pwa-node"] = {type = "server",host = "localhost",port = "''${port}",executable = {command = "js-debug",args = {"''${port}"}},processId = require("dap.utils").pick_process,}
dap.adapters.codelldb = {type = 'executable',command = 'codelldb',}
dap.configurations.rust = {{name = 'Launch file',type = 'codelldb',request = 'launch',program = function()return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')end,cwd = vim.fn.getcwd(),stopOnEntry = false,}}
dap.adapters.gdb = {type = 'executable',command = 'gdb',args = { '-i', 'dap' }}
dap.configurations.javascript = {{type = "pwa-node",request = "launch",name = "Launch File",program = "''${file}",cwd = "''${workspaceFolder}",}}
dap.adapters["pwa-node"] = {type = "server",host = "localhost",port = "''${port}",executable = {command = "js-debug",args = {"''${port}"}},processId = require("dap.utils").pick_process,}-- only for nasmdap.configurations.nasm = {{name = "Launch NASM (CodeLLDB)",type = "codelldb",request = "launch",program = function()local file_dir = vim.fn.expand('%:p:h') -- dir of current filelocal file = vim.fn.expand('%:t') -- filename without extensionlocal source = vim.fn.expand('%:t:r') -- filename with extensionvim.fn.system('mkdir -p ' .. file_dir .. '/target')-- assemblevim.fn.system('nasm -f elf64 -g -F dwarf ' .. file_dir .. source .. ' -o ' .. file_dir .. '/target/' .. file .. '.o')-- linkvim.fn.system('ld ' .. file_dir .. '/target/' .. file .. '.o -o ' .. file_dir .. '/target/' .. file)-- path to execreturn file_dir .. '/target/' .. sourceend,cwd = vim.fn.expand('%:p:h'),stopOnEntry = true,terminal = "integrated",initCommands = {"settings set target.x86-disassembly-flavor intel",},-- showDisassembly = "never",presentationHint = "normal",sourceLanguages = { "asm" },}}dap.configurations.rust = {{name = 'Launch file',type = 'codelldb',request = 'launch',program = function()return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')end,cwd = vim.fn.getcwd(),stopOnEntry = false,}}dap.configurations.javascript = {{type = "pwa-node",request = "launch",name = "Launch File",program = "''${file}",cwd = "''${workspaceFolder}",}}dap.configurations.typescript = {{type = "pwa-node",request = "launch",name = "Launch File",program = "''${workspaceFolder}/../node_modules/astro/astro.js",args = { "dev" },cwd = "''${workspaceFolder}",rootPath = "''${workspaceFolder}",sourceMaps = true,console = "integratedTerminal",outFiles = {"''${workspaceFolder}/dist/**/*.js","''${workspaceFolder}/.astro/**/*.ts"},resolveSourceMapLocations = {"''${workspaceFolder}/dist/**/*.js","''${workspaceFolder}/.astro/**/*.ts"},skipFiles = {"<node_internals>/**"}}}dap.configurations.astro = dap.configurations.typescript
dap.configurations.typescript = {{type = "pwa-node",request = "launch",name = "Launch File",program = "''${workspaceFolder}/../node_modules/astro/astro.js",args = { "dev" },cwd = "''${workspaceFolder}",rootPath = "''${workspaceFolder}",sourceMaps = true,console = "integratedTerminal",outFiles = {"''${workspaceFolder}/dist/**/*.js","''${workspaceFolder}/.astro/**/*.ts"},resolveSourceMapLocations = {"''${workspaceFolder}/dist/**/*.js","''${workspaceFolder}/.astro/**/*.ts"},skipFiles = {"<node_internals>/**"}}}
-- open dapui on debugger startdap.listeners.before.attach.dapui_config = function()require("dapui").open()enddap.listeners.before.launch.dapui_config = function()require("dapui").open()end
dap.configurations.astro = dap.configurations.typescript
vim.keymap.set('n', '<leader>da', function()local word = vim.fn.expand('<cword>')if word and word ~= "" thenlocal dapui = require('dapui')dapui.elements.watches.add(word)endend, { desc = 'Add default single LLDB formatted watch' })vim.keymap.set('n', '<leader>dA', function()local word = vim.fn.expand('<cword>')if word and word ~= "" thenlocal dapui = require('dapui')-- Format options - key maps to suffixlocal formats = {d = ',d', -- (d)ecimalc = ',c', -- (c)haracteru = ',u', -- (u)nsignedb = ',b', -- (b)inaryx = ',x', -- he(x)o = ',o', -- (o)ctalf = ',f', -- (f)loatp = ',p', -- (p)ointers = ',s', -- (s)tringy = ',y', -- b(y)tesY = ',Y', -- b(Y)tes+ASCII}local help_text = '(d)ecimal (c)haracter (u)nsigned (b)inary he(x) (o)ctal (f)loat (p)ointer (s)tring b(y)tes b(Y)tes+ASCII'vim.ui.input({prompt = 'Format for "' .. word .. '" - ' .. help_text .. ': ',default = ""}, function(input)if input and input ~= "" thenlocal char = input:sub(1, 1):lower()local suffix = formats[char]if suffix thendapui.elements.watches.add(word .. suffix)print('Added: ' .. word .. suffix)elseprint('Invalid format: ' .. char)endendend)elseprint('No word under cursor')endend, { desc = 'Add specific single LLDB formatted watch' })
# cant get it working well in nasm at least"nvim-dap-virtual-text" = {package = pkgs.vimPlugins.nvim-dap-virtual-text;enabled = true;lazy = true;setupModule = "nvim-dap-virtual-text";setupOpts = {enabled = true;enabled_commands = true;highlight_new_as_changed = true;commented = true;virt_text_win_col = 80;};after = ''require("nvim-dap-virtual-text").setup({enabled = true;enabled_commands = true;highlight_new_as_changed = true;commented = true;virt_text_win_col = 80;})'';};
}{event = ["BufRead""BufNewFile"];pattern = ["*.asm""*.inc"];callback = mkLuaInline ''function()local lines = vim.api.nvim_buf_get_lines(0, 0, 10, false)local content = table.concat(lines, "\n")if content:match("format ELF64 executable 3") thenvim.bo.filetype = "fasm"vim.o.shiftwidth = 4vim.o.tabstop = 4vim.o.softtabstop = 4vim.o.expandtab = true -- for nicer indentationelsevim.bo.filetype = "nasm"vim.o.shiftwidth = 4vim.o.tabstop = 4vim.o.softtabstop = 4vim.o.expandtab = true -- for nicer indentationendend'';desc = "detect fasm vs nasm by format directive";
vim.o.tabstop = 4vim.o.shiftwidth = 4vim.o.softtabstop = 4vim.o.expandtab = true -- for nicer indentation
vim.o.tabstop = 4vim.o.shiftwidth = 4vim.o.softtabstop = 4vim.o.expandtab = true -- for nicer indentation