|
| 1 | +-- Make sure to install fvm in yout system for this to work |
| 2 | +return { |
| 3 | + 'nvim-flutter/flutter-tools.nvim', |
| 4 | + lazy = false, |
| 5 | + dependencies = { |
| 6 | + 'nvim-lua/plenary.nvim', |
| 7 | + 'folke/snacks.nvim', -- optional for vim.ui.select |
| 8 | + }, |
| 9 | + opts = { |
| 10 | + fvm = true, |
| 11 | + }, |
| 12 | + config = function(_, config_opts) |
| 13 | + local root_patterns = { '.fvm' } |
| 14 | + local root_dir = vim.fs.dirname(vim.fs.find(root_patterns, { upward = true })[1]) |
| 15 | + if not root_dir then |
| 16 | + return |
| 17 | + end |
| 18 | + |
| 19 | + require('flutter-tools').setup(config_opts) |
| 20 | + local commands = { |
| 21 | + -- Commands |
| 22 | + 'FlutterRun', |
| 23 | + 'FlutterDebug', |
| 24 | + 'FlutterLspRestart', |
| 25 | + 'FlutterAttach', |
| 26 | + 'FlutterDetach', |
| 27 | + 'FlutterReload', |
| 28 | + 'FlutterRestart', |
| 29 | + 'FlutterQuit', |
| 30 | + 'FlutterVisualDebug', |
| 31 | + 'FlutterChangeTargetPlatform', |
| 32 | + 'FlutterToggleBrightness', |
| 33 | + -- Lists |
| 34 | + 'FlutterDevices', |
| 35 | + 'FlutterEmulators', |
| 36 | + --- Outline |
| 37 | + 'FlutterOutlineOpen', |
| 38 | + 'FlutterOutlineToggle', |
| 39 | + --- Dev tools |
| 40 | + 'FlutterDevTools', |
| 41 | + 'FlutterDevToolsActivate', |
| 42 | + 'FlutterCopyProfilerUrl', |
| 43 | + 'FlutterOpenDevTools', |
| 44 | + 'FlutterInspectWidget', |
| 45 | + 'FlutterPubGet', |
| 46 | + 'FlutterPubUpgrade', |
| 47 | + --- Log |
| 48 | + 'FlutterLogClear', |
| 49 | + 'FlutterLogToggle', |
| 50 | + --- LSP |
| 51 | + 'FlutterSuper', |
| 52 | + 'FlutterReanalyze', |
| 53 | + 'FlutterRename', |
| 54 | + } |
| 55 | + |
| 56 | + local opts = {} |
| 57 | + opts.prompt = 'Flutter Tools> ' |
| 58 | + opts.actions = { |
| 59 | + ['default'] = function(selected) |
| 60 | + vim.cmd(selected) |
| 61 | + end, |
| 62 | + } |
| 63 | + |
| 64 | + vim.api.nvim_create_autocmd('BufEnter', { |
| 65 | + callback = function() |
| 66 | + vim.keymap.set('n', '<leader>F', function() |
| 67 | + require('fzf-lua').fzf_exec(commands, opts) |
| 68 | + end, { desc = 'Flutter Tools Commands' }) |
| 69 | + end, |
| 70 | + }) |
| 71 | + end, |
| 72 | +} |
0 commit comments