refactor: iwyu (#26269)

This commit is contained in:
zeertzjq
2023-11-28 19:00:14 +08:00
committed by GitHub
parent ba564442ae
commit c9f53d0e40
11 changed files with 66 additions and 67 deletions

View File

@@ -3,9 +3,9 @@
#include <stdint.h> // IWYU pragma: keep #include <stdint.h> // IWYU pragma: keep
#include "nvim/api/private/defs.h" // IWYU pragma: keep #include "nvim/api/private/defs.h" // IWYU pragma: keep
#include "nvim/grid_defs.h" // IWYU pragma: keep
#include "nvim/highlight_defs.h" // IWYU pragma: keep #include "nvim/highlight_defs.h" // IWYU pragma: keep
#include "nvim/map.h" #include "nvim/map.h"
#include "nvim/types_defs.h" // IWYU pragma: keep
#include "nvim/ui.h" #include "nvim/ui.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS #ifdef INCLUDE_GENERATED_DECLARATIONS

View File

@@ -9,63 +9,62 @@
#include "nvim/eval/typval_defs.h" #include "nvim/eval/typval_defs.h"
#include "nvim/ex_cmds_defs.h" #include "nvim/ex_cmds_defs.h"
#include "nvim/func_attr.h" #include "nvim/func_attr.h"
#include "nvim/grid_defs.h"
#include "nvim/macros.h" #include "nvim/macros.h"
#include "nvim/memline.h" #include "nvim/memline.h"
#include "nvim/memline_defs.h" #include "nvim/memline_defs.h"
#include "nvim/pos_defs.h" #include "nvim/pos_defs.h"
// Values for buflist_getfile() /// Values for buflist_getfile()
enum getf_values { enum getf_values {
GETF_SETMARK = 0x01, // set pcmark before jumping GETF_SETMARK = 0x01, ///< set pcmark before jumping
GETF_ALT = 0x02, // jumping to alternate file (not buf num) GETF_ALT = 0x02, ///< jumping to alternate file (not buf num)
GETF_SWITCH = 0x04, // respect 'switchbuf' settings when jumping GETF_SWITCH = 0x04, ///< respect 'switchbuf' settings when jumping
}; };
// Return values of getfile() // Return values of getfile()
enum getf_retvalues { enum getf_retvalues {
GETFILE_ERROR = 1, // normal error GETFILE_ERROR = 1, ///< normal error
GETFILE_NOT_WRITTEN = 2, // "not written" error GETFILE_NOT_WRITTEN = 2, ///< "not written" error
GETFILE_SAME_FILE = 0, // success, same file GETFILE_SAME_FILE = 0, ///< success, same file
GETFILE_OPEN_OTHER = (-1), // success, opened another file GETFILE_OPEN_OTHER = -1, ///< success, opened another file
GETFILE_UNUSED = 8, GETFILE_UNUSED = 8,
}; };
// Values for buflist_new() flags /// Values for buflist_new() flags
enum bln_values { enum bln_values {
BLN_CURBUF = 1, // May re-use curbuf for new buffer BLN_CURBUF = 1, ///< May re-use curbuf for new buffer
BLN_LISTED = 2, // Put new buffer in buffer list BLN_LISTED = 2, ///< Put new buffer in buffer list
BLN_DUMMY = 4, // Allocating dummy buffer BLN_DUMMY = 4, ///< Allocating dummy buffer
BLN_NEW = 8, // create a new buffer BLN_NEW = 8, ///< create a new buffer
BLN_NOOPT = 16, // Don't copy options to existing buffer BLN_NOOPT = 16, ///< Don't copy options to existing buffer
// BLN_DUMMY_OK = 32, // also find an existing dummy buffer // BLN_DUMMY_OK = 32, // also find an existing dummy buffer
// BLN_REUSE = 64, // may re-use number from buf_reuse // 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 { enum dobuf_action_values {
DOBUF_GOTO = 0, // go to specified buffer DOBUF_GOTO = 0, ///< go to specified buffer
DOBUF_SPLIT = 1, // split window and go to specified buffer DOBUF_SPLIT = 1, ///< split window and go to specified buffer
DOBUF_UNLOAD = 2, // unload specified buffer(s) DOBUF_UNLOAD = 2, ///< unload specified buffer(s)
DOBUF_DEL = 3, // delete specified buffer(s) from buflist DOBUF_DEL = 3, ///< delete specified buffer(s) from buflist
DOBUF_WIPE = 4, // delete specified buffer(s) really 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 { enum dobuf_start_values {
DOBUF_CURRENT = 0, // "count" buffer from current buffer DOBUF_CURRENT = 0, ///< "count" buffer from current buffer
DOBUF_FIRST = 1, // "count" buffer from first buffer DOBUF_FIRST = 1, ///< "count" buffer from first buffer
DOBUF_LAST = 2, // "count" buffer from last buffer DOBUF_LAST = 2, ///< "count" buffer from last buffer
DOBUF_MOD = 3, // "count" mod. buffer from current buffer DOBUF_MOD = 3, ///< "count" mod. buffer from current buffer
}; };
// flags for buf_freeall() /// flags for buf_freeall()
enum bfa_values { enum bfa_values {
BFA_DEL = 1, // buffer is going to be deleted BFA_DEL = 1, ///< buffer is going to be deleted
BFA_WIPE = 2, // buffer is going to be wiped out BFA_WIPE = 2, ///< buffer is going to be wiped out
BFA_KEEP_UNDO = 4, // do not free undo information BFA_KEEP_UNDO = 4, ///< do not free undo information
BFA_IGNORE_ABORT = 8, // do not abort for aborting() BFA_IGNORE_ABORT = 8, ///< do not abort for aborting()
}; };
EXTERN char *msg_loclist INIT( = N_("[Location List]")); 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) static inline bool buf_is_empty(buf_T *buf)
{ {
return buf->b_ml.ml_line_count == 1 return buf->b_ml.ml_line_count == 1 && *ml_get_buf(buf, 1) == '\0';
&& *ml_get_buf(buf, 1) == '\0';
} }

