diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-12-25 10:21:13 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-25 10:21:13 +0800 |
commit | 2877672d70e76f71ae1190090b8aea7044d458be (patch) | |
tree | c078af69d7a394a8e83f2316cf707548d70368f4 /src | |
parent | 2ff2785c396e66c285fecf5b151d8f8863f9d4e6 (diff) | |
download | rneovim-2877672d70e76f71ae1190090b8aea7044d458be.tar.gz rneovim-2877672d70e76f71ae1190090b8aea7044d458be.tar.bz2 rneovim-2877672d70e76f71ae1190090b8aea7044d458be.zip |
feat(health): make :checkhealth support more split modifiers (#26731)
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/eval.c | 33 | ||||
-rw-r--r-- | src/nvim/ex_docmd.c | 44 |
2 files changed, 40 insertions, 37 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index a1ac1de1df..540c10e494 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -8810,39 +8810,6 @@ void eval_fmt_source_name_line(char *buf, size_t bufsize) } } -/// ":checkhealth [plugins]" -void ex_checkhealth(exarg_T *eap) -{ - Error err = ERROR_INIT; - MAXSIZE_TEMP_ARRAY(args, 2); - if (cmdmod.cmod_split & WSP_VERT) { - ADD_C(args, CSTR_AS_OBJ("vertical")); - } else if (cmdmod.cmod_split & WSP_HOR) { - ADD_C(args, CSTR_AS_OBJ("horizontal")); - } else { - ADD_C(args, CSTR_AS_OBJ("tab")); - } - ADD_C(args, CSTR_AS_OBJ(eap->arg)); - NLUA_EXEC_STATIC("return vim.health._check(...)", args, &err); - if (!ERROR_SET(&err)) { - return; - } - - const char *vimruntime_env = os_getenv("VIMRUNTIME"); - if (vimruntime_env == NULL) { - emsg(_("E5009: $VIMRUNTIME is empty or unset")); - } else { - bool rtp_ok = NULL != strstr(p_rtp, vimruntime_env); - if (rtp_ok) { - semsg(_("E5009: Invalid $VIMRUNTIME: %s"), vimruntime_env); - } else { - emsg(_("E5009: Invalid 'runtimepath'")); - } - } - semsg_multiline(err.msg); - api_clear_error(&err); -} - void invoke_prompt_callback(void) { typval_T rettv; diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 70c8dc9019..964ddca887 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -7386,6 +7386,44 @@ void set_pressedreturn(bool val) ex_pressedreturn = val; } +/// ":checkhealth [plugins]" +static void ex_checkhealth(exarg_T *eap) +{ + Error err = ERROR_INIT; + MAXSIZE_TEMP_ARRAY(args, 2); + + char mods[1024]; + size_t mods_len = 0; + mods[0] = NUL; + + if (cmdmod.cmod_tab > 0 || cmdmod.cmod_split != 0) { + bool multi_mods = false; + mods_len = add_win_cmd_modifiers(mods, &cmdmod, &multi_mods); + assert(mods_len < sizeof(mods)); + } + ADD_C(args, STRING_OBJ(((String){ .data = mods, .size = mods_len }))); + ADD_C(args, CSTR_AS_OBJ(eap->arg)); + + NLUA_EXEC_STATIC("return vim.health._check(...)", args, &err); + if (!ERROR_SET(&err)) { + return; + } + + const char *vimruntime_env = os_getenv("VIMRUNTIME"); + if (vimruntime_env == NULL) { + emsg(_("E5009: $VIMRUNTIME is empty or unset")); + } else { + bool rtp_ok = NULL != strstr(p_rtp, vimruntime_env); + if (rtp_ok) { + semsg(_("E5009: Invalid $VIMRUNTIME: %s"), vimruntime_env); + } else { + emsg(_("E5009: Invalid 'runtimepath'")); + } + } + semsg_multiline(err.msg); + api_clear_error(&err); +} + static void ex_terminal(exarg_T *eap) { char ex_cmd[1024]; @@ -7393,10 +7431,8 @@ static void ex_terminal(exarg_T *eap) if (cmdmod.cmod_tab > 0 || cmdmod.cmod_split != 0) { bool multi_mods = false; - - // ex_cmd must be a null terminated string before passing to add_win_cmd_modifiers - ex_cmd[0] = '\0'; - + // ex_cmd must be a null-terminated string before passing to add_win_cmd_modifiers + ex_cmd[0] = NUL; len = add_win_cmd_modifiers(ex_cmd, &cmdmod, &multi_mods); assert(len < sizeof(ex_cmd)); int result = snprintf(ex_cmd + len, sizeof(ex_cmd) - len, " new"); |