aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/option_defs.h
Commit message (Collapse)AuthorAge
* 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
* 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.
* 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
* 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(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.
* docs: small fixes (#26651)dundargoc2023-12-28
| | | | Co-authored-by: Gregory Anders <greg@gpanders.com> Co-authored-by: WillLillis <wlillis@umass.edu>
* refactor(options): use `OptIndex` for `os_idx`Famiu Haque2023-12-23
|
* refactor(IWYU): add "private" pragma to more generated headers (#26706)zeertzjq2023-12-22
| | | | | "export" only prevents IWYU from adding these headers if the headers that export them are included, while "private" ensures that IWYU never adds these headers.
* refactor: move non-symbols to defs.h headersdundargoc2023-12-17
|
* refactor(options): remove option type macrosFamiu Haque2023-12-14
| | | | | | | | Problem: We have `P_(BOOL|NUM|STRING)` macros to represent an option's type, which is redundant because `OptValType` can already do that. The current implementation of option type flags is also too limited to allow adding multitype options in the future. Solution: Remove `P_(BOOL|NUM|STRING)` and replace it with a new `type_flags` attribute in `vimoption_T`. Also do some groundwork for adding multitype options in the future. Side-effects: Attempting to set an invalid keycode option (e.g. `set t_foo=123`) no longer gives an error.
* refactor(options): reduce `findoption()` usageFamiu Haque2023-12-09
| | | | | | Problem: Many places in the code use `findoption()` to access an option using its name, even if the option index is available. This is very slow because it requires looping through the options array over and over. Solution: Use option index instead of name wherever possible. Also introduce an `OptIndex` enum which contains the index for every option as enum constants, this eliminates the need to pass static option names as strings.
* vim-patch:9.0.2142: [security]: stack-buffer-overflow in option callback ↵zeertzjq2023-12-02
| | | | | | | | | | | | | | | | | | | | | functions Problem: [security]: stack-buffer-overflow in option callback functions Solution: pass size of errbuf down the call stack, use snprintf() instead of sprintf() We pass the error buffer down to the option callback functions, but in some parts of the code, we simply use sprintf(buf) to write into the error buffer, which can overflow. So let's pass down the length of the error buffer and use sprintf(buf, size) instead. Reported by @henices, thanks! https://github.com/vim/vim/commit/b39b240c386a5a29241415541f1c99e2e6b8ce47 Co-authored-by: Christian Brabandt <cb@256bit.org>
* refactor: rename types.h to types_defs.hdundargoc2023-11-27
|
* refactor: move Arena and ArenaMem to memory_defs.h (#26240)zeertzjq2023-11-27
|
* refactor: replace manual header guards with #pragma oncedundargoc2023-11-12
| | | | | It is less error-prone than manually defining header guards. Pretty much all compilers support it even if it's not part of the C standard.
* refactor(options): remove `os_doskip`Famiu Haque2023-10-31
| | | | | | Problem: `os_doskip` seems to be unnecessary since everything that sets it to true also returns an error, and `errmsg` being non-`NULL` already skips most of the processing. Solution: Remove `os_doskip`.
* refactor(options): make `os_oldval` and `os_newval` use `OptValData`Famiu Haque2023-10-17
|
* refactor(options): remove `os_op`Famiu Haque2023-10-17
|
* refactor: move cmdline completion types to cmdexpand_defs.h (#25465)zeertzjq2023-10-02
|
* vim-patch:9.0.1968: cmdline completion should consider key optionzeertzjq2023-10-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: cmdline completion should consider key option Solution: Disable cmdline completion for key option, slightly refactor how P_NO_CMD_EXPAND is handled Harden crypto 'key' option: turn off cmdline completion, disable set-= "set-=" can be used maliciously with a crypto key, as it allows an attacker (who either has access to the computer or a plugin author) to guess a substring by observing the modified state. Simply turn off set+=/-=/^= for this option as there is no good reason for them to be used. Update docs to make that clear as well. Also, don't allow cmdline completion for 'key' as it just shows ***** which is not useful and confusing to the user what it means (if the user accidentally hits enter they will have replaced their key with "*****" instead). Move logic to better location, don't use above 32-bit for flags Move P_NO_CMD_EXPAND to use the unused 0x20 instead of going above 32-bits, as currently the flags parameter is only 32-bits on some systems. Left a comment to warn that future additions will need to change how the flags work either by making it 64-bit or split into two member vars. Also, move the logic for detecting P_NO_CMD_EXPAND earlier so it's not up to each handler to decide, and you won't see the temporary "..." that Vim shows while waiting for completion handler to complete. closes: vim/vim#13224 https://github.com/vim/vim/commit/6ee7b521fa7531ef356ececc8be7575c3800f872 Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
* vim-patch:9.0.1958: cannot complete option valueszeertzjq2023-10-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: cannot complete option values Solution: Add completion functions for several options Add cmdline tab-completion for setting string options Add tab-completion for setting string options on the cmdline using `:set=` (along with `:set+=` and `:set-=`). The existing tab completion for setting options currently only works when nothing is typed yet, and it only fills in with the existing value, e.g. when the user does `:set diffopt=<Tab>` it will be completed to `set diffopt=internal,filler,closeoff` and nothing else. This isn't too useful as a user usually wants auto-complete to suggest all the possible values, such as 'iblank', or 'algorithm:patience'. For set= and set+=, this adds a new optional callback function for each option that can be invoked when doing completion. This allows for each option to have control over how completion works. For example, in 'diffopt', it will suggest the default enumeration, but if `algorithm:` is selected, it will further suggest different algorithm types like 'meyers' and 'patience'. When using set=, the existing option value will be filled in as the first choice to preserve the existing behavior. When using set+= this won't happen as it doesn't make sense. For flag list options (e.g. 'mouse' and 'guioptions'), completion will take into account existing typed values (and in the case of set+=, the existing option value) to make sure it doesn't suggest duplicates. For set-=, there is a new `ExpandSettingSubtract` function which will handle flag list and comma-separated options smartly, by only suggesting values that currently exist in the option. Note that Vim has some existing code that adds special handling for 'filetype', 'syntax', and misc dir options like 'backupdir'. This change preserves them as they already work, instead of converting to the new callback API for each option. closes: vim/vim#13182 https://github.com/vim/vim/commit/900894b09a95398dfc75599e9f0aa2ea25723384 Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
* 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
* refactor: remove longdundargoc2023-09-29
| | | | | long is 32-bits even on 64-bit windows which makes the type suboptimal for a codebase meant to be cross-platform.
* refactor(options)!: graduate some more shortmess flagsbfredl2023-09-25
| | | | | | | | A lot of updated places in the docs were already incorrect since long since they did not reflect the default behaviour. "[dos format]" could've been argued being better for discoverability but that ship has already sailed as it is no longer displayed by default.
* feat(extmark): support proper multiline rangesbfredl2023-09-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The removes the previous restriction that nvim_buf_set_extmark() could not be used to highlight arbitrary multi-line regions The problem can be summarized as follows: let's assume an extmark with a hl_group is placed covering the region (5,0) to (50,0) Now, consider what happens if nvim needs to redraw a window covering the lines 20-30. It needs to be able to ask the marktree what extmarks cover this region, even if they don't begin or end here. Therefore the marktree needs to be augmented with the information covers a point, not just what marks begin or end there. To do this, we augment each node with a field "intersect" which is a set the ids of the marks which overlap this node, but only if it is not part of the set of any parent. This ensures the number of nodes that need to be explicitly marked grows only logarithmically with the total number of explicitly nodes (and thus the number of of overlapping marks). Thus we can quickly iterate all marks which overlaps any query position by looking up what leaf node contains that position. Then we only need to consider all "start" marks within that leaf node, and the "intersect" set of that node and all its parents. Now, and the major source of complexity is that the tree restructuring operations (to ensure that each node has T-1 <= size <= 2*T-1) also need to update these sets. If a full inner node is split in two, one of the new parents might start to completely overlap some ranges and its ids will need to be moved from its children's sets to its own set. Similarly, if two undersized nodes gets joined into one, it might no longer completely overlap some ranges, and now the children which do needs to have the have the ids in its set instead. And then there are the pivots! Yes the pivot operations when a child gets moved from one parent to another.
* refactor(option): remove OPT_CLEARLewis Russell2023-08-31
|
* refactor(option): change some int to boolLewis Russell2023-08-31
|
* refactor(option): use `void *` for pointer to option valueFamiu Haque2023-06-20
| | | | | | Option related code uses `char *` for pointer to option value, which is not the best way of representing a type-agnostic pointer. Solution: Make pointers to option value use `void *` instead.
* refactor(options): remove `getoption_T` and introduce `OptVal` (#23850)Famiu Haque2023-06-07
| | | | | | | | Removes the `getoption_T` struct and also introduces the `OptVal` struct to unify the methods of getting/setting different option value types. This is the first of many PRs to reduce code duplication in the Vim option code as well as to make options easier to maintain. It also increases the flexibility and extensibility of options. Which opens the door for things like Array and Dictionary options.
* vim-patch:9.0.1613: some make output gets picked up by 'errorformat' (#23926)Gregory Anders2023-06-05
| | | | | | Problem: Some make output gets picked up by 'errorformat'. Solution: Ignore make output by default. (Gregory Anders, closes vim/vim#12481) https://github.com/vim/vim/commit/d1911a8e2b1498f0cb0275a98f63dd212204a1a8
* refactor: remove typval.h from most header files (#23601)zeertzjq2023-05-13
| | | Because typval_defs.h is enough for most of them.
* vim-patch:9.0.1518: search stats not always visible when searching backwards ↵zeertzjq2023-05-07
| | | | | | | | | | | (#23517) Problem: Search stats not always visible when searching backwards. Solution: Do not display the top/bot message on top of the search stats. (Christian Brabandt, closes vim/vim#12322, closes vim/vim#12222) https://github.com/vim/vim/commit/34a6a3617b5b6ce11372439f14762caddc4b0cea Co-authored-by: Christian Brabandt <cb@256bit.org>
* vim-patch:9.0.0640: cannot scroll by screen line if a line wrapsLuuk van Baal2023-05-02
| | | | | | | | | | | | | | | | | Problem: Cannot scroll by screen line if a line wraps. Solution: Add the 'smoothscroll' option. Only works for CTRL-E and CTRL-Y so far. https://github.com/vim/vim/commit/f6196f424474e2a9c160f2a995fc2691f82b58f9 vim-patch:9.0.0641: missing part of the new option code Problem: Missing part of the new option code. Solution: Add missing WV_SMS. https://github.com/vim/vim/commit/bbbda8fd81f6d720962b67ae885825bad9be4456 Co-authored-by: Bram Moolenaar <Bram@vim.org>
* vim-patch:9.0.1336: functions without arguments are not always declared properlyzeertzjq2023-04-28
| | | | | | | | | Problem: Functions without arguments are not always declared properly. Solution: Use "(void)" instead of "()". (Yegappan Lakshmanan, closes vim/vim#12031) https://github.com/vim/vim/commit/a23a11b5bf03454b71fdb5deac0d5f641e222160 Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
* vim-patch:9.0.1374: function for setting options not used consistentlyLewis Russell2023-04-28
| | | | | | | | Problem: Function for setting options not used consistently. Solution: Use a function for 'encoding' and terminal options. (Yegappan Lakshmanan, closes vim/vim#12099) https://github.com/vim/vim/commit/c727b19e9f1df36e44321d933334c7b4961daa54
* vim-patch:9.0.1359: too many "else if" statements in handling optionsLewis Russell2023-04-28
| | | | | | | | Problem: Too many "else if" statements in handling options. Solution: Add more functions for handling option changes. (Yegappan Lakshmanan, closes vim/vim#12060) https://github.com/vim/vim/commit/5da901bb68717b2baff6e971c1517219b6ee3a67
* vim-patch:9.0.1353: too many "else if" statements to handle option valuesLewis Russell2023-04-28
| | | | | | | | Problem: Too many "else if" statements to handle option values. Solution: Add more functions to handle option value changes. (Yegappan Lakshmanan, closes vim/vim#12058) https://github.com/vim/vim/commit/6d611de58c8e324491415da8e79c6bd3faa3e848
* vim-patch:9.0.1330: handling new value of an option has a long "else if" chainLewis Russell2023-04-28
| | | | | | | Problem: Handling new value of an option has a long "else if" chain. Solution: Use a function pointer. (Yegappan Lakshmanan, closes vim/vim#12015) https://github.com/vim/vim/commit/af93691b53f38784efce0b93fe7644c44a7e382e
* refactor: uncrustifydundargoc2023-04-26
| | | | Notable changes: replace all infinite loops to `while(true)` and remove `int` from `unsigned int`.
* vim-patch:9.0.1064: code for making 'shortmess' temporarily empty is repeatedzeertzjq2023-04-16
| | | | | | | | | | Problem: Code for making 'shortmess' temporarily empty is repeated. Solution: Add functions for making 'shortmess' empty and restoring it. (Christian Brabandt, closes vim/vim#11709) https://github.com/vim/vim/commit/9aee8ec400fe617f6d82441c46a22d0cef6fa3e6 Co-authored-by: Christian Brabandt <cb@256bit.org>
* refactor: remove char_u (#22829)dundargoc2023-04-02
| | | Closes https://github.com/neovim/neovim/issues/459
* feat(options)!: deprecate paste, remove pastetoggle (#22647)ii142023-03-13
| | | | | we cannot remove 'paste'. It is very common in plugins and configs. 'pastetoggle' can and should be removed though, it's a total waste of everyone's time because it generates bug reports and doesn't work well, and is useless because bracketed-paste works better.
* vim-patch:9.0.1397: highlight for popupmenu kind and extra cannot be set ↵zeertzjq2023-03-11
| | | | | | | | | | | (#22619) Problem: Highlight for popupmenu kind and extra cannot be set. Solution: Add PmenuKind, PmenuKindSel, PmenuExtra and PmenuExtraSel highlight groups and use them. (Gianmaria Bajo, closes vim/vim#12114) https://github.com/vim/vim/commit/6a7c7749204b256e779c245b1e999bf852ad7b64 Co-authored-by: Gianmaria Bajo <mg1979.git@gmail.com>
* feat(edit)!: remove old c implementation of hebrew keymapbfredl2023-02-28
| | | | | | | This feature has long been obsolete. The 'keymap' option can be used to support language keymaps, including hebrew and hebrewp (phonetic mapping). There is no need to keep the old c code with hardcoded keymaps for some languages.
* refactor(ui): cleanup 'redrawdebug', introduce "flush" modebfredl2023-02-08
|
* refactor: replace char_u with char 25 (#21838)dundargoc2023-01-19
| | | | | refactor: replace char_u with char Work on https://github.com/neovim/neovim/issues/459
* refactor: replace char_u with char 24 (#21823)dundargoc2023-01-18
| | | | | refactor: replace char_u with char Work on https://github.com/neovim/neovim/issues/459
* vim-patch:8.2.4463: completion only uses strict matchingSean Dewar2023-01-17
| | | | | | | | | | | | | Problem: Completion only uses strict matching. Solution: Add the "fuzzy" item for 'wildoptions'. (Yegappan Lakshmanan, closes vim/vim#9803) https://github.com/vim/vim/commit/38b85cb4d7216705058708bacbc25ab90cd61595 Use MAX_FUZZY_MATCHES in fuzzy_match_str(). Omit fuzmatch_str_free() as it is only used on allocation failure. Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>