@@ -39,4 +39,85 @@ function M.clamp(v, lo, hi)
3939 return v
4040end
4141
42+ --- The filetype set on every buffer the plugin owns. Users can add this to
43+ --- their UI plugins' exclusion lists as a fallback.
44+ M .FORM_FILETYPE = " input-form"
45+
46+ local _excluded_registered = false
47+
48+ -- Append `ft` to a list-shaped config field if missing.
49+ local function ensure_excluded (cfg , key , ft )
50+ if type (cfg ) ~= " table" then
51+ return
52+ end
53+ cfg [key ] = cfg [key ] or {}
54+ if not vim .tbl_contains (cfg [key ], ft ) then
55+ table.insert (cfg [key ], ft )
56+ end
57+ end
58+
59+ --- Tell known UI plugins (scrollbars, indent guides, etc.) to skip buffers
60+ --- with filetype `input-form`. Idempotent. Called lazily on the first
61+ --- `form:show()` so it works whether or not the user called `setup()`.
62+ function M .register_ui_exclusions ()
63+ if _excluded_registered then
64+ return
65+ end
66+ _excluded_registered = true
67+
68+ -- nvim-scrollbar (petertriho/nvim-scrollbar).
69+ -- Its real config lives at `require("scrollbar.config")` — the module stores
70+ -- the active table under `.config` and exposes it via `.get()`. We patch
71+ -- both paths defensively in case the module layout differs across versions.
72+ local ok , sbar_cfg = pcall (require , " scrollbar.config" )
73+ if ok and sbar_cfg then
74+ if type (sbar_cfg .get ) == " function" then
75+ local cfg = sbar_cfg .get ()
76+ ensure_excluded (cfg , " excluded_filetypes" , M .FORM_FILETYPE )
77+ ensure_excluded (cfg , " excluded_buftypes" , " nofile" )
78+ end
79+ if type (sbar_cfg .config ) == " table" then
80+ ensure_excluded (sbar_cfg .config , " excluded_filetypes" , M .FORM_FILETYPE )
81+ end
82+ end
83+ -- Some older layouts exposed the config directly on the main module.
84+ local ok_top , sbar = pcall (require , " scrollbar" )
85+ if ok_top and type (sbar ) == " table" and type (sbar .config ) == " table" then
86+ ensure_excluded (sbar .config , " excluded_filetypes" , M .FORM_FILETYPE )
87+ end
88+
89+ -- satellite.nvim (lewis6991/satellite.nvim).
90+ local ok2 , sat_cfg = pcall (require , " satellite.config" )
91+ if ok2 and sat_cfg then
92+ if type (sat_cfg .user_config ) == " table" then
93+ ensure_excluded (sat_cfg .user_config , " excluded_filetypes" , M .FORM_FILETYPE )
94+ end
95+ if type (sat_cfg .config ) == " table" then
96+ ensure_excluded (sat_cfg .config , " excluded_filetypes" , M .FORM_FILETYPE )
97+ end
98+ end
99+ end
100+
101+ --- Mark a buffer as an internal form buffer so third-party UI plugins
102+ --- (scrollbars, indent guides, git signs, etc.) skip it.
103+ ---
104+ --- Sets `filetype = "input-form"` plus the opt-out buffer variables
105+ --- recognized by common plugins. Users whose plugins don't honour these can
106+ --- add `input-form` to their plugin's exclusion list.
107+ function M .mark_form_buffer (buf )
108+ if not (buf and vim .api .nvim_buf_is_valid (buf )) then
109+ return
110+ end
111+ vim .bo [buf ].filetype = M .FORM_FILETYPE
112+ -- nvim-scrollbar (petertriho/nvim-scrollbar)
113+ vim .b [buf ].scrollbar_disabled = true
114+ -- satellite.nvim (lewis6991/satellite.nvim)
115+ vim .b [buf ].satellite_disable = true
116+ -- mini.indentscope / mini.map
117+ vim .b [buf ].miniindentscope_disable = true
118+ vim .b [buf ].minimap_disable = true
119+ -- gitsigns (defensive; unlikely on a nofile buf but cheap)
120+ vim .b [buf ].gitsigns_disable = true
121+ end
122+
42123return M
0 commit comments