diff options
| author | dundargoc <gocdundar@gmail.com> | 2023-12-28 13:42:24 +0100 |
|---|---|---|
| committer | dundargoc <33953936+dundargoc@users.noreply.github.com> | 2023-12-30 12:45:38 +0100 |
| commit | c89292fcb7f2ebf06efb7c1d00c28f34c6f68fec (patch) | |
| tree | b1257a572495337ca936c47839bb08aa45528c84 /src | |
| parent | d634cd5b0bc3ac6bdf285432f74a1c10f12b6031 (diff) | |
| download | rneovim-c89292fcb7f2ebf06efb7c1d00c28f34c6f68fec.tar.gz rneovim-c89292fcb7f2ebf06efb7c1d00c28f34c6f68fec.tar.bz2 rneovim-c89292fcb7f2ebf06efb7c1d00c28f34c6f68fec.zip | |
refactor: follow style guide
Diffstat (limited to 'src')
90 files changed, 953 insertions, 1121 deletions
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index 23ec815346..06addbecb7 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -138,7 +138,7 @@ bool try_end(Error *err) api_set_error(err, kErrorTypeException, "Keyboard interrupt"); got_int = false; } else if (msg_list != NULL && *msg_list != NULL) { - int should_free; + bool should_free; char *msg = get_exception_string(*msg_list, ET_ERROR, NULL, diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 860cca582c..2bb3f0fac7 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -599,7 +599,7 @@ ArrayOf(String) nvim__get_runtime(Array pat, Boolean all, Dict(runtime) *opts, E if (opts->do_source) { for (size_t i = 0; i < res.size; i++) { String name = res.items[i].data.string; - (void)do_source(name.data, false, DOSO_NONE, NULL); + do_source(name.data, false, DOSO_NONE, NULL); } } diff --git a/src/nvim/api/vimscript.c b/src/nvim/api/vimscript.c index 6f3f0127d1..953bd80b0f 100644 --- a/src/nvim/api/vimscript.c +++ b/src/nvim/api/vimscript.c @@ -231,8 +231,8 @@ static Object _call_function(String fn, Array args, dict_T *self, Error *err) TRY_WRAP(err, { // call_func() retval is deceptive, ignore it. Instead we set `msg_list` // (see above) to capture abort-causing non-exception errors. - (void)call_func(fn.data, (int)fn.size, &rettv, (int)args.size, - vim_args, &funcexe); + call_func(fn.data, (int)fn.size, &rettv, (int)args.size, + vim_args, &funcexe); }); if (!ERROR_SET(err)) { diff --git a/src/nvim/arglist.c b/src/nvim/arglist.c index a2f3aa11ca..46725bbfc2 100644 --- a/src/nvim/arglist.c +++ b/src/nvim/arglist.c @@ -918,7 +918,7 @@ static void arg_all_close_unused_windows(arg_all_state_T *aall) if (!buf_hide(buf) && buf->b_nwindows <= 1 && bufIsChanged(buf)) { bufref_T bufref; set_bufref(&bufref, buf); - (void)autowrite(buf, false); + autowrite(buf, false); // Check if autocommands removed the window. if (!win_valid(wp) || !bufref_valid(&bufref)) { wpnext = lastwin->w_floating ? lastwin : firstwin; // Start all over... @@ -1018,10 +1018,10 @@ static void arg_all_open_windows(arg_all_state_T *aall, int count) aall->new_curwin = curwin; aall->new_curtab = curtab; } - (void)do_ecmd(0, alist_name(&AARGLIST(aall->alist)[i]), NULL, NULL, ECMD_ONE, - ((buf_hide(curwin->w_buffer) - || bufIsChanged(curwin->w_buffer)) ? ECMD_HIDE : 0) + ECMD_OLDBUF, - curwin); + do_ecmd(0, alist_name(&AARGLIST(aall->alist)[i]), NULL, NULL, ECMD_ONE, + ((buf_hide(curwin->w_buffer) + || bufIsChanged(curwin->w_buffer)) ? ECMD_HIDE : 0) + ECMD_OLDBUF, + curwin); if (tab_drop_empty_window && i == count - 1) { autocmd_no_enter++; } diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c index a7fe6667e8..5cb9a519ea 100644 --- a/src/nvim/autocmd.c +++ b/src/nvim/autocmd.c @@ -530,7 +530,7 @@ bool augroup_exists(const char *name) } /// ":augroup {name}". -void do_augroup(char *arg, int del_group) +void do_augroup(char *arg, bool del_group) { if (del_group) { if (*arg == NUL) { @@ -755,7 +755,7 @@ void do_autocmd(exarg_T *eap, char *arg_in, int forceit) char *arg = arg_in; char *envpat = NULL; char *cmd; - int need_free = false; + bool need_free = false; bool nested = false; bool once = false; int group; @@ -1222,7 +1222,7 @@ void ex_doautoall(exarg_T *eap) // Execute autocommands for the current buffer last. if (retval == OK) { - (void)do_doautocmd(arg, false, &did_aucmd); + do_doautocmd(arg, false, &did_aucmd); if (call_do_modelines && did_aucmd) { do_modelines(0); } @@ -1568,12 +1568,11 @@ bool apply_autocmds_group(event_T event, char *fname, char *fname_io, bool force bool retval = false; static int nesting = 0; char *save_cmdarg; - varnumber_T save_cmdbang; static bool filechangeshell_busy = false; proftime_T wait_time; bool did_save_redobuff = false; save_redo_T save_redo; - const bool save_KeyTyped = KeyTyped; // NOLINT + const bool save_KeyTyped = KeyTyped; // Quickly return if there are no autocommands for this event or // autocommands are blocked. @@ -1782,7 +1781,7 @@ bool apply_autocmds_group(event_T event, char *fname, char *fname_io, bool force patcmd.data = data; // set v:cmdarg (only when there is a matching pattern) - save_cmdbang = get_vim_var_nr(VV_CMDBANG); + varnumber_T save_cmdbang = get_vim_var_nr(VV_CMDBANG); if (eap != NULL) { save_cmdarg = set_cmdarg(eap, NULL); set_vim_var_nr(VV_CMDBANG, eap->forceit); @@ -1815,7 +1814,7 @@ bool apply_autocmds_group(event_T event, char *fname, char *fname_io, bool force } if (eap != NULL) { - (void)set_cmdarg(NULL, save_cmdarg); + set_cmdarg(NULL, save_cmdarg); set_vim_var_nr(VV_CMDBANG, save_cmdbang); } // delete from active_apc_list @@ -2164,7 +2163,7 @@ char *expand_get_augroup_name(expand_T *xp, int idx) } /// @param doautocmd true for :doauto*, false for :autocmd -char *set_context_in_autocmd(expand_T *xp, char *arg, int doautocmd) +char *set_context_in_autocmd(expand_T *xp, char *arg, bool doautocmd) { // check for a group name, skip it if present autocmd_include_groups = false; @@ -2478,7 +2477,7 @@ bool au_event_is_empty(event_T event) /// Scan over the events. "*" stands for all events. /// true when group name was found -static char *arg_event_skip(char *arg, int have_group) +static char *arg_event_skip(char *arg, bool have_group) { char *pat; char *p; diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 24eab644a1..41ab7ae13d 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -128,7 +128,7 @@ int get_highest_fnum(void) /// @param read_stdin read file from stdin, otherwise fifo /// @param eap for forced 'ff' and 'fenc' or NULL /// @param flags extra flags for readfile() -static int read_buffer(int read_stdin, exarg_T *eap, int flags) +static int read_buffer(bool read_stdin, exarg_T *eap, int flags) { int retval = OK; bool silent = shortmess(SHM_FILEINFO); @@ -269,9 +269,7 @@ int open_buffer(bool read_stdin, exarg_T *eap, int flags_arg) if (curbuf->b_ffname != NULL) { #ifdef UNIX int save_bin = curbuf->b_p_bin; - int perm; - - perm = os_getperm(curbuf->b_ffname); + int perm = os_getperm(curbuf->b_ffname); if (perm >= 0 && (0 || S_ISFIFO(perm) || S_ISSOCK(perm) # ifdef OPEN_CHR_FILES @@ -327,7 +325,7 @@ int open_buffer(bool read_stdin, exarg_T *eap, int flags_arg) // if first time loading this buffer, init b_chartab[] if (curbuf->b_flags & BF_NEVERLOADED) { - (void)buf_init_chartab(curbuf, false); + buf_init_chartab(curbuf, false); parse_cino(curbuf); } @@ -937,8 +935,8 @@ void goto_buffer(exarg_T *eap, int start, int dir, int count) if (swap_exists_action == SEA_NONE) { swap_exists_action = SEA_DIALOG; } - (void)do_buffer(*eap->cmd == 's' ? DOBUF_SPLIT : DOBUF_GOTO, - start, dir, count, eap->forceit); + do_buffer(*eap->cmd == 's' ? DOBUF_SPLIT : DOBUF_GOTO, + start, dir, count, eap->forceit); if (swap_exists_action == SEA_QUIT && *eap->cmd == 's') { cleanup_T cs; @@ -1046,7 +1044,7 @@ char *do_bufdel(int command, char *arg, int addr_count, int start_bnr, int end_b int bnr; // buffer number if (addr_count == 0) { - (void)do_buffer(command, DOBUF_CURRENT, FORWARD, 0, forceit); + do_buffer(command, DOBUF_CURRENT, FORWARD, 0, forceit); } else { if (addr_count == 2) { if (*arg) { // both range and argument is not allowed @@ -1125,7 +1123,7 @@ char *do_bufdel(int command, char *arg, int addr_count, int start_bnr, int end_b /// Make the current buffer empty. /// Used when it is wiped out and it's the last buffer. -static int empty_curbuf(int close_others, int forceit, int action) +static int empty_curbuf(bool close_others, int forceit, int action) { buf_T *buf = curbuf; @@ -1197,8 +1195,8 @@ int do_buffer(int action, int start, int dir, int count, int forceit) { buf_T *buf; buf_T *bp; - int unload = (action == DOBUF_UNLOAD || action == DOBUF_DEL - || action == DOBUF_WIPE); + bool unload = (action == DOBUF_UNLOAD || action == DOBUF_DEL + || action == DOBUF_WIPE); switch (start) { case DOBUF_FIRST: @@ -1374,9 +1372,7 @@ int do_buffer(int action, int start, int dir, int count, int forceit) if (au_new_curbuf.br_buf != NULL && bufref_valid(&au_new_curbuf)) { buf = au_new_curbuf.br_buf; } else if (curwin->w_jumplistlen > 0) { - int jumpidx; - - jumpidx = curwin->w_jumplistidx - 1; + int jumpidx = curwin->w_jumplistidx - 1; if (jumpidx < 0) { jumpidx = curwin->w_jumplistlen - 1; } @@ -1665,7 +1661,7 @@ void enter_buffer(buf_T *buf) need_fileinfo = true; // display file info after redraw } // check if file changed - (void)buf_check_timestamp(curbuf); + buf_check_timestamp(curbuf); curwin->w_topline = 1; curwin->w_topfill = 0; @@ -1690,12 +1686,12 @@ void enter_buffer(buf_T *buf) do_autochdir(); if (curbuf->b_kmap_state & KEYMAP_INIT) { - (void)keymap_init(); + keymap_init(); } // May need to set the spell language. Can only do this after the buffer // has been properly setup. if (!curbuf->b_help && curwin->w_p_spell && *curwin->w_s->b_p_spl != NUL) { - (void)parse_spelllang(curwin); + parse_spelllang(curwin); } curbuf->b_last_used = time(NULL); @@ -1961,7 +1957,7 @@ bool curbuf_reusable(void) /// Free the memory for the options of a buffer. /// If "free_p_ff" is true also free 'fileformat', 'buftype' and /// 'fileencoding'. -void free_buf_options(buf_T *buf, int free_p_ff) +void free_buf_options(buf_T *buf, bool free_p_ff) { if (free_p_ff) { clear_string_option(&buf->b_p_fenc); @@ -2224,7 +2220,7 @@ int buflist_findpat(const char *pattern, const char *pattern_end, bool unlisted, return -1; } char *patend = pat + strlen(pat) - 1; - int toggledollar = (patend > pat && *patend == '$'); + bool toggledollar = (patend > pat && *patend == '$'); // First try finding a listed buffer. If not found and "unlisted" // is true, try finding an unlisted buffer. @@ -2755,8 +2751,6 @@ linenr_T buflist_findlnum(buf_T *buf) void buflist_list(exarg_T *eap) { buf_T *buf = firstbuf; - int len; - int i; garray_T buflist; buf_T **buflist_data = NULL; @@ -2821,21 +2815,21 @@ void buflist_list(exarg_T *eap) } msg_putchar('\n'); - len = vim_snprintf(IObuff, IOSIZE - 20, "%3d%c%c%c%c%c \"%s\"", - buf->b_fnum, - buf->b_p_bl ? ' ' : 'u', - buf == curbuf ? '%' : (curwin->w_alt_fnum == buf->b_fnum ? '#' : ' '), - buf->b_ml.ml_mfp == NULL ? ' ' : (buf->b_nwindows == 0 ? 'h' : 'a'), - ro_char, - changed_char, - NameBuff); + int len = vim_snprintf(IObuff, IOSIZE - 20, "%3d%c%c%c%c%c \"%s\"", + buf->b_fnum, + buf->b_p_bl ? ' ' : 'u', + buf == curbuf ? '%' : (curwin->w_alt_fnum == buf->b_fnum ? '#' : ' '), + buf->b_ml.ml_mfp == NULL ? ' ' : (buf->b_nwindows == 0 ? 'h' : 'a'), + ro_char, + changed_char, + NameBuff); if (len > IOSIZE - 20) { len = IOSIZE - 20; } // put "line 999" in column 40 or after the file name - i = 40 - vim_strsize(IObuff); + int i = 40 - vim_strsize(IObuff); do { IObuff[len++] = ' '; } while (--i > 0 && len < IOSIZE - 18); @@ -3134,7 +3128,7 @@ static bool buf_same_file_id(buf_T *buf, FileID *file_id) /// Print info about the current buffer. /// /// @param fullname when non-zero print full path -void fileinfo(int fullname, int shorthelp, int dont_truncate) +void fileinfo(int fullname, int shorthelp, bool dont_truncate) { char *name; int n; @@ -3208,7 +3202,7 @@ void fileinfo(int fullname, int shorthelp, int dont_truncate) (int)curwin->w_cursor.col + 1, (int)curwin->w_virtcol + 1); } - (void)append_arg_number(curwin, buffer, IOSIZE); + append_arg_number(curwin, buffer, IOSIZE); if (dont_truncate) { // Temporarily set msg_scroll to avoid the message being truncated. @@ -3251,7 +3245,6 @@ void maketitle(void) char *title_str = NULL; char *icon_str = NULL; int maxlen = 0; - int len; char buf[IOSIZE]; if (!redrawing()) { @@ -3374,7 +3367,7 @@ void maketitle(void) #undef SPACE_FOR_ARGNR } } - int mustset = value_change(title_str, &lasttitle); + bool mustset = value_change(title_str, &lasttitle); if (p_icon |