diff --git a/.cspell/words.txt b/.cspell/words.txt new file mode 100644 index 0000000..f67f3e2 --- /dev/null +++ b/.cspell/words.txt @@ -0,0 +1,7 @@ +darcula +keymaps +neovim +nmap +nvim +sgraves76 +stdpath \ No newline at end of file diff --git a/.gitignore b/.gitignore index 0667445..c441603 100644 --- a/.gitignore +++ b/.gitignore @@ -40,4 +40,4 @@ luac.out *.x86_64 *.hex - +cspell.json diff --git a/README.md b/README.md index 8850710..02ca132 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,115 @@ # nvim-flutter-companion -Tools for Fluttter \ No newline at end of file +Enhances existing Flutter tools by storing selected device and emulator in local project configuration file (`.flutter-companion`). + +- Requires `coc-flutter/coc-flutter-tools` if using CoC. +- Requires `flutter-tools.nvim` if using native LSP. + +### Global functions + +```lua +_G.Flutter_Companion_Clear_Selected_Device = function() + M.flutter_clear(false) +end + +_G.Flutter_Companion_Run_Selected_Device = function() + M.flutter_run(false) +end + +_G.Flutter_Companion_Select_Device = function() + M.flutter_list(false) +end + +_G.Flutter_Companion_Clear_Selected_Emulator = function() + M.flutter_clear(true) +end + +_G.Flutter_Companion_Run_Selected_Emulator = function() + M.flutter_run(true) +end + +_G.Flutter_Companion_Select_Emulator = function() + M.flutter_list(true) +end +``` + +### Example + +> Example utilizes my custom Neovim distribution `darcula`. +> This is not publicly available yet, but should be self-explanatory nonetheless :) + +```lua +local M = { + disabled = false +} + +M.keymaps = function() { + local km = require("darcula.utils.keymap") + local companion = require("nvim-flutter-companion") + local opts = {remap = false, silent = true} + + km.nmap( + km.leader "fld", + function() + companion.flutter_list(false) + end, + opts + ) + + km.nmap( + km.leader "flv", + function() + companion.flutter_list(false) + end, + opts + ) + + km.nmap( + km.leader "fle", + function() + companion.flutter_list(true) + end, + opts + ) + + km.nmap( + km.leader "flm", + function() + companion.flutter_run(true) + end, + opts + ) + + km.nmap( + km.leader "flx", + function() + companion.flutter_run(false) + end, + opts + ) +} + +M.lua_add_library = function(library_list) + table.insert(library_list, "nvim-flutter-companion") +end + +M.plug = function(Plug) + Plug "sgraves76/nvim-flutter-companion" +end + +M.setup = function() + local plugins = require("nvim-goodies.plugins") + if not plugins.check_requires("nvim-flutter-companion") then + return + end + + -- Native LSP + require("nvim-flutter-companion").setup({use_coc = true}) + + -- CoC + require("nvim-flutter-companion").setup({use_coc = false}) +end + +return M +``` +