mfussenegger / nvim-dap

Debug Adapter Protocol client implementation for Neovim
GNU General Public License v3.0
5.17k stars 180 forks source link

Change argument input prompt from launch.json loading module to run asynchronously using vim.ui.input() #1040

Closed MahboobMMonza closed 8 months ago

MahboobMMonza commented 10 months ago

Problem Statement

Currently, the load_launchjs functionality resolves "promptString" evaluations with vim.fn.input to ask for the user input, which is a blocking statement. Instead, vim.ui.input could be used instead to create a coroutine that can asynchronously ask for user input so that other processes can continue, as well as provide an easier extensibility point for UI configurations.

Possible Solutions

Implement the prompts with vim.ui.input and coroutines instead. Example (from my override for prompting inputs in nvim-jdtls):

local function get_inp()
  return coroutine.create(function(dap_run_co)
    vim.ui.input({ prompt = 'Args: ' }, function(argstr)
      coroutine.resume(dap_run_co, argstr)
    end)
  end)
end

Considered Alternatives

No response