You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>The previous “reset by explicitly setting initial background color” behavior is available by setting the new <code>opts.explicit_reset</code> option to <code>true</code>.</p></li>
<li><p>Add <code>safely()</code> to execute a function reporting its possible error as warning. It can also postpone execution until certain condition (like event, fixed delay, etc.).</p>
1307
+
<p>It is intended to be a future replacement for <code>MiniDeps.now()</code> and <code>MiniDeps.later()</code>.</p></li>
<li><p><ahref="../../mini.nvim/doc/mini-misc.html#minimisc.log_add">MiniMisc.log_add()</a>, <ahref="../../mini.nvim/doc/mini-misc.html#minimisc.log_show">MiniMisc.log_show()</a> and other helper functions to work with a special in-memory log array. Useful when debugging Lua code.</p></li>
486
491
<li><p><ahref="../../mini.nvim/doc/mini-misc.html#minimisc.put">MiniMisc.put()</a> and <ahref="../../mini.nvim/doc/mini-misc.html#minimisc.put_text">MiniMisc.put_text()</a> to pretty print its arguments into command line and current buffer respectively.</p></li>
487
492
<li><p><ahref="../../mini.nvim/doc/mini-misc.html#minimisc.resize_window">MiniMisc.resize_window()</a> to resize current window to its editable width.</p></li>
493
+
<li><p><ahref="../../mini.nvim/doc/mini-misc.html#minimisc.safely">MiniMisc.safely()</a> to execute a function on a condition and warn on error. Useful to organize <ahref="https://neovim.io/doc/user/helptag.html?tag=init.lua">init.lua</a> in fail-safe sections with simple lazy loading.</p></li>
488
494
<li><p><ahref="../../mini.nvim/doc/mini-misc.html#minimisc.setup_auto_root">MiniMisc.setup_auto_root()</a> to set up automated change of current directory.</p></li>
489
495
<li><p><ahref="../../mini.nvim/doc/mini-misc.html#minimisc.setup_termbg_sync">MiniMisc.setup_termbg_sync()</a> to set up terminal background synchronization (removes possible “frame” around current Neovim instance).</p></li>
490
496
<li><p><ahref="../../mini.nvim/doc/mini-misc.html#minimisc.setup_restore_cursor">MiniMisc.setup_restore_cursor()</a> to set up automated restoration of cursor position on file reopen.</p></li>
<p>Execute a function on a condition and warn on error</p>
703
+
<p>Input function is executed exactly once. Its possible error is captured and is shown as a <ahref="https://neovim.io/doc/user/helptag.html?tag=vim.notify()">vim.notify()</a> warning.</p>
704
+
<p>Useful to organize <ahref="https://neovim.io/doc/user/helptag.html?tag=init.lua">init.lua</a> in fail-safe sections with simple lazy loading.</p>
<p><spanclass="help-syntax-special">{when}</span><code>(string)</code> When to execute a function. One of:</p>
708
+
<ul>
709
+
<li><p><code>'now'</code> - immediately.</p></li>
710
+
<li><p><code>'later'</code> - queue to be executed soon without blocking the execution of next code in file. Queued functions are executed in order they are added.</p></li>
711
+
<li><p><code>'delay:<number>'</code> - after a specified delay with <ahref="https://neovim.io/doc/user/helptag.html?tag=vim.defer_fn()">vim.defer_fn()</a>.</p></li>
712
+
<li><p><code>'event:<events>'</code> - on whichever specified event is triggered first.</p></li>
713
+
<li><p><code>'event:<events>~<patterns></code> - same as above, but events must match specified <ahref="https://neovim.io/doc/user/helptag.html?tag=autocmd-pattern">autocmd-pattern</a>.</p></li>
714
+
<li><p><code>'filetype:<filetypes>'</code> - same as <code>'event:FileType~<filetypes>'</code>, but follow successful function execution with <ahref="https://neovim.io/doc/user/helptag.html?tag=filetype-detect">filetype-detect</a> for all normal buffers (if new <ahref="https://neovim.io/doc/user/helptag.html?tag=ftdetect">ftdetect</a> scripts were added) and sourcing <ahref="https://neovim.io/doc/user/helptag.html?tag=ftplugin">ftplugin</a> (for buffers matching <code><filetypes></code>). Intended to be used for loading “language plugins”.</p></li>
715
+
</ul>
716
+
<p><spanclass="help-syntax-special">{f}</span><code>(function)</code> Function to execute (without arguments).</p>
<spanid="cb4-2"><ahref="#cb4-2" aria-hidden="true" tabindex="-1"></a><spanclass="va">vim</span><spanclass="op">.</span>notify<spanclass="op">(</span><spanclass="st">'This will be executed after the next "now" call'</span><spanclass="op">)</span></span>
<spanid="cb4-4"><ahref="#cb4-4" aria-hidden="true" tabindex="-1"></a><spanclass="va">MiniMisc</span><spanclass="op">.</span>safely<spanclass="op">(</span><spanclass="st">'now'</span><spanclass="op">,</span><spanclass="kw">function</span><spanclass="op">()</span><spanclass="fu">error</span><spanclass="op">(</span><spanclass="st">'This will be a warning'</span><spanclass="op">)</span><spanclass="kw">end</span><spanclass="op">)</span></span>
<spanid="cb4-10"><ahref="#cb4-10" aria-hidden="true" tabindex="-1"></a><spanclass="va">vim</span><spanclass="op">.</span>notify<spanclass="op">(</span><spanclass="st">'Start searching for the first time'</span><spanclass="op">)</span></span>
<p>This works by parsing ‘commentstring’ buffer option, extracting non-whitespace comment leader (symbols on the left of commented line), and locally modifying ‘comments’ option (by prepending <code>n:<leader></code>). Does nothing if ‘commentstring’ is empty or has comment symbols both in front and back (like “/%s/”).</p>
845
892
<p>Nested comment leader added with this function is useful for formatting nested comments. For example, have in Lua “first-level” comments with ‘–’ and “second-level” comments with ‘—-’. With nested comment leader second type can be formatted with <code>gq</code> in the same way as first one.</p>
846
893
<p>Recommended usage is with <ahref="https://neovim.io/doc/user/helptag.html?tag=autocmd">autocmd</a>:</p>
<spanid="cb7-2"><ahref="#cb7-2" aria-hidden="true" tabindex="-1"></a><spanclass="va">vim</span><spanclass="op">.</span><spanclass="va">api</span><spanclass="op">.</span>nvim_create_autocmd<spanclass="op">(</span><spanclass="st">'BufEnter'</span><spanclass="op">,</span><spanclass="op">{</span><spanclass="va">callback</span><spanclass="op">=</span><spanclass="va">use_nested_comments</span><spanclass="op">})</span></span></code></pre></div><buttontitle="Copy to Clipboard" class="code-copy-button"><iclass="bi"></i></button></div>
849
896
<p>Note: for most filetypes ‘commentstring’ option is added only when buffer with this filetype is entered, so using non-current <code>buf_id</code> can not lead to desired effect.</p>
<li><code>log_add()</code> / <code>log_show()</code> and other helper functions to work with a special in-memory log array. Useful when debugging Lua code (instead of <code>print()</code>).</li>
426
426
<li><code>put()</code> and <code>put_text()</code> print Lua objects in command line and current buffer respectively.</li>
427
427
<li><code>resize_window()</code> resizes current window to its editable width.</li>
428
+
<li><code>safely()</code> to execute a function on a condition and warn on error. Useful to organize ‘init.lua’ in fail-safe sections with simple lazy loading.</li>
428
429
<li><code>setup_auto_root()</code> sets up automated change of current directory.</li>
429
430
<li><code>setup_termbg_sync()</code> to set up terminal background synchronization (removes possible “frame” around current Neovim instance).</li>
430
431
<li><code>setup_restore_cursor()</code> sets up automated restoration of cursor position on file reopen.</li>
0 commit comments