Build flutter and dart applications in neovim using the native lsp.
Status: Alpha
I plan to try and keep things relatively stable but ultimately there might still need to be some breaking changes while I flesh out some of the functionality.
This plugin draws inspiration from emacs-lsp/lsp-dart, coc-flutter and nvim-metals, the idea being
to allow users to easily develop flutter apps using neovim.
neovim 0.5+(nightly)
using vim-plug
Plug "neovim/nvim-lspconfig"
Plug "akinsho/flutter-tools.nvim"or using packer.nvim
use {"akinsho/flutter-tools.nvim", requires = {"neovim/nvim-lspconfig"}}Currently this plugin depends on nvim-lspconfig for some default setup this might change.
To set it up
require("flutter-tools").setup{} -- use defaults
-- alternatively you can override the default configs
require("flutter-tools").setup {
experimental = { -- map of feature flags
lsp_derive_paths = false, -- experimental: Attempt to find the user's flutter SDK
},
debugger = { -- experimental: integrate with nvim dap
enabled = false,
},
flutter_path = "<full/path/if/needed>", -- <-- this takes priority over the lookup
flutter_lookup_cmd = nil, -- example "dirname $(which flutter)" or "asdf where flutter"
widget_guides = {
enabled = false,
},
closing_tags = {
highlight = "ErrorMsg",
prefix = ">"
},
dev_log = {
open_cmd = "tabedit",
},
outline = {
open_cmd = "30vnew",
},
lsp = {
on_attach = my_custom_on_attach,
capabilities = my_custom_capabilities -- e.g. lsp_status capabilities
}
}You can override any options available in the lspconfig setup, this call essentially wraps
it and adds some extra flutter specific handlers and utilisation options.
In order to run flutter commands you might need to pass either a path or a command to the plugin so it can find your
installation of flutter. Most people will not need this since it will find the executable path of flutter if it is in your $PATH.
If using something like asdf or some other version manager, or you installed flutter via snap or in some other custom way,
then you need to pass in a command by specifying flutter_lookup_cmd = <my-command>.
If you have a full path already you can pass it in using flutter_path.
If using a snap installation set your flutter_lookup_cmd to "echo $HOME/snap/flutter/common/flutter/bin/flutter"
which is where this is usually installed by snap. Alternatively you can use the experimental.lsp_derive_paths option
which should auto-magically find your flutter installation.
NOTE: To configure the highlight colour you can override the FlutterWidgetGuides highlight group
FlutterRun- Run the current project. This needs to be run from within a flutter project.FlutterDevices- Brings up a list of connected devices to select from.FlutterEmulators- Similar to devices but shows a list of emulators to choose from.FlutterReload- Reload the running projectFlutterRestart- Restart the current projectFlutterQuit- Ends a running sessionFlutterOutline- Opens an outline window showing the widget tree for the given file
Requires nvim-dap
-- with packer
use 'mfussenegger/nvim-dap'This plugin integrates with nvim-dap to provide debug capabilities.
Currently if debugger is set to true in the user's config it will expect nvim-dap to be installed.
If dap is installed the plugin will attempt to install the debugger (Dart-Code's debugger)
For now this should setup dap so that once you have already started a flutter app. You should be able
to use dap commands to begin to debug it.
- Add wrapper functions/commands around dab functionality to simplify.
- Investigate sporadic debugger crash.





