diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-05-31 17:49:30 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-05-31 17:49:30 +0200 |
commit | d881b516da0184052d2f9d33c3f72c5c014316bd (patch) | |
tree | faadc52b11a24da6c1ba2b147fd1f7a061198e88 /src/cindent.c | |
parent | e023e88bed3f2e0a7ea4cf10cac2de80bc9c271c (diff) | |
download | vim-git-d881b516da0184052d2f9d33c3f72c5c014316bd.tar.gz |
patch 8.2.0864: pragmas are indented all the way to the leftv8.2.0864
Problem: Pragmas are indented all the way to the left.
Solution: Add an option to indent progmas like normal code. (Max Rumpf,
closes #5468)
Diffstat (limited to 'src/cindent.c')
-rw-r--r-- | src/cindent.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/cindent.c b/src/cindent.c index 3dc7b1635..aeecc4b95 100644 --- a/src/cindent.c +++ b/src/cindent.c @@ -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: |