0
0
mirror of https://github.com/vim/vim.git synced 2025-09-26 04:04:07 -04:00

patch 8.2.0864: pragmas are indented all the way to the left

Problem:    Pragmas are indented all the way to the left.
Solution:   Add an option to indent progmas like normal code. (Max Rumpf,
            closes #5468)
This commit is contained in:
Bram Moolenaar
2020-05-31 17:49:30 +02:00
parent e023e88bed
commit d881b516da
5 changed files with 58 additions and 4 deletions

View File

@@ -1845,6 +1845,9 @@ parse_cino(buf_T *buf)
// Handle C++ extern "C" or "C++"
buf->b_ind_cpp_extern_c = 0;
// Handle C #pragma directives
buf->b_ind_pragma = 0;
for (p = buf->b_p_cino; *p; )
{
l = p++;
@@ -1920,6 +1923,7 @@ parse_cino(buf_T *buf)
case 'N': buf->b_ind_cpp_namespace = n; break;
case 'k': buf->b_ind_if_for_while = n; break;
case 'E': buf->b_ind_cpp_extern_c = n; break;
case 'P': buf->b_ind_pragma = n; break;
}
if (*p == ',')
++p;
@@ -2116,11 +2120,16 @@ get_c_indent(void)
goto laterend;
}
// #defines and so on always go at the left when included in 'cinkeys'.
// #defines and so on go at the left when included in 'cinkeys',
// exluding pragmas when customized in 'cinoptions'
if (*theline == '#' && (*linecopy == '#' || in_cinkeys('#', ' ', TRUE)))
{
amount = curbuf->b_ind_hash_comment;
goto theend;
char_u *directive = skipwhite(theline + 1);
if (curbuf->b_ind_pragma == 0 || STRNCMP(directive, "pragma", 6) != 0)
{
amount = curbuf->b_ind_hash_comment;
goto theend;
}
}
// Is it a non-case label? Then that goes at the left margin too unless: