aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/syntax.c
Commit message (Collapse)AuthorAge
* refactor(charset)!: delete 'isprint' and cleanup 'iskeyword' and friendsbfredl2026-09-22
| | | | | | | | | | | | | In the `enc=utf-8` only world, the 'isprint' option is quite obsolete. The function is only consulted for decoded U+0080 to U+00FF chars whose printability is defined by the unicode charset, just like higher codepoints. Meanwhile, invalid `\x80` to `\xFF` bytes are always unprintable. Disentangle 'iskeyword', 'isfname' and 'isident' from each other by giving them all separate bitsets. Now these can be updated individually. These updaters can back out of errors gracefully, no need for extra panic logic in option[str].c to restore partially updated chartabs.
* vim-patch:9.2.1125: missing check for invalid "syntax iskeyword" value (#42032)zeertzjq2026-09-22
| | | | | | | | | | problem: no error if "syntax iskeyword" uses an invalid value solution: Check for error and return (bfredl) closes: vim/vim#21357 https://github.com/vim/vim/commit/12c69acc0a1f1530dc0f0618c763bd9c07b7b6b3 Co-authored-by: bfredl <bjorn.linse@gmail.com>
* vim-patch:9.2.1036: syntax highlighting is slower than necessary (#41644)zeertzjq2026-09-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: While advancing the syntax highlighting, store_current_state() calls syn_stack_find_entry() about once per parsed line, and that function rescans the state-cache list from its head every time. With the list capped at 1000 entries this linear rescan dominates the cost of highlighting a large file. Solution: Keep a cached position to the entry last located in the list and resume the scan from it when it is at or before the wanted line, advancing the finger as new states are stored (Julien Voisin). The list is sorted by line number, so when the remembered entry is at or before the wanted line the answer can only follow it, never precede it; resuming from there returns the same entry as a scan from the head. The "at or before" guard keeps this correct for any lookup order: a backward or random-access lookup whose remembered entry is past the wanted line falls back to a full scan. The pointer is cleared whenever an entry is freed, the array is reallocated or the block is freed, so it cannot dangle. Parsing the syntax of a 20000-line C file is about a third faster, a 5000-line file about a quarter faster, benchmarked via something like this: ``` call synID(1, 1, 1) " warm-up let s = reltime() for l in range(1, line('$')) | call synID(l, 1, 1) | endfor call writefile([reltimefloat(reltime(s))], $T) ``` closes: vim/vim#21166 https://github.com/vim/vim/commit/f1b454912996d6417acd0d738de0eb7b60902c56 Co-authored-by: Julien Voisin <julien.voisin@dustri.org>
* vim-patch:9.2.0743: string macros silently accept a size of the wrong type ↵zeertzjq2026-06-29
| | | | | | | | | | | | | | | | | | | | | | | | | | | (#40470) Problem: Several string and memory wrapper macros cast their size argument to size_t although the wrapped function's prototype already declares that parameter size_t; such casts silence the warning a compiler would otherwise give when a value of the wrong type, such as a pointer, is passed as the size. Solution: Where the wrapped function's prototype already declares the parameter size_t, remove the cast so that a size argument of the wrong type can be reported at compile time (K.Takata, Shane Harper). From gcc 14 on, -Wint-conversion is an error by default. With gcc, passing a signed value where size_t is expected triggers -Wsign-conversion, but the check is off by default and the build already emits many such warnings. related: vim/vim#20642 closes: vim/vim#20656 https://github.com/vim/vim/commit/7f122f9effba51adc107909b8ca4d9b220c2bfaf Co-authored-by: Shane Harper <shane@shaneharper.net> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
* vim-patch:9.2.0718: :syn sync without an argument also lists syntax cluster ↵Dmytro Meleshko2026-06-25
| | | | | | | | | | | | (#40399) Problem: :syn sync without an argument also lists every defined cluster Solution: Fix control flow in syn_cmd_list() so that only the syncing items are printed when this function gets called by :syn sync. (dmitmel) closes: vim/vim#20614 https://github.com/vim/vim/commit/f2954c821ebf007503bc29cd25d01974f691432c
* vim-patch:9.2.0635: checking the syntax contains/cluster list is slow (#40230)zeertzjq2026-06-14
| | | | | | | | | | | | | | | Problem: Deciding whether a group is in a "contains"/cluster list scans the list and expands clusters on every check, which is slow for syntaxes with large lists (e.g. plugins such as netrw). Solution: Resolve each list once into a sorted, cluster-expanded set of group IDs and use a binary search; cache it per syntax block and drop the cache when syntax definitions change (Hirohito Higashi). closes: vim/vim#20490 https://github.com/vim/vim/commit/48fbae4378ab9bb6e7fcbd2480544847eac10cd7 Co-authored-by: Hirohito Higashi <h.east.727@gmail.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix(path): normalize path slashes on Windows #37729tao2026-04-24
| | | | | | | | | | | | | | | | | | | | Problem: On Windows, path separators may become inconsistent for various reasons, which makes normalization quite painful. Solution: Normalize paths to `/` at the entry boundaries and always use it internally, converting back only in rare cases where `\` is really needed (e.g. cmd.exe/bat scripts?). This is the first commit in a series of incremental steps. Note: * some funcs won't respect shellslash. e.g. `expand/fnamemodify` * some funcs still respect shellslash, but will be updated in a follow PR. e.g. `ex_pwd/f_chdir/f_getcwd` * uv's built-in funcs always return `\`. e.g. `uv.cwd/uv.exepath` Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
* build(clang-analyzer): UB pointer subtractionJustin M. Keyes2026-04-14
| | | | | | | | | | | | | Problem: clang-analyzer-security.PointerSub reports "Subtraction of two pointers that do not point into the same array is undefined behavior" in the HIKEY2SFT macro. Computing the offset of a flexible array member by subtracting pointers from a dummy static object, is technically UB. Solution: Use standard `offsetof()` instead. Co-Authored-By: Claude
* vim-patch:9.2.0285: :syn sync grouphere may go beyond end of line (#38727)zeertzjq2026-04-03
| | | | | | | | | Problem: :syn sync grouphere may go beyond end of line. Solution: Start searching for the end of region at the end of match instead of a possibly invalid position (zeertzjq). closes: vim/vim#19896 https://github.com/vim/vim/commit/b7cffc84340d6c141fb8f7dbe771c4c15dcc47d4
* fix(messages): unwanted newlines with ext_messages #37733luukvbaal2026-02-08
| | | | | | | | | | | | | | | Problem: Newlines intended to write messages below the cmdline or to mark the start of a new message on message grid are emitted through ext_messages. This results in unnecessary newlines for a UI that has decoupled its message area from the cmdline. msg_col is set directly in some places which is not transmitted to msg_show events. Various missing message kind for list commands. Trailing newlines on various list commands. Solution: Only emit such newlines without ext_messages enabled. Use msg_advance() instead of setting msg_col directly. Assign them the "list_cmd" kind. Ensure no trailing newline is printed.
* vim-patch:partial:8.1.1939: code for handling v: variables in generic eval ↵Jan Edmund Lazo2025-10-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | file (#35968) Problem: Code for handling v: variables in generic eval file. Solution: Move v: variables to evalvars.c. (Yegappan Lakshmanan, closes vim/vim#4872) https://github.com/vim/vim/commit/e5cdf153bcb348c68011b308c8988cea42d6ddeb Remove direct reference to "vimvars" for following functions: - assert_error() - get_vim_var_nr() - get_vim_var_list() - get_vim_var_dict() - get_vim_var_str() - set_cmdarg() - set_reg_var() - set_vcount() - set_vexception() - set_vthrowpoint() - set_vim_var_bool() - set_vim_var_dict() - set_vim_var_list() - set_vim_var_nr() - set_vim_var_special() - set_vim_var_string() - set_vim_var_type() Reorder functions based on v8.2.4930 for eval_one_expr_in_str() and eval_all_expr_in_str(). Co-authored-by: Bram Moolenaar <Bram@vim.org>
* refactor(build): remove INCLUDE_GENERATED_DECLARATIONS guardsbfredl2025-08-14
| | | | | | | | | These are not needed after #35129 but making uncrustify still play nice with them was a bit tricky. Unfortunately `uncrustify --update-config-with-doc` breaks strings with backslashes. This issue has been reported upstream, and in the meanwhile auto-update on every single run has been disabled.
* docs: deprecate :ownsyntaxJustin M. Keyes2025-07-10
|
* vim-patch:9.1.1077: included syntax items do not understand contains=TOP ↵zeertzjq2025-02-06
| | | | | | | | | | | | | | | | | | | | (#32343) Problem: Syntax engine interpreted contains=TOP as matching nothing inside included files, since :syn-include forces HL_CONTAINED on for every included item. After 8.2.2761, interprets contains=TOP as contains=@INCLUDED, which is also not correct since it doesn't respect exclusions, and doesn't work if there is no @INCLUDED cluster. Solution: revert patch 8.2.2761, instead track groups that have had HL_CONTAINED forced, and interpret contains=TOP and contains=CONTAINED using this. (Theodore Dubois) fixes: vim/vim#11277 closes: vim/vim#16571 https://github.com/vim/vim/commit/f50d5364d790619a3b982a3ad3658b5a10daf511 Co-authored-by: Theodore Dubois <tblodt@icloud.com>
* refactor: iwyu #31637Justin M. Keyes2024-12-23
| | | Result of `make iwyu` (after some "fixups").
* refactor(highlight): make enum of builtin highlights start with 1bfredl2024-11-13
| | | | | This makes it possible to use HLF_ values directly as highlight id:s and avoids +1 adjustments especially around messages.
* refactor(message): propagate highlight id instead of attrsLuuk van Baal2024-11-08
| | | | | | | Problem: Highlight group id is not propagated to the end of the message call stack, where ext_messages are emitted. Solution: Refactor message functions to pass along highlight group id instead of attr id.
* vim-patch:9.1.0652: too many strlen() calls in syntax.c (#29949)zeertzjq2024-08-02
| | | | | | | | | | | | Problem: too many strlen() calls in syntax.c Solution: refactor code to reduce the number or strlen() calls, get rid of un-used SYN_NAMELEN macro (John Marriott) closes: vim/vim#15368 https://github.com/vim/vim/commit/b4ea77185c7deeb6f7c8d5aa14f8c97a097e5dee Co-authored-by: John Marriott <basilisk@internode.on.net>
* revert: "refactor: use S_LEN macro" (#29319)Lewis Russell2024-06-14
| | | | | revert: "refactor: use S_LEN(s) instead of s, n (#29219)" This reverts commit c37695a5d5f2e8914fff86f3581bed70b4c85d3c.
* Merge pull request #29278 from bfredl/strcatbfredl2024-06-11
|\ | | | | refactor(memory): use builtin strcat() instead of STRCAT()
| * refactor(memory): use builtin strcat() instead of STRCAT()bfredl2024-06-11
| | | | | | | | | | | | | | | | The latter was mostly relevant with the past char_u madness. NOTE: STRCAT also functioned as a counterfeit "NOLINT" for clint apparently. But NOLINT-ing every usecase is just the same as disabling the check entirely.
* | refactor: use S_LEN(s) instead of s, n (#29219)James2024-06-11
|/
* refactor: move shared messages to errors.h #26214Justin M. Keyes2024-06-01
|
* refactor: add xmemcpyz() and use it in place of some xstrlcpy() (#28422)zeertzjq2024-04-20
| | | | | | Problem: Using xstrlcpy() when the exact length of the string to be copied is known is not ideal because it requires adding 1 to the length and an unnecessary strlen(). Solution: Add xmemcpyz() and use it in place of such xstrlcpy() calls.
* vim-patch:9.1.0172: More code can use ml_get_buf_len() instead of STRLEN()zeertzjq2024-03-14
| | | | | | | | | | | | Problem: More code can use ml_get_buf_len() instead of STRLEN(). Solution: Change more STRLEN() calls to ml_get_buf_len(). Also do not set ml_line_textlen in ml_replace_len() if "has_props" is set, because "len_arg" also includes the size of text properties in that case. (zeertzjq) closes: vim/vim#14183 https://github.com/vim/vim/commit/94b7c3233ef534acc669b3083ed1fe59cf3a090b
* refactor(IWYU): fix headersdundargoc2024-01-11
| | | | | | Remove `export` pramgas from defs headers as it causes IWYU to believe that the definitions from the defs headers comes from main header, which is not what we really want.
* refactor: remove redundant struct namesdundargoc2024-01-02
| | | | A struct can be anonymous if only its typedef is used.
* refactor: follow style guidedundargoc2023-12-30
|
* refactor(IWYU): move decor provider types to decoration_defs.h (#26692)zeertzjq2023-12-21
|
* refactor: use `bool` to represent boolean valuesdundargoc2023-12-19
|
* build: don't define FUNC_ATTR_* as empty in headers (#26317)zeertzjq2023-11-30
| | | | | | FUNC_ATTR_* should only be used in .c files with generated headers. Defining FUNC_ATTR_* as empty in headers causes misuses of them to be silently ignored. Instead don't define them by default, and only define them as empty after a .c file has included its generated header.
* refactor: move some constants out of vim_defs.h (#26298)zeertzjq2023-11-29
|
* refactor: fix headers with IWYUdundargoc2023-11-28
|
* refactor: rename types.h to types_defs.hdundargoc2023-11-27
|
* build(IWYU): fix includes for undo_defs.hdundargoc2023-11-27
|
* build(IWYU): fix includes for func_attr.hdundargoc2023-11-27
|
* refactor(encoding): remove redundant vim_isprintc_strictbfredl2023-11-26
| | | | | | | This function is identical to vim_isprintc when encoding=utf-8 is used As this is the only internal encoding nvim supports, it is now redundant ref #2905
* refactor: enable formatting for ternariesdundargoc2023-11-20
| | | | | | This requires removing the "Inner expression should be aligned" rule from clint as it prevents essentially any formatting regarding ternary operators.
* refactor: follow style guidedundargoc2023-11-19
| | | | | - reduce variable scope - prefer initialization over declaration and assignment
* refactor: follow style guidedundargoc2023-11-13
| | | | | | - reduce variable scope - prefer initialization over declaration and assignment - use bool to represent boolean values
* build: remove PVSdundargoc2023-11-12
| | | | | | | We already have an extensive suite of static analysis tools we use, which causes a fair bit of redundancy as we get duplicate warnings. PVS is also prone to give false warnings which creates a lot of work to identify and disable.
* refactor: remove redundant castsdundargoc2023-11-11
|
* refactor: the long goodbyedundargoc2023-11-05
| | | | | | long is 32 bits on windows, while it is 64 bits on other architectures. This makes the type suboptimal for a codebase meant to be cross-platform. Replace it with more appropriate integer types.
* build(lint): remove unnecessary clint.py rulesdundargoc2023-10-23
| | | | | Uncrustify is the source of truth where possible. Remove any redundant checks from clint.py.
* refactor(options): rename `empty_option` to `empty_string_option`Famiu Haque2023-10-17
|
* refactor: the long goodbyedundargoc2023-10-09
| | | | | | long is 32 bits on windows, while it is 64 bits on other architectures. This makes the type suboptimal for a codebase meant to be cross-platform. Replace it with more appropriate integer types.
* refactor: the long goodbyedundargoc2023-10-03
| | | | | | long is 32 bits on windows, while it is 64 bits on other architectures. This makes the type suboptimal for a codebase meant to be cross-platform. Replace it with more appropriate integer types.
* refactor: move cmdline completion types to cmdexpand_defs.h (#25465)zeertzjq2023-10-02
|
* refactor: reorganize option header files (#25437)zeertzjq2023-09-30
| | | | | | - Move vimoption_T to option.h - option_defs.h is for option-related types - option_vars.h corresponds to Vim's option.h - option_defs.h and option_vars.h don't include each other
* build(iwyu): add a few more _defs.h mappings (#25435)zeertzjq2023-09-30
|