nvim-dap-ui icon indicating copy to clipboard operation
nvim-dap-ui copied to clipboard

open() fails

Open milssky opened this issue 1 year ago • 10 comments

Hey. I have an error:

E5108: Error executing lua .../Local/nvim-data/lazy/nvim-dap-ui/lua/dapui/controls.lua:14: attempt to index local 'element' (a nil value)
stack traceback:
        .../Local/nvim-data/lazy/nvim-dap-ui/lua/dapui/controls.lua:14: in function 'enable_controls'
        ...Data/Local/nvim-data/lazy/nvim-dap-ui/lua/dapui/init.lua:353: in function 'toggle'
        [string ":lua"]:1: in main chunk

Windows 11, NVIM v0.10.0-dev-463+g780ab11b9

milssky avatar Jun 15 '23 19:06 milssky

Same issue image Win 11 (WSL2) NVIM v0.10.0-dev Build type: RelWithDebInfo LuaJIT 2.1.0-beta3

Johan-Palacios avatar Jun 18 '23 05:06 Johan-Palacios

Can you provide your config for nvim-dap-ui?

rcarriga avatar Jun 18 '23 13:06 rcarriga

Had the same issue just now because I forget to call the setup method.

local dap, dapui = require("dap"), require("dapui")
dapui.setup()

raphaelseher avatar Jun 18 '23 20:06 raphaelseher

Same issue image Win 11 (WSL2) NVIM v0.10.0-dev Build type: RelWithDebInfo LuaJIT 2.1.0-beta3

I solved it, apparently the problem was my config with lazy.

  {
    "rcarriga/nvim-dap-ui",
    keys = {
      {
        "<leader>du",
        function()
          require("dapui").toggle()
        end,
        silent = true,
      },
    },
    opts = {
      icons = { expanded = "", collapsed = "", circular = "" },
      mappings = {
        expand = { "<CR>", "<2-LeftMouse>" },
        open = "o",
        remove = "d",
        edit = "e",
        repl = "r",
        toggle = "t",
      },
      layouts = {
        {
          elements = {
            { id = "repl", size = 0.30 },
            { id = "console", size = 0.70 },
          },
          size = 0.19,
          position = "bottom",
        },
        {
          elements = {
            { id = "scopes", size = 0.30 },
            { id = "breakpoints", size = 0.20 },
            { id = "stacks", size = 0.10 },
            { id = "watches", size = 0.30 },
          },
          size = 0.20,
          position = "right",
        },
      },
      controls = {
        enabled = true,
        element = "repl",
        icons = {
          pause = "",
          play = "ε½ô",
          step_into = "ε½ö",
          step_over = "ε½û ",
          step_out = "ε½ò",
          step_back = "ε«Å ",
          run_last = " ",
          terminate = "ε½ù ",
        },
      },
      floating = {
        max_height = 0.9,
        max_width = 0.5,
        border = vim.g.border_chars,
        mappings = {
          close = { "q", "<Esc>" },
        },
      },
    },
    config = function(_, opts)
      local icons = require("core.icons").dap
      for name, sign in pairs(icons) do
        ---@diagnostic disable-next-line: cast-local-type
        sign = type(sign) == "table" and sign or { sign }
        vim.fn.sign_define("Dap" .. name, { text = sign[1] })
      end
      require("dapui").setup(opts)
    end,
  },

Johan-Palacios avatar Jun 19 '23 04:06 Johan-Palacios

how did you solve it exactly? Im using Lazy with the kickstart.nvim, I get the same error with an default dapui lua config file:

-- file: lua/custom/plugins/nvim-dap-ui.lua
return {
  'rcarriga/nvim-dap-ui',
  dependencies = {
    'mfussenegger/nvim-dap',
    'nvim-neotest/nvim-nio', -- Assuming this is also a dependency you want to include
  },
  opts = {},

  config = function()
    local dap, dapui = require 'dap', require 'dapui'
    dap.listeners.before.attach.dapui_config = function()
      dapui.open()
    end
    dap.listeners.before.launch.dapui_config = function()
      dapui.open()
    end
    dap.listeners.before.event_terminated.dapui_config = function()
      dapui.close()
    end
    dap.listeners.before.event_exited.dapui_config = function()
      dapui.close()
    end
  end,
}

This is my dap config:

return {
  'mfussenegger/nvim-dap',
  config = function()
    local dap = require 'dap'
    dap.adapters.gdb = {
      type = 'executable',
      command = 'gdb', -- Adjust this path as necessary
      args = { '-i', 'dap' },
    }
    dap.configurations.c = {
      {
        name = 'Launch',
        type = 'gdb',
        request = 'launch',
        program = function()
          return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
        end,
        cwd = '${workspaceFolder}',
        stopAtBeginningOfMainSubprogram = false,
      },
    }

    dap.configurations.cpp = dap.configurations.c

    -- Load custom DAP key mappings
    require('custom.mappings.dap_mappings').setup()
  end,
}

The same error appears if I place a break point on my sample cpp code and run it

PabloPicose avatar May 15 '24 07:05 PabloPicose

I have the same issue on Gentoo, what's the solution?

MZH-Amr avatar Jun 12 '24 16:06 MZH-Amr

I had same problem. Although I was calling dapui.setup in my dap.lua, so I was puzzled. Anyway to test @raphaelseher's solution, I added require("dapui").setup() to my init.lua, and it works now. I guess the issue was the way I was calling setup from my dap.lua? Still unsure, but maybe it will help someone.

bruteforks avatar Jun 22 '24 04:06 bruteforks

Check and see if you are missing the call to the setup function on the config function, as instructed in the usage section

gustavosinacio avatar Jun 22 '24 04:06 gustavosinacio

Oh it was a stupid mistake on my end, I did dap.setup() instead of dapui.setup() 😳, I'm really sorry

MZH-Amr avatar Jun 22 '24 10:06 MZH-Amr

Debug adapter reported a frame at line 74 column 1, but: Cursor position outside buffer. Ensure executable is up2date and if using a source mapping ensure it is correct

what is the prolem?

nurul5801 avatar Jul 11 '24 15:07 nurul5801