Tip: I highly recommend checking out my first video, Vim for Absolute Beginners, before diving into the setup!
We are going to config our Nvim for Flutter
We are going to play with
$~/.config/nvim.
❯ tree
├── init.lua
├── lazy-lock.json
├── lua
│ ├── config
│ │ ├── keymap.lua # gonna add a keymap
│ │ ├── run_file.lua # will create to for hot-reload
│ │ ├── lazy.lua
│ │ └── lsp
│ │ ├── ....
│ │ ├── init.lua
│ │ └── servers
│ │ ├── .....
│ │ ├── flutter.lua # our flutter configs
│ │ └── lua_ls.lua
│ └── plugins
│ ├── .... # rest stuff
│ ├── flutter_tools.lua # flutter nvim plugins
│ └── pubspec_assist.lua # show out-dated pkg
Custom keymap for hot-reload
--- nvim/config/run_file.lua
local M = {}
-- Dart (Flutter Reload)
function M.fileRunner()
local ft = vim.bo.filetype
if ft == "dart" then
local terms = require("toggleterm.terminal").get_all()
if #terms == 0 then
vim.notify("⚠️ No terminal running", vim.log.levels.WARN)
return
end
terms[1]:send("r\n")
vim.notify("🔥 Sent hot reload to Flutter terminal")
else
vim.notify("❌ Unsupported filetype: " .. ft)
end
end
return M
Also make sure to have
--- .....rest configuration
-- extend the keymaps.lua
local run = require("config.run_file")
-- Smart Run keymap; you can use different key-map as you please
vim.keymap.set("n", "<leader>r", run.fileRunner, {
desc = "Smart Run",
})
All files can be found here. Unzip as
nvimand put into your.configfolder. Make sure to have a backup.