View File

@@ -2,12 +2,10 @@
#include <limits.h> #include <limits.h>
#include <stddef.h> #include <stddef.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include "nvim/api/extmark.h" #include "nvim/api/extmark.h"
#include "nvim/api/private/defs.h" #include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h" #include "nvim/api/private/helpers.h"
#include "nvim/ascii.h"
#include "nvim/buffer.h" #include "nvim/buffer.h"
#include "nvim/decoration.h" #include "nvim/decoration.h"
#include "nvim/drawscreen.h" #include "nvim/drawscreen.h"
@@ -16,7 +14,6 @@
#include "nvim/grid.h" #include "nvim/grid.h"
#include "nvim/highlight.h" #include "nvim/highlight.h"
#include "nvim/highlight_group.h" #include "nvim/highlight_group.h"
#include "nvim/mbyte.h"
#include "nvim/memory.h" #include "nvim/memory.h"
#include "nvim/move.h" #include "nvim/move.h"
#include "nvim/option_vars.h" #include "nvim/option_vars.h"

View File

@@ -49,7 +49,6 @@
#include "nvim/gettext.h" #include "nvim/gettext.h"
#include "nvim/globals.h" #include "nvim/globals.h"
#include "nvim/grid.h" #include "nvim/grid.h"
#include "nvim/grid_defs.h"
#include "nvim/iconv.h" #include "nvim/iconv.h"
#include "nvim/keycodes.h" #include "nvim/keycodes.h"
#include "nvim/macros.h" #include "nvim/macros.h"

View File

@@ -7,7 +7,6 @@
#include "nvim/cmdexpand_defs.h" // IWYU pragma: keep #include "nvim/cmdexpand_defs.h" // IWYU pragma: keep
#include "nvim/eval/typval_defs.h" // IWYU pragma: keep #include "nvim/eval/typval_defs.h" // IWYU pragma: keep
#include "nvim/func_attr.h" #include "nvim/func_attr.h"
#include "nvim/grid_defs.h"
#include "nvim/mbyte_defs.h" // IWYU pragma: export #include "nvim/mbyte_defs.h" // IWYU pragma: export
#include "nvim/os/os_defs.h" #include "nvim/os/os_defs.h"
#include "nvim/types_defs.h" // IWYU pragma: keep #include "nvim/types_defs.h" // IWYU pragma: keep

View File

@@ -51,6 +51,7 @@
#include "nvim/regexp.h" #include "nvim/regexp.h"
#include "nvim/runtime.h" #include "nvim/runtime.h"
#include "nvim/strings.h" #include "nvim/strings.h"
#include "nvim/types_defs.h"
#include "nvim/ui.h" #include "nvim/ui.h"
#include "nvim/ui_compositor.h" #include "nvim/ui_compositor.h"
#include "nvim/vim.h" #include "nvim/vim.h"

View File

