Neovim Home
src
nvim
vim.h
Go to the documentation of this file.
1
#ifndef NVIM_VIM_H
2
#define NVIM_VIM_H
3
4
#include "
nvim/pos.h
"
// for linenr_T, MAXCOL, etc...
5
#include "
nvim/types.h
"
6
7
// Some defines from the old feature.h
8
#define SESSION_FILE "Session.vim"
9
#define MAX_MSG_HIST_LEN 200
10
#define SYS_OPTWIN_FILE "$VIMRUNTIME/optwin.vim"
11
#define RUNTIME_DIRNAME "runtime"
12
13
#include "auto/config.h"
14
#define HAVE_PATHDEF
15
16
// Check if configure correctly managed to find sizeof(int). If this failed,
17
// it becomes zero. This is likely a problem of not being able to run the
18
// test program. Other items from configure may also be wrong then!
19
#if (SIZEOF_INT == 0)
20
# error Configure did not run properly.
21
#endif
22
23
#include "
nvim/os/os_defs.h
"
// bring lots of system header files
24
26
enum
{
NUMBUFLEN
= 65, };
27
28
#define MAX_TYPENR 65535
29
30
#define ROOT_UID 0
31
32
#include "
nvim/gettext.h
"
33
#include "
nvim/keycodes.h
"
34
#include "
nvim/macros.h
"
35
36
// special attribute addition: Put message in history
37
#define MSG_HIST 0x1000
38
39
// Values for State
40
//
41
// The lower bits up to 0x80 are used to distinguish normal/visual/op_pending
42
// /cmdline/insert/replace/terminal mode. This is used for mapping. If none
43
// of these bits are set, no mapping is done. See the comment above do_map().
44
// The upper bits are used to distinguish between other states and variants of
45
// the base modes.
46
47
#define MODE_NORMAL 0x01 // Normal mode, command expected
48
#define MODE_VISUAL 0x02 // Visual mode - use get_real_state()
49
#define MODE_OP_PENDING 0x04 // Normal mode, operator is pending - use
50
// get_real_state()
51
#define MODE_CMDLINE 0x08 // Editing the command line
52
#define MODE_INSERT 0x10 // Insert mode, also for Replace mode
53
#define MODE_LANGMAP 0x20 // Language mapping, can be combined with
54
// MODE_INSERT and MODE_CMDLINE
55
#define MODE_SELECT 0x40 // Select mode, use get_real_state()
56
#define MODE_TERMINAL 0x80 // Terminal mode
57
58
#define MAP_ALL_MODES 0xff // all mode bits used for mapping
59
60
#define REPLACE_FLAG 0x100 // Replace mode flag
61
#define MODE_REPLACE (REPLACE_FLAG | MODE_INSERT)
62
#define VREPLACE_FLAG 0x200 // Virtual-replace mode flag
63
#define MODE_VREPLACE (REPLACE_FLAG | VREPLACE_FLAG | MODE_INSERT)
64
#define MODE_LREPLACE (REPLACE_FLAG | MODE_LANGMAP)
65
66
#define MODE_NORMAL_BUSY (0x1000 | MODE_NORMAL) // Normal mode, busy with a command
67
#define MODE_HITRETURN (0x2000 | MODE_NORMAL) // waiting for return or command
68
#define MODE_ASKMORE 0x3000 // Asking if you want --more--
69
#define MODE_SETWSIZE 0x4000 // window size has changed
70
#define MODE_EXTERNCMD 0x5000 // executing an external command
71
#define MODE_SHOWMATCH (0x6000 | MODE_INSERT) // show matching paren
72
#define MODE_CONFIRM 0x7000 // ":confirm" prompt
73
75
typedef
enum
{
76
kDirectionNotSet
= 0,
77
FORWARD
= 1,
78
BACKWARD
= (-1),
79
FORWARD_FILE
= 3,
80
BACKWARD_FILE
= (-3),
81
}
Direction
;
82
83
// return values for functions
84
#if !(defined(OK) && (OK == 1))
85
// OK already defined to 1 in MacOS X curses, skip this
86
# define OK 1
87
#endif
88
#define FAIL 0
89
#define NOTDONE 2 // not OK or FAIL but skipped
90
91
// Type values for type().
92
#define VAR_TYPE_NUMBER 0
93
#define VAR_TYPE_STRING 1
94
#define VAR_TYPE_FUNC 2
95
#define VAR_TYPE_LIST 3
96
#define VAR_TYPE_DICT 4
97
#define VAR_TYPE_FLOAT 5
98
#define VAR_TYPE_BOOL 6
99
#define VAR_TYPE_SPECIAL 7
100
#define VAR_TYPE_BLOB 10
101
102
// values for xp_context when doing command line completion
103
104
enum
{
105
EXPAND_UNSUCCESSFUL
= -2,
106
EXPAND_OK
= -1,
107
EXPAND_NOTHING
= 0,
108
EXPAND_COMMANDS
,
109
EXPAND_FILES
,
110
EXPAND_DIRECTORIES
,
111
EXPAND_SETTINGS
,
112
EXPAND_BOOL_SETTINGS
,
113
EXPAND_TAGS
,
114
EXPAND_OLD_SETTING
,
115
EXPAND_HELP
,
116
EXPAND_BUFFERS
,
117
EXPAND_EVENTS
,
118
EXPAND_MENUS
,
119
EXPAND_SYNTAX
,
120
EXPAND_HIGHLIGHT
,
121
EXPAND_AUGROUP
,
122
EXPAND_USER_VARS
,
123
EXPAND_MAPPINGS
,
124
EXPAND_TAGS_LISTFILES
,
125
EXPAND_FUNCTIONS
,
126
EXPAND_USER_FUNC
,
127
EXPAND_EXPRESSION
,
128
EXPAND_MENUNAMES
,
129
EXPAND_USER_COMMANDS
,
130
EXPAND_USER_CMD_FLAGS
,
131
EXPAND_USER_NARGS
,
132
EXPAND_USER_COMPLETE
,
133
EXPAND_ENV_VARS
,
134
EXPAND_LANGUAGE
,
135
EXPAND_COLORS
,
136
EXPAND_COMPILER
,
137
EXPAND_USER_DEFINED
,
138
EXPAND_USER_LIST
,
139
EXPAND_USER_LUA
,
140
EXPAND_SHELLCMD
,
141
EXPAND_CSCOPE
,
142
EXPAND_SIGN
,
143
EXPAND_PROFILE
,
144
EXPAND_BEHAVE
,
145
EXPAND_FILETYPE
,
146
EXPAND_FILES_IN_PATH
,
147
EXPAND_OWNSYNTAX
,
148
EXPAND_LOCALES
,
149
EXPAND_HISTORY
,
150
EXPAND_USER
,
151
EXPAND_SYNTIME
,
152
EXPAND_USER_ADDR_TYPE
,
153
EXPAND_PACKADD
,
154
EXPAND_MESSAGES
,
155
EXPAND_MAPCLEAR
,
156
EXPAND_ARGLIST
,
157
EXPAND_DIFF_BUFFERS
,
158
EXPAND_CHECKHEALTH
,
159
EXPAND_LUA
,
160
};
161
162
// Minimal size for block 0 of a swap file.
163
// NOTE: This depends on size of struct block0! It's not done with a sizeof(),
164
// because struct block0 is defined in memline.c (Sorry).
165
// The maximal block size is arbitrary.
166
167
#define MIN_SWAP_PAGE_SIZE 1048
168
#define MAX_SWAP_PAGE_SIZE 50000
169
170
// Boolean constants
171
172
#ifndef TRUE
173
# define FALSE 0 // note: this is an int, not a long!
174
# define TRUE 1
175
#endif
176
177
#define MAYBE 2 // sometimes used for a variant on TRUE
178
179
#define STATUS_HEIGHT 1 // height of a status line under a window
180
#define QF_WINHEIGHT 10 // default height for quickfix window
181
182
// Buffer sizes
183
184
#ifndef CMDBUFFSIZE
185
# define CMDBUFFSIZE 256 // size of the command processing buffer
186
#endif
187
188
#define LSIZE 512 // max. size of a line in the tags file
189
190
#define DIALOG_MSG_SIZE 1000 // buffer size for dialog_msg()
191
192
enum
{
FOLD_TEXT_LEN
= 51, };
193
194
// Maximum length of key sequence to be mapped.
195
// Must be able to hold an Amiga resize report.
196
197
#define MAXMAPLEN 50
198
199
// Size in bytes of the hash used in the undo file.
200
#define UNDO_HASH_SIZE 32
201
202
#define CLEAR_POINTER(ptr) memset((ptr), 0, sizeof(*(ptr)))
203
204
// defines to avoid typecasts from (char_u *) to (char *) and back
205
// (vim_strchr() is now in strings.c)
206
207
#define STRLEN(s) strlen((char *)(s))
208
#ifdef HAVE_STRNLEN
209
# define STRNLEN(s, n) strnlen((char *)(s), (size_t)(n))
210
#else
211
# define STRNLEN(s, n) xstrnlen((char *)(s), (size_t)(n))
212
#endif
213
#define STRCPY(d, s) strcpy((char *)(d), (char *)(s))
214
#define STRNCPY(d, s, n) strncpy((char *)(d), (char *)(s), (size_t)(n))
215
#define STRLCPY(d, s, n) xstrlcpy((char *)(d), (char *)(s), (size_t)(n))
216
#define STRCMP(d, s) strcmp((char *)(d), (char *)(s))
217
#define STRNCMP(d, s, n) strncmp((char *)(d), (char *)(s), (size_t)(n))
218
#ifdef HAVE_STRCASECMP
219
# define STRICMP(d, s) strcasecmp((char *)(d), (char *)(s))
220
#else
221
# ifdef HAVE_STRICMP
222
# define STRICMP(d, s) stricmp((char *)(d), (char *)(s))
223
# else
224
# define STRICMP(d, s) vim_stricmp((char *)(d), (char *)(s))
225
# endif
226
#endif
227
228
// Like strcpy() but allows overlapped source and destination.
229
#define STRMOVE(d, s) memmove((d), (s), STRLEN(s) + 1)
230
231
#ifdef HAVE_STRNCASECMP
232
# define STRNICMP(d, s, n) strncasecmp((char *)(d), (char *)(s), (size_t)(n))
233
#else
234
# ifdef HAVE_STRNICMP
235
# define STRNICMP(d, s, n) strnicmp((char *)(d), (char *)(s), (size_t)(n))
236
# else
237
# define STRNICMP(d, s, n) vim_strnicmp((char *)(d), (char *)(s), (size_t)(n))
238
# endif
239
#endif
240
241
#define STRRCHR(s, c) (char_u *)strrchr((const char *)(s), (c))
242
243
#define STRCAT(d, s) strcat((char *)(d), (char *)(s))
244
#define STRNCAT(d, s, n) strncat((char *)(d), (char *)(s), (size_t)(n))
245
#define STRLCAT(d, s, n) xstrlcat((char *)(d), (char *)(s), (size_t)(n))
246
247
// Character used as separated in autoload function/variable names.
248
#define AUTOLOAD_CHAR '#'
249
250
#include "
nvim/message.h
"
251
252
// Prefer using semsg(), because perror() may send the output to the wrong
253
// destination and mess up the screen.
254
#define PERROR(msg) (void)semsg("%s: %s", (msg), strerror(errno))
255
256
#define SHOWCMD_COLS 10 // columns needed by shown command
257
258
#include "
nvim/path.h
"
259
272
#define FNAMECMP(x, y) path_fnamecmp((const char *)(x), (const char *)(y))
273
#define FNAMENCMP(x, y, n) path_fnamencmp((const char *)(x), \
274
(const char *)(y), \
275
(size_t)(n))
276
277
// Enums need a typecast to be used as array index (for Ultrix).
278
#define HL_ATTR(n) highlight_attr[(int)(n)]
279
283
#define MB_MAXBYTES 21
284
285
// This has to go after the include of proto.h, as proto/gui.pro declares
286
// functions of these names. The declarations would break if the defines had
287
// been seen at that stage. But it must be before globals.h, where error_ga
288
// is declared.
289
#ifndef WIN32
290
# define mch_errmsg(str) fprintf(stderr, "%s", (str))
291
# define mch_msg(str) printf("%s", (str))
292
#endif
293
294
#include "
nvim/buffer_defs.h
"
// buffer and windows
295
#include "
nvim/ex_cmds_defs.h
"
// Ex command defines
296
#include "
nvim/globals.h
"
// global variables and messages
297
298
// Lowest number used for window ID. Cannot have this many windows per tab.
299
#define LOWEST_WIN_ID 1000
300
301
// BSD is supposed to cover FreeBSD and similar systems.
302
#if (defined(BSD) || defined(__FreeBSD_kernel__)) \
303
&& (defined(S_ISCHR) || defined(S_IFCHR))
304
# define OPEN_CHR_FILES
305
#endif
306
307
// Replacement for nchar used by nv_replace().
308
#define REPLACE_CR_NCHAR (-1)
309
#define REPLACE_NL_NCHAR (-2)
310
311
#endif // NVIM_VIM_H
EXPAND_BOOL_SETTINGS
@ EXPAND_BOOL_SETTINGS
Definition:
vim.h:112
path.h
EXPAND_SETTINGS
@ EXPAND_SETTINGS
Definition:
vim.h:111
EXPAND_LUA
@ EXPAND_LUA
Definition:
vim.h:159
keycodes.h
EXPAND_OLD_SETTING
@ EXPAND_OLD_SETTING
Definition:
vim.h:114
EXPAND_MENUNAMES
@ EXPAND_MENUNAMES
Definition:
vim.h:128
EXPAND_USER_VARS
@ EXPAND_USER_VARS
Definition:
vim.h:122
EXPAND_USER_LIST
@ EXPAND_USER_LIST
Definition:
vim.h:138
EXPAND_PACKADD
@ EXPAND_PACKADD
Definition:
vim.h:153
EXPAND_FILES_IN_PATH
@ EXPAND_FILES_IN_PATH
Definition:
vim.h:146
EXPAND_USER_FUNC
@ EXPAND_USER_FUNC
Definition:
vim.h:126
FOLD_TEXT_LEN
@ FOLD_TEXT_LEN
Definition:
vim.h:192
BACKWARD
@ BACKWARD
Definition:
vim.h:78
types.h
EXPAND_USER_ADDR_TYPE
@ EXPAND_USER_ADDR_TYPE
Definition:
vim.h:152
EXPAND_HISTORY
@ EXPAND_HISTORY
Definition:
vim.h:149
EXPAND_MENUS
@ EXPAND_MENUS
Definition:
vim.h:118
EXPAND_COMMANDS
@ EXPAND_COMMANDS
Definition:
vim.h:108
Direction
Direction
Directions.
Definition:
vim.h:75
macros.h
EXPAND_CHECKHEALTH
@ EXPAND_CHECKHEALTH
Definition:
vim.h:158
EXPAND_BEHAVE
@ EXPAND_BEHAVE
Definition:
vim.h:144
EXPAND_MAPCLEAR
@ EXPAND_MAPCLEAR
Definition:
vim.h:155
globals.h
EXPAND_COMPILER
@ EXPAND_COMPILER
Definition:
vim.h:136
EXPAND_MAPPINGS
@ EXPAND_MAPPINGS
Definition:
vim.h:123
message.h
EXPAND_USER_DEFINED
@ EXPAND_USER_DEFINED
Definition:
vim.h:137
EXPAND_SYNTAX
@ EXPAND_SYNTAX
Definition:
vim.h:119
EXPAND_DIRECTORIES
@ EXPAND_DIRECTORIES
Definition:
vim.h:110
EXPAND_COLORS
@ EXPAND_COLORS
Definition:
vim.h:135
EXPAND_USER
@ EXPAND_USER
Definition:
vim.h:150
EXPAND_USER_NARGS
@ EXPAND_USER_NARGS
Definition:
vim.h:131
EXPAND_TAGS_LISTFILES
@ EXPAND_TAGS_LISTFILES
Definition:
vim.h:124
gettext.h
EXPAND_HELP
@ EXPAND_HELP
Definition:
vim.h:115
NUMBUFLEN
@ NUMBUFLEN
Definition:
vim.h:26
FORWARD
@ FORWARD
Definition:
vim.h:77
EXPAND_PROFILE
@ EXPAND_PROFILE
Definition:
vim.h:143
EXPAND_EVENTS
@ EXPAND_EVENTS
Definition:
vim.h:117
EXPAND_USER_COMPLETE
@ EXPAND_USER_COMPLETE
Definition:
vim.h:132
EXPAND_SIGN
@ EXPAND_SIGN
Definition:
vim.h:142
EXPAND_BUFFERS
@ EXPAND_BUFFERS
Definition:
vim.h:116
kDirectionNotSet
@ kDirectionNotSet
Definition:
vim.h:76
EXPAND_NOTHING
@ EXPAND_NOTHING
Definition:
vim.h:107
BACKWARD_FILE
@ BACKWARD_FILE
Definition:
vim.h:80
EXPAND_LOCALES
@ EXPAND_LOCALES
Definition:
vim.h:148
EXPAND_UNSUCCESSFUL
@ EXPAND_UNSUCCESSFUL
Definition:
vim.h:105
EXPAND_EXPRESSION
@ EXPAND_EXPRESSION
Definition:
vim.h:127
EXPAND_FILES
@ EXPAND_FILES
Definition:
vim.h:109
EXPAND_CSCOPE
@ EXPAND_CSCOPE
Definition:
vim.h:141
EXPAND_HIGHLIGHT
@ EXPAND_HIGHLIGHT
Definition:
vim.h:120
os_defs.h
EXPAND_SHELLCMD
@ EXPAND_SHELLCMD
Definition:
vim.h:140
FORWARD_FILE
@ FORWARD_FILE
Definition:
vim.h:79
ex_cmds_defs.h
EXPAND_OK
@ EXPAND_OK
Definition:
vim.h:106
EXPAND_FUNCTIONS
@ EXPAND_FUNCTIONS
Definition:
vim.h:125
buffer_defs.h
EXPAND_OWNSYNTAX
@ EXPAND_OWNSYNTAX
Definition:
vim.h:147
EXPAND_FILETYPE
@ EXPAND_FILETYPE
Definition:
vim.h:145
EXPAND_LANGUAGE
@ EXPAND_LANGUAGE
Definition:
vim.h:134
EXPAND_SYNTIME
@ EXPAND_SYNTIME
Definition:
vim.h:151
EXPAND_MESSAGES
@ EXPAND_MESSAGES
Definition:
vim.h:154
EXPAND_USER_CMD_FLAGS
@ EXPAND_USER_CMD_FLAGS
Definition:
vim.h:130
EXPAND_ENV_VARS
@ EXPAND_ENV_VARS
Definition:
vim.h:133
EXPAND_USER_COMMANDS
@ EXPAND_USER_COMMANDS
Definition:
vim.h:129
EXPAND_TAGS
@ EXPAND_TAGS
Definition:
vim.h:113
EXPAND_DIFF_BUFFERS
@ EXPAND_DIFF_BUFFERS
Definition:
vim.h:157
EXPAND_USER_LUA
@ EXPAND_USER_LUA
Definition:
vim.h:139
EXPAND_ARGLIST
@ EXPAND_ARGLIST
Definition:
vim.h:156
EXPAND_AUGROUP
@ EXPAND_AUGROUP
Definition:
vim.h:121
pos.h