mirror of
https://github.com/jbranchaud/til
synced 2026-01-04 23:58:01 +00:00
Add Run A Lua Statement From The Command Prompt as a Neovim TIL
This commit is contained in:
25
neovim/run-a-lua-statement-from-the-command-prompt.md
Normal file
25
neovim/run-a-lua-statement-from-the-command-prompt.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# Run A Lua Statement From The Command Prompt
|
||||
|
||||
The `:lua` command is provided by Neovim as a way to execute a Lua _chunk_.
|
||||
|
||||
I can use it to, for instance, execute a print statement.
|
||||
|
||||
```
|
||||
:lua print('Hello, World!')
|
||||
```
|
||||
|
||||
I could print out something more interesting like the full path of the current
|
||||
file using `vim.fn.expand` with `%`.
|
||||
|
||||
```
|
||||
:lua print(vim.fn.expand('%'))
|
||||
```
|
||||
|
||||
Or as the helpfiles point out, I can see the value of some expression by
|
||||
including a preceeding `=`.
|
||||
|
||||
```
|
||||
:lua =jit.version
|
||||
```
|
||||
|
||||
See `:h :lua` for more details.
|
||||
Reference in New Issue
Block a user