From f5d12889e80d3369359b8248806694cf6d21f820 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Tue, 6 Jun 2023 14:00:32 +0200 Subject: refactor: adjust headers according to the style guide (#23934) System headers should be included first to prevent naming conflicts. --- src/nvim/buffer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/buffer.h') diff --git a/src/nvim/buffer.h b/src/nvim/buffer.h index 610d9e37ec..1bca08e357 100644 --- a/src/nvim/buffer.h +++ b/src/nvim/buffer.h @@ -10,7 +10,7 @@ #include "nvim/eval/typval_defs.h" #include "nvim/ex_cmds_defs.h" #include "nvim/func_attr.h" -#include "nvim/grid_defs.h" // for StlClickRecord +#include "nvim/grid_defs.h" #include "nvim/macros.h" #include "nvim/memline.h" #include "nvim/memline_defs.h" -- cgit From cefd774fac76b91f5368833555818c80c992c3b1 Mon Sep 17 00:00:00 2001 From: bfredl Date: Thu, 24 Aug 2023 15:14:23 +0200 Subject: refactor(memline): distinguish mutating uses of ml_get_buf() ml_get_buf() takes a third parameters to indicate whether the caller wants to mutate the memline data in place. However the vast majority of the call sites is using this function just to specify a buffer but without any mutation. This makes it harder to grep for the places which actually perform mutation. Solution: Remove the bool param from ml_get_buf(). it now works like ml_get() except for a non-current buffer. Add a new ml_get_buf_mut() function for the mutating use-case, which can be grepped along with the other ml_replace() etc functions which can modify the memline. --- src/nvim/buffer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/buffer.h') diff --git a/src/nvim/buffer.h b/src/nvim/buffer.h index 1bca08e357..10d35ffc7e 100644 --- a/src/nvim/buffer.h +++ b/src/nvim/buffer.h @@ -138,7 +138,7 @@ static inline void buf_inc_changedtick(buf_T *const buf) static inline bool buf_is_empty(buf_T *buf) { return buf->b_ml.ml_line_count == 1 - && *ml_get_buf(buf, (linenr_T)1, false) == '\0'; + && *ml_get_buf(buf, (linenr_T)1) == '\0'; } #endif // NVIM_BUFFER_H -- cgit From 5f03a1eaabfc8de2b3a9c666fcd604763f41e152 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Fri, 20 Oct 2023 15:10:33 +0200 Subject: build(lint): remove unnecessary clint.py rules Uncrustify is the source of truth where possible. Remove any redundant checks from clint.py. --- src/nvim/buffer.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/buffer.h') diff --git a/src/nvim/buffer.h b/src/nvim/buffer.h index 10d35ffc7e..2351ddc61b 100644 --- a/src/nvim/buffer.h +++ b/src/nvim/buffer.h @@ -69,8 +69,8 @@ enum bfa_values { BFA_IGNORE_ABORT = 8, // do not abort for aborting() }; -EXTERN char *msg_loclist INIT(= N_("[Location List]")); -EXTERN char *msg_qflist INIT(= N_("[Quickfix List]")); +EXTERN char *msg_loclist INIT( = N_("[Location List]")); +EXTERN char *msg_qflist INIT( = N_("[Quickfix List]")); #ifdef INCLUDE_GENERATED_DECLARATIONS # include "buffer.h.generated.h" -- cgit From 8e58d37f2e15ac8540377148e55ed08a039aadb6 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Sat, 11 Nov 2023 11:20:08 +0100 Subject: refactor: remove redundant casts --- src/nvim/buffer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/buffer.h') diff --git a/src/nvim/buffer.h b/src/nvim/buffer.h index 2351ddc61b..2b0e6b2525 100644 --- a/src/nvim/buffer.h +++ b/src/nvim/buffer.h @@ -138,7 +138,7 @@ static inline void buf_inc_changedtick(buf_T *const buf) static inline bool buf_is_empty(buf_T *buf) { return buf->b_ml.ml_line_count == 1 - && *ml_get_buf(buf, (linenr_T)1) == '\0'; + && *ml_get_buf(buf, 1) == '\0'; } #endif // NVIM_BUFFER_H -- cgit From 4f8941c1a5f1ef6caa410feeb52e343db22763ce Mon Sep 17 00:00:00 2001 From: dundargoc Date: Fri, 10 Nov 2023 12:23:42 +0100 Subject: refactor: replace manual header guards with #pragma once It is less error-prone than manually defining header guards. Pretty much all compilers support it even if it's not part of the C standard. --- src/nvim/buffer.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/nvim/buffer.h') diff --git a/src/nvim/buffer.h b/src/nvim/buffer.h index 2b0e6b2525..83c9e20041 100644 --- a/src/nvim/buffer.h +++ b/src/nvim/buffer.h @@ -1,5 +1,4 @@ -#ifndef NVIM_BUFFER_H -#define NVIM_BUFFER_H +#pragma once #include #include @@ -140,5 +139,3 @@ static inline bool buf_is_empty(buf_T *buf) return buf->b_ml.ml_line_count == 1 && *ml_get_buf(buf, 1) == '\0'; } - -#endif // NVIM_BUFFER_H -- cgit From 09541d514dd18bf86f673d3784d406236fcbdad8 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 27 Nov 2023 09:51:26 +0800 Subject: build(IWYU): replace public-to-public mappings with pragmas (#26237) --- src/nvim/buffer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/buffer.h') diff --git a/src/nvim/buffer.h b/src/nvim/buffer.h index 83c9e20041..6069022178 100644 --- a/src/nvim/buffer.h +++ b/src/nvim/buffer.h @@ -4,7 +4,7 @@ #include #include -#include "nvim/buffer_defs.h" +#include "nvim/buffer_defs.h" // IWYU pragma: export #include "nvim/eval/typval.h" #include "nvim/eval/typval_defs.h" #include "nvim/ex_cmds_defs.h" -- cgit From f4aedbae4cb1f206f5b7c6142697b71dd473059b Mon Sep 17 00:00:00 2001 From: dundargoc Date: Mon, 27 Nov 2023 18:39:38 +0100 Subject: build(IWYU): fix includes for undo_defs.h --- src/nvim/buffer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/buffer.h') diff --git a/src/nvim/buffer.h b/src/nvim/buffer.h index 6069022178..00bbced55a 100644 --- a/src/nvim/buffer.h +++ b/src/nvim/buffer.h @@ -13,7 +13,7 @@ #include "nvim/macros.h" #include "nvim/memline.h" #include "nvim/memline_defs.h" -#include "nvim/pos.h" +#include "nvim/pos_defs.h" // Values for buflist_getfile() enum getf_values { -- cgit From c9f53d0e40815644bbf7c57a0792f2c793c954aa Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 28 Nov 2023 19:00:14 +0800 Subject: refactor: iwyu (#26269) --- src/nvim/buffer.h | 66 +++++++++++++++++++++++++++---------------------------- 1 file changed, 32 insertions(+), 34 deletions(-) (limited to 'src/nvim/buffer.h') diff --git a/src/nvim/buffer.h b/src/nvim/buffer.h index 00bbced55a..b93681ac14 100644 --- a/src/nvim/buffer.h +++ b/src/nvim/buffer.h @@ -9,63 +9,62 @@ #include "nvim/eval/typval_defs.h" #include "nvim/ex_cmds_defs.h" #include "nvim/func_attr.h" -#include "nvim/grid_defs.h" #include "nvim/macros.h" #include "nvim/memline.h" #include "nvim/memline_defs.h" #include "nvim/pos_defs.h" -// Values for buflist_getfile() +/// Values for buflist_getfile() enum getf_values { - GETF_SETMARK = 0x01, // set pcmark before jumping - GETF_ALT = 0x02, // jumping to alternate file (not buf num) - GETF_SWITCH = 0x04, // respect 'switchbuf' settings when jumping + GETF_SETMARK = 0x01, ///< set pcmark before jumping + GETF_ALT = 0x02, ///< jumping to alternate file (not buf num) + GETF_SWITCH = 0x04, ///< respect 'switchbuf' settings when jumping }; // Return values of getfile() enum getf_retvalues { - GETFILE_ERROR = 1, // normal error - GETFILE_NOT_WRITTEN = 2, // "not written" error - GETFILE_SAME_FILE = 0, // success, same file - GETFILE_OPEN_OTHER = (-1), // success, opened another file + GETFILE_ERROR = 1, ///< normal error + GETFILE_NOT_WRITTEN = 2, ///< "not written" error + GETFILE_SAME_FILE = 0, ///< success, same file + GETFILE_OPEN_OTHER = -1, ///< success, opened another file GETFILE_UNUSED = 8, }; -// Values for buflist_new() flags +/// Values for buflist_new() flags enum bln_values { - BLN_CURBUF = 1, // May re-use curbuf for new buffer - BLN_LISTED = 2, // Put new buffer in buffer list - BLN_DUMMY = 4, // Allocating dummy buffer - BLN_NEW = 8, // create a new buffer - BLN_NOOPT = 16, // Don't copy options to existing buffer + BLN_CURBUF = 1, ///< May re-use curbuf for new buffer + BLN_LISTED = 2, ///< Put new buffer in buffer list + BLN_DUMMY = 4, ///< Allocating dummy buffer + BLN_NEW = 8, ///< create a new buffer + BLN_NOOPT = 16, ///< Don't copy options to existing buffer // BLN_DUMMY_OK = 32, // also find an existing dummy buffer // BLN_REUSE = 64, // may re-use number from buf_reuse - BLN_NOCURWIN = 128, // buffer is not associated with curwin + BLN_NOCURWIN = 128, ///< buffer is not associated with curwin }; -// Values for action argument for do_buffer() +/// Values for action argument for do_buffer() enum dobuf_action_values { - DOBUF_GOTO = 0, // go to specified buffer - DOBUF_SPLIT = 1, // split window and go to specified buffer - DOBUF_UNLOAD = 2, // unload specified buffer(s) - DOBUF_DEL = 3, // delete specified buffer(s) from buflist - DOBUF_WIPE = 4, // delete specified buffer(s) really + DOBUF_GOTO = 0, ///< go to specified buffer + DOBUF_SPLIT = 1, ///< split window and go to specified buffer + DOBUF_UNLOAD = 2, ///< unload specified buffer(s) + DOBUF_DEL = 3, ///< delete specified buffer(s) from buflist + DOBUF_WIPE = 4, ///< delete specified buffer(s) really }; -// Values for start argument for do_buffer() +/// Values for start argument for do_buffer() enum dobuf_start_values { - DOBUF_CURRENT = 0, // "count" buffer from current buffer - DOBUF_FIRST = 1, // "count" buffer from first buffer - DOBUF_LAST = 2, // "count" buffer from last buffer - DOBUF_MOD = 3, // "count" mod. buffer from current buffer + DOBUF_CURRENT = 0, ///< "count" buffer from current buffer + DOBUF_FIRST = 1, ///< "count" buffer from first buffer + DOBUF_LAST = 2, ///< "count" buffer from last buffer + DOBUF_MOD = 3, ///< "count" mod. buffer from current buffer }; -// flags for buf_freeall() +/// flags for buf_freeall() enum bfa_values { - BFA_DEL = 1, // buffer is going to be deleted - BFA_WIPE = 2, // buffer is going to be wiped out - BFA_KEEP_UNDO = 4, // do not free undo information - BFA_IGNORE_ABORT = 8, // do not abort for aborting() + BFA_DEL = 1, ///< buffer is going to be deleted + BFA_WIPE = 2, ///< buffer is going to be wiped out + BFA_KEEP_UNDO = 4, ///< do not free undo information + BFA_IGNORE_ABORT = 8, ///< do not abort for aborting() }; EXTERN char *msg_loclist INIT( = N_("[Location List]")); @@ -136,6 +135,5 @@ static inline void buf_inc_changedtick(buf_T *const buf) static inline bool buf_is_empty(buf_T *buf) { - return buf->b_ml.ml_line_count == 1 - && *ml_get_buf(buf, 1) == '\0'; + return buf->b_ml.ml_line_count == 1 && *ml_get_buf(buf, 1) == '\0'; } -- cgit From 79b6ff28ad1204fbb4199b9092f5c578d88cb28e Mon Sep 17 00:00:00 2001 From: dundargoc Date: Tue, 28 Nov 2023 20:31:00 +0100 Subject: refactor: fix headers with IWYU --- src/nvim/buffer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/buffer.h') diff --git a/src/nvim/buffer.h b/src/nvim/buffer.h index b93681ac14..36e70d1927 100644 --- a/src/nvim/buffer.h +++ b/src/nvim/buffer.h @@ -9,7 +9,7 @@ #include "nvim/eval/typval_defs.h" #include "nvim/ex_cmds_defs.h" #include "nvim/func_attr.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/memline.h" #include "nvim/memline_defs.h" #include "nvim/pos_defs.h" -- cgit