Code Monkey home page Code Monkey logo

vim-flutter's Introduction

vim-flutter

Vim commands for Flutter, including hot-reload-on-save and more.

Demo usage GIF

Usage

Usage documentation can be found both in this README, as well as via calling :h flutter.

Installation

vim-flutter is a Vimscript-only plugin, and makes heavy use of Vim8's async jobs. It can be installed with a package manager like vim-plug , for example.

Though this package doesn't depend on it, having dart-vim-plugin available is recommended, for a better experience.

You may also consider combining package:dart_language_server with a Language Server Protocol client, like ale.

Plug 'dart-lang/dart-vim-plugin'
Plug 'thosakwe/vim-flutter'

" Run :PlugInstall to install the plugin.

Ultimately, installation is up to you.

Options

  • g:flutter_command - The Flutter executable path/name; defaults to 'flutter'.
  • g:flutter_hot_reload_on_save - Whether to auto hot-reload when dart files are saved; defaults to 1.
  • g:flutter_hot_restart_on_save - Whether to auto hot-restart when dart files are saved; defaults to 0.
  • g:flutter_show_log_on_run - Automatically open __Flutter_Output__ when starting flutter using :FlutterRun; it can have one of the following values:
    • "split" or 1: Open the log in a split, this is the default.
    • "tab": Open the log in a new tab.
    • "hidden" or 0: Do not open the log by default, can be opened later with FlutterSplit etc.
  • g:flutter_show_log_on_attach - Identical to g:flutter_show_log_on_run but affecting the :FlutterAttach command.
  • g:flutter_split_height - Initial height of the window opened by :FlutterSplit (or :FlutterRun and :FlutterAttach, when g:flutter_show_log_on_run is set to "split"); defaults to standard vim behavior, which is splitting the window in half.
  • g:flutter_autoscroll - Autoscroll the flutter log when 1, defaults to 0.
  • g:flutter_use_last_run_option - When set to 1 then :FlutterRun will use the arguments from the previous call when no arguments are specified.
  • g:flutter_use_last_attach_option - Identical to g:flutter_use_last_run_option but affecting the :FlutterAttach command.
  • g:flutter_close_on_quit - Whether to close all __Flutter_Output__ windows (splits and tabs) on :FlutterQuit; defaults to 0.

Provided Commands

  • :FlutterRun <args> - calls flutter run <args>
  • :FlutterAttach <args> - calls flutter attach <args>
  • :FlutterHotReload - triggers a hot reload on the current Flutter process
  • :FlutterHotRestart - triggers a hot restart on the current Flutter process
  • :FlutterScreenshot - takes a screenshot of the current Flutter application and saves it in the project directory
  • :FlutterQuit - quits the current Flutter process
  • :FlutterDevices - opens a new buffer, and writes the output of flutter devices to it
  • :FlutterSplit - opens Flutter output in a horizontal split
  • :FlutterEmulators - Executes a flutter emulators process.
  • :FlutterEmulatorsLaunch - Executes a flutter emulators --launch process, with any provided arguments.
  • :FlutterVisualDebug - Toggles visual debugging in the running Flutter process.

The following are self-explanatory:

  • :FlutterVSplit
  • :FlutterTab

Menu Support

If you are using a GUI Vim Variant, you can add a Flutter menu by calling call FlutterMenu().

Hot Reload on Save

A convenient feature to have when working with Flutter is to automatically hot-reload an app once a file is saved. By default, whenever a dart file is saved, if and only if a Flutter process is running, it will be hot-reloaded.

You can disable this by setting g:hot_reload_on_save=0, before vim-flutter is loaded.

Example .vimrc

Plug 'thosakwe/vim-flutter'
call plug#end()

" Enable Flutter menu
call FlutterMenu()

" Some of these key choices were arbitrary;
" it's just an example.
nnoremap <leader>fa :FlutterRun<cr>
nnoremap <leader>fq :FlutterQuit<cr>
nnoremap <leader>fr :FlutterHotReload<cr>
nnoremap <leader>fR :FlutterHotRestart<cr>
nnoremap <leader>fD :FlutterVisualDebug<cr>

vim-flutter's People

Contributors

3to8-decoder avatar datsuns avatar davrack avatar dihak avatar get-me-power avatar insidewhy avatar jimgerth avatar mracos avatar paulreimer avatar stefanoamorelli avatar studiome avatar thosakwe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vim-flutter's Issues

FlutterRun args from file

Is there a way to add --dart-define <args> from a file?

Currently this is done via :FlutterRun --dart-define <arg1>=<value1> --dart-define <arg2>=<value2>. This is tedious for long values such as protected credentials.

