aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/private/helpers.c
diff options
context:
space:
mode:
authorTJ DeVries <devries.timothyj@gmail.com>2021-05-28 15:45:34 -0400
committerbfredl <bjorn.linse@gmail.com>2022-02-27 22:04:55 +0100
commit991e472881bf29805982b402c1a010cde051ded3 (patch)
tree8d453a80320e49c2748f03240db8a4338384c9a1 /src/nvim/api/private/helpers.c
parent1b5767aa3480c0cdc43f7a4b78f36a14e85a182f (diff)
downloadrneovim-991e472881bf29805982b402c1a010cde051ded3.tar.gz
rneovim-991e472881bf29805982b402c1a010cde051ded3.tar.bz2
rneovim-991e472881bf29805982b402c1a010cde051ded3.zip
feat(lua): add api and lua autocmds
Diffstat (limited to 'src/nvim/api/private/helpers.c')
-rw-r--r--src/nvim/api/private/helpers.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c
index 971fa1cb0f..3d4a04f096 100644
--- a/src/nvim/api/private/helpers.c
+++ b/src/nvim/api/private/helpers.c
@@ -396,19 +396,14 @@ void set_option_to(uint64_t channel_id, void *to, int type, String name, Object
stringval = value.data.string.data;
}
- const sctx_T save_current_sctx = current_sctx;
- current_sctx.sc_sid =
- channel_id == LUA_INTERNAL_CALL ? SID_LUA : SID_API_CLIENT;
- current_sctx.sc_lnum = 0;
- current_channel_id = channel_id;
-
- const int opt_flags = (type == SREQ_WIN && !(flags & SOPT_GLOBAL))
- ? 0 : (type == SREQ_GLOBAL)
- ? OPT_GLOBAL : OPT_LOCAL;
- set_option_value_for(name.data, numval, stringval,
- opt_flags, type, to, err);
-
- current_sctx = save_current_sctx;
+ WITH_SCRIPT_CONTEXT(channel_id, {
+ const int opt_flags = (type == SREQ_WIN && !(flags & SOPT_GLOBAL))
+ ? 0 : (type == SREQ_GLOBAL)
+ ? OPT_GLOBAL : OPT_LOCAL;
+
+ set_option_value_for(name.data, numval, stringval,
+ opt_flags, type, to, err);
+ });
}
buf_T *find_buffer_by_handle(Buffer buffer, Error *err)
@@ -1614,3 +1609,16 @@ err:
NLUA_CLEAR_REF(luaref);
NLUA_CLEAR_REF(compl_luaref);
}
+
+int find_sid(uint64_t channel_id)
+{
+ switch (channel_id) {
+ case VIML_INTERNAL_CALL:
+ // TODO(autocmd): Figure out what this should be
+ // return SID_API_CLIENT;
+ case LUA_INTERNAL_CALL:
+ return SID_LUA;
+ default:
+ return SID_API_CLIENT;
+ }
+}