mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-23 01:08:43 +02:00
helpers: Add option helpers for types that are either a lua str or a value (#876)
Those types needed the following code in apply: if builtins.isString value then mkRaw value else value This commit avoids this boilerplate, and clarifies that the `str` is lua code in the documentation.
This commit is contained in:
parent
8b8a1c0f4b
commit
8aa4b7e4ce
13 changed files with 109 additions and 129 deletions
|
@ -81,7 +81,7 @@ with lib; let
|
|||
};
|
||||
|
||||
parser = {
|
||||
type = str;
|
||||
type = helpers.nixvimTypes.strLuaFn;
|
||||
description = "The code for your parser function.";
|
||||
example = ''
|
||||
require('lint.parser').from_pattern(pattern, groups, severity_map, defaults, opts)
|
||||
|
|
|
@ -84,21 +84,17 @@ with lib; {
|
|||
selection mode per capture, default is `v`(charwise).
|
||||
'';
|
||||
|
||||
includeSurroundingWhitespace =
|
||||
helpers.defaultNullOpts.mkNullable
|
||||
(with types; either bool str)
|
||||
"`false`"
|
||||
''
|
||||
`true` or `false`, when `true` textobjects are extended to include preceding or
|
||||
succeeding whitespace.
|
||||
includeSurroundingWhitespace = helpers.defaultNullOpts.mkStrLuaFnOr types.bool "`false`" ''
|
||||
`true` or `false`, when `true` textobjects are extended to include preceding or
|
||||
succeeding whitespace.
|
||||
|
||||
Can also be a function which gets passed a table with the keys `query_string`
|
||||
(`@function.inner`) and `selection_mode` (`v`) and returns `true` of `false`.
|
||||
Can also be a function which gets passed a table with the keys `query_string`
|
||||
(`@function.inner`) and `selection_mode` (`v`) and returns `true` of `false`.
|
||||
|
||||
If you set this to `true` (default is `false`) then any textobject is extended to
|
||||
include preceding or succeeding whitespace.
|
||||
Succeeding whitespace has priority in order to act similarly to eg the built-in `ap`.
|
||||
'';
|
||||
If you set this to `true` (default is `false`) then any textobject is extended to
|
||||
include preceding or succeeding whitespace.
|
||||
Succeeding whitespace has priority in order to act similarly to eg the built-in `ap`.
|
||||
'';
|
||||
};
|
||||
|
||||
swap = {
|
||||
|
@ -227,10 +223,7 @@ with lib; {
|
|||
;
|
||||
keymaps = processKeymapsOpt keymaps;
|
||||
selection_modes = selectionModes;
|
||||
include_surrounding_whitespace =
|
||||
if isString includeSurroundingWhitespace
|
||||
then helpers.mkRaw includeSurroundingWhitespace
|
||||
else includeSurroundingWhitespace;
|
||||
include_surrounding_whitespace = includeSurroundingWhitespace;
|
||||
};
|
||||
swap = with swap; {
|
||||
inherit
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue