Skip to content

Commit 417304b

Browse files
authored
feat!: remove support to older than 0.11 nvim versions (#525)
1 parent 7fc434e commit 417304b

21 files changed

Lines changed: 285 additions & 135 deletions

.github/ISSUE_TEMPLATE/bug_report.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ body:
4545
- **OS**: Ubuntu 20.04
4646
- **Flutter version**: 3.7.0
4747
- **Is flutter in $PATH**: yes
48-
- **neovim version**: 0.8.3
48+
- **neovim version**: 0.11.0
4949
value: |
5050
- OS:
5151
- Flutter version:

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
uses: kdheepak/panvimdoc@main
4343
with:
4444
vimdoc: flutter-tools
45-
version: "Neovim >= 0.8.0"
45+
version: "Neovim >= 0.11"
4646
demojify: true
4747
treesitter: true
4848
- name: Push changes

README.md

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,15 @@ nnoremap K <Cmd>lua vim.lsp.buf.hover()<CR>
3232
nnoremap gd <Cmd>lua vim.lsp.buf.definition()<CR>
3333
" Open code actions using the default lsp UI, if you want to change this please see the plugins above
3434
nnoremap <leader>ca <Cmd>lua vim.lsp.buf.code_action()<CR>
35-
" Open code actions for the selected visual range
36-
xnoremap <leader>ca <Cmd>lua vim.lsp.buf.range_code_action()<CR>
35+
xnoremap <leader>ca <Cmd>lua vim.lsp.buf.code_action()<CR>
3736
```
3837

3938
Please note this is not a replacement for reading the documentation, this is only to show new users what
4039
some basic setup might look like.
4140

4241
## Prerequisites
4342

44-
- neovim 0.8.0+
43+
- Neovim 0.11+
4544

4645
## Installation
4746

@@ -159,14 +158,21 @@ require("flutter-tools").setup {} -- use defaults
159158
- `FlutterDetach` - Ends a running session locally but keeps the process running on the device.
160159
- `FlutterOutlineToggle` - Toggle the outline window showing the widget tree for the given file.
161160
- `FlutterOutlineOpen` - Opens an outline window showing the widget tree for the given file.
161+
- `FlutterVisualDebug` - Toggle Flutter visual debugging.
162+
- `FlutterChangeTargetPlatform` - Cycle the target platform override for the running app.
163+
- `FlutterToggleBrightness` - Toggle the app brightness override.
162164
- `FlutterDevTools` - Starts a Dart Dev Tools server.
163165
- `FlutterDevToolsActivate` - Activates a Dart Dev Tools server.
166+
- `FlutterOpenDevTools` - Open the currently connected DevTools page.
167+
- `FlutterInspectWidget` - Toggle widget inspection for the running app.
164168
- `FlutterCopyProfilerUrl` - Copies the profiler url to your system clipboard (+ register). Note that commands `FlutterRun` and
165169
`FlutterDevTools` must be executed first.
170+
- `FlutterPubGet` - Run `flutter pub get` in the project root.
171+
- `FlutterPubUpgrade [args]` - Run `flutter pub upgrade` with optional extra arguments.
166172
- `FlutterLspRestart` - This command restarts the dart language server, and is intended for situations where it begins to work incorrectly.
167173
- `FlutterSuper` - Go to super class, method using custom LSP method `dart/textDocument/super`.
168174
- `FlutterReanalyze` - Forces LSP server reanalyze using custom LSP method `dart/reanalyze`.
169-
- `FlutterRename` - Renames and updates imports if `lsp.settings.renameFilesWithClasses == "always"`
175+
- `FlutterRename` - Rename a symbol and update imports if `lsp.settings.renameFilesWithClasses == "always"`.
170176
- `FlutterLogClear` - Clears the log buffer.
171177
- `FlutterLogToggle` - Toggles the log buffer.
172178

@@ -270,14 +276,6 @@ require("flutter-tools").setup {
270276
auto_open = false -- if true this will open the outline automatically when it is first populated
271277
},
272278
lsp = {
273-
color = { -- show the derived colours for dart variables
274-
enabled = false, -- whether or not to highlight color variables at all, only supported on flutter >= 2.10
275-
background = false, -- highlight the background
276-
background_color = nil, -- required, when background is transparent (i.e. background_color = { r = 19, g = 17, b = 24},)
277-
foreground = false, -- highlight the foreground
278-
virtual_text = true, -- show the highlight using virtual text
279-
virtual_text_str = "", -- the virtual text character to highlight
280-
},
281279
on_attach = my_custom_on_attach,
282280
capabilities = my_custom_capabilities, -- e.g. lsp_status capabilities
283281
--- OR you can specify a function to deactivate or change or control how the config is created
@@ -302,6 +300,30 @@ require("flutter-tools").setup {
302300
You can override any options available in the `lspconfig` setup, this call essentially wraps
303301
it and adds some extra `flutter` specific handlers and utilisation options.
304302

303+
### Document colors
304+
305+
Plugin-managed `lsp.color` rendering is deprecated and will be removed when flutter-tools.nvim requires Neovim `0.12+`.
306+
307+
On Neovim `0.12+`, use the built-in LSP document color support instead:
308+
309+
```lua
310+
vim.api.nvim_create_autocmd("LspAttach", {
311+
callback = function(ev)
312+
vim.lsp.document_color.enable(true, { bufnr = ev.buf })
313+
end,
314+
})
315+
```
316+
317+
If you want to opt out of Neovim's built-in document colors for some buffers:
318+
319+
```lua
320+
vim.api.nvim_create_autocmd("LspAttach", {
321+
callback = function(ev)
322+
vim.lsp.document_color.enable(false, { bufnr = ev.buf })
323+
end,
324+
})
325+
```
326+
305327
**NOTE:**
306328
By default this plugin excludes analysis of the packages in the flutter SDK. If for example
307329
you jump to the definition of `StatelessWidget`, the lsp will not try and index the 100s (maybe 1000s) of

doc/flutter-tools.txt

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
*flutter-tools.txt*
2-
For Neovim >= 0.8.0 Last change: 2026 April 23
2+
For Neovim >= 0.11 Last change: 2026 May 03
33

44
==============================================================================
55
Table of Contents *flutter-tools-table-of-contents*
@@ -62,9 +62,8 @@ A minimal native LSP configuration might look like:
6262
" Jump to definition
6363
nnoremap gd <Cmd>lua vim.lsp.buf.definition()<CR>
6464
" Open code actions using the default lsp UI, if you want to change this please see the plugins above
65-
nnoremap <leader>ca <Cmd>lua vim.lsp.buf.code_action()<CR>
66-
" Open code actions for the selected visual range
67-
xnoremap <leader>ca <Cmd>lua vim.lsp.buf.range_code_action()<CR>
65+
nnoremap <leader>ca <Cmd>lua vim.lsp.buf.code_action()<CR>
66+
xnoremap <leader>ca <Cmd>lua vim.lsp.buf.code_action()<CR>
6867
<
6968

7069
Please note this is not a replacement for reading the documentation, this is
@@ -73,7 +72,7 @@ only to show new users what some basic setup might look like.
7372

7473
PREREQUISITES *flutter-tools-flutter-tools.nvim-prerequisites*
7574

76-
- neovim 0.8.0+
75+
- Neovim 0.11+
7776

7877

7978
INSTALLATION *flutter-tools-flutter-tools.nvim-installation*
@@ -193,14 +192,21 @@ APP VERSION
193192
- `FlutterDetach` - Ends a running session locally but keeps the process running on the device.
194193
- `FlutterOutlineToggle` - Toggle the outline window showing the widget tree for the given file.
195194
- `FlutterOutlineOpen` - Opens an outline window showing the widget tree for the given file.
195+
- `FlutterVisualDebug` - Toggle Flutter visual debugging.
196+
- `FlutterChangeTargetPlatform` - Cycle the target platform override for the running app.
197+
- `FlutterToggleBrightness` - Toggle the app brightness override.
196198
- `FlutterDevTools` - Starts a Dart Dev Tools server.
197199
- `FlutterDevToolsActivate` - Activates a Dart Dev Tools server.
200+
- `FlutterOpenDevTools` - Open the currently connected DevTools page.
201+
- `FlutterInspectWidget` - Toggle widget inspection for the running app.
198202
- `FlutterCopyProfilerUrl` - Copies the profiler url to your system clipboard (+ register). Note that commands `FlutterRun` and
199203
`FlutterDevTools` must be executed first.
204+
- `FlutterPubGet` - Run `flutter pub get` in the project root.
205+
- `FlutterPubUpgrade [args]` - Run `flutter pub upgrade` with optional extra arguments.
200206
- `FlutterLspRestart` - This command restarts the dart language server, and is intended for situations where it begins to work incorrectly.
201207
- `FlutterSuper` - Go to super class, method using custom LSP method `dart/textDocument/super`.
202208
- `FlutterReanalyze` - Forces LSP server reanalyze using custom LSP method `dart/reanalyze`.
203-
- `FlutterRename` - Renames and updates imports if `lsp.settings.renameFilesWithClasses == "always"`
209+
- `FlutterRename` - Rename a symbol and update imports if `lsp.settings.renameFilesWithClasses == "always"`.
204210
- `FlutterLogClear` - Clears the log buffer.
205211
- `FlutterLogToggle` - Toggles the log buffer.
206212

@@ -306,14 +312,6 @@ both are set.
306312
auto_open = false -- if true this will open the outline automatically when it is first populated
307313
},
308314
lsp = {
309-
color = { -- show the derived colours for dart variables
310-
enabled = false, -- whether or not to highlight color variables at all, only supported on flutter >= 2.10
311-
background = false, -- highlight the background
312-
background_color = nil, -- required, when background is transparent (i.e. background_color = { r = 19, g = 17, b = 24},)
313-
foreground = false, -- highlight the foreground
314-
virtual_text = true, -- show the highlight using virtual text
315-
virtual_text_str = "■", -- the virtual text character to highlight
316-
},
317315
on_attach = my_custom_on_attach,
318316
capabilities = my_custom_capabilities, -- e.g. lsp_status capabilities
319317
--- OR you can specify a function to deactivate or change or control how the config is created
@@ -339,6 +337,32 @@ You can override any options available in the `lspconfig` setup, this call
339337
essentially wraps it and adds some extra `flutter` specific handlers and
340338
utilisation options.
341339

340+
341+
DOCUMENT COLORS ~
342+
343+
Plugin-managed `lsp.color` rendering is deprecated and will be removed when
344+
flutter-tools.nvim requires Neovim `0.12+`.
345+
346+
On Neovim `0.12+`, use the built-in LSP document color support instead:
347+
348+
>lua
349+
vim.api.nvim_create_autocmd("LspAttach", {
350+
callback = function(ev)
351+
vim.lsp.document_color.enable(true, { bufnr = ev.buf })
352+
end,
353+
})
354+
<
355+
356+
If you want to opt out of Neovim's built-in document colors for some buffers:
357+
358+
>lua
359+
vim.api.nvim_create_autocmd("LspAttach", {
360+
callback = function(ev)
361+
vim.lsp.document_color.enable(false, { bufnr = ev.buf })
362+
end,
363+
})
364+
<
365+
342366
**NOTE:** By default this plugin excludes analysis of the packages in the
343367
flutter SDK. If for example you jump to the definition of `StatelessWidget`,
344368
the lsp will not try and index the 100s (maybe 1000s) of files in that

lua/flutter-tools/config.lua

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,9 @@ local function validate_prefs(prefs)
6565
end
6666
)
6767
end
68-
if vim.fn.has("nvim-0.11") == 1 then
69-
vim.validate("outline", prefs.outline, "table", true)
70-
vim.validate("dev_log", prefs.dev_log, "table", true)
71-
vim.validate("closing_tags", prefs.closing_tags, "table", true)
72-
else
73-
vim.validate({
74-
outline = { prefs.outline, "table", true },
75-
dev_log = { prefs.dev_log, "table", true },
76-
closing_tags = { prefs.closing_tags, "table", true },
77-
})
78-
end
68+
vim.validate("outline", prefs.outline, "table", true)
69+
vim.validate("dev_log", prefs.dev_log, "table", true)
70+
vim.validate("closing_tags", prefs.closing_tags, "table", true)
7971
end
8072

8173
---Create a proportional split using a percentage specified as a float
@@ -163,15 +155,47 @@ local deprecations = {
163155
fallback = "widget_guides",
164156
message = "please use 'widget_guides' instead",
165157
},
158+
lsp = {
159+
nested = {
160+
color = {
161+
when = function() return vim.fn.has("nvim-0.12") == 1 end,
162+
message = "plugin-managed document colors are deprecated and will be removed when flutter-tools.nvim requires Neovim 0.12+. On Neovim 0.12+, use vim.lsp.document_color.enable() instead",
163+
},
164+
},
165+
},
166166
}
167167

168-
local function handle_deprecation(key, value, conf)
169-
local deprecation = deprecations[key]
170-
if not deprecation then return end
168+
local function notify_deprecation(key, message)
171169
vim.defer_fn(
172-
function() ui.notify(fmt("%s is deprecated: %s", key, deprecation.message), ui.WARN) end,
170+
function() ui.notify(fmt("%s is deprecated: %s", key, message), ui.WARN, { once = true }) end,
173171
1000
174172
)
173+
end
174+
175+
local function should_notify_deprecation(deprecation)
176+
return not deprecation.when or deprecation.when()
177+
end
178+
179+
local function handle_nested_deprecation(prefix, value, deprecation)
180+
if type(value) ~= "table" or type(deprecation.nested) ~= "table" then return end
181+
for key, nested_value in pairs(value) do
182+
local nested_deprecation = deprecation.nested[key]
183+
if nested_deprecation then
184+
if nested_deprecation.message and should_notify_deprecation(nested_deprecation) then
185+
notify_deprecation(("%s.%s"):format(prefix, key), nested_deprecation.message)
186+
end
187+
handle_nested_deprecation(("%s.%s"):format(prefix, key), nested_value, nested_deprecation)
188+
end
189+
end
190+
end
191+
192+
local function handle_deprecation(key, value, conf)
193+
local deprecation = deprecations[key]
194+
if not deprecation then return end
195+
if deprecation.message and should_notify_deprecation(deprecation) then
196+
notify_deprecation(key, deprecation.message)
197+
end
198+
handle_nested_deprecation(key, value, deprecation)
175199
if deprecation.fallback then conf[deprecation.fallback] = value end
176200
end
177201

lua/flutter-tools/dev_tools.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ end
207207

208208
function M.stop()
209209
if devtools_pid then
210-
local uv = vim.loop
210+
local uv = vim.uv
211211
uv.kill(devtools_pid, uv.constants.SIGTERM)
212212
devtools_pid = nil
213213
devtools_url = nil

lua/flutter-tools/devices.lua

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,18 @@ function M.to_selection_entries(result, device_type)
6464
if not result or #result < 1 then return {} end
6565
if not device_type then device_type = DEVICE end
6666
local devices = get_devices(result, device_type)
67-
if #devices == 0 then vim.tbl_map(function(item) return { text = item } end, result) end
67+
if #devices == 0 then
68+
return vim.tbl_map(
69+
function(item)
70+
return {
71+
text = item,
72+
type = ui.entry_type.INFO,
73+
data = nil,
74+
}
75+
end,
76+
result
77+
)
78+
end
6879
return vim.tbl_map(function(device)
6980
local has_platform = device.platform and device.platform ~= ""
7081
return {

lua/flutter-tools/executable.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ local Job = require("plenary.job")
3030

3131
local fn = vim.fn
3232
local fs = vim.fs
33-
local luv = vim.loop
33+
local uv = vim.uv
3434

3535
local M = {}
3636

@@ -124,13 +124,13 @@ end
124124

125125
local function flutter_bin_from_fvm()
126126
local fvm_root =
127-
fs.dirname(fs.find(".fvm", { path = luv.cwd(), upward = true, type = "directory" })[1])
127+
fs.dirname(fs.find(".fvm", { path = uv.cwd(), upward = true, type = "directory" })[1])
128128

129129
local binary_name = path.is_windows and "flutter.bat" or "flutter"
130130
local flutter_bin_symlink = path.join(fvm_root, ".fvm", "flutter_sdk", "bin", binary_name)
131131
flutter_bin_symlink = fn.exepath(flutter_bin_symlink)
132132

133-
local flutter_bin = luv.fs_realpath(flutter_bin_symlink)
133+
local flutter_bin = uv.fs_realpath(flutter_bin_symlink)
134134
if path.exists(flutter_bin_symlink) and path.exists(flutter_bin) then return flutter_bin end
135135
end
136136

0 commit comments

Comments
 (0)