Closed thanhdatvo closed 1 week ago
I'm using "program": "lib/main.dart"
without {workspaceFolder}
. Could you try this in your setup?
Why are there three run options? Is the complete launch.json
file shared?
@sidlatau Thank you for your suggestion!
I removed {workspaceFolder}
but the error persists.
Why are there three run options? A: I don't know.
Is the complete launch.json file shared? A: Yes, it is
Following your provided setup, there should only be a single DAP configuration. However, it looks like more configurations are added somewhere in your config. You may try to remove register_configurations
, your config does not add any custom flags, flutter_tools
should be able to run the project with default values.
Hi @sidlatau ,
I removed register_configurations
, but the repeats still persist, and I could not start debugging (same error appeared).
I double-checked the DAP configuration in the LazyVim setup. I have only two files configured for DAP: one for Golang and one for Flutter.
I’m not sure if I mistakenly installed any LazyVim plugin that might be affecting how flutter_tools
works
This is the list of Lazy Vim plugins I installed:
@thanhdatvo I can not debug your local config. Please try to get a minimal init.lua with exact reproduction steps.
@sidlatau thank you for your reply. I really appreciate you taking time to help me. I will try to config nvim with only flutter_tools to see how it works, and will come back to you.
@sidlatau Today, I tried to run nvim with Lazyvim starter I only installed flutter_tools and enabled dap.core in LazyExtra
I kept the same config for flutter_tools. All the mentioned issues still persist.
I am not familiar with Lazyvim, so maybe it causes an issue. Could you try a minimal setup without Lazyvim? I did not see such problem as you are facing before, so I still assume it is a local config issue.
@sidlatau I used to use Packer before switching to LazyVim. However, Packer is now outdated, and I am currently only familiar with LazyVim.
Since you mentioned a minimal init.lua, you likely know how to create one. Could you kindly provide me with a minimal init.lua configuration for Neovim that includes flutter_tools? I’d like to configure and test flutter_tools using this setup.
Thank you very much!
I suggest to setup everything in a single file, then you could easily share it. I think the easiest way to do it would be with https://github.com/nvim-lua/kickstart.nvim - just remove what you are not using, add flutter-tools and try to reproduce the issue.
Hi @sidlatau, As you suggested, I used the Neovim kickstart configuration with only flutter-tools, and it worked perfectly. (Note that I did not use nvim-dap.)
It seems that flutter-tools might not work properly with LazyVim (https://www.lazyvim.org/) for certain reasons.
@sidlatau For some reason, when I switched back to my old LazyVim configuration, it resolved the duplication issue in the VSCode launch configuration (now only showing one test_delete instead of two as before).
However, I tried to run test_delete, the old error Unable to restart debugging. Please try ending the debug session and starting again
still persisted.
You still haven't provided any minimum reproducible steps.
@sidlatau Here’s what I experimented with:
For 2nd Attempt: I failed to config nvim-dap to debug.
About 2nd Attempt: Since the Kickstart Neovim configuration you mentioned organizes its dependencies across multiple files, I will list all the files I have configured below:
flutter_tools.lua:
return {
'nvim-flutter/flutter-tools.nvim',
lazy = false,
dependencies = {
'nvim-lua/plenary.nvim',
'stevearc/dressing.nvim', -- optional for vim.ui.select
},
-- config = true,
config = function()
require('flutter-tools').setup {
debugger = {
enabled = true,
register_configurations = function(paths)
local dap = require 'dap'
dap.adapters.dart = {
type = 'executable',
command = 'dart', -- if you're using fvm, you'll need to provide the full path to dart (dart.exe for windows users), or you could prepend the fvm command
args = { 'debug_adapter' },
-- windows users will need to set 'detached' to false
options = {
detached = false,
},
}
dap.adapters.flutter = {
type = 'executable',
command = 'flutter', -- if you're using fvm, you'll need to provide the full path to flutter (flutter.bat for windows users), or you could prepend the fvm command
args = { 'debug_adapter' },
-- windows users will need to set 'detached' to false
options = {
detached = false,
},
}
dap.configurations.dart = {
{
type = 'dart',
request = 'launch',
name = 'Launch dart',
dartSdkPath = '/opt/flutter/bin/cache/dart-sdk/bin/dart', -- ensure this is correct
flutterSdkPath = '/opt/flutter/bin/flutter', -- ensure this is correct
program = '${workspaceFolder}/lib/main.dart', -- ensure this is correct
cwd = '${workspaceFolder}',
},
{
type = 'flutter',
request = 'launch',
name = 'Launch flutter',
dartSdkPath = '/opt/flutter/bin/cache/dart-sdk/bin/dart', -- ensure this is correct
flutterSdkPath = '/opt/flutter/bin/flutter', -- ensure this is correct
program = '${workspaceFolder}/lib/main.dart', -- ensure this is correct
cwd = '${workspaceFolder}',
},
}
require('dap.ext.vscode').load_launchjs()
end,
},
}
end,
}
- dap-ui.lua
return {
'rcarriga/nvim-dap-ui',
-- dependencies = { 'nvim-neotest/nvim-nio' },
-- stylua: ignore
keys = {
{ "
- dap.lua
return { 'mfussenegger/nvim-dap', recommended = true, desc = 'Debugging support. Requires language specific adapters to be configured. (see lang extras)',
dependencies = { 'rcarriga/nvim-dap-ui', -- virtual text for the debugger -- { -- 'theHamsta/nvim-dap-virtual-text', -- opts = {}, -- }, },
-- stylua: ignore
keys = {
{ "
config = function() -- load mason-nvim-dap here, after all adapters have been setup if LazyVim.has 'mason-nvim-dap.nvim' then require('mason-nvim-dap').setup(LazyVim.opts 'mason-nvim-dap.nvim') end
vim.api.nvim_set_hl(0, 'DapStoppedLine', { default = true, link = 'Visual' })
-- for name, sign in pairs(LazyVim.config.icons.dap) do
-- sign = type(sign) == 'table' and sign or { sign }
-- vim.fn.sign_define('Dap' .. name, { text = sign[1], texthl = sign[2] or 'DiagnosticInfo', linehl = sign[3], numhl = sign[3] })
-- end
-- setup dap config by VsCode launch.json file
local vscode = require 'dap.ext.vscode'
local json = require 'plenary.json'
vscode.json_decode = function(str)
return vim.json.decode(json.json_strip_comments(str))
end
end, }
- mason.lua
return { 'williamboman/mason.nvim', }
I already installed dart debug adapter with command: `MasonInstall dart-debug-adapter`
-----
I believe I have provided detailed information about all my attempts. However, using nvim kickstart may not align with my configuration. The simplest way to reproduce the issue is to use LazyVim with only flutter-tools installed.
Please let me know if you need any additional information from me.
Are you running on Windows? I see this in your config:
-- windows users will need to set 'detached' to false
options = {
detached = false,
},
@sidlatau
I continues to fix problem nvim-dap with kickstart
When I ran :
lua require("dap").continue()
I encountered the following error:
Config references missing adapter dart. Available are:
However, then I started debug session using:
FlutterRun
it worked fine
I think I figured it out.
I reverted back to my config with LazyVim
When I tried to start a debug session using the command:
lua require("dap").continue()
I encountered the error:
Unable to restart debugging. Please try ending the debug session and starting again.
However, when I started the session using:
FlutterRun
it worked fine.
I think I’m fine at the moment; however, the description in the README should be updated:
from
To use the debugger you need to run :lua require('dap').continue()<CR>
to
To use the debugger you need to run :FlutterRun
I will close this issue for now.
Thank you a lot!
Is there an existing issue for this?
Current Behavior
Cannot debug flutter with launch.json
Expected Behavior
Could debug flutter with launch.json
Steps To Reproduce
My setup for flutter-tools in Lazyvim:
This is my launch.json
I could debug the app with option 1., but could not debug the app with option 2. and 3. (from launch.json)
This is the error in debug console
Environment
Anything else?
No response