Help on FlutterMenu

could you please add some detail on how to enable the FlutterMenu?
i'm a newbie when it come to vim, so any help appreciated

hot reload not working

Hi,

I'm using nvim if it matters, I can run the app using :FlutterRun but when I save or run :FlutterHotReload nothing seem to happen :(
would appreciate help

Error: Flutter is not running

Neovim: v0.4.4

I'm getting this error even if flutter is running.

Error detected while processing function flutter#hot_reload[1]..flutter#send:
line    2:
Flutter is not running.

There's no error though if I ran flutter inside neovim using :FlutterRun

Is this the intended behavior? Having to run :FlutterRun in order for the plugin to recognize that flutter is running? If yes, I suggest that the plugin should still work even if flutter was run outside of vim/neovim. And if not, then this is a bug.

Feature Request: HotReload-vs-HotRestart file patterns

Super useful plugin! I had a bash script to do this, but (neo)vim integration is much better.

One thing I miss from my script, is the ability to set a file or directory matching rule, where a HotRestart is needed (for example files having generated code / transformers).

It would be nice to have that as a vimrc setting and/or run-time option.

Hot reload is not working for vim auto command update

I have a auto command to save dart file when insert leave
augroup AUTOSAVE
au!
autocmd InsertLeave,TextChanged,FocusLost * silent! update
augroup END

But HotRelaod is not triggered until I manually write it. (:w).

autocmd chaining spawns two windows instead of one

Hello,

I have the following autocommand

autocmd Filetype .dart exe "FlutterRun" | exe "FlutterVSplit"

Why does this spawn two additional windows with the output buffer, instead of one.
I am curious how to fix this, because chaining | exe "clo 2" does close both additional windows.

Thanks in advance.

Feature Request: open Flutter Output at bottom by default instead of top

Hey @thosakwe! Hope you are doing great and thank you for taking the time to develop this awesome plugin!

I wanted to see if its possible to add an option in the future to make the Flutter Output split to appear at the bottom of the already opened editor screen instead of at the top. This would totally change the way I work (before I used to have an open terminal window at the bottom and on changes, I would just go down to the terminal window and run a hot restart/reload, so I already have the memory of going down lol).

Thank you!

fvm Support

Hi!

Nice plug. Would it be difficult to add fvm support so that vim-flutter uses that if detected?

hot reload not working for linux device

I'm running flutter run using vim-flutter as vim plugin, to reload my changes after save, I need hit r at the terminal to reload, it seems vim's save could not trigger it. I checked g:flutter_hot_reload_on_save to be 1. I develop on ubuntu and the app is also built for linux as the target platform. is hot-reload only for android and ios?

FlutterRun apparently not working on windows

Hi! I'm having some trouble setting up my vim to work with flutter. I have my flutter project opened, my emulator is running, but when I run FlutterRun on my vim nothing happens, just the Flutter_Output is opened, but my project won't start. Am I doing something wrong?
I'm on Windows, and while using VSCode everything works fine; and other commands also work on vim, like FlutterEmulators or FlutterEmulatorsLaunch, but not FlutterRun.

Is there any log of some sort that I can check to try and see whats happening?
Thanks!

image

Hot reload fails

Hello! I just started trying to build an app with flutter with vim.
I installed this plugin and wanted to see the hot reload function when I save the main.dart file. But I got the following error.
I am now using neovim v0.2.2 on OSX.

Error detected while processing function flutter#hot_reload[1]..flutter#send:
line    4:
E117: Unknown function: job_getchannel
E15: Invalid expression: job_getchannel(g:flutter_job)

Thanks in advance!

Problem executing FlutterRun when not in the root of the project

First of all, I would like to thank you for this excellent package. I am having he following problem:
image
This is the root of my github repository. The problem is that goheay_customer and goheay_driver are two diifferent apks related to the same project. The point is that when I try to execute the following command:
FlutterRun --flavor dev -t goheavy_customer/lib/main_dev.dart I get the following error:
image
I would like to know if there is any alternative for me to use this command and still open the project root, which is not the flutter project root. Thanks in advance

FlutterTest command needed

I think executing test tasks without leaving vim is a necessity and unfortunately I couldnt find any command related. Can you please add a command like FlutterTest which would have at least the following functionality:

  1. FlutterTest without no parameters executes all tasks same as CLI tool
  2. FlutterTest will execute only given tasks if there is a parameter available same as CLI tool

autoscroll?

Can you make the output of :FlutterRun automatically scroll to the bottom when new lines appear?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.