nvim config updated
This commit is contained in:
21
.config/nvim/lua/autocmds.lua
Normal file
21
.config/nvim/lua/autocmds.lua
Normal file
@@ -0,0 +1,21 @@
|
||||
-- Autocommand: trigger Flutter hot reload on save
|
||||
--
|
||||
-- This runs whenever you save a *.dart file (BufWritePost).
|
||||
-- It checks if a tmux session named "flutter" exists.
|
||||
-- If it does, it sends the keys "r<Enter>" to the "app" window
|
||||
-- of that session, which tells `flutter run` to hot-reload.
|
||||
--
|
||||
-- Workflow:
|
||||
-- 1. Start tmux: tmux new -s flutter -n app
|
||||
-- 2. Inside tmux "app" window, run: flutter run
|
||||
-- 3. Open another window/pane for nvim.
|
||||
-- 4. Whenever you :w a Dart file in nvim, hot reload will fire.
|
||||
--
|
||||
|
||||
vim.api.nvim_create_autocmd("BufWritePost", {
|
||||
pattern = "*.dart",
|
||||
callback = function()
|
||||
local result = vim.fn.system({ "tmux", "send-keys", "-t", "flutter:app", "r", "Enter" })
|
||||
vim.notify("Flutter hot reload triggered", vim.log.levels.INFO)
|
||||
end,
|
||||
})
|
||||
Reference in New Issue
Block a user