mirror of
https://github.com/NotAShelf/nvf.git
synced 2026-01-06 10:47:15 +00:00
modules: explicit lib usage
This commit is contained in:
parent
9b2e2ef833
commit
caf342adb1
27 changed files with 673 additions and 684 deletions
105
lib/binds.nix
Normal file
105
lib/binds.nix
Normal file
|
|
@ -0,0 +1,105 @@
|
||||||
|
{lib}: let
|
||||||
|
inherit (lib.options) mkOption;
|
||||||
|
inherit (lib.modules) mkIf;
|
||||||
|
inherit (lib.types) nullOr str submodule bool;
|
||||||
|
inherit (lib.attrsets) isAttrs mapAttrs attrsOf;
|
||||||
|
in rec {
|
||||||
|
# mkLuaBinding creates a binding with Lua and silent flags.
|
||||||
|
#
|
||||||
|
# Arguments:
|
||||||
|
# - key: The name of the binding.
|
||||||
|
# - action: The action to be performed when the binding is activated.
|
||||||
|
# - desc: The description of the binding.
|
||||||
|
mkLuaBinding = key: action: desc:
|
||||||
|
mkIf (key != null) {
|
||||||
|
"${key}" = {
|
||||||
|
inherit action desc;
|
||||||
|
lua = true;
|
||||||
|
silent = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# mkExprBinding creates a binding with Lua, silent, and expr flags.
|
||||||
|
#
|
||||||
|
# Arguments:
|
||||||
|
# - key: The name of the binding.
|
||||||
|
# - action: The action to be performed when the binding is activated.
|
||||||
|
# - desc: The description of the binding.
|
||||||
|
mkExprBinding = key: action: desc:
|
||||||
|
mkIf (key != null) {
|
||||||
|
"${key}" = {
|
||||||
|
inherit action desc;
|
||||||
|
lua = true;
|
||||||
|
silent = true;
|
||||||
|
expr = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# mkBinding creates a binding with silent flag.
|
||||||
|
#
|
||||||
|
# Arguments:
|
||||||
|
# - key: The name of the binding.
|
||||||
|
# - action: The action to be performed when the binding is activated.
|
||||||
|
# - desc: The description of the binding.
|
||||||
|
mkBinding = key: action: desc:
|
||||||
|
mkIf (key != null) {
|
||||||
|
"${key}" = {
|
||||||
|
inherit action desc;
|
||||||
|
silent = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# mkMappingOption creates an option that can be null or a string.
|
||||||
|
#
|
||||||
|
# Arguments:
|
||||||
|
# - description: The description of the option.
|
||||||
|
# - default: The default value of the option.
|
||||||
|
mkMappingOption = description: default:
|
||||||
|
mkOption {
|
||||||
|
type = nullOr str;
|
||||||
|
inherit default description;
|
||||||
|
};
|
||||||
|
|
||||||
|
# Utility function that takes two attrsets:
|
||||||
|
# { someKey = "some_value" } and
|
||||||
|
# { someKey = { description = "Some Description"; }; }
|
||||||
|
# and merges them into
|
||||||
|
# { someKey = { value = "some_value"; description = "Some Description"; }; }
|
||||||
|
addDescriptionsToMappings = actualMappings: mappingDefinitions:
|
||||||
|
mapAttrs (name: value: let
|
||||||
|
isNested = isAttrs value;
|
||||||
|
returnedValue =
|
||||||
|
if isNested
|
||||||
|
then addDescriptionsToMappings actualMappings."${name}" mappingDefinitions."${name}"
|
||||||
|
else {
|
||||||
|
inherit value;
|
||||||
|
inherit (mappingDefinitions."${name}") description;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
returnedValue)
|
||||||
|
actualMappings;
|
||||||
|
|
||||||
|
# mkSetBinding creates a binding with the provided action and description.
|
||||||
|
#
|
||||||
|
# Arguments:
|
||||||
|
# - binding: The binding to be set.
|
||||||
|
# - action: The action to be performed when the binding is activated.
|
||||||
|
mkSetBinding = binding: action:
|
||||||
|
mkBinding binding.value action binding.description;
|
||||||
|
|
||||||
|
# mkSetExprBinding creates an expression binding with the provided action and description.
|
||||||
|
#
|
||||||
|
# Arguments:
|
||||||
|
# - binding: The binding to be set.
|
||||||
|
# - action: The action to be performed when the binding is activated.
|
||||||
|
mkSetExprBinding = binding: action:
|
||||||
|
mkExprBinding binding.value action binding.description;
|
||||||
|
|
||||||
|
# mkSetLuaBinding creates a Lua binding with the provided action and description.
|
||||||
|
#
|
||||||
|
# Arguments:
|
||||||
|
# - binding: The binding to be set.
|
||||||
|
# - action: The action to be performed when the binding is activated.
|
||||||
|
mkSetLuaBinding = binding: action:
|
||||||
|
mkLuaBinding binding.value action binding.description;
|
||||||
|
}
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
{lib}: {
|
{lib}: {
|
||||||
modules = import ./modules.nix {inherit lib;};
|
|
||||||
dag = import ./dag.nix {inherit lib;};
|
|
||||||
types = import ./types {inherit lib;};
|
types = import ./types {inherit lib;};
|
||||||
|
|
||||||
|
binds = import ./binds.nix {inherit lib;};
|
||||||
|
dag = import ./dag.nix {inherit lib;};
|
||||||
languages = import ./languages.nix {inherit lib;};
|
languages = import ./languages.nix {inherit lib;};
|
||||||
lua = import ./lua.nix {inherit lib;};
|
lua = import ./lua.nix {inherit lib;};
|
||||||
|
modules = import ./modules.nix {inherit lib;};
|
||||||
vim = import ./vim.nix {inherit lib;};
|
vim = import ./vim.nix {inherit lib;};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,70 +4,9 @@
|
||||||
nixpkgsLib: let
|
nixpkgsLib: let
|
||||||
mkNvimLib = import ./.;
|
mkNvimLib = import ./.;
|
||||||
in
|
in
|
||||||
nixpkgsLib.extend (self: super: rec {
|
nixpkgsLib.extend (self: super: {
|
||||||
nvim = mkNvimLib {lib = self;};
|
nvim = mkNvimLib {lib = self;};
|
||||||
|
|
||||||
mkLuaBinding = key: action: desc:
|
|
||||||
self.mkIf (key != null) {
|
|
||||||
"${key}" = {
|
|
||||||
inherit action desc;
|
|
||||||
lua = true;
|
|
||||||
silent = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
mkExprBinding = key: action: desc:
|
|
||||||
self.mkIf (key != null) {
|
|
||||||
"${key}" = {
|
|
||||||
inherit action desc;
|
|
||||||
lua = true;
|
|
||||||
silent = true;
|
|
||||||
expr = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
mkBinding = key: action: desc:
|
|
||||||
self.mkIf (key != null) {
|
|
||||||
"${key}" = {
|
|
||||||
inherit action desc;
|
|
||||||
silent = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
mkMappingOption = description: default:
|
|
||||||
self.mkOption {
|
|
||||||
type = self.types.nullOr self.types.str;
|
|
||||||
inherit default description;
|
|
||||||
};
|
|
||||||
|
|
||||||
# Utility function that takes two attrsets:
|
|
||||||
# { someKey = "some_value" } and
|
|
||||||
# { someKey = { description = "Some Description"; }; }
|
|
||||||
# and merges them into
|
|
||||||
# { someKey = { value = "some_value"; description = "Some Description"; }; }
|
|
||||||
addDescriptionsToMappings = actualMappings: mappingDefinitions:
|
|
||||||
self.attrsets.mapAttrs (name: value: let
|
|
||||||
isNested = self.isAttrs value;
|
|
||||||
returnedValue =
|
|
||||||
if isNested
|
|
||||||
then addDescriptionsToMappings actualMappings."${name}" mappingDefinitions."${name}"
|
|
||||||
else {
|
|
||||||
value = value;
|
|
||||||
description = mappingDefinitions."${name}".description;
|
|
||||||
};
|
|
||||||
in
|
|
||||||
returnedValue)
|
|
||||||
actualMappings;
|
|
||||||
|
|
||||||
mkSetBinding = binding: action:
|
|
||||||
mkBinding binding.value action binding.description;
|
|
||||||
|
|
||||||
mkSetExprBinding = binding: action:
|
|
||||||
mkExprBinding binding.value action binding.description;
|
|
||||||
|
|
||||||
mkSetLuaBinding = binding: action:
|
|
||||||
mkLuaBinding binding.value action binding.description;
|
|
||||||
|
|
||||||
# For forward compatibility.
|
# For forward compatibility.
|
||||||
literalExpression = super.literalExpression or super.literalExample;
|
literalExpression = super.literalExpression or super.literalExample;
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -39,13 +39,12 @@
|
||||||
|
|
||||||
core = map (p: ./core + "/${p}") [
|
core = map (p: ./core + "/${p}") [
|
||||||
"build"
|
"build"
|
||||||
"mappings"
|
|
||||||
"warnings"
|
"warnings"
|
||||||
];
|
];
|
||||||
|
|
||||||
neovim = map (p: ./neovim + "/${p}") [
|
neovim = map (p: ./neovim + "/${p}") [
|
||||||
"basic"
|
"basic"
|
||||||
"maps"
|
"mappings"
|
||||||
"spellcheck"
|
"spellcheck"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{lib, ...}: let
|
{lib, ...}: let
|
||||||
inherit (lib) mkOption types;
|
inherit (lib.types) submodule str bool attrsOf nullOr;
|
||||||
inherit (lib) nvim;
|
inherit (lib.options) mkOption;
|
||||||
inherit (nvim.modules) mkBoolOption;
|
inherit (lib.nvim.modules) mkBoolOption;
|
||||||
|
|
||||||
# Most of the keybindings code is highly inspired by pta2002/nixvim. Thank you!
|
# Most of the keybindings code is highly inspired by pta2002/nixvim. Thank you!
|
||||||
mapConfigOptions = {
|
mapConfigOptions = {
|
||||||
|
|
@ -30,23 +30,23 @@
|
||||||
"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.";
|
"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.";
|
||||||
|
|
||||||
desc = mkOption {
|
desc = mkOption {
|
||||||
type = types.nullOr types.str;
|
type = nullOr str;
|
||||||
default = null;
|
default = null;
|
||||||
description = "A description of this keybind, to be shown in which-key, if you have it enabled.";
|
description = "A description of this keybind, to be shown in which-key, if you have it enabled.";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
mapOption = types.submodule {
|
mapOption = submodule {
|
||||||
options =
|
options =
|
||||||
mapConfigOptions
|
mapConfigOptions
|
||||||
// {
|
// {
|
||||||
action = mkOption {
|
action = mkOption {
|
||||||
type = types.str;
|
type = str;
|
||||||
description = "The action to execute.";
|
description = "The action to execute.";
|
||||||
};
|
};
|
||||||
|
|
||||||
lua = mkOption {
|
lua = mkOption {
|
||||||
type = types.bool;
|
type = bool;
|
||||||
description = ''
|
description = ''
|
||||||
If true, `action` is considered to be lua code.
|
If true, `action` is considered to be lua code.
|
||||||
Thus, it will not be wrapped in `""`.
|
Thus, it will not be wrapped in `""`.
|
||||||
|
|
@ -59,14 +59,14 @@
|
||||||
mapOptions = mode:
|
mapOptions = mode:
|
||||||
mkOption {
|
mkOption {
|
||||||
description = "Mappings for ${mode} mode";
|
description = "Mappings for ${mode} mode";
|
||||||
type = types.attrsOf mapOption;
|
type = attrsOf mapOption;
|
||||||
default = {};
|
default = {};
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
options = {
|
options = {
|
||||||
vim = {
|
vim = {
|
||||||
maps = mkOption {
|
maps = mkOption {
|
||||||
type = types.submodule {
|
type = submodule {
|
||||||
options = {
|
options = {
|
||||||
normal = mapOptions "normal";
|
normal = mapOptions "normal";
|
||||||
insert = mapOptions "insert";
|
insert = mapOptions "insert";
|
||||||
|
|
@ -1,11 +1,15 @@
|
||||||
{
|
{
|
||||||
pkgs,
|
|
||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (builtins) toJSON;
|
inherit (builtins) toJSON;
|
||||||
inherit (lib) mkIf nvim mkLuaBinding mkMerge;
|
inherit (lib.trivial) boolToString toString;
|
||||||
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
|
inherit (lib.strings) optionalString;
|
||||||
|
inherit (lib.lists) optionals;
|
||||||
|
inherit (lib.nvim.binds) mkLuaBinding;
|
||||||
|
inherit (lib.nvim.dag) entryAnywhere;
|
||||||
|
|
||||||
cfg = config.vim.assistant.copilot;
|
cfg = config.vim.assistant.copilot;
|
||||||
|
|
||||||
|
|
@ -22,69 +26,73 @@
|
||||||
'';
|
'';
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
vim.startPlugins =
|
vim = {
|
||||||
[
|
startPlugins =
|
||||||
"copilot-lua"
|
[
|
||||||
cfg.copilotNodePackage
|
"copilot-lua"
|
||||||
]
|
cfg.copilotNodePackage
|
||||||
++ lib.optionals (cfg.cmp.enable) [
|
]
|
||||||
"copilot-cmp"
|
++ optionals cfg.cmp.enable [
|
||||||
];
|
"copilot-cmp"
|
||||||
|
];
|
||||||
|
|
||||||
vim.luaConfigRC.copilot = nvim.dag.entryAnywhere ''
|
luaConfigRC.copilot = entryAnywhere ''
|
||||||
require("copilot").setup({
|
require("copilot").setup({
|
||||||
-- available options: https://github.com/zbirenbaum/copilot.lua
|
-- available options: https://github.com/zbirenbaum/copilot.lua
|
||||||
copilot_node_command = "${cfg.copilotNodeCommand}",
|
copilot_node_command = "${cfg.copilotNodeCommand}",
|
||||||
panel = {
|
panel = {
|
||||||
enabled = ${lib.boolToString (!cfg.cmp.enable)},
|
enabled = ${boolToString (!cfg.cmp.enable)},
|
||||||
keymap = {
|
keymap = {
|
||||||
jump_prev = false,
|
jump_prev = false,
|
||||||
jump_next = false,
|
jump_next = false,
|
||||||
accept = false,
|
accept = false,
|
||||||
refresh = false,
|
refresh = false,
|
||||||
open = false,
|
open = false,
|
||||||
|
},
|
||||||
|
layout = {
|
||||||
|
position = "${cfg.panel.position}",
|
||||||
|
ratio = ${toString cfg.panel.ratio},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
layout = {
|
suggestion = {
|
||||||
position = "${cfg.panel.position}",
|
enabled = ${boolToString (!cfg.cmp.enable)},
|
||||||
ratio = ${toString cfg.panel.ratio},
|
keymap = {
|
||||||
|
accept = false,
|
||||||
|
accept_word = false,
|
||||||
|
accept_line = false,
|
||||||
|
next = false,
|
||||||
|
prev = false,
|
||||||
|
dismiss = false,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
})
|
||||||
suggestion = {
|
|
||||||
enabled = ${lib.boolToString (!cfg.cmp.enable)},
|
|
||||||
keymap = {
|
|
||||||
accept = false,
|
|
||||||
accept_word = false,
|
|
||||||
accept_line = false,
|
|
||||||
next = false,
|
|
||||||
prev = false,
|
|
||||||
dismiss = false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
${lib.optionalString (cfg.cmp.enable) ''
|
${optionalString cfg.cmp.enable ''
|
||||||
require("copilot_cmp").setup()
|
require("copilot_cmp").setup()
|
||||||
''}
|
''}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
vim.maps.normal = mkMerge [
|
maps = {
|
||||||
(mkLuaBinding cfg.mappings.panel.jumpPrev (wrapPanelBinding "require(\"copilot.panel\").jump_prev" cfg.mappings.panel.jumpPrev) "[copilot] Accept suggestion")
|
normal = mkMerge [
|
||||||
(mkLuaBinding cfg.mappings.panel.jumpNext (wrapPanelBinding "require(\"copilot.panel\").jump_next" cfg.mappings.panel.jumpNext) "[copilot] Accept suggestion")
|
(mkLuaBinding cfg.mappings.panel.jumpPrev (wrapPanelBinding "require(\"copilot.panel\").jump_prev" cfg.mappings.panel.jumpPrev) "[copilot] Accept suggestion")
|
||||||
(mkLuaBinding cfg.mappings.panel.accept (wrapPanelBinding ''require("copilot.panel").accept'' cfg.mappings.panel.accept) "[copilot] Accept suggestion")
|
(mkLuaBinding cfg.mappings.panel.jumpNext (wrapPanelBinding "require(\"copilot.panel\").jump_next" cfg.mappings.panel.jumpNext) "[copilot] Accept suggestion")
|
||||||
(mkLuaBinding cfg.mappings.panel.refresh (wrapPanelBinding "require(\"copilot.panel\").refresh" cfg.mappings.panel.refresh) "[copilot] Accept suggestion")
|
(mkLuaBinding cfg.mappings.panel.accept (wrapPanelBinding ''require("copilot.panel").accept'' cfg.mappings.panel.accept) "[copilot] Accept suggestion")
|
||||||
(mkLuaBinding cfg.mappings.panel.open (wrapPanelBinding ''
|
(mkLuaBinding cfg.mappings.panel.refresh (wrapPanelBinding "require(\"copilot.panel\").refresh" cfg.mappings.panel.refresh) "[copilot] Accept suggestion")
|
||||||
function() require("copilot.panel").open({ position = "${cfg.panel.position}", ratio = ${toString cfg.panel.ratio}, }) end
|
(mkLuaBinding cfg.mappings.panel.open (wrapPanelBinding ''
|
||||||
''
|
function() require("copilot.panel").open({ position = "${cfg.panel.position}", ratio = ${toString cfg.panel.ratio}, }) end
|
||||||
cfg.mappings.panel.open) "[copilot] Accept suggestion")
|
''
|
||||||
];
|
cfg.mappings.panel.open) "[copilot] Accept suggestion")
|
||||||
|
];
|
||||||
|
|
||||||
vim.maps.insert = mkMerge [
|
insert = mkMerge [
|
||||||
(mkLuaBinding cfg.mappings.suggestion.accept "require(\"copilot.suggestion\").accept" "[copilot] Accept suggestion")
|
(mkLuaBinding cfg.mappings.suggestion.accept "require(\"copilot.suggestion\").accept" "[copilot] Accept suggestion")
|
||||||
(mkLuaBinding cfg.mappings.suggestion.acceptLine "require(\"copilot.suggestion\").accept_line" "[copilot] Accept suggestion (line)")
|
(mkLuaBinding cfg.mappings.suggestion.acceptLine "require(\"copilot.suggestion\").accept_line" "[copilot] Accept suggestion (line)")
|
||||||
(mkLuaBinding cfg.mappings.suggestion.acceptWord "require(\"copilot.suggestion\").accept_word" "[copilot] Accept suggestion (word)")
|
(mkLuaBinding cfg.mappings.suggestion.acceptWord "require(\"copilot.suggestion\").accept_word" "[copilot] Accept suggestion (word)")
|
||||||
(mkLuaBinding cfg.mappings.suggestion.next "require(\"copilot.suggestion\").next" "[copilot] next suggestion")
|
(mkLuaBinding cfg.mappings.suggestion.next "require(\"copilot.suggestion\").next" "[copilot] next suggestion")
|
||||||
(mkLuaBinding cfg.mappings.suggestion.prev "require(\"copilot.suggestion\").prev" "[copilot] previous suggestion")
|
(mkLuaBinding cfg.mappings.suggestion.prev "require(\"copilot.suggestion\").prev" "[copilot] previous suggestion")
|
||||||
(mkLuaBinding cfg.mappings.suggestion.dismiss "require(\"copilot.suggestion\").dismiss" "[copilot] dismiss suggestion")
|
(mkLuaBinding cfg.mappings.suggestion.dismiss "require(\"copilot.suggestion\").dismiss" "[copilot] dismiss suggestion")
|
||||||
];
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,9 @@
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib) mkEnableOption mkOption types;
|
inherit (lib.types) enum float nullOr package str;
|
||||||
|
inherit (lib.options) mkOption mkEnableOption;
|
||||||
|
inherit (lib.meta) getExe;
|
||||||
|
|
||||||
cfg = config.vim.assistant.copilot;
|
cfg = config.vim.assistant.copilot;
|
||||||
in {
|
in {
|
||||||
|
|
@ -14,7 +16,7 @@ in {
|
||||||
|
|
||||||
panel = {
|
panel = {
|
||||||
position = mkOption {
|
position = mkOption {
|
||||||
type = types.enum [
|
type = enum [
|
||||||
"bottom"
|
"bottom"
|
||||||
"top"
|
"top"
|
||||||
"left"
|
"left"
|
||||||
|
|
@ -24,7 +26,7 @@ in {
|
||||||
description = "Panel position";
|
description = "Panel position";
|
||||||
};
|
};
|
||||||
ratio = mkOption {
|
ratio = mkOption {
|
||||||
type = types.float;
|
type = float;
|
||||||
default = 0.4;
|
default = 0.4;
|
||||||
description = "Panel size";
|
description = "Panel size";
|
||||||
};
|
};
|
||||||
|
|
@ -33,81 +35,81 @@ in {
|
||||||
mappings = {
|
mappings = {
|
||||||
panel = {
|
panel = {
|
||||||
jumpPrev = mkOption {
|
jumpPrev = mkOption {
|
||||||
type = types.nullOr types.str;
|
type = nullOr str;
|
||||||
default = "[[";
|
default = "[[";
|
||||||
description = "Jump to previous suggestion";
|
description = "Jump to previous suggestion";
|
||||||
};
|
};
|
||||||
jumpNext = mkOption {
|
jumpNext = mkOption {
|
||||||
type = types.nullOr types.str;
|
type = nullOr str;
|
||||||
default = "]]";
|
default = "]]";
|
||||||
description = "Jump to next suggestion";
|
description = "Jump to next suggestion";
|
||||||
};
|
};
|
||||||
accept = mkOption {
|
accept = mkOption {
|
||||||
type = types.nullOr types.str;
|
type = nullOr str;
|
||||||
default = "<CR>";
|
default = "<CR>";
|
||||||
description = "Accept suggestion";
|
description = "Accept suggestion";
|
||||||
};
|
};
|
||||||
refresh = mkOption {
|
refresh = mkOption {
|
||||||
type = types.nullOr types.str;
|
type = nullOr str;
|
||||||
default = "gr";
|
default = "gr";
|
||||||
description = "Refresh suggestions";
|
description = "Refresh suggestions";
|
||||||
};
|
};
|
||||||
open = mkOption {
|
open = mkOption {
|
||||||
type = types.nullOr types.str;
|
type = nullOr str;
|
||||||
default = "<M-CR>";
|
default = "<M-CR>";
|
||||||
description = "Open suggestions";
|
description = "Open suggestions";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
suggestion = {
|
suggestion = {
|
||||||
accept = mkOption {
|
accept = mkOption {
|
||||||
type = types.nullOr types.str;
|
type = nullOr str;
|
||||||
default = "<M-l>";
|
default = "<M-l>";
|
||||||
description = "Accept suggetion";
|
description = "Accept suggetion";
|
||||||
};
|
};
|
||||||
acceptWord = mkOption {
|
acceptWord = mkOption {
|
||||||
type = types.nullOr types.str;
|
type = nullOr str;
|
||||||
default = null;
|
default = null;
|
||||||
description = "Accept next word";
|
description = "Accept next word";
|
||||||
};
|
};
|
||||||
acceptLine = mkOption {
|
acceptLine = mkOption {
|
||||||
type = types.nullOr types.str;
|
type = nullOr str;
|
||||||
default = null;
|
default = null;
|
||||||
description = "Accept next line";
|
description = "Accept next line";
|
||||||
};
|
};
|
||||||
prev = mkOption {
|
prev = mkOption {
|
||||||
type = types.nullOr types.str;
|
type = nullOr str;
|
||||||
default = "<M-[>";
|
default = "<M-[>";
|
||||||
description = "Previous suggestion";
|
description = "Previous suggestion";
|
||||||
};
|
};
|
||||||
next = mkOption {
|
next = mkOption {
|
||||||
type = types.nullOr types.str;
|
type = nullOr str;
|
||||||
default = "<M-]>";
|
default = "<M-]>";
|
||||||
description = "Next suggestion";
|
description = "Next suggestion";
|
||||||
};
|
};
|
||||||
dismiss = mkOption {
|
dismiss = mkOption {
|
||||||
type = types.nullOr types.str;
|
type = nullOr str;
|
||||||
default = "<C-]>";
|
default = "<C-]>";
|
||||||
description = "Dismiss suggestion";
|
description = "Dismiss suggestion";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
copilotNodeCommand = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
default = "${lib.getExe cfg.copilotNodePackage}";
|
|
||||||
description = ''
|
|
||||||
The command that will be executed to initiate nodejs for GitHub Copilot.
|
|
||||||
Recommended to leave as default.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
copilotNodePackage = mkOption {
|
copilotNodePackage = mkOption {
|
||||||
type = with types; nullOr package;
|
type = nullOr package;
|
||||||
default = pkgs.nodejs-slim;
|
default = pkgs.nodejs-slim;
|
||||||
description = ''
|
description = ''
|
||||||
The nodeJS package that will be used for GitHub Copilot. If you are using a custom node command
|
The nodeJS package that will be used for GitHub Copilot. If you are using a custom node command
|
||||||
you may want to set this option to null so that the package is not pulled from nixpkgs.
|
you may want to set this option to null so that the package is not pulled from nixpkgs.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
copilotNodeCommand = mkOption {
|
||||||
|
type = str;
|
||||||
|
default = "${getExe cfg.copilotNodePackage}";
|
||||||
|
description = ''
|
||||||
|
The command that will be executed to initiate nodejs for GitHub Copilot.
|
||||||
|
Recommended to leave as default.
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
_: {
|
{
|
||||||
imports = [
|
imports = [
|
||||||
./copilot
|
./copilot
|
||||||
# ./tabnine.nix # removed until I find a way around the initialisation script the plugin requires
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,54 +0,0 @@
|
||||||
{
|
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
...
|
|
||||||
}: let
|
|
||||||
inherit (builtins) toJSON;
|
|
||||||
inherit (lib) mkIf mkMerge mkExprBinding boolToString nvim;
|
|
||||||
|
|
||||||
cfg = config.vim.assistant.tabnine;
|
|
||||||
in {
|
|
||||||
config = mkIf cfg.enable {
|
|
||||||
vim.startPlugins = ["tabnine-nvim"];
|
|
||||||
|
|
||||||
vim.maps.insert = mkMerge [
|
|
||||||
(mkExprBinding cfg.mappings.accept ''
|
|
||||||
function()
|
|
||||||
local state = require("tabnine.state")
|
|
||||||
local completion = require("tabnine.completion")
|
|
||||||
|
|
||||||
if not state.completions_cache then
|
|
||||||
return "${toJSON cfg.mappings.accept}"
|
|
||||||
end
|
|
||||||
|
|
||||||
vim.schedule(completion.accept)
|
|
||||||
end
|
|
||||||
'' "orzel")
|
|
||||||
(mkExprBinding cfg.mappings.dismiss ''
|
|
||||||
function()
|
|
||||||
local state = require("tabnine.state")
|
|
||||||
local completion = require("tabnine.completion")
|
|
||||||
|
|
||||||
if not state.completions_cache then
|
|
||||||
return "${toJSON cfg.mappings.dismiss}"
|
|
||||||
end
|
|
||||||
|
|
||||||
vim.schedule(function()
|
|
||||||
completion.clear()
|
|
||||||
state.completions_cache = nil
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
'' "orzel")
|
|
||||||
];
|
|
||||||
|
|
||||||
vim.luaConfigRC.tabnine-nvim = nvim.dag.entryAnywhere ''
|
|
||||||
require('tabnine').setup({
|
|
||||||
disable_auto_comment = ${boolToString cfg.disable_auto_comment},
|
|
||||||
accept_keymap = null,
|
|
||||||
dismiss_keymap = null,
|
|
||||||
debounce_ms = ${cfg.debounce_ms},
|
|
||||||
exclude_filetypes = ${cfg.exclude_filetypes},
|
|
||||||
})
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
_: {
|
|
||||||
imports = [
|
|
||||||
./config.nix
|
|
||||||
./tabnine.nix
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
{lib, ...}: let
|
|
||||||
inherit (lib) mkEnableOption mkOption types mkMappingOption;
|
|
||||||
in {
|
|
||||||
options.vim.assistant.tabnine = {
|
|
||||||
enable = mkEnableOption "Tabnine assistant";
|
|
||||||
|
|
||||||
disable_auto_comment = mkOption {
|
|
||||||
type = types.bool;
|
|
||||||
default = true;
|
|
||||||
description = "Disable auto comment";
|
|
||||||
};
|
|
||||||
|
|
||||||
mappings = {
|
|
||||||
accept = mkMappingOption "Accept [Tabnine]" "<Tab>";
|
|
||||||
dismiss = mkMappingOption "Dismiss [Tabnine]" "<C-]>";
|
|
||||||
};
|
|
||||||
|
|
||||||
debounce_ms = mkOption {
|
|
||||||
type = types.int;
|
|
||||||
default = 800;
|
|
||||||
description = "Debounce ms";
|
|
||||||
};
|
|
||||||
|
|
||||||
exclude_filetypes = mkOption {
|
|
||||||
type = types.listOf types.str;
|
|
||||||
default = ["TelescopePrompt" "NvimTree" "alpha"];
|
|
||||||
description = "Exclude filetypes";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
_: {
|
{
|
||||||
imports = [
|
imports = [
|
||||||
./nvim-autopairs
|
./nvim-autopairs
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,20 @@
|
||||||
{
|
{
|
||||||
lib,
|
|
||||||
config,
|
config,
|
||||||
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib) mkIf nvim optionalString boolToString;
|
inherit (lib.strings) optionalString;
|
||||||
|
inherit (lib.trivial) boolToString;
|
||||||
|
inherit (lib.modules) mkIf;
|
||||||
|
inherit (lib.nvim.dag) entryAnywhere;
|
||||||
|
|
||||||
cfg = config.vim.autopairs;
|
cfg = config.vim.autopairs;
|
||||||
in {
|
in {
|
||||||
config =
|
config = mkIf cfg.enable {
|
||||||
mkIf (cfg.enable)
|
vim = {
|
||||||
{
|
startPlugins = ["nvim-autopairs"];
|
||||||
vim.startPlugins = ["nvim-autopairs"];
|
|
||||||
|
|
||||||
vim.luaConfigRC.autopairs = nvim.dag.entryAnywhere ''
|
luaConfigRC.autopairs = entryAnywhere ''
|
||||||
require("nvim-autopairs").setup{}
|
require("nvim-autopairs").setup{}
|
||||||
${optionalString (config.vim.autocomplete.type == "nvim-compe") ''
|
${optionalString (config.vim.autocomplete.type == "nvim-compe") ''
|
||||||
require('nvim-autopairs.completion.compe').setup({
|
require('nvim-autopairs.completion.compe').setup({
|
||||||
|
|
@ -23,4 +25,5 @@ in {
|
||||||
''}
|
''}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
_: {
|
{
|
||||||
imports = [
|
imports = [
|
||||||
./config.nix
|
./config.nix
|
||||||
./nvim-autopairs.nix
|
./nvim-autopairs.nix
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,37 @@
|
||||||
{lib, ...}: let
|
{lib, ...}: let
|
||||||
inherit (lib) mkEnableOption mkOption types;
|
inherit (lib.options) mkEnableOption mkOption;
|
||||||
|
inherit (lib.tyoes) enum bool;
|
||||||
in {
|
in {
|
||||||
options.vim = {
|
options.vim = {
|
||||||
autopairs = {
|
autopairs = {
|
||||||
enable = mkEnableOption "autopairs" // {default = false;};
|
enable = mkEnableOption "autopairs";
|
||||||
|
|
||||||
type = mkOption {
|
type = mkOption {
|
||||||
type = types.enum ["nvim-autopairs"];
|
type = enum ["nvim-autopairs"];
|
||||||
default = "nvim-autopairs";
|
default = "nvim-autopairs";
|
||||||
description = "Set the autopairs type. Options: nvim-autopairs [nvim-autopairs]";
|
description = ''
|
||||||
|
Set the autopairs type.
|
||||||
|
|
||||||
|
Options:
|
||||||
|
- nvim-autopairs [nvim-autopairs]
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
nvim-compe = {
|
nvim-compe = {
|
||||||
map_cr = mkOption {
|
map_cr = mkOption {
|
||||||
type = types.bool;
|
type = bool;
|
||||||
default = true;
|
default = true;
|
||||||
description = ''map <CR> on insert mode'';
|
description = ''map <CR> on insert mode'';
|
||||||
};
|
};
|
||||||
|
|
||||||
map_complete = mkOption {
|
map_complete = mkOption {
|
||||||
type = types.bool;
|
type = bool;
|
||||||
default = true;
|
default = true;
|
||||||
description = "auto insert `(` after select function or method item";
|
description = "auto insert `(` after select function or method item";
|
||||||
};
|
};
|
||||||
|
|
||||||
auto_select = mkOption {
|
auto_select = mkOption {
|
||||||
type = types.bool;
|
type = bool;
|
||||||
default = false;
|
default = false;
|
||||||
description = "auto select first item";
|
description = "auto select first item";
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
{lib, ...}: let
|
{lib, ...}: let
|
||||||
inherit (lib) mkEnableOption mkMappingOption;
|
inherit (lib.options) mkEnableOption;
|
||||||
|
inherit (lib.nvim.binds) mkMappingOption;
|
||||||
in {
|
in {
|
||||||
options.vim.comments.comment-nvim = {
|
options.vim.comments.comment-nvim = {
|
||||||
enable = mkEnableOption "smart and powerful comment plugin for neovim comment-nvim";
|
enable = mkEnableOption "smart and powerful comment plugin for neovim [comment-nvim]";
|
||||||
|
|
||||||
mappings = {
|
mappings = {
|
||||||
toggleCurrentLine = mkMappingOption "Toggle current line comment" "gcc";
|
toggleCurrentLine = mkMappingOption "Toggle current line comment" "gcc";
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
_: {
|
{
|
||||||
imports = [
|
imports = [
|
||||||
./comment-nvim
|
./comment-nvim
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
_: {
|
{
|
||||||
imports = [
|
imports = [
|
||||||
./nvim-cmp
|
./nvim-cmp
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,11 @@
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (builtins) toJSON;
|
inherit (builtins) toJSON;
|
||||||
inherit (lib) addDescriptionsToMappings concatMapStringsSep attrNames concatStringsSep mapAttrsToList mkIf mkSetLuaBinding mkMerge optionalString;
|
inherit (lib.binds) addDescriptionsToMappings mkSetLuaBinding;
|
||||||
inherit (lib.nvim) dag;
|
inherit (lib.strings) concatMapStringsSep concatStringsSep optionalString;
|
||||||
|
inherit (lib.attrsets) attrNames mapAttrsToList;
|
||||||
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
|
inherit (lib.nvim.dag) entryAfter entryAnywhere;
|
||||||
|
|
||||||
cfg = config.vim.autocomplete;
|
cfg = config.vim.autocomplete;
|
||||||
lspkindEnabled = config.vim.lsp.enable && config.vim.lsp.lspkind.enable;
|
lspkindEnabled = config.vim.lsp.enable && config.vim.lsp.lspkind.enable;
|
||||||
|
|
@ -33,209 +36,213 @@
|
||||||
|
|
||||||
dagPlacement =
|
dagPlacement =
|
||||||
if lspkindEnabled
|
if lspkindEnabled
|
||||||
then dag.entryAfter ["lspkind"]
|
then entryAfter ["lspkind"]
|
||||||
else dag.entryAnywhere;
|
else entryAnywhere;
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
vim.startPlugins = [
|
vim = {
|
||||||
"nvim-cmp"
|
startPlugins = [
|
||||||
"cmp-buffer"
|
"nvim-cmp"
|
||||||
"cmp-vsnip"
|
"cmp-buffer"
|
||||||
"cmp-path"
|
"cmp-vsnip"
|
||||||
"vim-vsnip"
|
"cmp-path"
|
||||||
];
|
"vim-vsnip"
|
||||||
|
];
|
||||||
|
|
||||||
vim.autocomplete.sources = {
|
autocomplete.sources = {
|
||||||
"nvim-cmp" = null;
|
"nvim-cmp" = null;
|
||||||
"vsnip" = "[VSnip]";
|
"vsnip" = "[VSnip]";
|
||||||
"buffer" = "[Buffer]";
|
"buffer" = "[Buffer]";
|
||||||
"crates" = "[Crates]";
|
"crates" = "[Crates]";
|
||||||
"path" = "[Path]";
|
"path" = "[Path]";
|
||||||
"copilot" = "[Copilot]";
|
"copilot" = "[Copilot]";
|
||||||
|
};
|
||||||
|
|
||||||
|
maps = {
|
||||||
|
insert = mkMerge [
|
||||||
|
(mkSetLuaBinding mappings.complete ''
|
||||||
|
require('cmp').complete
|
||||||
|
'')
|
||||||
|
(mkSetLuaBinding mappings.confirm ''
|
||||||
|
function()
|
||||||
|
if not require('cmp').confirm({ select = true }) then
|
||||||
|
local termcode = vim.api.nvim_replace_termcodes(${toJSON mappings.confirm.value}, true, false, true)
|
||||||
|
|
||||||
|
vim.fn.feedkeys(termcode, 'n')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
'')
|
||||||
|
(mkSetLuaBinding mappings.next ''
|
||||||
|
function()
|
||||||
|
local has_words_before = function()
|
||||||
|
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||||
|
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local cmp = require('cmp')
|
||||||
|
|
||||||
|
local feedkey = function(key, mode)
|
||||||
|
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
|
||||||
|
end
|
||||||
|
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_next_item()
|
||||||
|
elseif vim.fn['vsnip#available'](1) == 1 then
|
||||||
|
feedkey("<Plug>(vsnip-expand-or-jump)", "")
|
||||||
|
elseif has_words_before() then
|
||||||
|
cmp.complete()
|
||||||
|
else
|
||||||
|
local termcode = vim.api.nvim_replace_termcodes(${toJSON mappings.next.value}, true, false, true)
|
||||||
|
|
||||||
|
vim.fn.feedkeys(termcode, 'n')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
'')
|
||||||
|
(mkSetLuaBinding mappings.previous ''
|
||||||
|
function()
|
||||||
|
local cmp = require('cmp')
|
||||||
|
|
||||||
|
local feedkey = function(key, mode)
|
||||||
|
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
|
||||||
|
end
|
||||||
|
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_prev_item()
|
||||||
|
elseif vim.fn['vsnip#available'](-1) == 1 then
|
||||||
|
feedkeys("<Plug>(vsnip-jump-prev)", "")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
'')
|
||||||
|
(mkSetLuaBinding mappings.close ''
|
||||||
|
require('cmp').mapping.abort()
|
||||||
|
'')
|
||||||
|
(mkSetLuaBinding mappings.scrollDocsUp ''
|
||||||
|
require('cmp').mapping.scroll_docs(-4)
|
||||||
|
'')
|
||||||
|
(mkSetLuaBinding mappings.scrollDocsDown ''
|
||||||
|
require('cmp').mapping.scroll_docs(4)
|
||||||
|
'')
|
||||||
|
];
|
||||||
|
|
||||||
|
command = mkMerge [
|
||||||
|
(mkSetLuaBinding mappings.complete ''
|
||||||
|
require('cmp').complete
|
||||||
|
'')
|
||||||
|
(mkSetLuaBinding mappings.close ''
|
||||||
|
require('cmp').mapping.close()
|
||||||
|
'')
|
||||||
|
(mkSetLuaBinding mappings.scrollDocsUp ''
|
||||||
|
require('cmp').mapping.scroll_docs(-4)
|
||||||
|
'')
|
||||||
|
(mkSetLuaBinding mappings.scrollDocsDown ''
|
||||||
|
require('cmp').mapping.scroll_docs(4)
|
||||||
|
'')
|
||||||
|
];
|
||||||
|
|
||||||
|
select = mkMerge [
|
||||||
|
(mkSetLuaBinding mappings.next ''
|
||||||
|
function()
|
||||||
|
local cmp = require('cmp')
|
||||||
|
local has_words_before = function()
|
||||||
|
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||||
|
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local feedkey = function(key, mode)
|
||||||
|
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
|
||||||
|
end
|
||||||
|
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_next_item()
|
||||||
|
elseif vim.fn['vsnip#available'](1) == 1 then
|
||||||
|
feedkey("<Plug>(vsnip-expand-or-jump)", "")
|
||||||
|
elseif has_words_before() then
|
||||||
|
cmp.complete()
|
||||||
|
else
|
||||||
|
local termcode = vim.api.nvim_replace_termcodes(${toJSON mappings.next.value}, true, false, true)
|
||||||
|
|
||||||
|
vim.fn.feedkeys(termcode, 'n')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
'')
|
||||||
|
(mkSetLuaBinding mappings.previous ''
|
||||||
|
function()
|
||||||
|
local cmp = require('cmp')
|
||||||
|
|
||||||
|
local feedkey = function(key, mode)
|
||||||
|
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
|
||||||
|
end
|
||||||
|
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_prev_item()
|
||||||
|
elseif vim.fn['vsnip#available'](-1) == 1 then
|
||||||
|
feedkeys("<Plug>(vsnip-jump-prev)", "")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
'')
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
# TODO: alternative snippet engines to vsnip
|
||||||
|
# https://github.com/hrsh7th/nvim-cmp/blob/main/doc/cmp.txt#L82
|
||||||
|
luaConfigRC.completion = mkIf (cfg.type == "nvim-cmp") (dagPlacement ''
|
||||||
|
local nvim_cmp_menu_map = function(entry, vim_item)
|
||||||
|
-- name for each source
|
||||||
|
vim_item.menu = ({
|
||||||
|
${builtMaps}
|
||||||
|
})[entry.source.name]
|
||||||
|
print(vim_item.menu)
|
||||||
|
return vim_item
|
||||||
|
end
|
||||||
|
|
||||||
|
${optionalString lspkindEnabled ''
|
||||||
|
lspkind_opts.before = ${cfg.formatting.format}
|
||||||
|
''}
|
||||||
|
|
||||||
|
local cmp = require'cmp'
|
||||||
|
cmp.setup({
|
||||||
|
${optionalString config.vim.ui.borders.enable ''
|
||||||
|
-- explicitly enabled by setting ui.borders.enable = true
|
||||||
|
-- TODO: try to get nvim-cmp to follow global border style
|
||||||
|
window = {
|
||||||
|
completion = cmp.config.window.bordered(),
|
||||||
|
documentation = cmp.config.window.bordered(),
|
||||||
|
},
|
||||||
|
''}
|
||||||
|
|
||||||
|
snippet = {
|
||||||
|
expand = function(args)
|
||||||
|
vim.fn["vsnip#anonymous"](args.body)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
|
sources = {
|
||||||
|
${builtSources}
|
||||||
|
},
|
||||||
|
|
||||||
|
completion = {
|
||||||
|
completeopt = 'menu,menuone,noinsert',
|
||||||
|
},
|
||||||
|
|
||||||
|
formatting = {
|
||||||
|
format =
|
||||||
|
${
|
||||||
|
if lspkindEnabled
|
||||||
|
then "lspkind.cmp_format(lspkind_opts)"
|
||||||
|
else cfg.formatting.format
|
||||||
|
},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
${optionalString (config.vim.autopairs.enable && config.vim.autopairs.type == "nvim-autopairs") ''
|
||||||
|
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
|
||||||
|
cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done({ map_char = { text = ""} }))
|
||||||
|
''}
|
||||||
|
'');
|
||||||
|
|
||||||
|
snippets.vsnip.enable =
|
||||||
|
if (cfg.type == "nvim-cmp")
|
||||||
|
then true
|
||||||
|
else config.vim.snippets.vsnip.enable;
|
||||||
};
|
};
|
||||||
|
|
||||||
vim.maps.insert = mkMerge [
|
|
||||||
(mkSetLuaBinding mappings.complete ''
|
|
||||||
require('cmp').complete
|
|
||||||
'')
|
|
||||||
(mkSetLuaBinding mappings.confirm ''
|
|
||||||
function()
|
|
||||||
if not require('cmp').confirm({ select = true }) then
|
|
||||||
local termcode = vim.api.nvim_replace_termcodes(${toJSON mappings.confirm.value}, true, false, true)
|
|
||||||
|
|
||||||
vim.fn.feedkeys(termcode, 'n')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
'')
|
|
||||||
(mkSetLuaBinding mappings.next ''
|
|
||||||
function()
|
|
||||||
local has_words_before = function()
|
|
||||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
|
||||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
|
||||||
end
|
|
||||||
|
|
||||||
local cmp = require('cmp')
|
|
||||||
|
|
||||||
local feedkey = function(key, mode)
|
|
||||||
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
|
|
||||||
end
|
|
||||||
|
|
||||||
if cmp.visible() then
|
|
||||||
cmp.select_next_item()
|
|
||||||
elseif vim.fn['vsnip#available'](1) == 1 then
|
|
||||||
feedkey("<Plug>(vsnip-expand-or-jump)", "")
|
|
||||||
elseif has_words_before() then
|
|
||||||
cmp.complete()
|
|
||||||
else
|
|
||||||
local termcode = vim.api.nvim_replace_termcodes(${toJSON mappings.next.value}, true, false, true)
|
|
||||||
|
|
||||||
vim.fn.feedkeys(termcode, 'n')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
'')
|
|
||||||
(mkSetLuaBinding mappings.previous ''
|
|
||||||
function()
|
|
||||||
local cmp = require('cmp')
|
|
||||||
|
|
||||||
local feedkey = function(key, mode)
|
|
||||||
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
|
|
||||||
end
|
|
||||||
|
|
||||||
if cmp.visible() then
|
|
||||||
cmp.select_prev_item()
|
|
||||||
elseif vim.fn['vsnip#available'](-1) == 1 then
|
|
||||||
feedkeys("<Plug>(vsnip-jump-prev)", "")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
'')
|
|
||||||
(mkSetLuaBinding mappings.close ''
|
|
||||||
require('cmp').mapping.abort()
|
|
||||||
'')
|
|
||||||
(mkSetLuaBinding mappings.scrollDocsUp ''
|
|
||||||
require('cmp').mapping.scroll_docs(-4)
|
|
||||||
'')
|
|
||||||
(mkSetLuaBinding mappings.scrollDocsDown ''
|
|
||||||
require('cmp').mapping.scroll_docs(4)
|
|
||||||
'')
|
|
||||||
];
|
|
||||||
|
|
||||||
vim.maps.command = mkMerge [
|
|
||||||
(mkSetLuaBinding mappings.complete ''
|
|
||||||
require('cmp').complete
|
|
||||||
'')
|
|
||||||
(mkSetLuaBinding mappings.close ''
|
|
||||||
require('cmp').mapping.close()
|
|
||||||
'')
|
|
||||||
(mkSetLuaBinding mappings.scrollDocsUp ''
|
|
||||||
require('cmp').mapping.scroll_docs(-4)
|
|
||||||
'')
|
|
||||||
(mkSetLuaBinding mappings.scrollDocsDown ''
|
|
||||||
require('cmp').mapping.scroll_docs(4)
|
|
||||||
'')
|
|
||||||
];
|
|
||||||
|
|
||||||
vim.maps.select = mkMerge [
|
|
||||||
(mkSetLuaBinding mappings.next ''
|
|
||||||
function()
|
|
||||||
local cmp = require('cmp')
|
|
||||||
local has_words_before = function()
|
|
||||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
|
||||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
|
||||||
end
|
|
||||||
|
|
||||||
local feedkey = function(key, mode)
|
|
||||||
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
|
|
||||||
end
|
|
||||||
|
|
||||||
if cmp.visible() then
|
|
||||||
cmp.select_next_item()
|
|
||||||
elseif vim.fn['vsnip#available'](1) == 1 then
|
|
||||||
feedkey("<Plug>(vsnip-expand-or-jump)", "")
|
|
||||||
elseif has_words_before() then
|
|
||||||
cmp.complete()
|
|
||||||
else
|
|
||||||
local termcode = vim.api.nvim_replace_termcodes(${toJSON mappings.next.value}, true, false, true)
|
|
||||||
|
|
||||||
vim.fn.feedkeys(termcode, 'n')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
'')
|
|
||||||
(mkSetLuaBinding mappings.previous ''
|
|
||||||
function()
|
|
||||||
local cmp = require('cmp')
|
|
||||||
|
|
||||||
local feedkey = function(key, mode)
|
|
||||||
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
|
|
||||||
end
|
|
||||||
|
|
||||||
if cmp.visible() then
|
|
||||||
cmp.select_prev_item()
|
|
||||||
elseif vim.fn['vsnip#available'](-1) == 1 then
|
|
||||||
feedkeys("<Plug>(vsnip-jump-prev)", "")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
'')
|
|
||||||
];
|
|
||||||
|
|
||||||
# TODO: alternative snippet engines to vsnip
|
|
||||||
# https://github.com/hrsh7th/nvim-cmp/blob/main/doc/cmp.txt#L82
|
|
||||||
vim.luaConfigRC.completion = mkIf (cfg.type == "nvim-cmp") (dagPlacement ''
|
|
||||||
local nvim_cmp_menu_map = function(entry, vim_item)
|
|
||||||
-- name for each source
|
|
||||||
vim_item.menu = ({
|
|
||||||
${builtMaps}
|
|
||||||
})[entry.source.name]
|
|
||||||
print(vim_item.menu)
|
|
||||||
return vim_item
|
|
||||||
end
|
|
||||||
|
|
||||||
${optionalString lspkindEnabled ''
|
|
||||||
lspkind_opts.before = ${cfg.formatting.format}
|
|
||||||
''}
|
|
||||||
|
|
||||||
local cmp = require'cmp'
|
|
||||||
cmp.setup({
|
|
||||||
${optionalString (config.vim.ui.borders.enable) ''
|
|
||||||
-- explicitly enabled by setting ui.borders.enable = true
|
|
||||||
-- TODO: try to get nvim-cmp to follow global border style
|
|
||||||
window = {
|
|
||||||
completion = cmp.config.window.bordered(),
|
|
||||||
documentation = cmp.config.window.bordered(),
|
|
||||||
},
|
|
||||||
''}
|
|
||||||
|
|
||||||
snippet = {
|
|
||||||
expand = function(args)
|
|
||||||
vim.fn["vsnip#anonymous"](args.body)
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
|
|
||||||
sources = {
|
|
||||||
${builtSources}
|
|
||||||
},
|
|
||||||
|
|
||||||
completion = {
|
|
||||||
completeopt = 'menu,menuone,noinsert',
|
|
||||||
},
|
|
||||||
|
|
||||||
formatting = {
|
|
||||||
format =
|
|
||||||
${
|
|
||||||
if lspkindEnabled
|
|
||||||
then "lspkind.cmp_format(lspkind_opts)"
|
|
||||||
else cfg.formatting.format
|
|
||||||
},
|
|
||||||
}
|
|
||||||
})
|
|
||||||
${optionalString (config.vim.autopairs.enable && config.vim.autopairs.type == "nvim-autopairs") ''
|
|
||||||
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
|
|
||||||
cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done({ map_char = { text = ""} }))
|
|
||||||
''}
|
|
||||||
'');
|
|
||||||
|
|
||||||
vim.snippets.vsnip.enable =
|
|
||||||
if (cfg.type == "nvim-cmp")
|
|
||||||
then true
|
|
||||||
else config.vim.snippets.vsnip.enable;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
_: {
|
{
|
||||||
imports = [
|
imports = [
|
||||||
./config.nix
|
./config.nix
|
||||||
./nvim-cmp.nix
|
./nvim-cmp.nix
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
{lib, ...}: let
|
{lib, ...}: let
|
||||||
inherit (lib) mkEnableOption mkMappingOption mkOption types;
|
inherit (lib.types) enum nullOr attrsOf str;
|
||||||
|
inherit (lib) mkEnableOption mkMappingOption mkOption;
|
||||||
in {
|
in {
|
||||||
options.vim = {
|
options.vim = {
|
||||||
autocomplete = {
|
autocomplete = {
|
||||||
enable = mkEnableOption "enable autocomplete" // {default = false;};
|
enable = mkEnableOption "enable autocomplete";
|
||||||
|
|
||||||
mappings = {
|
mappings = {
|
||||||
complete = mkMappingOption "Complete [nvim-cmp]" "<C-Space>";
|
complete = mkMappingOption "Complete [nvim-cmp]" "<C-Space>";
|
||||||
|
|
@ -16,9 +17,14 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
type = mkOption {
|
type = mkOption {
|
||||||
type = types.enum ["nvim-cmp"];
|
type = enum ["nvim-cmp"];
|
||||||
default = "nvim-cmp";
|
default = "nvim-cmp";
|
||||||
description = "Set the autocomplete plugin. Options: [nvim-cmp]";
|
description = ''
|
||||||
|
Set the autocomplete plugin.
|
||||||
|
|
||||||
|
Options:
|
||||||
|
- [nvim-cmp]
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
sources = mkOption {
|
sources = mkOption {
|
||||||
|
|
@ -31,7 +37,7 @@ in {
|
||||||
|
|
||||||
Note: only use a single attribute name per attribute set
|
Note: only use a single attribute name per attribute set
|
||||||
'';
|
'';
|
||||||
type = with types; attrsOf (nullOr str);
|
type = attrsOf (nullOr str);
|
||||||
default = {};
|
default = {};
|
||||||
example = ''
|
example = ''
|
||||||
{nvim-cmp = null; buffer = "[Buffer]";}
|
{nvim-cmp = null; buffer = "[Buffer]";}
|
||||||
|
|
@ -48,9 +54,9 @@ in {
|
||||||
|
|
||||||
Default is to call the menu mapping function.
|
Default is to call the menu mapping function.
|
||||||
'';
|
'';
|
||||||
type = types.str;
|
type = str;
|
||||||
default = "nvim_cmp_menu_map";
|
default = "nvim_cmp_menu_map";
|
||||||
example = lib.literalMD ''
|
example = ''
|
||||||
```lua
|
```lua
|
||||||
function(entry, vim_item)
|
function(entry, vim_item)
|
||||||
return vim_item
|
return vim_item
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,7 @@
|
||||||
{
|
{lib, ...}: let
|
||||||
config,
|
inherit (lib.options) mkEnableOption;
|
||||||
lib,
|
|
||||||
...
|
|
||||||
}: let
|
|
||||||
inherit (lib) mkEnableOption;
|
|
||||||
in {
|
in {
|
||||||
options.vim.dashboard.alpha = {
|
options.vim.dashboard.alpha = {
|
||||||
enable = mkEnableOption "dashboard via alpha.nvim";
|
enable = mkEnableOption "dashboard [alpha-nvim]";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,217 +3,220 @@
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib) mkIf nvim;
|
inherit (lib.options) mkIf;
|
||||||
|
inherit (lib.nvim.dag) entryAnywhere;
|
||||||
|
|
||||||
cfg = config.vim.dashboard.alpha;
|
cfg = config.vim.dashboard.alpha;
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
vim.startPlugins = [
|
vim = {
|
||||||
"alpha-nvim"
|
startPlugins = [
|
||||||
"nvim-web-devicons"
|
"alpha-nvim"
|
||||||
];
|
"nvim-web-devicons"
|
||||||
|
];
|
||||||
|
|
||||||
# the entire credit for this dashboard configuration to https://github.com/Rishabh672003
|
# the entire credit for this dashboard configuration to https://github.com/Rishabh672003
|
||||||
# honestly, excellent work
|
# honestly, excellent work
|
||||||
vim.luaConfigRC.alpha = nvim.dag.entryAnywhere ''
|
luaConfigRC.alpha = entryAnywhere ''
|
||||||
local alpha = require("alpha")
|
local alpha = require("alpha")
|
||||||
local plenary_path = require("plenary.path")
|
local plenary_path = require("plenary.path")
|
||||||
local dashboard = require("alpha.themes.dashboard")
|
local dashboard = require("alpha.themes.dashboard")
|
||||||
local cdir = vim.fn.getcwd()
|
local cdir = vim.fn.getcwd()
|
||||||
local if_nil = vim.F.if_nil
|
local if_nil = vim.F.if_nil
|
||||||
|
|
||||||
local nvim_web_devicons = {
|
local nvim_web_devicons = {
|
||||||
enabled = true,
|
enabled = true,
|
||||||
highlight = true,
|
highlight = true,
|
||||||
}
|
}
|
||||||
|
|
||||||
local function get_extension(fn)
|
local function get_extension(fn)
|
||||||
local match = fn:match("^.+(%..+)$")
|
local match = fn:match("^.+(%..+)$")
|
||||||
local ext = ""
|
local ext = ""
|
||||||
if match ~= nil then
|
if match ~= nil then
|
||||||
ext = match:sub(2)
|
ext = match:sub(2)
|
||||||
end
|
end
|
||||||
return ext
|
return ext
|
||||||
end
|
end
|
||||||
|
|
||||||
local function icon(fn)
|
local function icon(fn)
|
||||||
local nwd = require("nvim-web-devicons")
|
local nwd = require("nvim-web-devicons")
|
||||||
local ext = get_extension(fn)
|
local ext = get_extension(fn)
|
||||||
return nwd.get_icon(fn, ext, { default = true })
|
return nwd.get_icon(fn, ext, { default = true })
|
||||||
end
|
end
|
||||||
|
|
||||||
local function file_button(fn, sc, short_fn)
|
local function file_button(fn, sc, short_fn)
|
||||||
short_fn = short_fn or fn
|
short_fn = short_fn or fn
|
||||||
local ico_txt
|
local ico_txt
|
||||||
local fb_hl = {}
|
local fb_hl = {}
|
||||||
|
|
||||||
if nvim_web_devicons.enabled then
|
if nvim_web_devicons.enabled then
|
||||||
local ico, hl = icon(fn)
|
local ico, hl = icon(fn)
|
||||||
local hl_option_type = type(nvim_web_devicons.highlight)
|
local hl_option_type = type(nvim_web_devicons.highlight)
|
||||||
if hl_option_type == "boolean" then
|
if hl_option_type == "boolean" then
|
||||||
if hl and nvim_web_devicons.highlight then
|
if hl and nvim_web_devicons.highlight then
|
||||||
table.insert(fb_hl, { hl, 0, 3 })
|
table.insert(fb_hl, { hl, 0, 3 })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if hl_option_type == "string" then
|
if hl_option_type == "string" then
|
||||||
table.insert(fb_hl, { nvim_web_devicons.highlight, 0, 3 })
|
table.insert(fb_hl, { nvim_web_devicons.highlight, 0, 3 })
|
||||||
end
|
end
|
||||||
ico_txt = ico .. " "
|
ico_txt = ico .. " "
|
||||||
else
|
else
|
||||||
ico_txt = ""
|
ico_txt = ""
|
||||||
end
|
end
|
||||||
local file_button_el = dashboard.button(sc, ico_txt .. short_fn, "<cmd>e " .. fn .. " <CR>")
|
local file_button_el = dashboard.button(sc, ico_txt .. short_fn, "<cmd>e " .. fn .. " <CR>")
|
||||||
local fn_start = short_fn:match(".*[/\\]")
|
local fn_start = short_fn:match(".*[/\\]")
|
||||||
if fn_start ~= nil then
|
if fn_start ~= nil then
|
||||||
table.insert(fb_hl, { "Comment", #ico_txt - 2, #fn_start + #ico_txt })
|
table.insert(fb_hl, { "Comment", #ico_txt - 2, #fn_start + #ico_txt })
|
||||||
end
|
end
|
||||||
file_button_el.opts.hl = fb_hl
|
file_button_el.opts.hl = fb_hl
|
||||||
return file_button_el
|
return file_button_el
|
||||||
end
|
end
|
||||||
|
|
||||||
local default_mru_ignore = { "gitcommit" }
|
local default_mru_ignore = { "gitcommit" }
|
||||||
|
|
||||||
local mru_opts = {
|
local mru_opts = {
|
||||||
ignore = function(path, ext)
|
ignore = function(path, ext)
|
||||||
return (string.find(path, "COMMIT_EDITMSG")) or (vim.tbl_contains(default_mru_ignore, ext))
|
return (string.find(path, "COMMIT_EDITMSG")) or (vim.tbl_contains(default_mru_ignore, ext))
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
--- @param start number
|
--- @param start number
|
||||||
--- @param cwd string optional
|
--- @param cwd string optional
|
||||||
--- @param items_number number optional number of items to generate, default = 10
|
--- @param items_number number optional number of items to generate, default = 10
|
||||||
local function mru(start, cwd, items_number, opts)
|
local function mru(start, cwd, items_number, opts)
|
||||||
opts = opts or mru_opts
|
opts = opts or mru_opts
|
||||||
items_number = if_nil(items_number, 15)
|
items_number = if_nil(items_number, 15)
|
||||||
|
|
||||||
local oldfiles = {}
|
local oldfiles = {}
|
||||||
for _, v in pairs(vim.v.oldfiles) do
|
for _, v in pairs(vim.v.oldfiles) do
|
||||||
if #oldfiles == items_number then
|
if #oldfiles == items_number then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
local cwd_cond
|
local cwd_cond
|
||||||
if not cwd then
|
if not cwd then
|
||||||
cwd_cond = true
|
cwd_cond = true
|
||||||
else
|
else
|
||||||
cwd_cond = vim.startswith(v, cwd)
|
cwd_cond = vim.startswith(v, cwd)
|
||||||
end
|
end
|
||||||
local ignore = (opts.ignore and opts.ignore(v, get_extension(v))) or false
|
local ignore = (opts.ignore and opts.ignore(v, get_extension(v))) or false
|
||||||
if (vim.fn.filereadable(v) == 1) and cwd_cond and not ignore then
|
if (vim.fn.filereadable(v) == 1) and cwd_cond and not ignore then
|
||||||
oldfiles[#oldfiles + 1] = v
|
oldfiles[#oldfiles + 1] = v
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local target_width = 35
|
local target_width = 35
|
||||||
|
|
||||||
local tbl = {}
|
local tbl = {}
|
||||||
for i, fn in ipairs(oldfiles) do
|
for i, fn in ipairs(oldfiles) do
|
||||||
local short_fn
|
local short_fn
|
||||||
if cwd then
|
if cwd then
|
||||||
short_fn = vim.fn.fnamemodify(fn, ":.")
|
short_fn = vim.fn.fnamemodify(fn, ":.")
|
||||||
else
|
else
|
||||||
short_fn = vim.fn.fnamemodify(fn, ":~")
|
short_fn = vim.fn.fnamemodify(fn, ":~")
|
||||||
end
|
end
|
||||||
|
|
||||||
if #short_fn > target_width then
|
if #short_fn > target_width then
|
||||||
short_fn = plenary_path.new(short_fn):shorten(1, { -2, -1 })
|
short_fn = plenary_path.new(short_fn):shorten(1, { -2, -1 })
|
||||||
if #short_fn > target_width then
|
if #short_fn > target_width then
|
||||||
short_fn = plenary_path.new(short_fn):shorten(1, { -1 })
|
short_fn = plenary_path.new(short_fn):shorten(1, { -1 })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local shortcut = tostring(i + start - 1)
|
local shortcut = tostring(i + start - 1)
|
||||||
|
|
||||||
local file_button_el = file_button(fn, shortcut, short_fn)
|
local file_button_el = file_button(fn, shortcut, short_fn)
|
||||||
tbl[i] = file_button_el
|
tbl[i] = file_button_el
|
||||||
end
|
end
|
||||||
return {
|
return {
|
||||||
type = "group",
|
type = "group",
|
||||||
val = tbl,
|
val = tbl,
|
||||||
opts = {},
|
opts = {},
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
local default_header = {
|
local default_header = {
|
||||||
type = "text",
|
type = "text",
|
||||||
val = {
|
val = {
|
||||||
|
|
||||||
[[███ ██ ███████ ██████ ██ ██ ██ ███ ███]],
|
[[███ ██ ███████ ██████ ██ ██ ██ ███ ███]],
|
||||||
[[████ ██ ██ ██ ██ ██ ██ ██ ████ ████]],
|
[[████ ██ ██ ██ ██ ██ ██ ██ ████ ████]],
|
||||||
[[██ ██ ██ █████ ██ ██ ██ ██ ██ ██ ████ ██]],
|
[[██ ██ ██ █████ ██ ██ ██ ██ ██ ██ ████ ██]],
|
||||||
[[██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██]],
|
[[██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██]],
|
||||||
[[██ ████ ███████ ██████ ████ ██ ██ ██]],
|
[[██ ████ ███████ ██████ ████ ██ ██ ██]],
|
||||||
|
|
||||||
-- [[ __ ]],
|
-- [[ __ ]],
|
||||||
-- [[ ___ ___ ___ __ __ /\_\ ___ ___ ]],
|
-- [[ ___ ___ ___ __ __ /\_\ ___ ___ ]],
|
||||||
-- [[ / _ `\ / __`\ / __`\/\ \/\ \\/\ \ / __` __`\ ]],
|
-- [[ / _ `\ / __`\ / __`\/\ \/\ \\/\ \ / __` __`\ ]],
|
||||||
-- [[/\ \/\ \/\ __//\ \_\ \ \ \_/ |\ \ \/\ \/\ \/\ \ ]],
|
-- [[/\ \/\ \/\ __//\ \_\ \ \ \_/ |\ \ \/\ \/\ \/\ \ ]],
|
||||||
-- [[\ \_\ \_\ \____\ \____/\ \___/ \ \_\ \_\ \_\ \_\]],
|
-- [[\ \_\ \_\ \____\ \____/\ \___/ \ \_\ \_\ \_\ \_\]],
|
||||||
-- [[ \/_/\/_/\/____/\/___/ \/__/ \/_/\/_/\/_/\/_/]],
|
-- [[ \/_/\/_/\/____/\/___/ \/__/ \/_/\/_/\/_/\/_/]],
|
||||||
},
|
},
|
||||||
opts = {
|
opts = {
|
||||||
position = "center",
|
position = "center",
|
||||||
hl = "Type",
|
hl = "Type",
|
||||||
-- wrap = "overflow";
|
-- wrap = "overflow";
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
local section_mru = {
|
local section_mru = {
|
||||||
type = "group",
|
type = "group",
|
||||||
val = {
|
val = {
|
||||||
{
|
{
|
||||||
type = "text",
|
type = "text",
|
||||||
val = "Recent files",
|
val = "Recent files",
|
||||||
opts = {
|
opts = {
|
||||||
hl = "SpecialComment",
|
hl = "SpecialComment",
|
||||||
shrink_margin = false,
|
shrink_margin = false,
|
||||||
position = "center",
|
position = "center",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ type = "padding", val = 1 },
|
{ type = "padding", val = 1 },
|
||||||
{
|
{
|
||||||
type = "group",
|
type = "group",
|
||||||
val = function()
|
val = function()
|
||||||
return { mru(0, cdir) }
|
return { mru(0, cdir) }
|
||||||
end,
|
end,
|
||||||
opts = { shrink_margin = false },
|
opts = { shrink_margin = false },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
local buttons = {
|
local buttons = {
|
||||||
type = "group",
|
type = "group",
|
||||||
val = {
|
val = {
|
||||||
{ type = "text", val = "Quick links", opts = { hl = "SpecialComment", position = "center" } },
|
{ type = "text", val = "Quick links", opts = { hl = "SpecialComment", position = "center" } },
|
||||||
{ type = "padding", val = 1 },
|
{ type = "padding", val = 1 },
|
||||||
-- TODO: buttons should be added based on whether or not the relevant plugin is available
|
-- TODO: buttons should be added based on whether or not the relevant plugin is available
|
||||||
dashboard.button("e", " New file", "<cmd>ene<CR>"), -- available all the time
|
dashboard.button("e", " New file", "<cmd>ene<CR>"), -- available all the time
|
||||||
dashboard.button("SPC F", " Find file"), -- telescope
|
dashboard.button("SPC F", " Find file"), -- telescope
|
||||||
dashboard.button("SPC ff", " Live grep"), -- telescope
|
dashboard.button("SPC ff", " Live grep"), -- telescope
|
||||||
dashboard.button("SPC p", " Projects"), -- any project
|
dashboard.button("SPC p", " Projects"), -- any project
|
||||||
dashboard.button("q", " Quit", "<cmd>qa<CR>"), -- available all the time
|
dashboard.button("q", " Quit", "<cmd>qa<CR>"), -- available all the time
|
||||||
},
|
},
|
||||||
position = "center",
|
position = "center",
|
||||||
}
|
}
|
||||||
|
|
||||||
local config = {
|
local config = {
|
||||||
layout = {
|
layout = {
|
||||||
{ type = "padding", val = 2 },
|
{ type = "padding", val = 2 },
|
||||||
default_header,
|
default_header,
|
||||||
{ type = "padding", val = 2 },
|
{ type = "padding", val = 2 },
|
||||||
section_mru,
|
section_mru,
|
||||||
{ type = "padding", val = 2 },
|
{ type = "padding", val = 2 },
|
||||||
buttons,
|
buttons,
|
||||||
},
|
},
|
||||||
opts = {
|
opts = {
|
||||||
margin = 5,
|
margin = 5,
|
||||||
setup = function()
|
setup = function()
|
||||||
vim.cmd([[
|
vim.cmd([[
|
||||||
autocmd alpha_temp DirChanged * lua require('alpha').redraw()
|
autocmd alpha_temp DirChanged * lua require('alpha').redraw()
|
||||||
]])
|
]])
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
alpha.setup(config)
|
alpha.setup(config)
|
||||||
'';
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
_: {
|
{
|
||||||
imports = [
|
imports = [
|
||||||
./alpha.nix
|
./alpha.nix
|
||||||
./config.nix
|
./config.nix
|
||||||
|
|
|
||||||
|
|
@ -3,17 +3,20 @@
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib) mkIf nvim;
|
inherit (lib.options) mkIf;
|
||||||
|
inherit (lib.nvim.dag) entryAnywhere;
|
||||||
|
|
||||||
cfg = config.vim.dashboard.dashboard-nvim;
|
cfg = config.vim.dashboard.dashboard-nvim;
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
vim.startPlugins = [
|
vim = {
|
||||||
"dashboard-nvim"
|
startPlugins = [
|
||||||
];
|
"dashboard-nvim"
|
||||||
|
];
|
||||||
|
|
||||||
vim.luaConfigRC.dashboard-nvim = nvim.dag.entryAnywhere ''
|
luaConfigRC.dashboard-nvim = entryAnywhere ''
|
||||||
require("dashboard").setup{}
|
require("dashboard").setup{}
|
||||||
'';
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
{...}: {
|
{
|
||||||
imports = [
|
imports = [
|
||||||
./alpha
|
./alpha
|
||||||
./dashboard-nvim
|
./dashboard-nvim
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue