summaryrefslogtreecommitdiffstatshomepage
path: root/src/nvim/syntax.c
AgeCommit message (Collapse)AuthorFiles
2026-04-24fix(path): normalize path slashes on Windows #37729tao1
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>
2026-04-14build(clang-analyzer): UB pointer subtractionJustin M. Keyes1
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
2026-04-03vim-patch:9.2.0285: :syn sync grouphere may go beyond end of line (#38727)zeertzjq1
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
2026-02-08fix(messages): unwanted newlines with ext_messages #37733luukvbaal1
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.
2025-10-04vim-patch:partial:8.1.1939: code for handling v: variables in generic eval ↵Jan Edmund Lazo1
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>
2025-08-14refactor(build): remove INCLUDE_GENERATED_DECLARATIONS guardsbfredl1
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.
2025-07-10docs: deprecate :ownsyntaxJustin M. Keyes1
2025-02-06vim-patch:9.1.1077: included syntax items do not understand contains=TOP ↵zeertzjq1
(#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>
2024-12-23refactor: iwyu #31637Justin M. Keyes1
Result of `make iwyu` (after some "fixups").
2024-11-13refactor(highlight): make enum of builtin highlights start with 1bfredl1
This makes it possible to use HLF_ values directly as highlight id:s and avoids +1 adjustments especially around messages.
2024-11-08refactor(message): propagate highlight id instead of attrsLuuk van Baal1
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.
2024-08-02vim-patch:9.1.0652: too many strlen() calls in syntax.c (#29949)zeertzjq1
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>
2024-06-14revert: "refactor: use S_LEN macro" (#29319)Lewis Russell1
revert: "refactor: use S_LEN(s) instead of s, n (#29219)" This reverts commit c37695a5d5f2e8914fff86f3581bed70b4c85d3c.
2024-06-11Merge pull request #29278 from bfredl/strcatbfredl1
refactor(memory): use builtin strcat() instead of STRCAT()
2024-06-11refactor: use S_LEN(s) instead of s, n (#29219)James1
2024-06-11refactor(memory): use builtin strcat() instead of STRCAT()bfredl1
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.
2024-06-01refactor: move shared messages to errors.h #26214Justin M. Keyes1
2024-04-20refactor: add xmemcpyz() and use it in place of some xstrlcpy() (#28422)zeertzjq1
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.
2024-03-14vim-patch:9.1.0172: More code can use ml_get_buf_len() instead of STRLEN()zeertzjq1
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
2024-01-11refactor(IWYU): fix headersdundargoc1
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.
2024-01-02refactor: remove redundant struct namesdundargoc1
A struct can be anonymous if only its typedef is used.
2023-12-30refactor: follow style guidedundargoc1
2023-12-21refactor(IWYU): move decor provider types to decoration_defs.h (#26692)zeertzjq1
2023-12-19refactor: use `bool` to represent boolean valuesdundargoc1
2023-11-30build: don't define FUNC_ATTR_* as empty in headers (#26317)zeertzjq1
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.
2023-11-29refactor: move some constants out of vim_defs.h (#26298)zeertzjq1
2023-11-28refactor: fix headers with IWYUdundargoc1
2023-11-27refactor: rename types.h to types_defs.hdundargoc1
2023-11-27build(IWYU): fix includes for undo_defs.hdundargoc1
2023-11-27build(IWYU): fix includes for func_attr.hdundargoc1
2023-11-26refactor(encoding): remove redundant vim_isprintc_strictbfredl1
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
2023-11-20refactor: enable formatting for ternariesdundargoc1
This requires removing the "Inner expression should be aligned" rule from clint as it prevents essentially any formatting regarding ternary operators.
2023-11-19refactor: follow style guidedundargoc1
- reduce variable scope - prefer initialization over declaration and assignment
2023-11-13refactor: follow style guidedundargoc1
- reduce variable scope - prefer initialization over declaration and assignment - use bool to represent boolean values
2023-11-12build: remove PVSdundargoc1
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.
2023-11-11refactor: remove redundant castsdundargoc1
2023-11-05refactor: the long goodbyedundargoc1
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.
2023-10-23build(lint): remove unnecessary clint.py rulesdundargoc1
Uncrustify is the source of truth where possible. Remove any redundant checks from clint.py.
2023-10-17refactor(options): rename `empty_option` to `empty_string_option`Famiu Haque1
2023-10-09refactor: the long goodbyedundargoc1
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.
2023-10-03refactor: the long goodbyedundargoc1
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.
2023-10-02refactor: move cmdline completion types to cmdexpand_defs.h (#25465)zeertzjq1
2023-09-30refactor: reorganize option header files (#25437)zeertzjq1
- 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
2023-09-30build(iwyu): add a few more _defs.h mappings (#25435)zeertzjq1
2023-09-27refactor(messages): fold msg_attr into msgbfredl1
problem: there are too many different functions in message.c solution: fold some of the functions into themselves
2023-09-27refactor(messages): fold msg_outtrans_attr into msg_outtransbfredl1
problem: there are too many different functions in message.c solution: fold some of the functions into themselves
2023-08-24refactor(memline): distinguish mutating uses of ml_get_buf()bfredl1
ml_get_buf() takes a third parameters to indicate whether the caller wants to mutate the memline data in place. However the vast majority of the call sites is using this function just to specify a buffer but without any mutation. This makes it harder to grep for the places which actually perform mutation. Solution: Remove the bool param from ml_get_buf(). it now works like ml_get() except for a non-current buffer. Add a new ml_get_buf_mut() function for the mutating use-case, which can be grepped along with the other ml_replace() etc functions which can modify the memline.
2023-07-01fix(api): nvim_parse_cmd error message in pcall() #23297Alexandre Teoi1
Problem: nvim_parse_cmd() in pcall() may show an error message (side-effect): :lua pcall(vim.api.nvim_parse_cmd, vim.fn.getcmdline(), {}) E16: Invalid range Solution: Avoid emsg() in the nvim_parse_cmd() codepath. - refactor(api): add error message output parameter to get_address() - fix: null check emsg() parameter - refactor: remove emsg_off workaround from do_incsearch_highlighting() - refactor: remove emsg_off workaround from cmdpreview_may_show() - refactor: remove remaining calls to emsg() from parse_cmd_address() and get_address() - (refactor): lint set_cmd_dflall_range() - refactor: addr_error() - move output parameter to return value Fix #20339 TODO: These are the functions called by `get_address()`: ``` nvim_parse_cmd() -> parse_cmdline() -> parse_cmd_address() -> get_address() skipwhite() addr_error() qf_get_cur_idx() qf_get_cur_valid_idx() qf_get_size() qf_get_valid_size() mark_get() mark_check() assert() skip_regexp() magic_isset() > do_search() > searchit() ascii_isdigit() getdigits() getdigits_int32() compute_buffer_local_count() hasFolding() ``` From these functions, I found at least two that call emsg directly: - do_search() - seems to be simple to refactor - searchit() - will be more challenging because it may generate multiple error messages, which can't be handled by the current `errormsg` out-parameter. For example, it makes multiple calls to `vim_regexec_multi()` in a loop that possibly generate error messages, and later `searchit()` itself may generate another one: - https://github.com/neovim/neovim/blob/c194acbfc479d8e5839fa629363f93f6550d035c/src/nvim/search.c#L631-L647 - https://github.com/neovim/neovim/blob/c194acbfc479d8e5839fa629363f93f6550d035c/src/nvim/search.c#L939-L954 --------- Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
2023-05-05vim-patch:8.2.4890: inconsistent capitalization in error messageszeertzjq1
Problem: Inconsistent capitalization in error messages. Solution: Make capitalization consistent. (Doug Kearns) https://github.com/vim/vim/commit/cf030578b26460643dca4a40e7f2e3bc19c749aa Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-04-26refactor: uncrustifydundargoc1
Notable changes: replace all infinite loops to `while(true)` and remove `int` from `unsigned int`.