Neovim
Neovim is a modal text editor forked off of Vim in 2014. Being modal means that you do not simply type text on screen, but the behavior and functionality of the editor changes entirely depending on the mode.
The most common and most used mode, the "normal mode" for Neovim is to essentially turn your keyboard in to hotkeys with which you can navigate and manipulate text. Several modes exist, but two other most common ones are "insert mode" where you type in text directly as if it was a traditional text editor, and "visual mode" where you select text.
Neovim seeks to enable further community participation in its development and to make drastic changes without turning it in to something that is "not Vim". Neovim also seeks to enable embedding the editor within GUI applications.
The Neovim logo by Jason Long is licensed under the Creative Commons Attribution 3.0 Unported License.
view the rest of the comments
vim.cmd.<command>
calls a command. Sovim.cmd.write
is effectively the same as:write
, the arguments passed to the function are the same that the command would take. Check:h vim.cmd()
and for a specific command, e.g. write, you can check:h :write
.Ok, I found it. list of all vim functions are here
:h builtin-function-list
and all commands are here::h ex-cmd-index
.From using other programming languages, I'm always looking for a list of functions with a complete function signature, "gotcha" notes, when errors can occur and so on. But
vim.cmd()
does not mention anything about if the command that is being passed in will succeed or fail. Nor does it mention anything about a return value.:h :write
mentions that a write might fail, but how could that be detected if it's being called asvim.cmd.write()
?You can wrap the call in pcall, which is a lua builtin for catching errors, which would suppress the error and let you know if the command failed.
You could for example do:
There are both lua and vim functions for writing to files but I recommend to not use them in this scenario, they write to the file directly and dont trigger autocommands.
I understand your frustration with no consitent error reporting and clear api, but I guess that's the consequence of the entire history of vi and vim and trying to be backwards compatible.