mirror of
https://github.com/nix-community/nixvim.git
synced 2025-11-09 03:56:05 +01:00
plugins/langmapper: init module
Change-Id: I1caf76d5a6bdd7b1bb9fecfb142a3af1f0b00bd6
This commit is contained in:
parent
32a3fa118d
commit
d60696f62d
2 changed files with 100 additions and 0 deletions
52
plugins/by-name/langmapper/default.nix
Normal file
52
plugins/by-name/langmapper/default.nix
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
inherit (lib)
|
||||||
|
mkEnableOption
|
||||||
|
mkIf
|
||||||
|
mkOption
|
||||||
|
stringToCharacters
|
||||||
|
types
|
||||||
|
;
|
||||||
|
inherit (lib.nixvim.lua) toLua;
|
||||||
|
in
|
||||||
|
lib.nixvim.plugins.mkNeovimPlugin {
|
||||||
|
name = "langmapper";
|
||||||
|
package = "langmapper-nvim";
|
||||||
|
description = "A plugin that makes Neovim more friendly to non-English input methods";
|
||||||
|
|
||||||
|
maintainers = [ lib.maintainers.shved ];
|
||||||
|
|
||||||
|
settingsExample = {
|
||||||
|
automapping_modes = stringToCharacters "invxs";
|
||||||
|
map_add_ctrl = false;
|
||||||
|
};
|
||||||
|
extraOptions = {
|
||||||
|
automapping = {
|
||||||
|
enable = mkEnableOption "calling `automapping` at the end of `init.lua`" // {
|
||||||
|
default = true;
|
||||||
|
};
|
||||||
|
argument = mkOption {
|
||||||
|
description = "An argument to `automapping` call";
|
||||||
|
type = with types; either rawLua (attrsOf anything);
|
||||||
|
default = {
|
||||||
|
global = true;
|
||||||
|
buffer = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
extraConfig = cfg: {
|
||||||
|
# The plugin documentation says that if we need to handle built-in and vim
|
||||||
|
# script mappings, we should call this at the very end of `init.lua`. On the
|
||||||
|
# other hand it says that we have to call `setup` at the very beginning of
|
||||||
|
# plugin list initialisation. But I believe that this is enough to call this
|
||||||
|
# at very end of `init.lua` to cover the issues produced by calling `setup`
|
||||||
|
# of this plugin at the middle of plugins list
|
||||||
|
extraConfigLuaPost = mkIf cfg.automapping.enable ''
|
||||||
|
require("langmapper").automapping(${toLua cfg.automapping.argument})
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
||||||
48
tests/test-sources/plugins/by-name/langmapper/default.nix
Normal file
48
tests/test-sources/plugins/by-name/langmapper/default.nix
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
{ lib, ... }:
|
||||||
|
{
|
||||||
|
empty = {
|
||||||
|
plugins.langmapper.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
example = {
|
||||||
|
plugins.langmapper = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
settings = {
|
||||||
|
automapping_modes = lib.stringToCharacters "invxs";
|
||||||
|
map_add_ctrl = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
defaults = {
|
||||||
|
plugins.langmapper = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
settings = {
|
||||||
|
map_add_ctrl = true;
|
||||||
|
ctrl_map_modes = lib.stringToCharacters "noictv";
|
||||||
|
hack_keymap = true;
|
||||||
|
disable_hack_modes = lib.stringToCharacters "i";
|
||||||
|
automapping_modes = lib.stringToCharacters "invxs";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
automapping-disabled = {
|
||||||
|
plugins.langmapper.enable = true;
|
||||||
|
plugins.langmapper.automapping.enable = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
automapping-changed = {
|
||||||
|
plugins.langmapper.enable = true;
|
||||||
|
plugins.langmapper.automapping.argument = {
|
||||||
|
buffer = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
automapping-changed-lua = {
|
||||||
|
plugins.langmapper.enable = true;
|
||||||
|
plugins.langmapper.automapping.argument = lib.nixvim.mkRaw "{ buffer = false, global = true }";
|
||||||
|
};
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue