Flutter support for (Neo)vim
- LSP features is power by analysis_server
- hover document
- signature help
- go to definition
- go to implementation
- go to references
- document highlight
- document symbol
- code actions
- more detail
need flutter sdk and add to
- Automatically finds SDKs from PATH
- Automatic hot reloads on save
- Automatically run
flutter pub getwhen
- Support flutter dev server
- Snippet enhance
- Sdk switching
- Devices List
- Emulators List
dart-vim-pluginplugin if your (neo)vim detect filetype incorrect
Most likely the extension will find your sdk automatically as long as the
flutter command maps to an sdk location on your system.
If you are using a version manager like
asdf that maps the
flutter command to another binary instead of an sdk location or this extension cannot find your sdk for another reason you'll have to provide the extension with how to find your sdk.
To do this there are a few options:
- If your version manager supports a
whichcommand like then you can set the
flutter.sdk.flutter-lookupconfig option. Eg.
"flutter.sdk.flutter-lookup": "asdf which flutter".
- You can add the path where to find the sdk to the
flutter.sdk.searchPathsconfig option. Either specify the exact folder the sdk is installed in or a folder that contains other folders which directly have an sdk in them. Note that not all of these folders need to have an sdk, if they don't contain one they will simply be ignored
- Set the
flutter.sdk.pathconfig option to the exact path you want to use for your sdk. If you have also set the
flutter.sdk.searchPathsthen you can use the
FlutterSDKslist (see below) to see what versions you have installed and set the config option for you. Note that this means that the
flutter.sdk.pathoption will be overriden by this list
Running the app
When the extension starts and has found an sdk it will request from flutter the available devices.
The device it will run the app on will be shown in the statusbar and can be changed using the
If you call
flutter.run with an explicit
-d deviceId argument then the selected device will be ignored.
After making sure that the correct device is selected you can run the app by calling the
If you want to give arguments to the flutter run command you can simply append them:
:CocCommand flutter.run -t lib/main.dart --flavor myflavor
Shows all the sdks that can be found by using the
searchPathsconfig and the
flutter-lookupconfig options and allows you to switch between them, either only for your current workspace or globally. Besides those two ways to find sdks it also checks if you are using fvm and if so uses those directories to find your sdk. You can disable this using the
You can also use this list to see what your current sdk is since it will have
(current)behind it clearly.
Shows a list of available devices that can be selected to use as run destination. When selecting a device it will by default be stored in the
workspaceStatesuch that a device can be selected on a per project basis. If no device is stored yet in the
workspaceStateit will fall back to the
globalStateand otherwise simply use the first device reported by flutter. It also has the
runaction which only runs the app once on that device without changing the selected device.
You can configure the default action that us used using the
flutter.devicesDefaultActionconfig option as described below.
Shows emulators available to start.
Trace level of log
Enable coc-flutter extension
Enable debug for language server
When set to true, analysis will only be performed for projects that have open files rather than the root workspace folder.
When set to false, completion will not include synbols that are not already imported into the current file
When set to true, will display closing labels at end of closing, only neovim support.
the paths to search for flutter sdks, either directories where flutter is installed or directories which contain directories where flutter versions have been installed eg.
dart command, leave empty should just work
(only use this if you don't have a flutter installation but only dart) command to find dart executable location, used to infer dart-sdk location
command to find flutter executable location, used to infer location of dart-sdk in flutter cache
Enable hot reload after save. Only when there are no errors for the save file
flutter.provider.enableSnippetEnable completion item snippet, default:
Vim command to open dev log window, like:
Path start within the list will not treat as workspaceFolder. Also flutter sdk will not treat as workspaceFolder, more detail issues 50
Automatically open devtools debugger web page when a project is run
Automatically open the dev log after calling flutter run
Automatically hide the dev log when the app stops running
The id of the device that was last selected using the FlutterDevices list (only if the device is selected using one of the
The default action to use when pressing enter in the
stateoptions will store the selected device in coc's
configoptions will store the selected device in the
An array of paths (absolute or relative to each workspace folder) that should be excluded from analysis.
When set to false, prevents registration (or unregisters) the SDK formatter. When set to true or not supplied, will register/reregister the SDK formatter.
The number of characters the formatter should wrap code at. If unspecified, code will be wrapped at 80 characters.
Completes functions/methods with their required parameters.
Whether to generate diagnostics for TODO comments. If unspecified, diagnostics will not be generated.
Enable format on save:
"coc.preferences.formatOnSaveFiletypes": [ "dart" ],
Add below config mapping
this config should be in the coc.nvim README
xmap <leader>a <Plug>(coc-codeaction-selected) nmap <leader>a <Plug>(coc-codeaction-selected)
Applying codeAction to the selected region.
<leader>aap for current paragraph,
<leader>aw for the current word
Then you will see action list:
- Wrap with Widget
- Wrap with Center
Open flutter only commands list:
CocList --input=flutter commands
flutter.runRun flutter dev server
flutter.attachAttach running application
flutter.createCreate flutter project using:
flutter pub get
flutter.devicesopen devices list
flutter.emulatorsopen emulators list
flutter.gotoSuperjump to the location of the super definition of the class or method
Dev Server Commands:
available when dev server running
flutter.dev.screenshotTo save a screenshot to flutter.png
flutter.dev.openDevLogOpen flutter dev server log
flutter.dev.clearDevLogClear the flutter dev server log
flutter.dev.openProfilerOpen observatory debugger and profiler web page
flutter.dev.copyProfilerUrlCopy the url of observatory debugger and profiler web page to the system clipboard (register +)
flutter.dev.openDevToolsProfilerOpen devtools debugger web page
flutter.dev.debugDumpAPPYou can dump the widget hierarchy of the app (debugDumpApp)
flutter.dev.elevationCheckerTo toggle the elevation checker
flutter.dev.debugDumpLayerTreeFor layers (debugDumpLayerTree)
flutter.dev.debugDumpRenderTreeTo dump the rendering tree of the app (debugDumpRenderTree)
flutter.dev.debugPaintSizeEnabledTo toggle the display of construction lines (debugPaintSizeEnabled)
flutter.dev.defaultTargetPlatformTo simulate different operating systems, (defaultTargetPlatform)
flutter.dev.showPerformanceOverlayTo display the performance overlay (WidgetsApp.showPerformanceOverlay)
flutter.dev.debugProfileWidgetBuildsTo enable timeline events for all widget build methods, (debugProfileWidgetBuilds)
flutter.dev.showWidgetInspectorOverrideTo toggle the widget inspector (WidgetsApp.showWidgetInspectorOverride)
flutter.dev.debugDumpSemanticsHitTestOrderAccessibility (debugDumpSemantics) for inverse hit test order
flutter.dev.debugDumpSemanticsTraversalOrderAccessibility (debugDumpSemantics) for traversal order
flutter.lsp.initialization.closingLabels is true,
the closing labels will be display at end of closing.
this feature only support neovim since vim do not support virtual text