Mercurial > vim
comparison src/cindent.c @ 28942:6cdf55afaae9 v8.2.4993
patch 8.2.4993: smart/C/lisp indenting is optional
Commit: https://github.com/vim/vim/commit/8e145b82464a21ee4fdf7948f04e2a1d505f8bfa
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat May 21 20:17:31 2022 +0100
patch 8.2.4993: smart/C/lisp indenting is optional
Problem: smart/C/lisp indenting is optional, which makes the code more
complex, while it only reduces the executable size a bit.
Solution: Graduate FEAT_CINDENT, FEAT_SMARTINDENT and FEAT_LISP.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 21 May 2022 21:30:04 +0200 |
parents | 85c2bbee17d0 |
children | fba9e366ced4 |
comparison
equal
deleted
inserted
replaced
28941:f17de8647585 | 28942:6cdf55afaae9 |
---|---|
30 #define LOOKFOR_CPP_BASECLASS 9 | 30 #define LOOKFOR_CPP_BASECLASS 9 |
31 #define LOOKFOR_ENUM_OR_INIT 10 | 31 #define LOOKFOR_ENUM_OR_INIT 10 |
32 #define LOOKFOR_JS_KEY 11 | 32 #define LOOKFOR_JS_KEY 11 |
33 #define LOOKFOR_COMMA 12 | 33 #define LOOKFOR_COMMA 12 |
34 | 34 |
35 #if defined(FEAT_CINDENT) || defined(FEAT_SMARTINDENT) | |
36 /* | 35 /* |
37 * Return TRUE if the string "line" starts with a word from 'cinwords'. | 36 * Return TRUE if the string "line" starts with a word from 'cinwords'. |
38 */ | 37 */ |
39 int | 38 int |
40 cin_is_cinword(char_u *line) | 39 cin_is_cinword(char_u *line) |
62 } | 61 } |
63 vim_free(cinw_buf); | 62 vim_free(cinw_buf); |
64 } | 63 } |
65 return retval; | 64 return retval; |
66 } | 65 } |
67 #endif | |
68 | 66 |
69 /* | 67 /* |
70 * Skip to the end of a "string" and a 'c' character. | 68 * Skip to the end of a "string" and a 'c' character. |
71 * If there is no string or character, return argument unmodified. | 69 * If there is no string or character, return argument unmodified. |
72 */ | 70 */ |
146 for (p = line; *p && (colnr_T)(p - line) < col; ++p) | 144 for (p = line; *p && (colnr_T)(p - line) < col; ++p) |
147 p = skip_string(p); | 145 p = skip_string(p); |
148 return !((colnr_T)(p - line) <= col); | 146 return !((colnr_T)(p - line) <= col); |
149 } | 147 } |
150 | 148 |
151 #if defined(FEAT_CINDENT) || defined(FEAT_SYN_HL) | |
152 | |
153 /* | 149 /* |
154 * Find the start of a comment, not knowing if we are in a comment right now. | 150 * Find the start of a comment, not knowing if we are in a comment right now. |
155 * Search starts at w_cursor.lnum and goes backwards. | 151 * Search starts at w_cursor.lnum and goes backwards. |
156 * Return NULL when not inside a comment. | 152 * Return NULL when not inside a comment. |
157 */ | 153 */ |
252 *is_raw = rs_pos->lnum; | 248 *is_raw = rs_pos->lnum; |
253 return rs_pos; | 249 return rs_pos; |
254 } | 250 } |
255 return comment_pos; | 251 return comment_pos; |
256 } | 252 } |
257 #endif // FEAT_CINDENT || FEAT_SYN_HL | 253 |
258 | |
259 #if defined(FEAT_CINDENT) || defined(PROTO) | |
260 | 254 |
261 /* | 255 /* |
262 * Return TRUE if C-indenting is on. | 256 * Return TRUE if C-indenting is on. |
263 */ | 257 */ |
264 int | 258 int |
265 cindent_on(void) | 259 cindent_on(void) |
266 { | 260 { |
267 return (!p_paste && (curbuf->b_p_cin | 261 return (!p_paste && (curbuf->b_p_cin |
268 # ifdef FEAT_EVAL | 262 #ifdef FEAT_EVAL |
269 || *curbuf->b_p_inde != NUL | 263 || *curbuf->b_p_inde != NUL |
270 # endif | 264 #endif |
271 )); | 265 )); |
272 } | 266 } |
273 | 267 |
274 // Find result cache for cpp_baseclass | 268 // Find result cache for cpp_baseclass |
275 typedef struct { | 269 typedef struct { |
4149 fixthisline(get_expr_indent); | 4143 fixthisline(get_expr_indent); |
4150 else | 4144 else |
4151 # endif | 4145 # endif |
4152 fixthisline(get_c_indent); | 4146 fixthisline(get_c_indent); |
4153 } | 4147 } |
4154 #endif | |
4155 | 4148 |
4156 #if defined(FEAT_EVAL) || defined(PROTO) | 4149 #if defined(FEAT_EVAL) || defined(PROTO) |
4157 /* | 4150 /* |
4158 * "cindent(lnum)" function | 4151 * "cindent(lnum)" function |
4159 */ | 4152 */ |
4160 void | 4153 void |
4161 f_cindent(typval_T *argvars UNUSED, typval_T *rettv) | 4154 f_cindent(typval_T *argvars UNUSED, typval_T *rettv) |
4162 { | 4155 { |
4163 # ifdef FEAT_CINDENT | |
4164 pos_T pos; | 4156 pos_T pos; |
4165 linenr_T lnum; | 4157 linenr_T lnum; |
4166 | 4158 |
4167 if (in_vim9script() && check_for_lnum_arg(argvars, 0) == FAIL) | 4159 if (in_vim9script() && check_for_lnum_arg(argvars, 0) == FAIL) |
4168 return; | 4160 return; |
4174 curwin->w_cursor.lnum = lnum; | 4166 curwin->w_cursor.lnum = lnum; |
4175 rettv->vval.v_number = get_c_indent(); | 4167 rettv->vval.v_number = get_c_indent(); |
4176 curwin->w_cursor = pos; | 4168 curwin->w_cursor = pos; |
4177 } | 4169 } |
4178 else | 4170 else |
4179 # endif | |
4180 rettv->vval.v_number = -1; | 4171 rettv->vval.v_number = -1; |
4181 } | 4172 } |
4182 #endif | 4173 #endif |