mirror of
https://github.com/neovim/neovim.git
synced 2026-05-05 13:35:02 +00:00
feat(:source, nvim_exec): support script-local variables
Based on #13143 (and #11507) with changes: - Omit script_type_E. Use sn_name == NULL to determine anon items. - Keep SID_STR. Used by anon :source for .lua files (no item). - Show SID in get_scriptname output (:verbose set). - Factor item creation into new_script_item. - Leave sc_seq = 0 (anon scripts don't re-use the same item when re-sourced). - Add tests for anon :source. Co-authored-by: Vikram Pal <vikrampal659@gmail.com> Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
This commit is contained in:
@@ -25,11 +25,14 @@ describe(':source', function()
|
||||
let b = #{
|
||||
\ k: "v"
|
||||
"\ (o_o)
|
||||
\ }]])
|
||||
\ }
|
||||
let s:s = 0zbeef.cafe
|
||||
let c = s:s]])
|
||||
|
||||
command('source')
|
||||
eq('2', meths.exec('echo a', true))
|
||||
eq("{'k': 'v'}", meths.exec('echo b', true))
|
||||
eq("0zBEEFCAFE", meths.exec('echo c', true))
|
||||
|
||||
exec('set cpoptions+=C')
|
||||
eq('Vim(let):E15: Invalid expression: #{', exc_exec('source'))
|
||||
@@ -43,7 +46,11 @@ describe(':source', function()
|
||||
let b = #{
|
||||
"\ (>_<)
|
||||
\ K: "V"
|
||||
\ }]])
|
||||
\ }
|
||||
function! s:C() abort
|
||||
return expand("<SID>") .. "C()"
|
||||
endfunction
|
||||
let D = {-> s:C()}]])
|
||||
|
||||
-- Source the 2nd line only
|
||||
feed('ggjV')
|
||||
@@ -55,6 +62,11 @@ describe(':source', function()
|
||||
feed_command(':source')
|
||||
eq('4', meths.exec('echo a', true))
|
||||
eq("{'K': 'V'}", meths.exec('echo b', true))
|
||||
eq("<SNR>3_C()", meths.exec('echo D()', true))
|
||||
|
||||
-- Source last line only
|
||||
feed_command(':$source')
|
||||
eq('Vim(echo):E117: Unknown function: s:C', exc_exec('echo D()'))
|
||||
|
||||
exec('set cpoptions+=C')
|
||||
eq('Vim(let):E15: Invalid expression: #{', exc_exec("'<,'>source"))
|
||||
|
||||
Reference in New Issue
Block a user