mirror of
https://github.com/nanotee/nvim-lua-guide
synced 2024-11-15 06:13:00 +00:00
remove todos
`nvim_exec` now supports script scope
This commit is contained in:
parent
56697b5c65
commit
c418303b27
10
README.md
10
README.md
@ -449,8 +449,6 @@ print(vim.api.nvim_eval('v:true')) -- true
|
||||
print(vim.api.nvim_eval('v:null')) -- nil
|
||||
```
|
||||
|
||||
**TODO**: is it possible for `vim.api.nvim_eval()` to return a `funcref`?
|
||||
|
||||
#### Caveats
|
||||
|
||||
Unlike `luaeval()`, `vim.api.nvim_eval()` does not provide an implicit `_A` variable to pass data to the expression.
|
||||
@ -462,21 +460,19 @@ This function evaluates a chunk of Vimscript code. It takes in a string containi
|
||||
```lua
|
||||
local result = vim.api.nvim_exec(
|
||||
[[
|
||||
let mytext = 'hello world'
|
||||
let s:mytext = 'hello world'
|
||||
|
||||
function! MyFunction(text)
|
||||
function! s:MyFunction(text)
|
||||
echo a:text
|
||||
endfunction
|
||||
|
||||
call MyFunction(mytext)
|
||||
call s:MyFunction(s:mytext)
|
||||
]],
|
||||
true)
|
||||
|
||||
print(result) -- 'hello world'
|
||||
```
|
||||
|
||||
**TODO**: the docs say that script-scope (`s:`) is supported, but running this snippet with a script-scoped variable throws an error. Why?
|
||||
|
||||
### vim.api.nvim_command()
|
||||
|
||||
This function executes an ex command. It takes in a string containing the command to execute.
|
||||
|
@ -553,9 +553,6 @@ It is the Lua equivalent of the `luaeval()` function in Vimscript
|
||||
print(vim.api.nvim_eval('v:null')) -- nil
|
||||
<
|
||||
|
||||
*Todo is it possible for `vim.api.nvim_eval()` to return a
|
||||
`funcref`?
|
||||
|
||||
Caveats~
|
||||
|
||||
Unlike `luaeval()`, `vim.api.nvim_eval()` does not provide an implicit
|
||||
@ -571,23 +568,19 @@ store the output in a variable, for example).
|
||||
>
|
||||
local result = vim.api.nvim_exec(
|
||||
[[
|
||||
let mytext = 'hello world'
|
||||
let s:mytext = 'hello world'
|
||||
|
||||
function! MyFunction(text)
|
||||
function! s:MyFunction(text)
|
||||
echo a:text
|
||||
endfunction
|
||||
|
||||
call MyFunction(mytext)
|
||||
call s:MyFunction(s:mytext)
|
||||
]],
|
||||
true)
|
||||
|
||||
print(result) -- 'hello world'
|
||||
<
|
||||
|
||||
*Todo the docs say that script-scope (`s:`) is supported,
|
||||
but running this snippet with a script-scoped variable throws
|
||||
an error. Why?
|
||||
|
||||
vim.api.nvim_command()~
|
||||
|
||||
This function executes an ex command. It takes in a string containing
|
||||
|
Loading…
Reference in New Issue
Block a user