+359
-71
lines changedFilter options
+359
-71
lines changed Original file line number Diff line number Diff line change
@@ -6716,8 +6716,8 @@ A jump table for the options with a short description can be found at |Q_op|.
6716
6716
global
6717
6717
When bigger than zero, Vim will give messages about what it is doing.
6718
6718
Currently, these messages are given:
6719
-
>= 1 When the shada file is read or written.
6720
-
>= 2 When a file is ":source"'ed.
6719
+
>= 1 Lua assignments to options,keymaps etc.
6720
+
>= 2 When a file is ":source"'ed and when the shada file is read or written..
6721
6721
>= 3 UI info, terminal capabilities
6722
6722
>= 4 Shell commands.
6723
6723
>= 5 Every searched tags file and include file.
Original file line number Diff line number Diff line change
@@ -461,10 +461,11 @@ g8 Print the hex values of the bytes used in the
461
461
*:verbose-cmd*
462
462
When 'verbose' is non-zero, listing the value of a Vim option or a key map or
463
463
an abbreviation or a user-defined function or a command or a highlight group
464
-
or an autocommand will also display where it was last defined. If it was
465
-
defined manually then there will be no "Last set" message. When it was
466
-
defined while executing a function, user command or autocommand, the script in
467
-
which it was defined is reported.
464
+
or an autocommand will also display where it was last defined. If they were
465
+
defined in Lua they will only be located if 'verbose' is set. So Start
466
+
nvim with -V1 arg to see them. If it was defined manually then there
467
+
will be no "Last set" message. When it was defined while executing a function,
468
+
user command or autocommand, the script in which it was defined is reported.
468
469
469
470
*K*
470
471
[count]K Runs the program given by 'keywordprg' to lookup the
Original file line number Diff line number Diff line change
@@ -64,6 +64,7 @@ set(LUA_F_MODULE_SOURCE ${PROJECT_SOURCE_DIR}/runtime/lua/vim/F.lua)
64
64
set(LUA_META_MODULE_SOURCE ${PROJECT_SOURCE_DIR}/runtime/lua/vim/_meta.lua)
65
65
set(LUA_FILETYPE_MODULE_SOURCE ${PROJECT_SOURCE_DIR}/runtime/lua/vim/filetype.lua)
66
66
set(LUA_LOAD_PACKAGE_MODULE_SOURCE ${PROJECT_SOURCE_DIR}/runtime/lua/vim/_load_package.lua)
67
+
set(LUA_KEYMAP_MODULE_SOURCE ${PROJECT_SOURCE_DIR}/runtime/lua/vim/keymap.lua)
67
68
set(CHAR_BLOB_GENERATOR ${GENERATOR_DIR}/gen_char_blob.lua)
68
69
set(LINT_SUPPRESS_FILE ${PROJECT_BINARY_DIR}/errors.json)
69
70
set(LINT_SUPPRESS_URL_BASE "https://raw.githubusercontent.com/neovim/doc/gh-pages/reports/clint")
@@ -338,6 +339,7 @@ add_custom_command(
338
339
${LUA_META_MODULE_SOURCE} lua_meta_module
339
340
${LUA_FILETYPE_MODULE_SOURCE} lua_filetype_module
340
341
${LUA_LOAD_PACKAGE_MODULE_SOURCE} lua_load_package_module
342
+
${LUA_KEYMAP_MODULE_SOURCE} lua_keymap_module
341
343
DEPENDS
342
344
${CHAR_BLOB_GENERATOR}
343
345
${LUA_VIM_MODULE_SOURCE}
@@ -347,6 +349,7 @@ add_custom_command(
347
349
${LUA_META_MODULE_SOURCE}
348
350
${LUA_FILETYPE_MODULE_SOURCE}
349
351
${LUA_LOAD_PACKAGE_MODULE_SOURCE}
352
+
${LUA_KEYMAP_MODULE_SOURCE}
350
353
VERBATIM
351
354
)
352
355
Original file line number Diff line number Diff line change
@@ -953,23 +953,24 @@ ArrayOf(Dictionary) nvim_buf_get_keymap(uint64_t channel_id, Buffer buffer, Stri
953
953
/// @see |nvim_set_keymap()|
954
954
///
955
955
/// @param buffer Buffer handle, or 0 for current buffer
956
-
void nvim_buf_set_keymap(Buffer buffer, String mode, String lhs, String rhs, Dict(keymap) *opts,
957
-
Error *err)
956
+
void nvim_buf_set_keymap(uint64_t channel_id, Buffer buffer, String mode, String lhs, String rhs,
957
+
Dict(keymap) *opts, Error *err)
958
958
FUNC_API_SINCE(6)
959
959
{
960
-
modify_keymap(buffer, false, mode, lhs, rhs, opts, err);
960
+
modify_keymap(channel_id, buffer, false, mode, lhs, rhs, opts, err);
961
961
}
962
962
963
963
/// Unmaps a buffer-local |mapping| for the given mode.
964
964
///
965
965
/// @see |nvim_del_keymap()|
966
966
///
967
967
/// @param buffer Buffer handle, or 0 for current buffer
968
-
void nvim_buf_del_keymap(Buffer buffer, String mode, String lhs, Error *err)
968
+
void nvim_buf_del_keymap(uint64_t channel_id, Buffer buffer, String mode,
969
+
String lhs, Error *err)
969
970
FUNC_API_SINCE(6)
970
971
{
971
972
String rhs = { .data = "", .size = 0 };
972
-
modify_keymap(buffer, true, mode, lhs, rhs, NULL, err);
973
+
modify_keymap(channel_id, buffer, true, mode, lhs, rhs, NULL, err);
973
974
}
974
975
975
976
/// Gets a map of buffer-local |user-commands|.
Original file line number Diff line number Diff line change
@@ -22,11 +22,11 @@
22
22
23
23
/// @deprecated
24
24
/// @see nvim_exec
25
-
String nvim_command_output(String command, Error *err)
25
+
String nvim_command_output(uint64_t channel_id, String command, Error *err)
26
26
FUNC_API_SINCE(1)
27
27
FUNC_API_DEPRECATED_SINCE(7)
28
28
{
29
-
return nvim_exec(command, true, err);
29
+
return nvim_exec(channel_id, command, true, err);
30
30
}
31
31
32
32
/// @deprecated Use nvim_exec_lua() instead.
Original file line number Diff line number Diff line change
@@ -585,8 +585,8 @@ Array string_to_array(const String input, bool crlf)
585
585
/// @param buffer Buffer handle for a specific buffer, or 0 for the current
586
586
/// buffer, or -1 to signify global behavior ("all buffers")
587
587
/// @param is_unmap When true, removes the mapping that matches {lhs}.
588
-
void modify_keymap(Buffer buffer, bool is_unmap, String mode, String lhs, String rhs,
589
-
Dict(keymap) *opts, Error *err)
588
+
void modify_keymap(uint64_t channel_id, Buffer buffer, bool is_unmap, String mode, String lhs,
589
+
String rhs, Dict(keymap) *opts, Error *err)
590
590
{
591
591
LuaRef lua_funcref = LUA_NOREF;
592
592
bool global = (buffer == -1);
@@ -599,6 +599,8 @@ void modify_keymap(Buffer buffer, bool is_unmap, String mode, String lhs, String
599
599
return;
600
600
}
601
601
602
+
const sctx_T save_current_sctx = api_set_sctx(channel_id);
603
+
602
604
if (opts != NULL && opts->callback.type == kObjectTypeLuaRef) {
603
605
lua_funcref = opts->callback.data.luaref;
604
606
opts->callback.data.luaref = LUA_NOREF;
@@ -710,6 +712,7 @@ void modify_keymap(Buffer buffer, bool is_unmap, String mode, String lhs, String
710
712
711
713
parsed_args.rhs_lua = LUA_NOREF; // don't clear ref on success
712
714
fail_and_free:
715
+
current_sctx = save_current_sctx;
713
716
NLUA_CLEAR_REF(parsed_args.rhs_lua);
714
717
xfree(parsed_args.rhs);
715
718
xfree(parsed_args.orig_rhs);
@@ -1622,3 +1625,20 @@ int find_sid(uint64_t channel_id)
1622
1625
return SID_API_CLIENT;
1623
1626
}
1624
1627
}
1628
+
1629
+
/// Sets sctx for API calls.
1630
+
///
1631
+
/// @param channel_id api clients id. Used to determine if it's a internal
1632
+
/// call or a rpc call.
1633
+
/// @return returns previous value of current_sctx. To be used
1634
+
/// to be used for restoring sctx to previous state.
1635
+
sctx_T api_set_sctx(uint64_t channel_id)
1636
+
{
1637
+
sctx_T old_current_sctx = current_sctx;
1638
+
if (channel_id != VIML_INTERNAL_CALL) {
1639
+
current_sctx.sc_sid =
1640
+
channel_id == LUA_INTERNAL_CALL ? SID_LUA : SID_API_CLIENT;
1641
+
current_sctx.sc_lnum = 0;
1642
+
}
1643
+
return old_current_sctx;
1644
+
}
Original file line number Diff line number Diff line change
@@ -1586,6 +1586,7 @@ ArrayOf(Dictionary) nvim_get_keymap(uint64_t channel_id, String mode)
1586
1586
/// nmap <nowait> <Space><NL> <Nop>
1587
1587
/// </pre>
1588
1588
///
1589
+
/// @param channel_id
1589
1590
/// @param mode Mode short-name (map command prefix: "n", "i", "v", "x", …)
1590
1591
/// or "!" for |:map!|, or empty string for |:map|.
1591
1592
/// @param lhs Left-hand-side |{lhs}| of the mapping.
@@ -1597,21 +1598,22 @@ ArrayOf(Dictionary) nvim_get_keymap(uint64_t channel_id, String mode)
1597
1598
/// a Lua function to call when the mapping is executed.
1598
1599
/// Values are Booleans. Unknown key is an error.
1599
1600
/// @param[out] err Error details, if any.
1600
-
void nvim_set_keymap(String mode, String lhs, String rhs, Dict(keymap) *opts, Error *err)
1601
+
void nvim_set_keymap(uint64_t channel_id, String mode, String lhs, String rhs, Dict(keymap) *opts,
1602
+
Error *err)
1601
1603
FUNC_API_SINCE(6)
1602
1604
{
1603
-
modify_keymap(-1, false, mode, lhs, rhs, opts, err);
1605
+
modify_keymap(channel_id, -1, false, mode, lhs, rhs, opts, err);
1604
1606
}
1605
1607
1606
1608
/// Unmaps a global |mapping| for the given mode.
1607
1609
///
1608
1610
/// To unmap a buffer-local mapping, use |nvim_buf_del_keymap()|.
1609
1611
///
1610
1612
/// @see |nvim_set_keymap()|
1611
-
void nvim_del_keymap(String mode, String lhs, Error *err)
1613
+
void nvim_del_keymap(uint64_t channel_id, String mode, String lhs, Error *err)
1612
1614
FUNC_API_SINCE(6)
1613
1615
{
1614
-
nvim_buf_del_keymap(-1, mode, lhs, err);
1616
+
nvim_buf_del_keymap(channel_id, -1, mode, lhs, err);
1615
1617
}
1616
1618
1617
1619
/// Gets a map of global (non-buffer-local) Ex commands.
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@
37
37
/// @param[out] err Error details (Vim error), if any
38
38
/// @return Output (non-error, non-shell |:!|) if `output` is true,
39
39
/// else empty string.
40
-
String nvim_exec(String src, Boolean output, Error *err)
40
+
String nvim_exec(uint64_t channel_id, String src, Boolean output, Error *err)
41
41
FUNC_API_SINCE(7)
42
42
{
43
43
const int save_msg_silent = msg_silent;
@@ -52,11 +52,16 @@ String nvim_exec(String src, Boolean output, Error *err)
52
52
if (output) {
53
53
msg_silent++;
54
54
}
55
+
56
+
const sctx_T save_current_sctx = api_set_sctx(channel_id);
57
+
55
58
do_source_str(src.data, "nvim_exec()");
56
59
if (output) {
57
60
capture_ga = save_capture_ga;
58
61
msg_silent = save_msg_silent;
59
62
}
63
+
64
+
current_sctx = save_current_sctx;
60
65
try_end(err);
61
66
62
67
if (ERROR_SET(err)) {
Original file line number Diff line number Diff line change
@@ -1086,6 +1086,7 @@ int autocmd_register(int64_t id, event_T event, char_u *pat, int patlen, int gro
1086
1086
ac->exec = aucmd_exec_copy(aucmd);
1087
1087
ac->script_ctx = current_sctx;
1088
1088
ac->script_ctx.sc_lnum += sourcing_lnum;
1089
+
nlua_set_sctx(&ac->script_ctx);
1089
1090
ac->next = NULL;
1090
1091
ac->once = once;
1091
1092
ac->nested = nested;
Original file line number Diff line number Diff line change
@@ -256,7 +256,8 @@ static inline void ctx_save_funcs(Context *ctx, bool scriptonly)
256
256
size_t cmd_len = sizeof("func! ") + STRLEN(name);
257
257
char *cmd = xmalloc(cmd_len);
258
258
snprintf(cmd, cmd_len, "func! %s", name);
259
-
String func_body = nvim_exec(cstr_as_string(cmd), true, &err);
259
+
String func_body = nvim_exec(VIML_INTERNAL_CALL, cstr_as_string(cmd),
260
+
true, &err);
260
261
xfree(cmd);
261
262
if (!ERROR_SET(&err)) {
262
263
ADD(ctx->funcs, STRING_OBJ(func_body));
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4