Merge branch 'main' of https://github.com/NotAShelf/nvf into language-overhaul

This commit is contained in:
sjcobb 2025-07-08 09:54:21 +01:00
commit 39da9a874e
88 changed files with 1160 additions and 509 deletions

View file

@ -6,7 +6,7 @@
}: let
inherit (lib.modules) mkIf;
inherit (lib.options) mkOption mkEnableOption mkPackageOption;
inherit (lib.types) nullOr either str listOf submodule;
inherit (lib.types) str submodule;
inherit (lib.attrsets) mapAttrs mapAttrsToList filterAttrs;
cfg = config.vim.clipboard;
in {
@ -20,7 +20,7 @@ in {
'';
registers = mkOption {
type = either str (listOf str);
type = str;
default = "";
example = "unnamedplus";
description = ''
@ -33,8 +33,8 @@ in {
`"+"` ({command}`:h quoteplus`) instead of register `"*"` for all yank, delete,
change and put operations which would normally go to the unnamed register.
When `unnamed` and `unnamedplus` is included simultaneously yank and delete
operations (but not put) will additionally copy the text into register `"*"`.
When `unnamed` and `unnamedplus` is included simultaneously as `"unnamed,unnamedplus"`,
yank and delete operations (but not put) will additionally copy the text into register `"*"`.
Please see {command}`:h clipboard` for more details.

View file

@ -57,14 +57,21 @@
signs = mkOption {
type = diagnosticType;
default = false;
example = {
signs.text = {
"vim.diagnostic.severity.ERROR" = "󰅚 ";
"vim.diagnostic.severity.WARN" = "󰀪 ";
};
};
example = literalExpression ''
signs.text = lib.generators.mkLuaInline '''
{
[vim.diagnostic.severity.ERROR] = "󰅚 ",
[vim.diagnostic.severity.WARN] = "󰀪 ",
}
''';
'';
description = ''
Use signs for diagnostics. See {command}`:help diagnostic-signs`.
:::{.note}
The code presented in that example section uses Lua expressions as object keys which
only translate well if you use `lib.generators.mkLuaInline` as in the example.
:::
'';
};

View file

@ -3,7 +3,7 @@
lib,
...
}: let
inherit (lib.modules) mkIf mkMerge;
inherit (lib.modules) mkMerge;
inherit (lib.trivial) pipe;
inherit (lib.attrsets) mapAttrsToList;
inherit (lib.lists) flatten;

View file

@ -0,0 +1,341 @@
{lib, ...}: let
inherit (lib.options) mkOption mkEnableOption literalMD;
inherit (lib.types) int str enum nullOr attrs bool;
inherit (lib.nvim.types) mkPluginSetupOption;
in {
options.vim.assistant = {
avante-nvim = {
enable = mkEnableOption "complementary Neovim plugin for avante.nvim";
setupOpts = mkPluginSetupOption "avante-nvim" {
provider = mkOption {
type = nullOr str;
default = null;
description = "The provider used in Aider mode or in the planning phase of Cursor Planning Mode.";
};
providers = mkOption {
type = nullOr attrs;
default = null;
description = "Define settings for builtin and custom providers.";
example = literalMD ''
```nix
openai = {
endpoint = "https://api.openai.com/v1";
model = "gpt-4o"; # your desired model (or use gpt-4o, etc.)
timeout = 30000; # Timeout in milliseconds, increase this for reasoning models
extra_request_body = {
temperature = 0;
max_completion_tokens = 8192; # Increase this to include reasoning tokens (for reasoning models)
reasoning_effort = "medium"; # low|medium|high, only used for reasoning models
};
};
ollama = {
endpoint = "http://127.0.0.1:11434";
timeout = 30000; # Timeout in milliseconds
extra_request_body = {
options = {
temperature = 0.75;
num_ctx = 20480;
keep_alive = "5m";
};
};
};
groq = {
__inherited_from = "openai";
api_key_name = "GROQ_API_KEY";
endpoint = "https://api.groq.com/openai/v1/";
model = "llama-3.3-70b-versatile";
disable_tools = true;
extra_request_body = {
temperature = 1;
max_tokens = 32768; # remember to increase this value, otherwise it will stop generating halfway
};
};
```
'';
};
auto_suggestions_provider = mkOption {
type = str;
default = "claude";
description = ''
Since auto-suggestions are a high-frequency operation and therefore expensive,
currently designating it as `copilot` provider is dangerous because:
https://github.com/yetone/avante.nvim/issues/1048
Of course, you can reduce the request frequency by increasing `suggestion.debounce`.
'';
};
cursor_applying_provider = mkOption {
type = nullOr str;
default = null;
description = ''
The provider used in the applying phase of Cursor Planning Mode, defaults to `nil`,
Config.provider will be used as the provider for the applying phase when `nil`.
'';
};
dual_boost = {
enabled = mkEnableOption "dual_boost mode.";
first_provider = mkOption {
type = str;
default = "openai";
description = "The first provider to generate response.";
};
second_provider = mkOption {
type = str;
default = "claude";
description = "The second provider to generate response.";
};
prompt = mkOption {
type = str;
default = ''
Based on the two reference outputs below, generate a response that incorporates
elements from both but reflects your own judgment and unique perspective.
Do not provide any explanation, just give the response directly. Reference Output 1:
[{{provider1_output}}], Reference Output 2: [{{provider2_output}}'';
description = "The prompt to generate response based on the two reference outputs.";
};
timeout = mkOption {
type = int;
default = 60000;
description = "Timeout in milliseconds.";
};
};
behaviour = {
auto_suggestions =
mkEnableOption "auto suggestions.";
auto_set_highlight_group =
mkEnableOption "automatically set the highlight group for the current line."
// {
default = true;
};
auto_set_keymaps =
mkEnableOption "automatically set the keymap for the current line."
// {
default = true;
};
auto_apply_diff_after_generation =
mkEnableOption "automatically apply diff after LLM response.";
support_paste_from_clipboard = mkEnableOption ''
pasting image from clipboard.
This will be determined automatically based whether img-clip is available or not.
'';
minimize_diff =
mkEnableOption "remove unchanged lines when applying a code block."
// {
default = true;
};
enable_token_counting =
mkEnableOption "token counting."
// {
default = true;
};
enable_cursor_planning_mode =
mkEnableOption "Cursor Planning Mode.";
enable_claude_text_editor_tool_mode =
mkEnableOption "Claude Text Editor Tool Mode.";
};
mappings = {
diff = mkOption {
type = nullOr attrs;
default = null;
description = "Define or override the default keymaps for diff.";
};
suggestion = mkOption {
type = nullOr attrs;
default = null;
description = "Define or override the default keymaps for suggestion actions.";
};
jump = mkOption {
type = nullOr attrs;
default = null;
description = "Define or override the default keymaps for jump actions.";
};
submit = mkOption {
type = nullOr attrs;
default = null;
description = "Define or override the default keymaps for submit actions.";
};
cancel = mkOption {
type = nullOr attrs;
default = null;
description = "Define or override the default keymaps for cancel actions.";
};
sidebar = mkOption {
type = nullOr attrs;
default = null;
description = "Define or override the default keymaps for sidebar actions.";
};
};
hints.enabled =
mkEnableOption ""
// {
default = true;
description = ''
Whether to enable hints.
'';
};
windows = {
position = mkOption {
type = enum ["right" "left" "top" "bottom"];
default = "right";
description = "The position of the sidebar.";
};
wrap =
mkEnableOption ""
// {
default = true;
description = ''
similar to vim.o.wrap.
'';
};
width = mkOption {
type = int;
default = 30;
description = "Default % based on available width.";
};
sidebar_header = {
enabled = mkOption {
type = bool;
default = true;
description = "enable/disable the header.";
};
align = mkOption {
type = enum ["right" "center" "left"];
default = "center";
description = "Position of the title.";
};
rounded = mkOption {
type = bool;
default = true;
description = "Enable rounded sidebar header";
};
};
input = {
prefix = mkOption {
type = str;
default = "> ";
description = "The prefix used on the user input.";
};
height = mkOption {
type = int;
default = 8;
description = ''
Height of the input window in vertical layout.
'';
};
};
edit = {
border = mkOption {
type = str;
default = "rounded";
description = "The border type on the edit window.";
};
start_insert = mkOption {
type = bool;
default = true;
description = ''
Start insert mode when opening the edit window.
'';
};
};
ask = {
floating = mkOption {
type = bool;
default = false;
description = ''
Open the 'AvanteAsk' prompt in a floating window.
'';
};
start_insert = mkOption {
type = bool;
default = true;
description = ''
Start insert mode when opening the ask window.
'';
};
border = mkOption {
type = str;
default = "rounded";
description = "The border type on the ask window.";
};
focus_on_apply = mkOption {
type = enum ["ours" "theirs"];
default = "ours";
description = "Which diff to focus after applying.";
};
};
};
diff = {
autojump =
mkEnableOption ""
// {
default = true;
description = "Automatically jumps to the next change.";
};
override_timeoutlen = mkOption {
type = int;
default = 500;
example = -1;
description = ''
Override the 'timeoutlen' setting while hovering over a diff (see {command}`:help timeoutlen`).
Helps to avoid entering operator-pending mode with diff mappings starting with `c`.
Disable by setting to -1.
'';
};
};
suggestion = {
debounce = mkOption {
type = int;
default = 600;
description = "Suggestion debounce in milliseconds.";
};
throttle = mkOption {
type = int;
default = 600;
description = "Suggestion throttle in milliseconds.";
};
};
};
};
};
}

