mirror of
https://github.com/neovim/neovim.git
synced 2026-08-28 01:51:52 +00:00
feat(options): schema, "dict" options, messages
Problem:
Options parsing is still painful for dict-style options.
Solution:
schema-maxxing => better `opt:get()` (will be the basis for `vim.o()`),
unified (and more-detailed) err msgs.
- Drop bespoke structure-builder in `_core/options.lua`.
- Define `schema` for all non-primitive options (except 'guicursor' and
statusline-style options); generate reified keysets `OptKeyDict`).
- Generate 'fillchars' => `fcs_tab`, 'listchars' => `lcs_tab`.
- `nvim_set_option_value`:
- Return the improved structures. Also from `vim.opt.x:get()`.
- Eliminate api <=> lua roundtrip, centralize option structure
handling.
- Improve/unify errors.
- Bump ERR_BUFLEN 80 → 256 so the "one of" list isn't truncated.
- Eliminate old 'diffopt' order-dependence (`iwhiteall` before `iwhite`)
Error samples:
Typed-key path (opt_strings_check → diffopt/mousescroll/breakindentopt):
E474: Unknown item 'foo'
E474: 'context' requires a number
E474: 'ver' number is out of range
E474: 'algorithm' must be one of: myers, minimal, patience, histogram
E474: 'filler' does not take a value
Related:
- #31084
- #34661
- #31820
- #14739
- #20107
- fix #18875
- :get() returns `{ sbr = true, shift = '3' }` (reified-keyset) instead of `{'sbr', 'shift:3'}`
- Setting via table now works too. `object_as_optval_for` `is_map` now recognizes struct options.
- fix #30296
- instead of `E474: Invalid argument`, errors now look like:
```
E474: Invalid value 'x', expected one of: single, double: ambiwidth=x
E474: Unknown item 'foo': diffopt=foo
E474: 'context' requires a number: diffopt=context:x
```
simplify `win_float_parse_option` from #26799.
This commit is contained in:
@@ -13,6 +13,7 @@ const embedded_data = @import("embedded_data");
|
||||
|
||||
// these are common dependencies used by many generators
|
||||
const hashy = @embedFile("gen/hashy.lua");
|
||||
const keyset = @embedFile("gen/keyset.lua");
|
||||
const c_grammar = @embedFile("gen/c_grammar.lua");
|
||||
|
||||
const Lua = ziglua.Lua;
|
||||
@@ -43,6 +44,8 @@ fn init_lua() !*Lua {
|
||||
_ = lua.getField(-1, "preload");
|
||||
try lua.loadBuffer(hashy, "hashy.lua"); // [package, preload, hashy]
|
||||
lua.setField(-2, "gen.hashy");
|
||||
try lua.loadBuffer(keyset, "keyset.lua"); // [package, preload, keyset]
|
||||
lua.setField(-2, "gen.keyset");
|
||||
try lua.loadBuffer(c_grammar, "c_grammar.lua"); // [package, preload, c_grammar]
|
||||
lua.setField(-2, "gen.c_grammar");
|
||||
lua.pop(2);
|
||||
|
||||
Reference in New Issue
Block a user