aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ex_cmds.lua
Commit message (Collapse)AuthorAge
* refactor(ex_cmds): use function arguments for magic behaviorbfredl2026-08-10
| | | | | | | | | | | | Now this was a cargo cult anti-pattern to write home about. Doing painful save-and-restore bookkeeping around a separate `magic_overruled` decoy global is just as messy as doing painful save-and-restore logic around `p_magic` itself. only that now you need to wrap every access to the effective value in a function call. This replaces this with a marvellous new Clean Code technique™: passing in the intended behavior as a function parameter to functions where either the option or an explicit value might be used.
* feat(editor): `:bcd` changes buffer-local directorysaher2026-08-04
| | | | | | | | | | | | | | | | | | Problem: No way to set a buffer-local directory. Use-cases: - "Root dir" for LSP (and the "project" concept). - `:terminal` OSC 7 Solution: Add `:bcd` command. - Extend `getcwd()` to take a third arg; `getcwd(-1, -1, bunfr)` returns the buffer-local working directory. - Buffer-local directories have less priority than window-local ones, and more priority than tab-local ones. Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
* feat(detach): opt-in to "server keeps running" #41133Justin M. Keyes2026-08-04
| | | | | | | | | | Problem: By default, `nvim` does not survive if its host terminal dies. This is inconvenient if you want to use Nvim as a "session manager" (like tmux). Solution: Let users opt-in to the "survive" behavior via `:detach!` (bang "!"). This marks the current UI as "detachable", so the server will not self-exit if the UI channel closes.
* feat(exmode): "1q:", :exmode #41010Justin M. Keyes2026-07-27
| | | | | | | | | Problem: Want `gQ` for _le multicursor_. Solution: - Don't use `gQ` for exmode. - Introduce `:exmode`. - Introduce `[count]q:` as an alias to `:exmode`.
* feat(ui): ":%detach!" detaches all other UIs #39216Jason Woodland2026-07-17
| | | | | | | Problem: Not easy for one UI to kick the others off a shared Nvim server. Solution: Treat `:%detach` as detach-other-UIs.
* feat(:restart)!: ":restart" (no bang) saves/restores session #40321Nathan Zeng2026-06-29
| | | | | | | | | | | Problem: `:restart` does not preserve window layout, etc. Solution: - Change `:restart` to save/restore a session automatically. - Introduce "bang" variant `:restart!` to restart *without* session save/restore. - Introduce `v:startreason`. - `ZR` maps to `:restart!`.
* feat(cmdwin): implement cmdwin as a normal buf+winJustin M. Keyes2026-06-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: cmdwin (the `:q` cmdline buffer) has various limitations which require special-casing all over the codebase. Besides complicating the code, it also breaks async plugins if they try to create buffers/windows after some work is done, if the user happens to open cmdwin at the wrong the moment: Lua callback: …/guh.nvim/lua/guh/util.lua:531: E11: Invalid in command-line window; <CR> executes, CTRL-C quits stack traceback: [C]: in function 'nvim_buf_delete' …/guh.nvim/lua/guh/util.lua:531: in function <…/guh.nvim/lua/guh/util.lua:526> Solution: Just say no to "inception". Reimplement cmdwin as a normal buffer+window. All of the cmdwin contortions (in both core, and innocent plugins) exist literally only to support "inception": recursive cmdwin-in-cmdline-things, like `<c-r>=`, `/`, search-during-substitute, `:input()`, etc. So we just won't support that (though I have a potential plan for that later, which I call "modal parking lot"). The benefit is that plugins, and core, no longer have to care about cmdwin. BONUS: - mouse-drag on vertical separators works (it only worked for horizontal/statusline before) - inccommand-in-cmdwin now works correctly, for free (thus don't need #40077). POTENTIAL FOLLOWUPS - Drop `CHECK_CMDWIN` ("E11: Invalid in command-line window"), allow chaos. - Unify `BUFLOCK_OK` / `LOCK_OK` ? DESIGN: - Eliminate lots of C globals, `EX_CMDWIN`, etc. - `text_locked()` no longer reports true for cmdwin. - cmdwin = a normal window with 'winfixbuf', 'bufhidden=wipe', 'buftype=nofile'. Invariants come from those options rather than special cases throughout the codebase. - `nv_record` for q:/q//q? calls Lua `nlua_call_vimfn("vim._core.cmdwin", …)`. No `K_CMDWIN` / cmdline-reader detour. - `cedit_key` (`c_CTRL-F`) schedules a deferred event that calls `vim._core.cmdwin.open(type, content, pos)` and returns `Ctrl_C` so the in-flight cmdline cancels. Reader state is not serialized; instead the captured `(type, line, col)` is replayed via `nvim_feedkeys(type..line.."<CR>", "nt", …)` after user confirms. - On confirm/cancel: `<CR>` / `<C-C>` calls into Lua which closes the window and re-feeds the cmdline. BREAKING CHANGES: - Expression-register cmdline (`<C-R>=` from insert-mode) no longer supports cmdwin. Same applies to `input()` / `inputlist()` (already covered by `text_locked`). - Usage of cmdwin in macros/mappings will probably break (assuming they ever worked).
* feat(pack): :packupdate, :packdel commands #39693Olivia Kinnear2026-05-16
| | | | | | Define `:packupdate` and `:packdel` as separate commands instead of a unified `:pack {subcommand}` because the semantics between the two commands vary differently enough that it doesn't make sense to combine them. Additionally, `:pack! update/del` looks bad.
* feat(excmd): add :uptime command #39331Olivia Kinnear2026-04-23
| | | | | | | Problem Nvim marks its v:starttime, but there is no user-friendly way to get Nvim's uptime. Solution Add :uptime (based loosely on uptime(1)).
* feat(connect): filepath completion #38959Justin M. Keyes2026-04-11
| | | | This is a stop-gap; the next step is for :connect to show a menu of known peers (and perhaps also any files in CWD that look like sockets).
* feat(ex): add `:log` commandOlivia Kinnear2026-04-10
|
* vim-patch:9.2.0130: missing range flags for the :tab command (#38216)zeertzjq2026-03-10
| | | | | | | | | | | | | | | | | Problem: :tab accepts a tab address range but doesn't specify this in the command specification. Solution: Add EX_RANGE and EX_ZEROR to the command specification and use ADDR_TABS (Doug Kearns). As command modifers are handled separately before these flags are tested in the ex-command parser they have no effect. However, it's better to use an accurate description and the command specification table has uses in other areas like runtime file generation for the Vim filetype. closes: vim/vim#19100 https://github.com/vim/vim/commit/49b8d9903bc7a2620ce7cf46228e16f7cd308d2e Co-authored-by: Doug Kearns <dougkearns@gmail.com>
* vim-patch:9.1.2040: :tlunmenu incorrectly accepts a range (#37206)zeertzjq2026-01-03
| | | | | | | | | | | Problem: :tlnumenu incorrectly accepts a range. Solution: Remove EX_RANGE and EX_ZEROR from the command definition and use ADDR_NONE (Doug Kearns). closes: vim/vim#19055 https://github.com/vim/vim/commit/19442ad11830bc9fc1474dfae9e813c31bc858b8 Co-authored-by: Doug Kearns <dougkearns@gmail.com>
* fix(lsp): tests for :lsp, rename start/stopOlivia Kinnear2025-12-16
| | | | | | - Rename :lsp start/stop to enable/disable - Move lua section of `:lsp` to `vim/_core` - Add tests
* feat(lsp): builtin :lsp commandbrianhuster2025-12-16
| | | | | | | | | | | | | Problem: - Despite [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig) claims to be a "data-only" plugin, in fact it still provides some user-facing commands because they haven't been upstreamed to Nvim. Solution: - Upstream `:LspRestart`, `:LspStart` and `:LspStop` commands as `:lsp restart`, `:lsp start` and `:lsp stop` respectively. Co-authored-by: glepnir <glephunter@gmail.com>
* vim-patch:9.1.1979: :helpclose allows range and counts (#36966)zeertzjq2025-12-15
| | | | | | | | | | | Problem: :helpclose incorrectly accepts a range and a count. Solution: Remove EX_COUNT and EX_RANGE from the command definition. (Doug Kearns) closes: vim/vim#18917 https://github.com/vim/vim/commit/4c141bae3bd7afd7eb63c72c835d356fbdff61e2 Co-authored-by: Doug Kearns <dougkearns@gmail.com>
* vim-patch:9.1.1915: :breaklist accepts unprocessed arguments. (#36561)zeertzjq2025-11-15
| | | | | | | | | | | | | | Problem: :breaklist accepts unprocessed arguments. Solution: Remove EX_EXTRA flag from the Ex command definition. (Doug Kearns) The command should emit an "E488: Trailing characters" error rather than silently accept arguments. closes: vim/vim#18746 https://github.com/vim/vim/commit/de7049ede1a31c73bfac70b78a2613d690eb1594 Co-authored-by: Doug Kearns <dougkearns@gmail.com>
* feat: ":wall ++p" creates parent dirs for each buf #36121Rob Pilling2025-10-11
| | | | `:wall ++p` will create parent directories if they do not exist, for each modified buffer
* fix(excmd): correct :connect abbreviationzeertzjq2025-08-18
|
* feat(ui): :connect command #34586Siddhant Agarwal2025-08-14
| | | | Add the `:connect <address>` command which connects the currently running TUI to the server at the given address.
* feat: ":restart [cmd]" can run commands #35045Sathya Pramodh2025-08-02
| | | | | | | Problem: Not easy for a user to tell ":restart" to "run this command(s) after restarting". Solution: All ":restart" args following the optional +cmd arg are treated as a big cmdline that is passed as a "-c" CLI arg when restarting nvim.
* feat: ":restart +cmd" #34788Sathya Pramodh2025-07-23
| | | | | | | | | | | Problem: ":restart" always executes ":qall" to exit the server. Solution: Support ":restart +cmd" so the user can control the command used to exit the server. Co-authored-by: Justin M. Keyes <justinkz@gmail.com> Co-authored-by: zeertzjq <zeertzjq@outlook.com>
* vim-patch:9.1.1477: no easy way to deduplicate textzeertzjq2025-07-05
| | | | | | | | | | | | Problem: no easy way to deduplicate text Solution: add the :uniq ex command (Hirohito Higashi) closes: vim/vim#17538 https://github.com/vim/vim/commit/74f0a77bb9a170a25b03cacf640aa4e1b1d222b2 Co-authored-by: Hirohito Higashi <h.east.727@gmail.com>
* fix(cmd): bar "|" not allowed after :fclose #34613glepnir2025-06-23
| | | | Problem: `:fclose` command failed when used with trailing `|` bar. Solution: Add `TRLBAR` flag to fclose command to support trailing bar.
* vim-patch:9.1.1473: inconsistent range arg for :diffget/diffput (#34588)zeertzjq2025-06-22
| | | | | | | | | | | | | | | | | | | | | | | | | | Problem: inconsistent range arg for :diffget/diffput Solution: fix the range specification, place the cursor for :diffput and :diffget consistently on the last line (Yee Cheng Chin) Previously, `:<range>diffget` only allowed using 1 or above in the range value, making it impossible to use the command for a diff block at the beginning of the file. Fix the range specification so the user can now use 0 to specify the space before the first line. This allows `:0,$+1diffget` to work to retrieve all the changes from the other file instead of missing the first diff block. Also do this for `:diffput`. Also, make `:diffput` work more similar to `:diffget`. Make it so that if the cursor is on the last line and a new line is inserted in the other file, doing `:diffput` will select that diff block below the line, just like `:diffget` would. Also clean up the logic a little bit for edge cases and for handling line matched diff blocks better. closes: vim/vim#17579 https://github.com/vim/vim/commit/d75ab0cbf5cfaefab3edb0aa553954de70b236f8 Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
* feat: make :restart work for remote UI (#34354)zeertzjq2025-06-07
|
* fix(excmd): don't allow range or args for :detach/:restart (#34280)zeertzjq2025-06-03
| | | | Also remove the CMDWIN and LOCK_OK flags, so that there is no need to check for text_locked() and curbuf_locked().
* feat(editor): ":restart" command #33953Sathya Pramodh2025-06-02
| | | | | | | | | | Problem: Developing/troubleshooting plugins has friction because "restarting" Nvim requires quitting and manually starting again. #32484 Solution: - Implement a `:restart` command which emits `restart` UI event. - Handle the `restart` UI event in the builtin TUI client: stop the `nvim --embed` server, start a new one, and attach to it.
* vim-patch:9.1.1224: cannot :put while keeping indent (#33076)zeertzjq2025-03-27
| | | | | | | | | | | | | | | | | | Problem: cannot :put while keeping indent (Peter Aronoff) Solution: add the :iput ex command (64-bitman) fixes: vim/vim#16225 closes: vim/vim#16886 https://github.com/vim/vim/commit/e08f10a55c3f15b0b4af631908551d88ec4fe502 Cherry-pick test_put.vim changes from patch 8.2.1593. N/A patches: vim-patch:9.1.1213: cannot :put while keeping indent vim-patch:9.1.1215: Patch 9.1.1213 has some issues Co-authored-by: 64-bitman <60551350+64-bitman@users.noreply.github.com> Co-authored-by: Hirohito Higashi <h.east.727@gmail.com>
* vim-patch:8.2.4594: need to write script to a file to be able to source themzeertzjq2025-02-28
| | | | | | | | | | | | | Problem: Need to write script to a file to be able to source them. Solution: Make ":source" use lines from the current buffer. (Yegappan Lakshmanan et al., closes vim/vim#9967) https://github.com/vim/vim/commit/36a5b6867bb6c0bd69c8da7d788000ab8a0b0ab0 Most code and test changes are reverted or modified again in patch 8.2.4603, so only port parts that are untouched in patch 8.2.4603. Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
* feat(ui): UI :detach commandJustin M. Keyes2025-02-10
| | | | | | | | | | | Problem: Cannot detach the current UI. Solution: - Introduce `:detach`. - Introduce `Channel.detach`. Co-authored-by: bfredl <bjorn.linse@gmail.com>
* vim-patch:9.1.0934: hard to view an existing buffer in the preview window ↵zeertzjq2024-12-17
| | | | | | | | | | | | | | | | | | | | | | (#31605) Problem: hard to view an existing buffer in the preview window Solution: add the :pbuffer command (Yinzuo Jiang) Similar as `:pedit` and `:buffer` command. `:pbuffer` edits buffer [N] from the buffer list in the preview window. `:pbuffer` can also open special buffer, for example terminal buffer. closes: vim/vim#16222 https://github.com/vim/vim/commit/a2a2fe841ed2efdbb1f8055f752a3a4d0988ae9d Cherry-pick Test_popup_and_previewwindow_dump() changes from patch 9.0.0625. Cherry-pick Run_noroom_for_newwindow_test() changes from patches 8.2.0432 and 9.0.0363. Co-authored-by: Yinzuo Jiang <jiangyinzuo@foxmail.com>
* vim-patch:9.1.0381: cbuffer and similar commands don't accept a range (#28571)zeertzjq2024-04-30
| | | | | | | | | | | | | Problem: cbuffer and similar quickfix and locationlist commands don't accept a range, even so it is documented they should (ilan-schemoul, after 8.1.1241) Solution: Define ex commands with ADDR_LINES instead of ADDR_OTHER fixes: vim/vim#14638 closes: vim/vim#14657 https://github.com/vim/vim/commit/652c821366691a8bd5474766581090df0c742fa1 Co-authored-by: Christian Brabandt <cb@256bit.org>
* refactor(lua): "module" => "M" #28426Justin M. Keyes2024-04-20
| | | | Most of the codebase uses the `M` convention for Lua module. Update the last remaining cases.
* vim-patch:9.1.0147: Cannot keep a buffer focused in a windowColin Kennedy2024-03-11
| | | | | | | | | | | | | | | Problem: Cannot keep a buffer focused in a window (Amit Levy) Solution: Add the 'winfixbuf' window-local option (Colin Kennedy) fixes: vim/vim#6445 closes: vim/vim#13903 https://github.com/vim/vim/commit/215703563757a4464907ead6fb9edaeb7f430bea N/A patch: vim-patch:58f1e5c0893a
* feat(ex_cmds): ranged :lua #27167luukvbaal2024-01-26
| | | | | | :{range}lua executes the specified lines in the current buffer as Lua code, regardless of its extension or 'filetype'. Close #27103
* build: enable lintlua for src/ dir #26395Justin M. Keyes2023-12-04
| | | | | | | | | | | Problem: Not all Lua code is checked by stylua. Automating code-style is an important mechanism for reducing time spent on accidental (non-essential) complexity. Solution: - Enable lintlua for `src/` directory. followup to 517f0cc634b985057da5b95cf4ad659ee456a77e
* refactor(float): rename ex_floatclose to ex_fclose (#25596)Raphael2023-10-11
|
* feat(float): add fclose commandglepnir2023-10-10
|
* vim-patch:9.0.1596: :registers command does not work in sandbox (#23866)zeertzjq2023-06-01
| | | | | | | | Problem: :registers command does not work in sandbox. Solution: Add flag to the command. (closes vim/vim#12473) https://github.com/vim/vim/commit/eb43b7f0531bd13d15580b5c262a25d6a52a0823 Co-authored-by: Julio B <julio.bacel@gmail.com>
* fix(excmd): make :def unknown rather than unimplemented (#23150)zeertzjq2023-04-17
|
* vim-patch:9.0.0370: cleaning up afterwards can make a function messyzeertzjq2023-04-16
| | | | | | | | | | | | Problem: Cleaning up afterwards can make a function messy. Solution: Add the :defer command. https://github.com/vim/vim/commit/1d84f7608f1e41dad03b8cc7925895437775f7c0 Omit EX_EXPR_ARG: Vim9 script only. Make :def throw E319 to avoid confusing behavior. Co-authored-by: Bram Moolenaar <Bram@vim.org>
* vim-patch:8.2.{0695,0725,0734,0753,0818,0819,0822} (#23075)zeertzjq2023-04-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | vim-patch:8.2.0695: Vim9: cannot define a function inside a function Problem: Vim9: cannot define a function inside a function. Solution: Initial support for :def inside :def. https://github.com/vim/vim/commit/04b12697838b232b8b17c553ccc74cf1f1bdb81c vim-patch:8.2.0725: Vim9: cannot call a function declared later in Vim9 script Problem: Vim9: cannot call a function declared later in Vim9 script. Solution: Make two passes through the script file. https://github.com/vim/vim/commit/09689a02840be40fa7bb10b1921fb5bc5b2908f1 vim-patch:8.2.0734: Vim9: leaking memory when using :finish Problem: Vim9: leaking memory when using :finish. Solution: Do not check for next line in third pass. https://github.com/vim/vim/commit/04816717dfea6e2469ff4c9d40f68b59aaf03724 vim-patch:8.2.0753: Vim9: expressions are evaluated in the discovery phase Problem: Vim9: expressions are evaluated in the discovery phase. Solution: Bail out if an expression is not a constant. Require a type for declared constants. https://github.com/vim/vim/commit/32e351179eacfc84f64cd5029e221582d400bb38 vim-patch:8.2.0818: Vim9: using a discovery phase doesn't work well Problem: Vim9: using a discovery phase doesn't work well. Solution: Remove the discovery phase, instead compile a function only when it is used. Add :defcompile to compile def functions earlier. https://github.com/vim/vim/commit/822ba24743af9ee1b5e7f656a7a61a38f3638bca vim-patch:8.2.0819: compiler warning for unused variable Problem: Compiler warning for unused variable. Solution: Remove the variable. https://github.com/vim/vim/commit/f40e51a880a95f94dbbbecc9476559506c2cc345 vim-patch:8.2.0822: Vim9: code left over from discovery phase Problem: Vim9: code left over from discovery phase. Solution: Remove the dead code. https://github.com/vim/vim/commit/2eec37926db6d31beb36f162ac00357a30c093c8 Co-authored-by: Bram Moolenaar <Bram@vim.org>
* feat(ex_cmds)!: remove :behavebfredl2023-04-13
| | | | | | | | | just use the individual options instead. set selection=exclusive set selectmode=mouse,key set mousemodel=popup set keymodel=startsel,stopsel
* feat(lua): allow `:=expr` as a shorter version of `:lua =expr`bfredl2023-03-22
| | | | | | | | | | | | | | | | existing behavior of := and :[range]= are unchanged. `|` is still allowed with this usage. However, :=p and similar are changed in a way which could be construed as a breaking change. Allowing |ex-flags| for := in the first place was a mistake as any form of := DOES NOT MOVE THE CURSOR. So it would print one line number and then print a completely different line contents after that.
* vim-patch:8.2.4617: no completion for :scriptnameszeertzjq2023-01-17
| | | | | | | | | | Problem: No completion for :scriptnames. Solution: Implement :scriptnames completion. (Yegappan Lakshmanan, closes vim/vim#10005) https://github.com/vim/vim/commit/454ce6737cadb82886f1fc0eb9e8666cc59ae42b Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
* feat!: remove hardcopyLewis Russell2023-01-03
| | | Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
* feat(secure): add `:trust` command and vim.secure.trust() (#21107)Jlll12022-11-28
| | | | | | | | | Introduce vim.secure.trust() to programmatically manage the trust database. Use this function in a new :trust ex command which can be used as a simple frontend. Resolves: https://github.com/neovim/neovim/issues/21092 Co-authored-by: Gregory Anders <greg@gpanders.com> Co-authored-by: ii14 <ii14@users.noreply.github.com>
* feat(cscope)!: removeLewis Russell2022-10-13
|
* vim-patch:9.0.0342: ":wincmd =" equalizes in two directionszeertzjq2022-09-01
| | | | | | | Problem: ":wincmd =" equalizes in two directions. Solution: Make ":vertical wincmd =" equalize vertically only and ":horizontal wincmd =" equalize horizontally only. https://github.com/vim/vim/commit/21c3a80a7fd6b7fc250ce5dc287963511f54b86f