mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-30 00:26:45 +00:00
Compare commits
1 commit
812f516dc0
...
92cdaaf14c
Author | SHA1 | Date | |
---|---|---|---|
|
92cdaaf14c |
5 changed files with 2108 additions and 2174 deletions
|
@ -4,7 +4,7 @@ Release notes for release 0.7
|
||||||
|
|
||||||
## Breaking Changes and Migration Guide {#sec-breaking-changes-and-migration-guide-0-7}
|
## Breaking Changes and Migration Guide {#sec-breaking-changes-and-migration-guide-0-7}
|
||||||
|
|
||||||
### `vim.configRC` removed {#sec-vim-configrc-removed}
|
### `vim.configRC` removed
|
||||||
|
|
||||||
In v0.7 we are removing `vim.configRC` in favor of making `vim.luaConfigRC` the
|
In v0.7 we are removing `vim.configRC` in favor of making `vim.luaConfigRC` the
|
||||||
top-level DAG, and thereby making the entire configuration Lua based. This
|
top-level DAG, and thereby making the entire configuration Lua based. This
|
||||||
|
@ -26,7 +26,7 @@ making good use of its extensive Lua API. Additionally, Vimscript is slow and
|
||||||
brings unnecessary performance overhead while working with different
|
brings unnecessary performance overhead while working with different
|
||||||
configuration formats.
|
configuration formats.
|
||||||
|
|
||||||
### `vim.maps` rewrite {#sec-vim-maps-rewrite}
|
### `vim.maps` rewrite
|
||||||
|
|
||||||
Instead of specifying map modes using submodules (eg.: `vim.maps.normal`), a new
|
Instead of specifying map modes using submodules (eg.: `vim.maps.normal`), a new
|
||||||
`mode` option has mode has been introduced. It can be either a string, or a list
|
`mode` option has mode has been introduced. It can be either a string, or a list
|
||||||
|
|
29
flake.lock
29
flake.lock
|
@ -69,11 +69,11 @@
|
||||||
},
|
},
|
||||||
"mnw": {
|
"mnw": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1722191188,
|
"lastModified": 1723419050,
|
||||||
"narHash": "sha256-YF//iMALbrd2Ni9aju7w8NniH16Qz6RFTRD6md5UkDc=",
|
"narHash": "sha256-Eb8jBUgHwpte+bGsqeXNbKMBfZaDB7RiPQwyb1vzJK8=",
|
||||||
"owner": "Gerg-L",
|
"owner": "Gerg-L",
|
||||||
"repo": "mnw",
|
"repo": "mnw",
|
||||||
"rev": "c7b289f3f5a31b6e744be37d83fc231816621231",
|
"rev": "e625f5965567f16102bc52897c7600dcde53c6c3",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -84,7 +84,10 @@
|
||||||
},
|
},
|
||||||
"naersk": {
|
"naersk": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": ["rnix-lsp", "nixpkgs"]
|
"nixpkgs": [
|
||||||
|
"rnix-lsp",
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1655042882,
|
"lastModified": 1655042882,
|
||||||
|
@ -102,8 +105,12 @@
|
||||||
},
|
},
|
||||||
"nil": {
|
"nil": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-utils": ["flake-utils"],
|
"flake-utils": [
|
||||||
"nixpkgs": ["nixpkgs"],
|
"flake-utils"
|
||||||
|
],
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
],
|
||||||
"rust-overlay": "rust-overlay"
|
"rust-overlay": "rust-overlay"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
|
@ -1932,8 +1939,14 @@
|
||||||
},
|
},
|
||||||
"rust-overlay": {
|
"rust-overlay": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-utils": ["nil", "flake-utils"],
|
"flake-utils": [
|
||||||
"nixpkgs": ["nil", "nixpkgs"]
|
"nil",
|
||||||
|
"flake-utils"
|
||||||
|
],
|
||||||
|
"nixpkgs": [
|
||||||
|
"nil",
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1714529851,
|
"lastModified": 1714529851,
|
||||||
|
|
|
@ -4,30 +4,29 @@
|
||||||
inherit (lib.types) nullOr str;
|
inherit (lib.types) nullOr str;
|
||||||
inherit (lib.attrsets) isAttrs mapAttrs;
|
inherit (lib.attrsets) isAttrs mapAttrs;
|
||||||
|
|
||||||
binds = rec {
|
mkLuaBinding = mode: key: action: desc:
|
||||||
mkLuaBinding = key: action: desc:
|
|
||||||
mkIf (key != null) {
|
mkIf (key != null) {
|
||||||
"${key}" = {
|
${key} = {
|
||||||
inherit action desc;
|
inherit mode action desc;
|
||||||
lua = true;
|
lua = true;
|
||||||
silent = true;
|
silent = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
mkExprBinding = key: action: desc:
|
mkExprBinding = mode: key: action: desc:
|
||||||
mkIf (key != null) {
|
mkIf (key != null) {
|
||||||
"${key}" = {
|
${key} = {
|
||||||
inherit action desc;
|
inherit mode action desc;
|
||||||
lua = true;
|
lua = true;
|
||||||
silent = true;
|
silent = true;
|
||||||
expr = true;
|
expr = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
mkBinding = key: action: desc:
|
mkBinding = mode: key: action: desc:
|
||||||
mkIf (key != null) {
|
mkIf (key != null) {
|
||||||
"${key}" = {
|
${key} = {
|
||||||
inherit action desc;
|
inherit mode action desc;
|
||||||
silent = true;
|
silent = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -48,25 +47,25 @@
|
||||||
isNested = isAttrs value;
|
isNested = isAttrs value;
|
||||||
returnedValue =
|
returnedValue =
|
||||||
if isNested
|
if isNested
|
||||||
then addDescriptionsToMappings actualMappings."${name}" mappingDefinitions."${name}"
|
then addDescriptionsToMappings actualMappings.${name} mappingDefinitions.${name}
|
||||||
else {
|
else {
|
||||||
inherit value;
|
inherit value;
|
||||||
inherit (mappingDefinitions."${name}") description;
|
inherit (mappingDefinitions.${name}) description;
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
returnedValue)
|
returnedValue)
|
||||||
actualMappings;
|
actualMappings;
|
||||||
|
|
||||||
mkSetBinding = binding: action:
|
mkSetBinding = mode: binding: action:
|
||||||
mkBinding binding.value action binding.description;
|
mkBinding mode binding.value action binding.description;
|
||||||
|
|
||||||
mkSetExprBinding = binding: action:
|
mkSetExprBinding = mode: binding: action:
|
||||||
mkExprBinding binding.value action binding.description;
|
mkExprBinding mode binding.value action binding.description;
|
||||||
|
|
||||||
mkSetLuaBinding = binding: action:
|
mkSetLuaBinding = mode: binding: action:
|
||||||
mkLuaBinding binding.value action binding.description;
|
mkLuaBinding mode binding.value action binding.description;
|
||||||
|
|
||||||
pushDownDefault = attr: mapAttrs (_: mkDefault) attr;
|
pushDownDefault = attr: mapAttrs (_: mkDefault) attr;
|
||||||
};
|
in {
|
||||||
in
|
inherit mkLuaBinding mkExprBinding mkBinding mkMappingOption addDescriptionsToMappings mkSetBinding mkSetExprBinding mkSetLuaBinding pushDownDefault;
|
||||||
binds
|
}
|
||||||
|
|
|
@ -1,9 +1,17 @@
|
||||||
{lib, ...}: let
|
{lib, ...}: let
|
||||||
inherit (lib.options) mkOption;
|
inherit (lib.options) mkOption;
|
||||||
inherit (lib.types) either str listOf attrsOf nullOr submodule bool;
|
inherit (lib.types) either str listOf attrsOf nullOr submodule;
|
||||||
inherit (lib.nvim.config) mkBool;
|
inherit (lib.nvim.config) mkBool;
|
||||||
|
|
||||||
mapConfigOptions = {
|
mapType = submodule {
|
||||||
|
mode = mkOption {
|
||||||
|
type = either str (listOf str);
|
||||||
|
description = ''
|
||||||
|
The short-name of the mode to set the keymapping for. Passing an empty string is the equivalent of `:map`.
|
||||||
|
|
||||||
|
See `:help map-modes` for a list of modes.
|
||||||
|
'';
|
||||||
|
};
|
||||||
desc = mkOption {
|
desc = mkOption {
|
||||||
type = nullOr str;
|
type = nullOr str;
|
||||||
default = null;
|
default = null;
|
||||||
|
@ -26,69 +34,10 @@
|
||||||
unique = mkBool false "Whether to fail if the map is already defined. Equivalent to adding <unique> to a map.";
|
unique = mkBool false "Whether to fail if the map is already defined. Equivalent to adding <unique> to a map.";
|
||||||
noremap = mkBool true "Whether to use the 'noremap' variant of the command, ignoring any custom mappings on the defined action. It is highly advised to keep this on, which is the default.";
|
noremap = mkBool true "Whether to use the 'noremap' variant of the command, ignoring any custom mappings on the defined action. It is highly advised to keep this on, which is the default.";
|
||||||
};
|
};
|
||||||
|
|
||||||
mapType = submodule {
|
|
||||||
options =
|
|
||||||
mapConfigOptions
|
|
||||||
// {
|
|
||||||
mode = mkOption {
|
|
||||||
type = either str (listOf str);
|
|
||||||
description = ''
|
|
||||||
The short-name of the mode to set the keymapping for. Passing an empty string is the equivalent of `:map`.
|
|
||||||
|
|
||||||
See `:help map-modes` for a list of modes.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
# legacy stuff
|
|
||||||
mapOption = submodule {
|
|
||||||
options =
|
|
||||||
mapConfigOptions
|
|
||||||
// {
|
|
||||||
action = mkOption {
|
|
||||||
type = str;
|
|
||||||
description = "The action to execute.";
|
|
||||||
};
|
|
||||||
|
|
||||||
lua = mkOption {
|
|
||||||
type = bool;
|
|
||||||
description = ''
|
|
||||||
If true, `action` is considered to be lua code.
|
|
||||||
Thus, it will not be wrapped in `""`.
|
|
||||||
'';
|
|
||||||
default = false;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
mapOptions = mode:
|
|
||||||
mkOption {
|
|
||||||
description = "Mappings for ${mode} mode";
|
|
||||||
type = attrsOf mapOption;
|
|
||||||
default = {};
|
|
||||||
};
|
|
||||||
in {
|
in {
|
||||||
options.vim = {
|
options.vim = {
|
||||||
maps = mkOption {
|
maps = mkOption {
|
||||||
type = submodule {
|
type = attrsOf mapType;
|
||||||
freeformType = attrsOf mapType;
|
|
||||||
options = {
|
|
||||||
normal = mapOptions "normal";
|
|
||||||
insert = mapOptions "insert";
|
|
||||||
select = mapOptions "select";
|
|
||||||
visual = mapOptions "visual and select";
|
|
||||||
terminal = mapOptions "terminal";
|
|
||||||
normalVisualOp = mapOptions "normal, visual, select and operator-pending (same as plain 'map')";
|
|
||||||
|
|
||||||
visualOnly = mapOptions "visual only";
|
|
||||||
operator = mapOptions "operator-pending";
|
|
||||||
insertCommand = mapOptions "insert and command-line";
|
|
||||||
lang = mapOptions "insert, command-line and lang-arg";
|
|
||||||
command = mapOptions "command-line";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
default = {};
|
default = {};
|
||||||
description = "Custom keybindings.";
|
description = "Custom keybindings.";
|
||||||
example = ''
|
example = ''
|
||||||
|
|
|
@ -3,8 +3,9 @@
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (builtins) map mapAttrs filter removeAttrs attrNames;
|
inherit (builtins) map mapAttrs filter;
|
||||||
inherit (lib.attrsets) mapAttrsToList filterAttrs attrsToList;
|
inherit (lib.options) mkOption;
|
||||||
|
inherit (lib.attrsets) mapAttrsToList filterAttrs getAttrs attrValues attrNames;
|
||||||
inherit (lib.strings) concatLines concatMapStringsSep;
|
inherit (lib.strings) concatLines concatMapStringsSep;
|
||||||
inherit (lib.trivial) showWarnings;
|
inherit (lib.trivial) showWarnings;
|
||||||
inherit (lib.generators) mkLuaInline;
|
inherit (lib.generators) mkLuaInline;
|
||||||
|
@ -45,35 +46,7 @@ in {
|
||||||
value,
|
value,
|
||||||
}: "vim.keymap.set(${toLuaObject value.mode}, ${toLuaObject name}, ${toLuaObject (getAction value)}, ${toLuaObject (getOpts value)})";
|
}: "vim.keymap.set(${toLuaObject value.mode}, ${toLuaObject name}, ${toLuaObject (getAction value)}, ${toLuaObject (getOpts value)})";
|
||||||
|
|
||||||
namedModes = {
|
keymaps = concatLines (map toLuaKeymap (attrsToList (filterNonNull config.maps)));
|
||||||
"normal" = ["n"];
|
|
||||||
"insert" = ["i"];
|
|
||||||
"select" = ["s"];
|
|
||||||
"visual" = ["v"];
|
|
||||||
"terminal" = ["t"];
|
|
||||||
"normalVisualOp" = ["n" "v" "o"];
|
|
||||||
"visualOnly" = ["n" "x"];
|
|
||||||
"operator" = ["o"];
|
|
||||||
"insertCommand" = ["i" "c"];
|
|
||||||
"lang" = ["l"];
|
|
||||||
"command" = ["c"];
|
|
||||||
};
|
|
||||||
|
|
||||||
maps =
|
|
||||||
removeAttrs cfg.maps (attrNames namedModes)
|
|
||||||
// mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.normal;}) cfg.maps.normal
|
|
||||||
// mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.insert;}) cfg.maps.insert
|
|
||||||
// mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.select;}) cfg.maps.select
|
|
||||||
// mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.visual;}) cfg.maps.visual
|
|
||||||
// mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.terminal;}) cfg.maps.terminal
|
|
||||||
// mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.normalVisualOp;}) cfg.maps.normalVisualOp
|
|
||||||
// mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.visualOnly;}) cfg.maps.visualOnly
|
|
||||||
// mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.operator;}) cfg.maps.operator
|
|
||||||
// mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.insertCommand;}) cfg.maps.insertCommand
|
|
||||||
// mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.lang;}) cfg.maps.lang
|
|
||||||
// mapAttrs (_: legacyMap: legacyMap // {mode = namedModes.command;}) cfg.maps.command;
|
|
||||||
|
|
||||||
keymaps = concatLines (map toLuaKeymap (attrsToList (filterNonNull maps)));
|
|
||||||
in {
|
in {
|
||||||
vim = {
|
vim = {
|
||||||
luaConfigRC = {
|
luaConfigRC = {
|
||||||
|
|
Loading…
Reference in a new issue