View file

@ -0,0 +1,41 @@
{
config,
lib,
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.lists) optionals;
cfg = config.vim.assistant.avante-nvim;
in {
config = mkIf cfg.enable {
vim = {
startPlugins =
[
"nvim-treesitter"
"plenary-nvim"
"dressing-nvim"
"nui-nvim"
]
++ (optionals config.vim.mini.pick.enable ["mini-pick"])
++ (optionals config.vim.telescope.enable ["telescope"])
++ (optionals config.vim.autocomplete.nvim-cmp.enable ["nvim-cmp"])
++ (optionals config.vim.fzf-lua.enable ["fzf-lua"])
++ (optionals config.vim.visuals.nvim-web-devicons.enable ["nvim-web-devicons"])
++ (optionals config.vim.utility.images.img-clip.enable ["img-clip"]);
lazy.plugins = {
avante-nvim = {
package = "avante-nvim";
setupModule = "avante";
inherit (cfg) setupOpts;
event = ["DeferredUIEnter"];
};
};
treesitter.enable = true;
languages.markdown.extensions.render-markdown-nvim.setupOpts.file_types = lib.mkAfter ["Avante"];
};
};
}

View file

@ -0,0 +1,6 @@
{
imports = [
./config.nix
./avante-nvim.nix
];
}

View file

@ -5,7 +5,6 @@
}: let
inherit (builtins) toJSON;
inherit (lib.modules) mkIf;
inherit (lib.strings) optionalString;
cfg = config.vim.assistant.copilot;

View file

@ -3,5 +3,6 @@
./chatgpt
./copilot
./codecompanion
./avante
];
}

View file

@ -1,7 +1,6 @@
{lib, ...}: let
inherit (lib.options) mkEnableOption mkOption literalMD;
inherit (lib.types) bool listOf str either attrsOf submodule enum anything int nullOr;
inherit (lib.generators) mkLuaInline;
inherit (lib.nvim.types) mkPluginSetupOption luaInline pluginType;
inherit (lib.nvim.binds) mkMappingOption;
inherit (lib.nvim.config) mkBool;
@ -10,7 +9,7 @@
freeformType = attrsOf (listOf (either str luaInline));
options = {
preset = mkOption {
type = enum ["default" "none" "super-tab" "enter"];
type = enum ["default" "none" "super-tab" "enter" "cmdline"];
default = "none";
description = "keymap presets";
};

View file

@ -3,11 +3,10 @@
config,
...
}: let
inherit (lib.modules) mkIf mkMerge;
inherit (lib.modules) mkIf;
inherit (lib.strings) optionalString;
inherit (lib.generators) mkLuaInline;
inherit (lib.nvim.lua) toLuaObject;
inherit (lib.nvim.attrsets) mapListToAttrs;
inherit (builtins) attrNames typeOf tryEval concatStringsSep;
borders = config.vim.ui.borders.plugins.nvim-cmp;

View file

@ -3,7 +3,7 @@
config,
...
}: let
inherit (lib.options) mkEnableOption mkOption literalExpression literalMD;
inherit (lib.options) mkEnableOption mkOption literalMD;
inherit (lib.types) str attrsOf nullOr either listOf;
inherit (lib.generators) mkLuaInline;
inherit (lib.nvim.binds) mkMappingOption;

View file

@ -4,7 +4,6 @@
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.dashboard.alpha;

View file

@ -10,7 +10,6 @@
inherit (lib.lists) isList;
inherit (lib.meta) getExe;
inherit (lib.types) enum either listOf package str;
inherit (lib.generators) mkLuaInline;
inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.attrsets) mapListToAttrs;
inherit (lib.nvim.types) mkGrammarOption diagnostics;
@ -46,7 +45,7 @@
defaultFormat = "prettier";
formats = {
prettier = {
package = pkgs.nodePackages.prettier;
package = pkgs.prettier;
};
prettierd = {

View file

@ -42,7 +42,7 @@
defaultFormat = "prettier";
formats = {
prettier = {
package = pkgs.nodePackages.prettier;
package = pkgs.prettier;
};
prettierd = {

View file

@ -26,9 +26,9 @@
];
};
defaultServers = ["nil_ls"];
defaultServers = ["nil"];
servers = {
nil_ls = {
nil = {
enable = true;
cmd = [(getExe pkgs.nil)];
settings = {

View file

@ -9,7 +9,6 @@
inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) isList;
inherit (lib.meta) getExe;
inherit (lib.generators) mkLuaInline;
inherit (lib.types) enum either listOf package str;
inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.types) mkGrammarOption diagnostics;
@ -19,7 +18,7 @@
defaultServer = "svelte";
servers = {
svelte = {
package = pkgs.nodePackages.svelte-language-server;
package = pkgs.svelte-language-server;
lspConfig = ''
lspconfig.svelte.setup {
capabilities = capabilities;
@ -38,7 +37,7 @@
defaultFormat = "prettier";
formats = {
prettier = {
package = pkgs.nodePackages.prettier;
package = pkgs.prettier;
};
biome = {

View file

@ -9,7 +9,6 @@
inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) isList;
inherit (lib.meta) getExe;
inherit (lib.generators) mkLuaInline;
inherit (lib.types) enum either listOf package str bool;
inherit (lib.nvim.lua) expToLua toLuaObject;
inherit (lib.nvim.types) mkGrammarOption diagnostics mkPluginSetupOption;
@ -76,7 +75,7 @@
defaultFormat = "prettier";
formats = {
prettier = {
package = pkgs.nodePackages.prettier;
package = pkgs.prettier;
};
prettierd = {

View file

@ -29,7 +29,7 @@
servers = {
yaml-language-server = {
enable = true;
cmd = [(getExe pkgs.nodePackages.yaml-language-server) "--stdio"];
cmd = [(getExe pkgs.yaml-language-server) "--stdio"];
filetypes = ["yaml" "yaml.docker-compose" "yaml.gitlab" "yaml.helm-values"];
root_markers = [".git"];
on_attach = onAttach;

View file

@ -1,8 +1,4 @@
{
config,
lib,
...
}: let
{lib, ...}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in {

View file

@ -1,8 +1,4 @@
{
config,
lib,
...
}: let
{lib, ...}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in {

View file

@ -1,8 +1,4 @@
{
config,
lib,
...
}: let
{lib, ...}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in {

View file

@ -1,8 +1,4 @@
{
config,
lib,
...
}: let
{lib, ...}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in {

View file

@ -1,8 +1,4 @@
{
config,
lib,
...
}: let
{lib, ...}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in {

View file

@ -1,8 +1,4 @@
{
config,
lib,
...
}: let
{lib, ...}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in {

View file

@ -1,8 +1,4 @@
{
config,
lib,
...
}: let
{lib, ...}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in {

View file

@ -1,8 +1,4 @@
{
config,
lib,
...
}: let
{lib, ...}: let
inherit (lib.options) mkEnableOption;
in {
options.vim.mini.colors = {

View file

@ -1,8 +1,4 @@
{
config,
lib,
...
}: let
{lib, ...}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in {

View file

@ -1,8 +1,4 @@
{
config,
lib,
...
}: let
{lib, ...}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in {

View file

@ -1,8 +1,4 @@
{
config,
lib,
...
}: let
{lib, ...}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in {

View file

@ -1,8 +1,4 @@
{
config,
lib,
...
}: let
{lib, ...}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in {

View file

@ -1,8 +1,4 @@
{
config,
lib,
...
}: let
{lib, ...}: let
inherit (lib.options) mkEnableOption;
in {
options.vim.mini.extra = {

View file

@ -1,8 +1,4 @@
{
config,
lib,
...
}: let
{lib, ...}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in {

View file

@ -1,8 +1,4 @@
{
config,
lib,
...
}: let
{lib, ...}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in {

View file

@ -1,8 +1,4 @@
{
config,
lib,
...
}: let
{lib, ...}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in {

View file

@ -1,8 +1,4 @@
{
config,
lib,
...
}: let
{lib, ...}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in {

View file

@ -1,10 +1,5 @@
{
config,
lib,
...
}: let
{lib, ...}: let
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.strings) hasPrefix;
inherit (lib.nvim.types) mkPluginSetupOption;
inherit (lib.nvim.types) hexColor;
in {

View file

@ -1,8 +1,4 @@
{
config,
lib,
...
}: let
{lib, ...}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in {

View file

@ -1,8 +1,4 @@
{
config,
lib,
...
}: let
{lib, ...}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in {

View file

@ -1,8 +1,4 @@
{
config,
lib,
...
}: let
{lib, ...}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in {

View file

@ -1,8 +1,4 @@
{
config,
lib,
...
}: let
{lib, ...}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in {

View file

@ -1,8 +1,4 @@
{
config,
lib,
...
}: let
{lib, ...}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in {

View file

@ -1,8 +1,4 @@
{
config,
lib,
...
}: let
{lib, ...}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in {

View file

@ -1,8 +1,4 @@
{
config,
lib,
...
}: let
{lib, ...}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in {

View file

@ -1,8 +1,4 @@
{
config,
lib,
...
}: let
{lib, ...}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in {

View file

@ -1,8 +1,4 @@
{
config,
lib,
...
}: let
{lib, ...}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in {

View file

@ -1,8 +1,4 @@
{
config,
lib,
...
}: let
{lib, ...}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in {

View file

@ -1,8 +1,4 @@
{
config,
lib,
...
}: let
{lib, ...}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in {

View file

@ -1,8 +1,4 @@
{
config,
lib,
...
}: let
{lib, ...}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in {

View file

@ -1,8 +1,4 @@
{
config,
lib,
...
}: let
{lib, ...}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in {

View file

@ -1,8 +1,4 @@
{
config,
lib,
...
}: let
{lib, ...}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in {

View file

@ -1,8 +1,4 @@
{
config,
lib,
...
}: let
{lib, ...}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in {

View file

@ -1,8 +1,4 @@
{
config,
lib,
...
}: let
{lib, ...}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in {

View file

@ -1,8 +1,4 @@
{
config,
lib,
...
}: let
{lib, ...}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in {

View file

@ -1,8 +1,4 @@
{
config,
lib,
...
}: let
{lib, ...}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in {

View file

@ -1,8 +1,4 @@
{
config,
lib,
...
}: let
{lib, ...}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in {

View file

@ -77,7 +77,7 @@ in {
};
autoload_mode = mkOption {
type = either (enum ["Disabled" "CurrentDir" "LastSession"]) luaInline;
type = either (enum ["Disabled" "CurrentDir" "LastSession" "GitSession"]) luaInline;
# Variable 'sm' is defined in the pluginRC of nvim-session-manager. The
# definition is as follows: `local sm = require('session_manager.config')`
apply = val:
@ -88,7 +88,7 @@ in {
description = ''
Define what to do when Neovim is started without arguments.
Takes either one of `"Disabled"`, `"CurrentDir"`, `"LastSession` in which case the value
Takes either one of `"Disabled"`, `"CurrentDir"`, `"LastSession"`, `"GitSession"` in which case the value
will be inserted into `sm.AutoloadMode.<value>`, or an inline Lua value.
'';
};

View file

@ -1,11 +1,48 @@
{
config,
lib,
pkgs,
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.lists) replicate;
inherit
(lib.strings)
optionalString
removeSuffix
concatStrings
stringAsChars
concatMapStringsSep
;
inherit (lib.attrsets) mapAttrsToList;
inherit (pkgs) writeTextFile;
cfg = config.vim.snippets.luasnip;
# LuaSnip freaks out if the indentation is wrong in snippets
indent = n: s: let
indentString = concatStrings (replicate n " ");
sep = "\n" + indentString;
in
indentString
+ stringAsChars (c:
if c == "\n"
then sep
else c) (removeSuffix "\n" s);
customSnipmateSnippetFiles =
mapAttrsToList (
name: value:
writeTextFile {
name = "${name}.snippets";
text =
concatMapStringsSep "\n" (x: ''
snippet ${x.trigger} ${x.description}
${indent 2 x.body}
'')
value;
destination = "/snippets/${name}.snippets";
}
)
cfg.customSnippets.snipmate;
in {
config = mkIf cfg.enable {
vim = {
@ -19,11 +56,16 @@ in {
after = cfg.loaders;
};
startPlugins = cfg.providers;
startPlugins = cfg.providers ++ customSnipmateSnippetFiles;
autocomplete.nvim-cmp = mkIf config.vim.autocomplete.nvim-cmp.enable {
sources = {luasnip = "[LuaSnip]";};
sourcePlugins = ["cmp-luasnip"];
};
snippets.luasnip.loaders = ''
${optionalString (
cfg.customSnippets.snipmate != {}
) "require('luasnip.loaders.from_snipmate').lazy_load()"}
'';
};
};
}

View file

@ -1,6 +1,6 @@
{lib, ...}: let
inherit (lib.options) mkEnableOption mkOption literalExpression literalMD;
inherit (lib.types) listOf lines;
inherit (lib.types) listOf lines submodule str attrsOf;
inherit (lib.nvim.types) pluginType mkPluginSetupOption;
in {
options.vim.snippets.luasnip = {
@ -36,5 +36,61 @@ in {
setupOpts = mkPluginSetupOption "LuaSnip" {
enable_autosnippets = mkEnableOption "autosnippets";
};
customSnippets.snipmate = mkOption {
type = attrsOf (
listOf (submodule {
options = {
trigger = mkOption {
type = str;
description = ''
The trigger used to activate this snippet.
'';
};
description = mkOption {
type = str;
default = "";
description = ''
The description shown for this snippet.
'';
};
body = mkOption {
type = str;
description = ''
[LuaSnip Documentation]: https://github.com/L3MON4D3/LuaSnip#add-snippets
The body of the snippet in SnipMate format (see [LuaSnip Documentation]).
'';
};
};
})
);
default = {};
example = ''
{
all = [
{
trigger = "if";
body = "if $1 else $2";
}
];
nix = [
{
trigger = "mkOption";
body = '''
mkOption {
type = $1;
default = $2;
description = $3;
example = $4;
}
''';
}
];
}
'';
description = ''
A list containing custom snippets in the SnipMate format to be loaded by LuaSnip.
'';
};
};
}

View file

@ -63,8 +63,8 @@ in {
options = {
icons_enabled = mkDefault cfg.icons.enable;
theme = mkDefault cfg.theme;
component_separators = mkDefault [cfg.componentSeparator.left cfg.componentSeparator.right];
section_separators = mkDefault [cfg.sectionSeparator.left cfg.sectionSeparator.right];
component_separators = mkDefault cfg.componentSeparator;
section_separators = mkDefault cfg.sectionSeparator;
globalstatus = mkDefault cfg.globalStatus;
refresh = mkDefault cfg.refresh;
always_divide_middle = mkDefault cfg.alwaysDivideMiddle;

View file

@ -2,7 +2,9 @@
config,
lib,
}: let
inherit (lib.strings) optionalString;
inherit (lib.strings) optionalString splitString;
inherit (lib.attrsets) mapCartesianProduct;
inherit (lib.lists) intersectLists;
inherit (lib.trivial) boolToString warnIf;
inherit (lib.nvim.lua) toLuaObject;
in {
@ -21,9 +23,14 @@ in {
'';
};
onedark = {
setup = {style ? "dark", ...}: ''
setup = {
style ? "dark",
transparent,
...
}: ''
-- OneDark theme
require('onedark').setup {
transparent = ${boolToString transparent},
style = "${style}"
}
require('onedark').load()
@ -95,7 +102,7 @@ in {
-- setup must be called before loading
vim.cmd.colorscheme "catppuccin"
'';
styles = ["latte" "frappe" "macchiato" "mocha"];
styles = ["auto" "latte" "frappe" "macchiato" "mocha"];
};
oxocarbon = {
@ -212,6 +219,55 @@ in {
'';
styles = ["dark" "light" "dark_dimmed" "dark_default" "light_default" "dark_high_contrast" "light_high_contrast" "dark_colorblind" "light_colorblind" "dark_tritanopia" "light_tritanopia"];
};
solarized = let
backgrounds = ["light" "dark"];
palettes = ["solarized" "selenized"];
variants = ["spring" "summer" "autumn" "winter"];
in {
setup = {
style ? "", # use plugin defaults
transparent ? false,
...
}: let
parts = splitString "-" style;
detect = list: let
intersection = intersectLists parts list;
in
if intersection == []
then null
else builtins.head intersection;
background = detect backgrounds;
palette = detect palettes;
variant = detect variants;
in ''
-- Solarized theme
require('solarized').setup {
transparent = {
enabled = ${boolToString transparent},
},
${optionalString (!isNull palette) ''palette = "${palette}",''}
${optionalString (!isNull variant) ''variant = "${variant}",''}
}
${optionalString (!isNull background) ''vim.opt.background = "${background}"''}
vim.cmd.colorscheme "solarized"
'';
styles = let
joinWithDashes = parts: lib.concatStringsSep "-" (lib.filter (s: s != "") parts);
combinations = mapCartesianProduct ({
bg,
pal,
var,
}:
joinWithDashes [bg pal var]) {
bg = [""] ++ backgrounds;
pal = [""] ++ palettes;
var = [""] ++ variants;
};
in
lib.filter (s: s != "") combinations;
};
solarized-osaka = {
setup = {transparent ? false, ...}: ''
require("solarized-osaka").setup({

View file

@ -19,6 +19,7 @@
./outline
./preview
./sleuth
./smart-splits
./snacks-nvim
./surround
./telescope

View file

@ -1,6 +1,6 @@
{lib, ...}: let
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) enum str bool;
inherit (lib.types) enum str;
inherit (lib.generators) mkLuaInline;
inherit (lib.nvim.types) mkPluginSetupOption luaInline;
in {

View file

@ -5,8 +5,6 @@
}: let
inherit (lib.modules) mkIf;
inherit (lib.nvim.binds) mkKeymap;
inherit (lib.nvim.lua) toLuaObject;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.utility.motion.flash-nvim;
in {

View file

@ -0,0 +1,50 @@
{
config,
options,
lib,
...
}: let
inherit (lib.modules) mkIf;
cfg = config.vim.utility.smart-splits;
inherit (options.vim.utility.smart-splits) keymaps;
mkSmartSplitKey = act: let
key = cfg.keymaps.${act};
in
lib.optional (key != null) {
inherit key;
desc = keymaps.${act}.description;
action = ''function() require('smart-splits').${act}() end'';
mode = "n";
lua = true;
};
in {
config = mkIf cfg.enable {
vim = {
lazy.plugins.smart-splits = {
package = "smart-splits";
setupModule = "smart-splits";
inherit (cfg) setupOpts;
# plugin needs to be loaded right after startup so that the multiplexer detects vim running in the pane
event = ["DeferredUIEnter"];
keys = lib.flatten [
(mkSmartSplitKey "resize_left")
(mkSmartSplitKey "resize_down")
(mkSmartSplitKey "resize_up")
(mkSmartSplitKey "resize_right")
(mkSmartSplitKey "move_cursor_left")
(mkSmartSplitKey "move_cursor_down")
(mkSmartSplitKey "move_cursor_up")
(mkSmartSplitKey "move_cursor_right")
(mkSmartSplitKey "move_cursor_previous")
(mkSmartSplitKey "swap_buf_left")
(mkSmartSplitKey "swap_buf_down")
(mkSmartSplitKey "swap_buf_up")
(mkSmartSplitKey "swap_buf_right")
];
};
};
};
}

View file

@ -0,0 +1,6 @@
{
imports = [
./config.nix
./smart-splits.nix
];
}

View file

@ -0,0 +1,37 @@
{lib, ...}: let
inherit (lib.options) mkOption;
inherit (lib.types) bool;
inherit (lib.nvim.types) mkPluginSetupOption;
inherit (lib.nvim.binds) mkMappingOption;
in {
options.vim.utility.smart-splits = {
enable = mkOption {
type = bool;
default = false;
description = ''
Whether to enable smart-splits.nvim, a Neovim plugin for smart,
seamless, directional navigation and resizing of splits.
Supports tmux, Wezterm, Kitty, and Zellij multiplexer integrations.
'';
};
setupOpts = mkPluginSetupOption "smart-splits" {};
keymaps = {
resize_left = mkMappingOption "Resize Window/Pane Left" "<A-h>";
resize_down = mkMappingOption "Resize Window/Pane Down" "<A-j>";
resize_up = mkMappingOption "Resize Window/Pane Up" "<A-k>";
resize_right = mkMappingOption "Resize Window/Pane Right" "<A-l>";
move_cursor_left = mkMappingOption "Focus Window/Pane on the Left" "<C-h>";
move_cursor_down = mkMappingOption "Focus Window/Pane Below" "<C-j>";
move_cursor_up = mkMappingOption "Focus Window/Pane Above" "<C-k>";
move_cursor_right = mkMappingOption "Focus Window/Pane on the Right" "<C-l>";
move_cursor_previous = mkMappingOption "Focus Previous Window/Pane" "<C-\\>";
swap_buf_left = mkMappingOption "Swap Buffer Left" "<leader><leader>h";
swap_buf_down = mkMappingOption "Swap Buffer Down" "<leader><leader>j";
swap_buf_up = mkMappingOption "Swap Buffer Up" "<leader><leader>k";
swap_buf_right = mkMappingOption "Swap Buffer Right" "<leader><leader>l";
};
};
}

View file

@ -5,8 +5,8 @@
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.strings) optionalString;
inherit (lib.lists) optionals;
inherit (lib.strings) optionalString concatMapStringsSep;
inherit (lib.lists) optionals concatLists;
inherit (lib.nvim.binds) pushDownDefault mkKeymap;
cfg = config.vim.telescope;
@ -16,7 +16,7 @@
in {
config = mkIf cfg.enable {
vim = {
startPlugins = ["plenary-nvim"];
startPlugins = ["plenary-nvim"] ++ concatLists (map (x: x.packages) cfg.extensions);
lazy.plugins.telescope = {
package = "telescope";
@ -28,11 +28,14 @@ in {
vim.g.loaded_telescope = nil
'';
after = ''
after = let
enabledExtensions = map (x: x.name) cfg.extensions;
in ''
local telescope = require("telescope")
${optionalString config.vim.ui.noice.enable "telescope.load_extension('noice')"}
${optionalString config.vim.notify.nvim-notify.enable "telescope.load_extension('notify')"}
${optionalString config.vim.projects.project-nvim.enable "telescope.load_extension('projects')"}
${concatMapStringsSep "\n" (x: "telescope.load_extension('${x}')") enabledExtensions}
'';
cmd = ["Telescope"];

View file

@ -1,12 +1,15 @@
{
config,
pkgs,
lib,
...
}: let
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) int str listOf float bool either enum submodule attrsOf;
inherit (lib.options) mkOption mkEnableOption literalExpression;
inherit (lib.types) int str listOf float bool either enum submodule attrsOf anything package;
inherit (lib.nvim.binds) mkMappingOption;
inherit (lib.nvim.types) mkPluginSetupOption luaInline;
cfg = config.vim.telescope;
setupOptions = {
pickers.find_files.find_command = mkOption {
description = "cmd to use for finding files";
@ -16,10 +19,6 @@
defaults = {
vimgrep_arguments = mkOption {
description = ''
Defines the command that will be used for `live_grep` and `grep_string` pickers.
Make sure that color is set to `never` because telescope does not yet interpret color codes.
'';
type = listOf str;
default = [
"${pkgs.ripgrep}/bin/rg"
@ -32,114 +31,169 @@
"--hidden"
"--no-ignore"
];
description = ''
Defines the command that will be used for `live_grep` and `grep_string` pickers.
Make sure that color is set to `never` because telescope does not yet interpret color codes.
'';
};
pickers.find_command = mkOption {
type = either (listOf str) luaInline;
default = ["${pkgs.fd}/bin/fd"];
description = ''
Command to use for finding files. If using an executable from {env}`PATH` then you must
make sure that the package is available in [](#opt-vim.extraPackages).
'';
};
prompt_prefix = mkOption {
description = "Shown in front of Telescope's prompt";
type = str;
default = " ";
description = "Shown in front of Telescope's prompt";
};
selection_caret = mkOption {
type = str;
default = " ";
description = "Character(s) to show in front of the current selection";
type = str;
default = " ";
};
entry_prefix = mkOption {
description = "Prefix in front of each result entry. Current selection not included.";
type = str;
default = " ";
description = "Prefix in front of each result entry. Current selection not included.";
};
initial_mode = mkOption {
description = "Determines in which mode telescope starts.";
type = enum ["insert" "normal"];
default = "insert";
description = "Determines in which mode telescope starts.";
};
selection_strategy = mkOption {
description = "Determines how the cursor acts after each sort iteration.";
type = enum ["reset" "follow" "row" "closest" "none"];
default = "reset";
description = "Determines how the cursor acts after each sort iteration.";
};
sorting_strategy = mkOption {
description = ''Determines the direction "better" results are sorted towards.'';
type = enum ["descending" "ascending"];
default = "ascending";
description = ''Determines the direction "better" results are sorted towards.'';
};
layout_strategy = mkOption {
description = "Determines the default layout of Telescope pickers. See `:help telescope.layout`.";
type = str;
default = "horizontal";
description = "Determines the default layout of Telescope pickers. See `:help telescope.layout`.";
};
layout_config = mkOption {
description = ''
Determines the default configuration values for layout strategies.
See telescope.layout for details of the configurations options for
each strategy.
'';
default = {};
type = submodule {
options = {
horizontal = {
prompt_position = mkOption {
description = "";
type = str;
type = enum ["top" "bottom"];
default = "top";
description = "Where to place prompt window";
};
preview_width = mkOption {
description = "";
type = float;
default = 0.55;
description = "Change the width of Telescope's preview window";
};
};
vertical = {
mirror = mkOption {
description = "";
type = bool;
default = false;
description = "Flip the location of the results/prompt and preview windows";
};
};
width = mkOption {
description = "";
type = float;
default = 0.8;
description = "How wide to make Telescope's entire layout";
};
height = mkOption {
description = "";
type = float;
default = 0.8;
description = "How tall to make Telescope's entire layout";
};
preview_cutoff = mkOption {
description = "";
type = int;
default = 120;
description = "When lines are less than this value, the preview will be disabled";
};
};
};
description = ''
Determines the default configuration values for layout strategies.
See `telescope.layout` for details of the configurations options for
each strategy.
'';
};
file_ignore_patterns = mkOption {
description = "A table of lua regex that define the files that should be ignored.";
type = listOf str;
default = ["node_modules" "%.git/" "dist/" "build/" "target/" "result/"];
description = "File patterns to omit from Telescope results";
};
color_devicons = mkOption {
description = "Boolean if devicons should be enabled or not.";
type = bool;
default = true;
};
color_devicons = mkEnableOption "colored devicons";
path_display = mkOption {
description = "Determines how file paths are displayed.";
type = listOf (enum ["hidden" "tail" "absolute" "smart" "shorten" "truncate"]);
default = ["absolute"];
description = "Determines how file paths are displayed.";
};
set_env = mkOption {
description = "Set an environment for term_previewer";
type = attrsOf str;
default = {
COLORTERM = "truecolor";
};
default = {COLORTERM = "truecolor";};
description = "Set an environment for term_previewer";
};
winblend = mkOption {
description = "pseudo-transparency of keymap hints floating window";
type = int;
default = 0;
description = "Pseudo-transparency of keymap hints floating window";
};
extensions = mkOption {
type = attrsOf anything;
default = builtins.foldl' (acc: x: acc // (x.setup or {})) {} cfg.extensions;
description = "Attribute set containing per-extension settings for Telescope";
};
};
};
extensionOpts = {
options = {
name = mkOption {
type = str;
description = "Name of the extension, will be used to load it with a `require`";
};
packages = mkOption {
type = listOf (either str package);
default = [];
description = "Package or packages providing the Telescope extension to be loaded.";
};
setup = mkOption {
type = attrsOf anything;
default = {};
example = {fzf = {fuzzy = true;};};
description = "Named attribute set to be inserted into Telescope's extensions table.";
};
};
};
@ -174,5 +228,24 @@ in {
enable = mkEnableOption "telescope.nvim: multi-purpose search and picker utility";
setupOpts = mkPluginSetupOption "Telescope" setupOptions;
extensions = mkOption {
type = listOf (submodule extensionOpts);
default = [];
example = literalExpression ''
[
{
name = "fzf";
packages = [pkgs.vimPlugins.telescope-fzf-native-nvim];
setup = {fzf = {fuzzy = true;};};
}
]
'';
description = ''
Individual extension configurations containing **name**, **packages** and **setup**
fields to resolve dependencies, handle `load_extension` calls and add the `setup`
table into the `extensions` portion of Telescope's setup table.
'';
};
};
}

View file

@ -32,7 +32,7 @@ in {
assertions = [
{
assertion = usingShada && ((config.vim.options.shada or "") == "");
assertion = usingShada -> (config.vim.options.shada or "") != "";
message = ''
Yanky.nvim is configured to use 'shada' for the storage backend, but shada is disabled
in 'vim.options'. Please re-enable shada, or switch to a different backend.

View file

@ -1,7 +1,7 @@
{lib, ...}: let
inherit (lib.modules) mkRemovedOptionModule;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) submodule attrs attrsOf;
inherit (lib.types) attrs;
inherit (lib.nvim.types) mkPluginSetupOption;
in {
imports = [

View file

@ -1,8 +1,4 @@
{
config,
lib,
...
}: let
{lib, ...}: let
inherit (lib.modules) mkRenamedOptionModule;
inherit (lib.options) mkOption mkEnableOption literalExpression;
inherit (lib.types) nullOr attrsOf attrs enum;

View file

@ -1,8 +1,4 @@
{
config,
lib,
...
}: let
{lib, ...}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in {

View file

@ -7,9 +7,9 @@
}: let
inherit (pkgs) vimPlugins;
inherit (lib.trivial) flip;
inherit (builtins) filter isString;
inherit (builtins) filter isString hasAttr getAttr;
getPin = name: ((pkgs.callPackages ../../../npins/sources.nix {}) // config.vim.pluginOverrides).${name};
getPin = flip getAttr (pkgs.callPackages ../../../npins/sources.nix {});
noBuildPlug = pname: let
pin = getPin pname;
@ -48,13 +48,22 @@
doCheck = false;
};
inherit (inputs.self.packages.${pkgs.stdenv.system}) blink-cmp;
inherit (inputs.self.packages.${pkgs.stdenv.system}) blink-cmp avante-nvim;
};
buildConfigPlugins = plugins:
map (plug:
if (isString plug)
then pluginBuilders.${plug} or (noBuildPlug plug)
then
if hasAttr plug config.vim.pluginOverrides
then
(let
plugin = config.vim.pluginOverrides.${plug};
in
if (lib.isType "flake" plugin)
then plugin // {name = plug;}
else plugin)
else pluginBuilders.${plug} or (noBuildPlug plug)
else plug) (
filter (f: f != null) plugins
);

View file

@ -11,7 +11,7 @@ in {
description = ''
[official documentation]: https://neovim.io/doc/user/lua.html#vim.loader.enable()
Whethere to enable the experimental Lua module loader to speed up the start
Whether to enable the experimental Lua module loader to speed up the start
up process. If `true`, this will enable the experimental Lua module loader
which: