Vimscripting in Lua
Why Lua?
Why Lua?
Pros
-
Lightweight
C
api, good for embedding into other softwares/applications
typish of lua
-
No
{…}
fence, blocs useend
keyword -
Dynamically typed, outsource memory allocation to compiler
-
English like
and
,or
, andnot
-
Function call, decleration+definition is same
-
Global variables
_G.myValue
-
Loop statements,
for
andwhile
do not use parenthesis(…)
-
Hash datastructure is called
table
, they have somebash
like options -
comments
--
-
Modules like nodejs
require("otherfile")
Lua count starts from 1 unlike other languages which starts with 0
|
What can you do to via with Lua
Lua Plugins can
-
Set vim options
vim.bo.tabstop
where bo means buffer specific local option -
Keybindings
vim.api.nvim_set_keymap('t','<ESC>','<C-\\><C-n>',opts)
-
Add Commands
vim.cmd('au FileType cpp ia <buffer> itn int')