Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ require("flutter-tools").setup {
notify_errors = false, -- if there is an error whilst running then notify the user
open_cmd = "15split", -- command to use to open the log buffer
focus_on_open = true, -- focus on the newly opened log window
win_opts = nil, -- window-local options for the log window, e.g. { winfixheight = true } to keep its size when the terminal resizes
},
dev_tools = {
autostart = false, -- autostart devtools server if not detected
Expand All @@ -302,6 +303,7 @@ require("flutter-tools").setup {
open_cmd = "30vnew", -- command to use to open the outline buffer
auto_open = false, -- if true this will open the outline automatically when it is first populated
icons = true, -- false hides the icons (e.g. without a Nerd Font); a table overrides icons per kind, e.g. { CLASS = "C", DEFAULT = "*" }
win_opts = nil, -- window-local options for the outline window, e.g. { wrap = true }
},
lsp = {
on_attach = my_custom_on_attach,
Expand Down
4 changes: 3 additions & 1 deletion lua/flutter-tools/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ local utils = lazy.require("flutter-tools.utils") ---@module "flutter-tools.util
---@field debugger? {enabled: boolean, exception_breakpoints?: table, evaluate_to_string_in_debug_views?: boolean, register_configurations?: fun(paths: table)}
---@field closing_tags? {highlight: string, prefix: string, priority: number, enabled: boolean}
---@field lsp? {debug?: number, color?: {enabled: boolean, background: boolean, foreground: boolean, virtual_text: boolean, virtual_text_str: string, background_color?: string}, settings?: table}
---@field outline? {auto_open: boolean, open_cmd?: string, icons?: boolean|table<string, string>}
---@field outline? {auto_open: boolean, open_cmd?: string, icons?: boolean|table<string, string>, win_opts?: table<string, any>}
---@field dev_log? flutter.DevLogOpts
---@field dev_tools? {autostart: boolean, auto_open_browser: boolean}
---@field widget_preview? {web_server: boolean}
Expand Down Expand Up @@ -77,8 +77,10 @@ local function validate_prefs(prefs)
vim.validate("outline", prefs.outline, "table", true)
if prefs.outline then
vim.validate("outline.icons", prefs.outline.icons, { "boolean", "table" }, true)
vim.validate("outline.win_opts", prefs.outline.win_opts, "table", true)
end
vim.validate("dev_log", prefs.dev_log, "table", true)
if prefs.dev_log then vim.validate("dev_log.win_opts", prefs.dev_log.win_opts, "table", true) end
vim.validate("closing_tags", prefs.closing_tags, "table", true)
end

Expand Down
1 change: 1 addition & 0 deletions lua/flutter-tools/log.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ local function create(config)
filetype = "log",
open_cmd = config.open_cmd,
focus_on_open = config.focus_on_open,
win_opts = config.win_opts,
}
ui.open_win(opts, function(buf, win)
if not buf then
Expand Down
1 change: 1 addition & 0 deletions lua/flutter-tools/outline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ function M.open(opts)
filetype = outline_filetype,
filename = outline_filename,
focus_on_open = true,
win_opts = options.win_opts,
}, function(buf, win)
setup_outline_window(buf, win, lines, highlights, opts.go_back)
vim.b[buf].outline_uri = outline.uri
Expand Down
5 changes: 5 additions & 0 deletions lua/flutter-tools/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ local entry_type = {
---@field filename? string Name to give the buffer
---@field filetype string Filetype to set for the buffer
---@field focus_on_open? boolean Whether to focus the window after opening
---@field win_opts? table<string, any> Window-local options to set on the window

---@enum
local M = {
Expand Down Expand Up @@ -129,6 +130,10 @@ function M.open_win(opts, on_open)
vim.bo[buf].buftype = "nofile"
vim.bo[buf].buflisted = false
if on_open then on_open(buf, win) end
for name, value in pairs(opts.win_opts or {}) do
local ok, err = pcall(api.nvim_set_option_value, name, value, { scope = "local", win = win })
if not ok then M.notify(fmt("Invalid window option %q: %s", name, err), M.WARN) end
end
if not opts.focus_on_open then
-- Switch back to the previous window
vim.cmd("wincmd p")
Expand Down
Loading