@@ -11,20 +11,24 @@
#include "nvim/macros.h" #include "nvim/macros.h"
#include "nvim/types_defs.h" #include "nvim/types_defs.h"
// Types of dialogs passed to do_dialog(). /// Types of dialogs passed to do_dialog().
#define VIM_GENERIC 0 enum {
#define VIM_ERROR 1 VIM_GENERIC = 0,
#define VIM_WARNING 2 VIM_ERROR = 1,
#define VIM_INFO 3 VIM_WARNING = 2,
#define VIM_QUESTION 4 VIM_INFO = 3,
#define VIM_LAST_TYPE 4 // sentinel value VIM_QUESTION = 4,
VIM_LAST_TYPE = 4, ///< sentinel value
};
// Return values for functions like vim_dialogyesno() /// Return values for functions like vim_dialogyesno()
#define VIM_YES 2 enum {
#define VIM_NO 3 VIM_YES = 2,
#define VIM_CANCEL 4 VIM_NO = 3,
#define VIM_ALL 5 VIM_CANCEL = 4,
#define VIM_DISCARDALL 6 VIM_ALL = 5,
VIM_DISCARDALL = 6,
};
typedef struct { typedef struct {
String text; String text;
@@ -50,20 +54,20 @@ extern MessageHistoryEntry *last_msg_hist;
EXTERN bool msg_ext_need_clear INIT( = false); EXTERN bool msg_ext_need_clear INIT( = false);
// allocated grid for messages. Used when display+=msgsep is set, or /// allocated grid for messages. Used when display+=msgsep is set, or
// ext_multigrid is active. See also the description at msg_scroll_flush() /// ext_multigrid is active. See also the description at msg_scroll_flush()
EXTERN ScreenGrid msg_grid INIT( = SCREEN_GRID_INIT); EXTERN ScreenGrid msg_grid INIT( = SCREEN_GRID_INIT);
EXTERN int msg_grid_pos INIT( = 0); EXTERN int msg_grid_pos INIT( = 0);
// "adjusted" message grid. This grid accepts positions relative to /// "adjusted" message grid. This grid accepts positions relative to
// default_grid. Internally it will be translated to a position on msg_grid /// default_grid. Internally it will be translated to a position on msg_grid
// relative to the start of the message area, or directly mapped to default_grid /// relative to the start of the message area, or directly mapped to default_grid
// for legacy (display-=msgsep) message scroll behavior. /// for legacy (display-=msgsep) message scroll behavior.
// // TODO(bfredl): refactor "internal" message logic, msg_row etc /// TODO(bfredl): refactor "internal" message logic, msg_row etc
// to use the correct positions already. /// to use the correct positions already.
EXTERN ScreenGrid msg_grid_adj INIT( = SCREEN_GRID_INIT); EXTERN ScreenGrid msg_grid_adj INIT( = SCREEN_GRID_INIT);
// value of msg_scrolled at latest msg_scroll_flush. /// value of msg_scrolled at latest msg_scroll_flush.
EXTERN int msg_scrolled_at_flush INIT( = 0); EXTERN int msg_scrolled_at_flush INIT( = 0);
EXTERN int msg_grid_scroll_discount INIT( = 0); EXTERN int msg_grid_scroll_discount INIT( = 0);

View File

@@ -1,8 +1,8 @@
#pragma once #pragma once
#include "nvim/api/private/defs.h" // IWYU pragma: keep #include "nvim/api/private/defs.h" // IWYU pragma: keep
#include "nvim/grid_defs.h" // IWYU pragma: keep
#include "nvim/highlight_defs.h" // IWYU pragma: keep #include "nvim/highlight_defs.h" // IWYU pragma: keep
#include "nvim/types_defs.h" // IWYU pragma: keep
#include "nvim/ui.h" #include "nvim/ui.h"
typedef struct TUIData TUIData; typedef struct TUIData TUIData;

View File

@@ -1,6 +1,6 @@
#pragma once #pragma once
#include "nvim/grid_defs.h" #include "nvim/types_defs.h"
typedef struct ucell { typedef struct ucell {
schar_T data; schar_T data;

View File

@@ -5,7 +5,7 @@
#include <stdint.h> #include <stdint.h>
#include "nvim/api/private/defs.h" #include "nvim/api/private/defs.h"
#include "nvim/grid_defs.h" #include "nvim/grid_defs.h" // IWYU pragma: keep
#include "nvim/macros.h" #include "nvim/macros.h"
#include "nvim/types_defs.h" #include "nvim/types_defs.h"

View File

@@ -3,6 +3,7 @@
#include "nvim/api/private/defs.h" // IWYU pragma: keep #include "nvim/api/private/defs.h" // IWYU pragma: keep
#include "nvim/event/defs.h" #include "nvim/event/defs.h"
#include "nvim/grid_defs.h" // IWYU pragma: keep #include "nvim/grid_defs.h" // IWYU pragma: keep
#include "nvim/types_defs.h" // IWYU pragma: keep
#include "nvim/ui.h" #include "nvim/ui.h"
#ifdef INCLUDE_GENERATED_DECLARATIONS #ifdef INCLUDE_GENERATED_DECLARATIONS