diff options
author | Christian Clason <c.clason@uni-graz.at> | 2023-12-19 23:39:33 +0100 |
---|---|---|
committer | Christian Clason <c.clason@uni-graz.at> | 2023-12-20 17:44:31 +0100 |
commit | 095bd8d0f8340475319cfa13776d5ec386984859 (patch) | |
tree | c8434af0f6d0f59f88e31b926f3dd41371039c57 /src/nvim/help.c | |
parent | 99d1e7da28061c2559c523f76b58b8bb113475ff (diff) | |
download | rneovim-095bd8d0f8340475319cfa13776d5ec386984859.tar.gz rneovim-095bd8d0f8340475319cfa13776d5ec386984859.tar.bz2 rneovim-095bd8d0f8340475319cfa13776d5ec386984859.zip |
fix(buffer): do not filter help buffer
Problem: If a help buffer is opened without legacy syntax set (because
treesitter is enabled), Vim strips (some) markup. This means the syntax
engine fails to parse (some) syntax if treesitter highlighting is
disabled again.
Solution: Do not strip the help buffer of markup since (legacy or
treesitter) highlighting is always enabled in Nvim. Similarly, remove
redundant setting of filetype and give the function a more descriptive
name.
Diffstat (limited to 'src/nvim/help.c')
-rw-r--r-- | src/nvim/help.c | 41 |
1 files changed, 2 insertions, 39 deletions
diff --git a/src/nvim/help.c b/src/nvim/help.c index 28b95b2346..b1b53bc0c3 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -642,46 +642,9 @@ void prepare_help_buffer(void) set_buflisted(false); } -/// After reading a help file: May cleanup a help buffer when syntax -/// highlighting is not used. -void fix_help_buffer(void) +/// After reading a help file: if help.txt, populate *local-additions* +void get_local_additions(void) { - // Set filetype to "help". - if (strcmp(curbuf->b_p_ft, "help") != 0) { - curbuf->b_ro_locked++; - set_option_value_give_err(kOptFiletype, STATIC_CSTR_AS_OPTVAL("help"), OPT_LOCAL); - curbuf->b_ro_locked--; - } - - if (!syntax_present(curwin)) { - bool in_example = false; - for (linenr_T lnum = 1; lnum <= curbuf->b_ml.ml_line_count; lnum++) { - char *line = ml_get_buf(curbuf, lnum); - const size_t len = strlen(line); - if (in_example && len > 0 && !ascii_iswhite(line[0])) { - // End of example: non-white or '<' in first column. - if (line[0] == '<') { - // blank-out a '<' in the first column - line = ml_get_buf_mut(curbuf, lnum); - line[0] = ' '; - } - in_example = false; - } - if (!in_example && len > 0) { - if (line[len - 1] == '>' && (len == 1 || line[len - 2] == ' ')) { - // blank-out a '>' in the last column (start of example) - line = ml_get_buf_mut(curbuf, lnum); - line[len - 1] = ' '; - in_example = true; - } else if (line[len - 1] == '~') { - // blank-out a '~' at the end of line (header marker) - line = ml_get_buf_mut(curbuf, lnum); - line[len - 1] = ' '; - } - } - } - } - // In the "help.txt" and "help.abx" file, add the locally added help // files. This uses the very first line in the help file. char *const fname = path_tail(curbuf->b_fname); |