aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/option.c
Commit message (Collapse)AuthorAge
* Merge remote-tracking branch 'upstream/master' into mix_20240309HEADrahmJosh Rahm2025-02-05
|\
| * vim-patch:9.0.1391: "clear" macros are not always used (#32312)zeertzjq2025-02-03
| | | | | | | | | | | | | | | | | | Problem: "clear" macros are not always used. Solution: Use ALLOC_ONE, VIM_CLEAR, CLEAR_POINTER and CLEAR_FIELD in more places. (Yegappan Lakshmanan, closes vim/vim#12104) https://github.com/vim/vim/commit/960dcbd098c761dd623bec9492d5391ff6e8dceb Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
| * fix(coverity/530826): validate_opt_idx unchecked negative idx (#32081)Devon Gardner2025-01-19
| | | | | | | | | | | | | | Problem: opt_idx possible negative value used as index Solution: check opt_idx not less than zero (kOptInvalid)
| * refactor(options): generic expand and did_set callbacks (#32011)Lewis Russell2025-01-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * refactor(options): generic expand and did_set callbacks Problem: Many options have similar callbacks to check the values are valid. Solution: Generalize these callbacks into a single function that reads the option table. * refactor: gen_options.lua refactor: gen_options.lua - inline get_cond * refactor(options): use a simpler format for the common default
| * refactor(options): remove code for multitype optionsFamiu Haque2025-01-14
| | | | | | | | | | | | Problem: It was decided on Matrix chat that multitype options won't be necessary for Neovim options, and that options should only have a single canonical type. Therefore the code for supporting multitype options is unnecessary. Solution: Remove the additional code that's used to provide multitype option support.
| * Revert "refactor(options): set option value for non-current context ↵zeertzjq2025-01-09
| | | | | | | | | | directly" (#31924) Reverts #31112
| * Merge pull request #31112 from famiu/refactor/options/set_option_forLewis Russell2025-01-08
| |\ | | | | | | refactor(options): set option value for non-current context directly
| | * refactor(options): set option value for non-current context directlyFamiu Haque2024-12-26
| | | | | | | | | | | | | | | | | | Problem: Currently, we use `switch_option_context` to temporarily switch the current option context before setting an option for a different buffer / window. This is not ideal because we already support getting and setting option values for non-current contexts in the underlying implementation. Solution: Set option value for non-current context by passing the context directly to the lower level functions. Also introduce a new `OptCtx` struct to store option context information, this will scale much better if we add more option scopes and other context information in the future.
| * | vim-patch:9.1.0993: New 'cmdheight' behavior may be surprising #31892luukvbaal2025-01-06
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Although patch 9.1.0990 fixed a real problem/inconsistency, it also introduced new behavior that may break BWC and/or be unexpected. Before 9.1.0990, window commands could make the topframe smaller (without changing 'cmdheight'; quirk that is now fixed), but did not allow extending the topframe beyond the 'cmdheight' set by the user. After 9.1.0990, the user can reduce the 'cmdheight' below the value they set explicitly, through window commands, which may lead to confusion. (aftere v9.1.0990) Solution: Store the value explicitly set by the user and clamp the 'cmdheight' when resizing the topframe. This also applies to dragging laststatus, which in contrast to window commands _did_ allow reducing the 'cmdheight' to values below the one set by the user. So with this patch there is still new behavior, but I think in a way that is less surprising. While at it, also fix a Coverity warning, introduced in v9.1.0990 (Luuk van Baal) https://github.com/vim/vim/commit/c97e8695353565d6b20adffa48aad47f6e09967f
| * | vim-patch:9.1.0990: Inconsistent behavior when changing cmdheight (#31830)luukvbaal2025-01-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Inconsistent behavior when changing cmdheight by resizing the topframe through wincmds and dragging laststatus. Changing cmdheight by resizing the topframe does not trigger OptionSet. Solution: Consolidate logic for changing the cmdheight, set the option value to handle side-effects (Luuk van Baal) https://github.com/vim/vim/commit/e15cbc1af47e9dea90448c714eb4908e5d4302fc vim-patch:9.0.0187: command line height changes when maximizing window height Problem: Command line height changes when maximizing window height. Solution: Do not change the command line height. (closes vim/vim#10885) https://github.com/vim/vim/commit/96bde99bf890acd9952863a02c1d15edca2000e1
| * | refactor(options): use `const` in more places (#31791)Famiu Haque2025-01-01
| |/
| * refactor: iwyu #31637Justin M. Keyes2024-12-23
| | | | | | Result of `make iwyu` (after some "fixups").
| * refactor(api): always use TRY_WRAP #31600luukvbaal2024-12-17
| | | | | | | | | | | | | | Problem: Two separate try/end wrappers, that only marginally differ by restoring a few variables. Wrappers that don't restore previous state are dangerous to use in "api-fast" functions. Solution: Remove wrappers that don't restore the previous state. Always use TRY_WRAP.
| * vim-patch:9.1.0908: not possible to configure :messages (#31492)zeertzjq2024-12-07
| | | | | | | | | | | | | | | | | | | | | | Problem: not possible to configure :messages Solution: add the 'messagesopt' option (Shougo Matsushita) closes: vim/vim#16068 https://github.com/vim/vim/commit/51d4d84d6a7159c6ce9e04b36f8edc105ca3794b Co-authored-by: Shougo Matsushita <Shougo.Matsu@gmail.com> Co-authored-by: h_east <h.east.727@gmail.com>
| * fix(ui): clamp 'cmdheight' for other tabpages on screen resize (#31419)zeertzjq2024-12-02
| |
| * vim-patch:9.1.0892: the max value of 'cmdheight' is limited by other ↵zeertzjq2024-11-29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | tabpages (#31378) Problem: the max value of 'cmdheight' is limited by other tabpages Solution: Limit the maximum value of 'cmdheight' to the current tabpage only. (Milly) The Help says that cmdheight is local to the tab page, but says nothing about the maximum value depending on the state of all tab pages. Users may wonder why they can't increase cmdheight when there are still rows available on the current tab page. This PR changes the behavior of cmdheight so that its maximum value depends only on the state of the current tab page. Also, since magic numbers were embedded in various places with the minimum value of cmdheight being 1, we defined a constant to make it easier to understand. closes: vim/vim#16131 https://github.com/vim/vim/commit/2cddf0e85a7f8304476397e1c51dcd0e41835ac3 Cherry-pick Test_cmdheight_not_changed() from patch 9.0.0187. Co-authored-by: Milly <milly.ca@gmail.com>
| * refactor(options): fix confusing naming of `scope` and `req_scope` (#31317)Famiu Haque2024-11-25
| | | | | | | | | | | | | | | | | | | | Problem: The name `scope` is often used to refer to option flags because `OPT_LOCAL` and `OPT_GLOBAL` are often used to determine the option scope. This leads to the name `req_scope` being used for actual option scopes instead. Solution: Since the end-goal is to remove `OPT_LOCAL` and `OPT_GLOBAL` entirely and replace them with `OptScope`, rename `OptScope` variables to `scope` and the old scope flag variables to `opt_flags`.
| * vim-patch:9.1.0883: message history cleanup is missing some tests (#31331)zeertzjq2024-11-24
| | | | | | | | | | | | | | | | | | | | | | | | Problem: message history cleanup is missing some tests Solution: Add tests, refactor common code into did_set_msghistory() (Shougo Matsushita) closes: vim/vim#16078 https://github.com/vim/vim/commit/9f860a14c308f7a9a27a6850d36790615717a710 Co-authored-by: Shougo Matsushita <Shougo.Matsu@gmail.com> Co-authored-by: Milly <milly.ca@gmail.com>
| * refactor(options): autogenerate valid values and flag enums for options (#31089)Famiu Haque2024-11-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Option metadata like list of valid values for an option and option flags are not listed in the `options.lua` file and are instead manually defined in C, which means option metadata is split between several places. Solution: Put metadata such as list of valid values for an option and option flags in `options.lua`, and autogenerate the corresponding C variables and enums. Supersedes #28659 Co-authored-by: glepnir <glephunter@gmail.com>
| * fix(highlight): 'winhl' shouldn't take priority over API (#31288)zeertzjq2024-11-22
| |
| * docs: misc (#31138)dundargoc2024-11-21
| | | | | | Co-authored-by: zeertzjq <zeertzjq@outlook.com>
| * fix(messages): more ext_messages kinds #31279luukvbaal2024-11-20
| | | | | | | | Add kinds for various commands that output a list, the 'wildmode' list, and for number prompts.
* | Merge remote-tracking branch 'upstream/master' into mix_20240309Josh Rahm2024-11-25
|\|
| * refactor(options): remove `.indir`, redesign option scopes #31066Famiu Haque2024-11-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: The way option scopes currently work is inflexible and does not allow for nested option scopes or easily finding the value of an option at any arbitrary scope without having to do long handwritten switch-case statements like in `get_varp()`. `.indir` is also confusing and redundant since option indices for each scope can be autogenerated. Solution: Expand option scopes in such a way that an option can support any amount of scopes using a set of scope flags, similarly to how it's already done for option types. Also make options contain information about its index at each scope it supports. This allows for massively simplifying `get_varp()` and `get_varp_scope()` in the future by just using a struct for options at each scope. This would be done by creating a table that stores the offset of an option's variable at a scope by using the option's index at that scope as a key. This PR also autogenerates enums for option indices at each scope to remove the need for `.indir` entirely, and also to allow easily iterating over options all options that support any scope. Ref: #29314
| * vim-patch:9.1.0864: message history is fixed to 200 (#31215)zeertzjq2024-11-15
| | | | | | | | | | | | | | | | | | | | | | | | Problem: message history is fixed to 200 Solution: Add the 'msghistory' option, increase the default value to 500 (Shougo Matsushita) closes: vim/vim#16048 https://github.com/vim/vim/commit/4bd9b2b2467e696061104a029000e9824c6c609e Co-authored-by: Shougo Matsushita <Shougo.Matsu@gmail.com> Co-authored-by: Milly <milly.ca@gmail.com>
| * 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.
| * Merge pull request #27813 from luukvbaal/msgidbfredl2024-11-11
| |\ | | | | | | feat(ext_messages): add hl_id to ext_messages chunks
| | * 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.
| * | docs: misc (#30914)dundargoc2024-11-09
| | | | | | | | | | | | | | | | | | | | | Co-authored-by: Ernie Rael <errael@raelity.com> Co-authored-by: Famiu Haque <famiuhaque@proton.me> Co-authored-by: Jade <spacey-sooty@proton.me> Co-authored-by: glepnir <glephunter@gmail.com> Co-authored-by: zeertzjq <zeertzjq@outlook.com>
| * | refactor(options): use os_win/os_buf for local options (#31060)zeertzjq2024-11-08
| | | | | | | | | Conversely, don't use them for global options.
| * | refactor(options): remove `varp` argument for `set_option` (#31111)Famiu Haque2024-11-08
| |/ | | | | | | | | | | | | | | Problem: The `varp` argument for `set_option` is extraneous as the option's variable pointer can be retrieved using the option's index and flags. Solution: Remove the `varp` argument for `set_option`
| * Merge pull request #31062 from famiu/refactor/options/ff_macrobfredl2024-11-06
| |\ | | | | | | refactor(options): remove fileformat macros
| | * refactor(options): remove fileformat macrosFamiu Haque2024-11-05
| | |
| * | refactor(options): remove unnecessary call to `find_option()` (#31088)Famiu Haque2024-11-06
| |/
| * feat(options)!: disallow setting hidden options #28400Famiu Haque2024-11-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: There are three different ways of marking an option as hidden, `enable_if = false`, `hidden = true` and `immutable = true`. These also have different behaviors. Options hidden with `enable_if = false` can't have their value fetched using Vim script or the API, but options hidden with `hidden = true` or `immutable = true` can. On the other hand, options with `hidden = true` do not error when trying to set their value, but options with `immutable = true` do. Solution: Remove `enable_if = false`, remove the `hidden` property for options, and use `immutable = true` to mark an option as hidden instead. Also make hidden option variable pointers always point to the default value, which allows fetching the value of every hidden option using Vim script and the API. This does also mean that trying to set a hidden option will now give an error instead of just being ignored.
| * vim-patch:9.1.0831: 'findexpr' can't be used as lambad or Funcref (#31058)zeertzjq2024-11-03
| | | | | | | | | | | | | | | | | | | | | | | | | | Problem: 'findexpr' can't be used for lambads (Justin Keyes) Solution: Replace the findexpr option with the findfunc option (Yegappan Lakshmanan) related: vim/vim#15905 closes: vim/vim#15976 https://github.com/vim/vim/commit/a13f3a4f5de9c150f70298850e34747838904995 Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
| * refactor(options): remove `get_option_value_strict`Famiu Haque2024-11-02
| | | | | | | | | | | | Problem: `get_option_value_for` can perfectly replace `get_option_value_strict`, making the latter redundant. Solution: Remove `get_option_value_strict`
| * refactor(options): unify `put_set(num|bool|string)` (#30993)Famiu Haque2024-11-02
| | | | | | | | | | | | | | | | | | | | | | | | | | Problem: There are three separate functions for printing the `:set` command for an setting an option to a file descriptor. These functions are used when creating the session file for an option. Having a function for each type increase code duplication and also makes it harder to add logic for new option types. Solution: Replace `put_set(num|bool|string)` with a single `put_set` function which works for all option types, this reduces code duplication and also makes it trivial to add support for more option types in the future.
| * vim-patch:9.1.0810: cannot easily adjust the |:find| commandzeertzjq2024-10-29
| | | | | | | | | | | | | | | | | | | | | | | | Problem: cannot easily adjust the |:find| command Solution: Add support for the 'findexpr' option (Yegappan Lakshmanan) closes: vim/vim#15901 closes: vim/vim#15905 https://github.com/vim/vim/commit/aeb1c97db5b9de4f4903e7f288f2aa5ad6c49440 Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
| * refactor(options): option flags enum #30961Famiu Haque2024-10-28
| | | | | | | | | | Problem: Currently we use macros with hardcoded flag values for option flags, which is messy and requires a lot of mental math for adding / removing option flags. Using macros for option flags also means that they cannot be used inside debuggers. Solution: Create a new `OptFlags` enum that stores all the option flags in an organized way that is easier to understand.
| * refactor(options): always allocate option values (#30917)Famiu Haque2024-10-27
| | | | | | | | | | | | | | Instead of keeping `P_ALLOCED` and `P_DEF_ALLOCED` flags to check if an option value is allocated, always allocate option values to simplify the logic. Ref: #25672
| * refactor(options)!: use OptVal for option defaults #26691Famiu Haque2024-10-25
| | | | | | | | | | | | | | | | | | Problem: We use `void *` for option default values, which is confusing and can cause problems with type-correctness. It also doesn't accomodate for multitype options. On top of that, it also leads to default boolean option values not behaving correctly on big endian systems. Solution: Use `OptVal` for option default values. BREAKING CHANGE: - `:set {option}<` removes the local value for all global-local options instead of just string global-local options. - `:setlocal {option}<` copies the global value to the local value for number and boolean global-local options instead of removing the local value.
| * fix(options): missing error check for global 'scl' and 'winhl' (#30919)zeertzjq2024-10-24
| |
| * vim-patch:9.1.0806: tests: no error check when setting global 'briopt'zeertzjq2024-10-24
| | | | | | | | | | | | | | | | | | | | | | Problem: tests: no error check when setting global 'briopt' Solution: also parse and check global 'briopt' value (Milly) closes: vim/vim#15911 https://github.com/vim/vim/commit/b38700ac81d90a652e5c8495056dd78df5babdde Co-authored-by: Milly <milly.ca@gmail.com>
| * vim-patch:9.1.0804: tests: no error check when setting global 'cc'zeertzjq2024-10-24
| | | | | | | | | | | | | | | | | | | | | | Problem: tests: no error check when setting global 'cc' Solution: also parse and check global 'cc' value (Milly) closes: vim/vim#15914 https://github.com/vim/vim/commit/a441a3eaabbfc14b4772e07ecbecaaff3bd06a58 Co-authored-by: Milly <milly.ca@gmail.com>
| * fix(options): fix 'winhl' still accepting invalid value (#30896)zeertzjq2024-10-22
| |
| * fix(options): fix :setglobal not working for 'spelloptions' (#30894)zeertzjq2024-10-22
| |
| * vim-patch:9.1.0783: 'spell' option setting has problems (#30818)zeertzjq2024-10-15
| | | | | | | | | | | | | | | | | | | | | | Problem: 'spell' option setting has problems Solution: correctly check for comma for 'spellfile' option, remove unnecessary checks, refactor slightly (Milly) closes: vim/vim#15873 https://github.com/vim/vim/commit/322ad0c953b7a3023cd2a65db61d05e180a5d682 Co-authored-by: Milly <milly.ca@gmail.com>
* | Merge remote-tracking branch 'upstream/master' into mix_20240309Josh Rahm2024-11-19
|\|
| * vim-patch:9.1.0762: 'cedit', 'termwinkey' and 'wildchar' may not be parsed ↵zeertzjq2024-10-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | correctly (#30704) Problem: 'cedit', 'termwinkey' and 'wildchar' may not be parsed correctly Solution: improve string_to_key() function in option.c (Milly) - Problem: `^@` raises an error. Solution: Store as `<Nul>`. - Problem: `<t_xx` does not raise an error. Solution: Raise an error if closing `>` is missing. - Problem: Single `<` or `^` raises an error. It is inconvenient for users. Solution: They are stored as a single character. closes: vim/vim#15811 https://github.com/vim/vim/commit/a9c6f90918d0012d1b8c8c5c1dccb77407f553fb Co-authored-by: Milly <milly.ca@gmail.com>