Vimscripting in Lua
Why Lua?
Why Lua?
Pros
-
Lightweight
Capi, good for embedding into other softwares/applications
typish of lua
-
No
{…}fence, blocs useendkeyword -
Dynamically typed, outsource memory allocation to compiler
-
English like
and,or, andnot -
Function call, decleration+definition is same
-
Global variables
_G.myValue -
Loop statements,
forandwhiledo not use parenthesis(…) -
Hash datastructure is called
table, they have somebashlike 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.tabstopwhere 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')