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

Add picker for executables/files #1130

Closed
cryptomilk opened this issue Jan 7, 2024 · 4 comments · Fixed by #1190
Closed

Add picker for executables/files #1130

cryptomilk opened this issue Jan 7, 2024 · 4 comments · Fixed by #1190

Comments

@cryptomilk
Copy link
Contributor

cryptomilk commented Jan 7, 2024

Problem Statement

You provide a nice picker to select a process to get the pid. It would be great to have the same available to select programs/executables to debug.

I'm currently using:

        program = function()
            local path = vim.fn.input({
                prompt = 'Path to executable: ',
                default = vim.fn.getcwd() .. '/',
                completion = 'file',
            })

            return (path and path ~= '') and path or dap.ABORT
        end,
        args = function()
            local args_str = vim.fn.input({
                prompt = 'Arguments: ',
            })
            return vim.split(args_str, ' +')
        end,

Possible Solutions

It would be nice if you would have a picker searching for executables in the directory.

    program = require('dap.utils').pick_file({ executables_only = true })

It could also be used maybe with a filter:

    program = require('dap.utils').pick_file({ filter = '*.py' })

Considered Alternatives

No response

@cryptomilk
Copy link
Contributor Author

@cryptomilk
Copy link
Contributor Author

image

cryptomilk added a commit to cryptomilk/nvim-dap that referenced this issue Apr 14, 2024
cryptomilk added a commit to cryptomilk/nvim-dap that referenced this issue Apr 14, 2024
mfussenegger pushed a commit to cryptomilk/nvim-dap that referenced this issue May 22, 2024
mfussenegger added a commit that referenced this issue May 23, 2024
This implements a file picker, to pick the file you want to execute with
the debugger.

Fixes #1130

Co-authored-by: Mathias Fussenegger <f.mathias@zignar.net>
@cryptomilk
Copy link
Contributor Author

I just noticed that you removed the search_path option. The Samba project has a lot of files (~50k), I don't really want to search for executables in the whole source tree, I only want to search for them in the build directory. That's why I added an option to specify it.

local cwd = vim.fn.getcwd()
local is_samba = cwd:find('samba')

local path = nil
if is_samba then
    path = cwd .. '/bin'
end

opts {
  path = path,
}

@mfussenegger
Copy link
Owner

Created #1218

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

Successfully merging a pull request may close this issue.

2 participants