Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Python debugger doesn't work. #19

Closed
TornaxO7 opened this issue Sep 1, 2021 · 4 comments
Closed

[Question] Python debugger doesn't work. #19

TornaxO7 opened this issue Sep 1, 2021 · 4 comments

Comments

@TornaxO7
Copy link

TornaxO7 commented Sep 1, 2021

Hello! I'm sorry, but I'm veeeery irritated how to setup this plugin.

If I start nvim-dap, then I'm getting the following error messages:

No configuration found for `python`. You need to add configs to `dap.configurations.python` (See `:h dap-configuration`)

Reproduction steps

Here are my settings:
~/.config/nvim/init.vim:

call plug#begin('~/.vim/plugged')
Plug 'mfussenegger/nvim-dap'
Plug 'theHamsta/nvim-dap-virtual-text'
Plug 'rcarriga/nvim-dap-ui'
Plug 'Pocco81/DAPInstall.nvim'
call plug#end()

source ~/.config/nvim/plugins/dap.vim
lua require("dapinstall")

~/.config/nvim/plugins/dap.vim:

augroup NvimDap
    autocmd!
    au FileType dap-repl lua require('dap.ext.autocompl').attach()
augroup END

let g:my_dap_repl_is_open = v:false

function OpenRepl()
    echo "called"
    " open repl if it isn't opened yet
    if !g:my_dap_repl_is_open
        lua require('dap').repl.open()
        let g:my_dap_repl_is_open = v:true
    endif

    lua require('dap').continue()
endfunction

nnoremap <F5> :call OpenRepl()<CR>
nnoremap <F6> :lua require('dap').step_over()<CR>
nnoremap <F7> :lua require('dap').step_into()<CR>
nnoremap <F8> :lua require('dap').step_out()<CR>
nnoremap <F9><F9> :lua require('dap').toggle_breakpoint()<CR>
nnoremap <F9><F10> :lua require('dap').set_breakpoint(vim.fn.input('Breakpoint condition: '))<CR>
nnoremap <F9><F7> :lua require('dap').set_breakpoint(nil, nil, vim.fn.input('Log point message: '))<CR>

lua require("dap_conf")

~/.config/nvim/lua/dap.lua:

local dap = require('dap')
local dap_ui = require('dapui')
dap.set_log_level('TRACE')
dap_ui.setup(
{
        icons = {
            expanded = "",
            collapsed = "",
            circular = ""
        },
        mappings = {
            expand = "<CR>",
            open = "o",
            remove = "d"
        },
        sidebar = {
            elements = {
                -- You can change the order of elements in the sidebar
                "scopes",
                "stacks",
                "watches"
            },
            width = 40,
            position = "left" -- Can be "left" or "right"
        },
        tray = {
            elements = {
                "repl"
            },
            height = 10,
            position = "bottom" -- Can be "bottom" or "top"
        },
        floating = {
            max_height = nil, -- These can be integers or a float between 0 and 1.
            max_width = nil   -- Floats will be treated as percentage of your screen.
        }
})

vim.g.dap_virtual_text = true

~/.config/nvim/lua/dapinstall.lua

local dap_install = require("dap-install")

dap_install.setup({
	installation_path = "~/Apps/nvim-dap/",
	verbosely_call_debuggers = false,
})

dap_install.config("python_dbg", {
    adapters = {
        type = "executable",
        command = "python3",
        args = {"-m", "debugpy.adapter"}
    },
    configurations = {
                {
                    type = "python",
                    request = "launch",
                    name = "Launch file",
                    program = "${file}",
                    pythonPath = "python3"
                }
            }
})
dap_install.config("php_dbg", {})

I already did :DIInstall python_dbg but it still says that I can't use the python debugger.

@TornaxO7
Copy link
Author

TornaxO7 commented Sep 1, 2021

I also noticed that my ~/Apps/nvim-dap/ directory is empty. Is that normal?

@pocco81
Copy link
Owner

pocco81 commented Sep 2, 2021

~ is a shortcut for $HOME, which is a system variable, and DAPInstall can't read system variables (although I think it might be possible through a luarock). If you want to specify the path to a directory under your $HOME then you could:

  1. just type it /home/pocco81/Apps/nvim-dap/
  2. Use nvim's vim api to fetch the $HOME var like so:
local dap_install = require("dap-install")

dap_install.setup({
	installation_path = vim.api.nvim_eval('$HOME') .. "Apps/nvim-dap/", -- this
	verbosely_call_debuggers = false,
})

I'm veeeery irritated how to setup this plugin.

Why? :(

@pocco81 pocco81 closed this as completed Sep 2, 2021
@TornaxO7
Copy link
Author

TornaxO7 commented Sep 2, 2021

Yeah it works now! Thank you :)

@TornaxO7
Copy link
Author

TornaxO7 commented Sep 2, 2021

I'm veeeery irritated how to setup this plugin.

It was because it didn't work. Thank you for simplifying the debugging process with this plugin :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants