Merge branch 'main' into avante

use pins for package call

syntax fix

add optional deps
This commit is contained in:
Alexandra Østermark 2025-05-15 19:23:58 +02:00
commit 5fe4106866
No known key found for this signature in database
GPG key ID: C2B9D34D979B6063
97 changed files with 1157 additions and 486 deletions

View file

@ -111,6 +111,15 @@ in {
under the diagnostics module. Please consider using one of 'vim.diagnostics.config' or
'vim.luaConfigRC' to configure LSP lines for Neovim through its own diagnostics API.
'')
# 2025-05-04
(mkRemovedOptionModule ["vim" "useSystemClipboard"] ''
Clipboard behaviour should now be controlled through the new, more fine-grained module
interface found in 'vim.clipboard'. To replicate previous behaviour, you may either
add 'vim.opt.clipboard:append("unnamedplus")' in luaConfigRC, or preferably set it
in 'vim.clipboard.registers'. Please see the documentation for the new module for more
details, or open an issue if you are confused.
'')
]
# Migrated via batchRenameOptions. Further batch renames must be below this line.

View file

@ -34,12 +34,6 @@ in {
description = "Enable syntax highlighting";
};
useSystemClipboard = mkOption {
type = bool;
default = false;
description = "Make use of the clipboard for default yank and paste operations. Don't use * and +";
};
lineNumberMode = mkOption {
type = enum ["relative" "number" "relNumber" "none"];
default = "relNumber";
@ -144,10 +138,6 @@ in {
# to pre-set Neovim options. Fear not, though as the Lua DAG is still as powerful as it
# could be.
luaConfigRC.basic = entryAfter ["globalsScript"] ''
${optionalString cfg.useSystemClipboard ''
vim.opt.clipboard:append("unnamedplus")
''}
${optionalString cfg.syntaxHighlighting ''
vim.cmd("syntax on")
''}

View file

@ -0,0 +1,80 @@
{
config,
pkgs,
lib,
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.options) mkOption mkEnableOption mkPackageOption;
inherit (lib.types) nullOr either str listOf submodule;
inherit (lib.attrsets) mapAttrs mapAttrsToList filterAttrs;
cfg = config.vim.clipboard;
in {
options = {
vim = {
clipboard = {
enable = mkEnableOption ''
clipboard management for Neovim. Users may still choose to manage their
clipboard through [](#opt-vim.options) should they wish to avoid using
this module.
'';
registers = mkOption {
type = either str (listOf str);
default = "";
example = "unnamedplus";
description = ''
The register to be used by the Neovim clipboard. Recognized types are:
* unnamed: Vim will use the clipboard register `"*"` for all yank, delete,
change and put operations which would normally go to the unnamed register.
* unnamedplus: A variant of the "unnamed" flag which uses the clipboard register
`"+"` ({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 `"*"`.
Please see {command}`:h clipboard` for more details.
'';
};
providers = mkOption {
type = submodule {
options = let
clipboards = {
# name = "package name";
wl-copy = "wl-clipboard";
xclip = "xclip";
xsel = "xsel";
};
in
mapAttrs (name: pname: {
enable = mkEnableOption name;
package = mkPackageOption pkgs pname {nullable = true;};
})
clipboards;
};
default = {};
description = ''
Clipboard providers for which packages will be added to nvf's
{option}`extraPackages`. The `package` field may be set to `null`
if related packages are already found in system packages to
potentially reduce closure sizes.
'';
};
};
};
};
config = mkIf cfg.enable {
vim = {
options.clipboard = cfg.registers;
extraPackages = mapAttrsToList (_: v: v.package) (
filterAttrs (_: v: v.enable && v.package != null) cfg.providers
);
};
};
}

View file

@ -2,6 +2,7 @@
imports = [
./autocmds.nix
./basic.nix
./clipboard.nix
./debug.nix
./diagnostics.nix
./highlight.nix

View file

@ -5,7 +5,7 @@
}: let
inherit (builtins) filter;
inherit (lib.modules) mkIf mkMerge mkDefault;
inherit (lib.options) mkOption;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) attrsOf;
inherit (lib.strings) concatLines;
inherit (lib.attrsets) mapAttrsToList attrNames filterAttrs;
@ -27,37 +27,48 @@
enabledServers = filterAttrs (_: u: u.enable) cfg.servers;
in {
options = {
vim.lsp.servers = mkOption {
type = attrsOf lspOptions;
default = {};
example = ''
{
"*" = {
root_markers = [".git"];
capabilities = {
textDocument = {
semanticTokens = {
multilineTokenSupport = true;
vim.lsp = {
enable = mkEnableOption ''
global LSP functionality for Neovim.
This option controls whether to enable LSP functionality within modules under
{option}`vim.languages`. You do not need to set this to `true` for language
servers defined in {option}`vim.lsp.servers` to take effect, since they are
enabled automatically.
'';
servers = mkOption {
type = attrsOf lspOptions;
default = {};
example = ''
{
"*" = {
root_markers = [".git"];
capabilities = {
textDocument = {
semanticTokens = {
multilineTokenSupport = true;
};
};
};
};
};
"clangd" = {
filetypes = ["c"];
};
}
'';
description = ''
LSP configurations that will be managed using `vim.lsp.config()` and
related utilities added in Neovim 0.11. LSPs defined here will be
added to the resulting {file}`init.lua` using `vim.lsp.config` and
enabled through `vim.lsp.enable` below the configuration table.
"clangd" = {
filetypes = ["c"];
};
}
'';
description = ''
LSP configurations that will be managed using `vim.lsp.config()` and related
utilities added in Neovim 0.11. LSPs defined here will be added to the
resulting {file}`init.lua` using `vim.lsp.config` and enabled through
`vim.lsp.enable()` API from Neovim below the configuration table.
You may review the generated configuration by running {command}`nvf-print-config`
in a shell. Please see {command}`:help lsp-config` for more details
on the underlying API.
'';
You may review the generated configuration by running {command}`nvf-print-config`
in a shell. Please see {command}`:help lsp-config` for more details
on the underlying API.
'';
};
};
};

View file

@ -683,15 +683,48 @@ in {
};
git_placement = mkOption {
type = enum ["before" "after" "signcolumn"];
description = "Place where the git icons will be rendered. `signcolumn` requires `view.signcolumn` to be enabled.";
type = enum ["before" "after" "signcolumn" "right_align"];
default = "before";
description = ''
Place where the git icons will be rendered.
`signcolumn` requires `view.signcolumn` to be enabled.
'';
};
modified_placement = mkOption {
type = enum ["before" "after" "signcolumn"];
description = "Place where the modified icons will be rendered. `signcolumn` requires `view.signcolumn` to be enabled.";
type = enum ["before" "after" "signcolumn" "right_align"];
default = "after";
description = ''
Place where the modified icons will be rendered.
`signcolumn` requires `view.signcolumn` to be enabled.
'';
};
hidden_placement = mkOption {
type = enum ["before" "after" "signcolumn" "right_align"];
default = "after";
description = ''
Place where the hidden icons will be rendered.
`signcolumn` requires `view.signcolumn` to be enabled.
'';
};
diagnostics_placement = mkOption {
type = enum ["before" "after" "signcolumn" "right_align"];
default = "after";
description = ''
Place where the diagnostics icons will be rendered.
`signcolumn` requires `view.signcolumn` to be enabled.
'';
};
bookmarks_placement = mkOption {
type = enum ["before" "after" "signcolumn" "right_align"];
default = "after";
description = ''
Place where the bookmark icons will be rendered.
`signcolumn` requires `view.signcolumn` to be enabled.
'';
};
padding = mkOption {

View file

@ -1,12 +1,9 @@
{
pkgs,
lib,
...
}: let
inherit (lib.options) mkOption mkEnableOption literalExpression;
inherit (lib.types) attrs enum nullOr;
inherit (lib.nvim.types) mkPluginSetupOption;
inherit (lib.nvim.lua) mkLuaInline;
{lib, ...}: let
inherit (lib.generators) mkLuaInline;
inherit (lib.options) mkOption mkEnableOption literalMD;
inherit (lib.types) attrs either nullOr;
inherit (lib.nvim.lua) toLuaObject;
inherit (lib.nvim.types) luaInline mkPluginSetupOption;
in {
options.vim.formatter.conform-nvim = {
enable = mkEnableOption "lightweight yet powerful formatter plugin for Neovim [conform-nvim]";
@ -31,26 +28,46 @@ in {
};
format_on_save = mkOption {
type = nullOr attrs;
default = {
lsp_format = "fallback";
timeout_ms = 500;
};
type = nullOr (either attrs luaInline);
default = mkLuaInline ''
function()
if not vim.g.formatsave or vim.b.disableFormatSave then
return
else
return {lsp_format = "fallback", timeout_ms = 500}
end
end
'';
defaultText = literalMD ''
enabled by default, and respects {option}`vim.lsp.formatOnSave` and
{option}`vim.lsp.mappings.toggleFormatSave`
'';
description = ''
Table that will be passed to `conform.format()`. If this
is set, Conform will run the formatter on save.
Attribute set or Lua function that will be passed to
`conform.format()`. If this is set, Conform will run the formatter
on save.
'';
};
format_after_save = mkOption {
type = nullOr attrs;
default = {lsp_format = "fallback";};
description = ''
Table that will be passed to `conform.format()`. If this
is set, Conform will run the formatter asynchronously after
save.
'';
};
format_after_save = let
defaultFormatAfterSaveOpts = {lsp_format = "fallback";};
in
mkOption {
type = nullOr (either attrs luaInline);
default = mkLuaInline ''
function()
if not vim.g.formatsave or vim.b.disableFormatSave then
return
else
return ${toLuaObject defaultFormatAfterSaveOpts}
end
end
'';
description = ''
Table or function(luainline) that will be passed to `conform.format()`. If this
is set, Conform will run the formatter asynchronously after save.
'';
};
};
};
}

View file

@ -20,7 +20,7 @@ in {
};
lsp = {
enable = mkEnableOption "Assembly LSP support (asm-lsp)" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Assembly LSP support (asm-lsp)" // {default = config.vim.lsp.enable;};
package = mkOption {
type = package;

View file

@ -81,7 +81,7 @@ in {
};
lsp = {
enable = mkEnableOption "Astro LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Astro LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
type = enum (attrNames servers);

View file

@ -56,7 +56,7 @@ in {
};
lsp = {
enable = mkEnableOption "Enable Bash LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Enable Bash LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
description = "Bash LSP server to use";

View file

@ -98,7 +98,7 @@ in {
};
lsp = {
enable = mkEnableOption "clang LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "clang LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
description = "The clang LSP server to use";

View file

@ -91,7 +91,7 @@ in {
};
lsp = {
enable = mkEnableOption "C# LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "C# LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
description = "C# LSP server to use";
type = enum (attrNames servers);

View file

@ -80,7 +80,7 @@ in {
};
lsp = {
enable = mkEnableOption "CSS LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "CSS LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
description = "CSS LSP server to use";

View file

@ -21,7 +21,7 @@ in {
};
lsp = {
enable = mkEnableOption "CUE LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "CUE LSP support" // {default = config.vim.lsp.enable;};
package = mkOption {
type = package;

View file

@ -77,7 +77,7 @@ in {
flutter-tools = {
enable = mkOption {
type = bool;
default = config.vim.languages.enableLSP;
default = config.vim.lsp.enable;
description = "Enable flutter-tools for flutter support";
};
@ -143,8 +143,6 @@ in {
})
(mkIf ftcfg.enable {
lsp.enable = true;
startPlugins = [
(
if ftcfg.enableNoResolvePatch

View file

@ -1,8 +1,5 @@
{
config,
lib,
...
}: let
{lib, ...}: let
inherit (lib.modules) mkRenamedOptionModule;
inherit (lib.nvim.languages) mkEnable;
in {
imports = [
@ -48,13 +45,12 @@ in {
./wgsl.nix
./yaml.nix
./ruby.nix
# This is now a hard deprecation.
(mkRenamedOptionModule ["vim" "languages" "enableLSP"] ["vim" "lsp" "enable"])
];
options.vim.languages = {
# LSPs are now built into Neovim, and we should enable them by default
# if `vim.lsp.enable` is true.
enableLSP = mkEnable "LSP" // {default = config.vim.lsp.enable;};
# Those are still managed by plugins, and should be enabled here.
enableDAP = mkEnable "Debug Adapter";
enableTreesitter = mkEnable "Treesitter";

View file

@ -53,7 +53,7 @@ in {
};
lsp = {
enable = mkEnableOption "Elixir LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Elixir LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
description = "Elixir LSP server to use";

View file

@ -51,7 +51,7 @@ in {
};
lsp = {
enable = mkEnableOption "F# LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "F# LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
type = enum (attrNames servers);
default = defaultServer;

View file

@ -41,7 +41,7 @@ in {
};
lsp = {
enable = mkEnableOption "Gleam LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Gleam LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
type = enum (attrNames servers);

View file

@ -67,7 +67,7 @@ in {
};
lsp = {
enable = mkEnableOption "Go LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Go LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
description = "Go LSP server to use";

View file

@ -25,7 +25,7 @@ in {
};
lsp = {
enable = mkEnableOption "LSP support for Haskell" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "LSP support for Haskell" // {default = config.vim.lsp.enable;};
package = mkOption {
description = "Haskell LSP package or command to run the Haskell LSP";
example = ''[ (lib.getExe pkgs.haskellPackages.haskell-language-server) "--debug" ]'';

View file

@ -43,7 +43,7 @@ in {
};
lsp = {
enable = mkEnableOption "HCL LSP support (terraform-ls)" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "HCL LSP support (terraform-ls)" // {default = config.vim.lsp.enable;};
# TODO: (maybe, is it better?) it would be cooler to use vscode-extensions.hashicorp.hcl probably, shouldn't be too hard
package = mkOption {
type = package;

View file

@ -54,7 +54,7 @@ in {
};
lsp = {
enable = mkEnableOption "Helm LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Helm LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
description = "Helm LSP server to use";

View file

@ -23,7 +23,7 @@ in {
};
lsp = {
enable = mkEnableOption "Java LSP support (java-language-server)" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Java LSP support (java-language-server)" // {default = config.vim.lsp.enable;};
package = mkOption {
description = "java language server package, or the command to run as a list of strings";
example = ''[lib.getExe pkgs.jdt-language-server "-data" "~/.cache/jdtls/workspace"]'';

View file

@ -78,7 +78,7 @@ in {
lsp = {
enable = mkOption {
type = bool;
default = config.vim.languages.enableLSP;
default = config.vim.lsp.enable;
description = ''
Whether to enable Julia LSP support.

View file

@ -30,7 +30,7 @@ in {
};
lsp = {
enable = mkEnableOption "Kotlin LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Kotlin LSP support" // {default = config.vim.lsp.enable;};
package = mkOption {
description = "kotlin_language_server package with Kotlin runtime";

View file

@ -43,7 +43,7 @@ in {
};
lsp = {
enable = mkEnableOption "Lua LSP support via LuaLS" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Lua LSP support via LuaLS" // {default = config.vim.lsp.enable;};
package = mkOption {
description = "LuaLS package, or the command to run as a list of strings";

View file

@ -67,7 +67,7 @@ in {
};
lsp = {
enable = mkEnableOption "Enable Markdown LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Enable Markdown LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
type = enum (attrNames servers);
@ -130,6 +130,18 @@ in {
};
};
};
markview-nvim = {
enable =
mkEnableOption ""
// {
description = ''
[markview.nvim]: https://github.com/OXY2DEV/markview.nvim
[markview.nvim] - a hackable markdown, Typst, latex, html(inline) & YAML previewer
'';
};
setupOpts = mkPluginSetupOption "markview-nvim" {};
};
};
extraDiagnostics = {
@ -175,6 +187,13 @@ in {
'';
})
(mkIf cfg.extensions.markview-nvim.enable {
vim.startPlugins = ["markview-nvim"];
vim.pluginRC.markview-nvim = entryAnywhere ''
require("markview").setup(${toLuaObject cfg.extensions.markview-nvim.setupOpts})
'';
})
(mkIf cfg.extraDiagnostics.enable {
vim.diagnostics.nvim-lint = {
enable = true;

View file

@ -54,7 +54,7 @@ in {
};
lsp = {
enable = mkEnableOption "Nim LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Nim LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
description = "Nim LSP server to use";
type = str;

View file

@ -2,6 +2,7 @@
config,
pkgs,
lib,
inputs,
...
}: let
inherit (builtins) attrNames;
@ -27,7 +28,7 @@
else ''{"${package}/bin/${defaultCmd}"}'';
servers = {
nil = {
package = pkgs.nil;
package = inputs.nil.packages.${pkgs.stdenv.system}.nil;
internalFormatter = true;
lspConfig = ''
lspconfig.nil_ls.setup{
@ -143,7 +144,7 @@ in {
};
lsp = {
enable = mkEnableOption "Nix LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Nix LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
description = "Nix LSP server to use";
type = enum (attrNames servers);

View file

@ -40,7 +40,7 @@ in {
};
lsp = {
enable = mkEnableOption "Nu LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Nu LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
type = str;
default = defaultServer;

View file

@ -49,7 +49,7 @@ in {
};
lsp = {
enable = mkEnableOption "OCaml LSP support (ocaml-lsp)" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "OCaml LSP support (ocaml-lsp)" // {default = config.vim.lsp.enable;};
server = mkOption {
description = "OCaml LSP server to user";
type = enum (attrNames servers);

View file

@ -41,7 +41,7 @@ in {
};
lsp = {
enable = mkEnableOption "Odin LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Odin LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
type = enum (attrNames servers);

View file

@ -95,7 +95,7 @@ in {
};
lsp = {
enable = mkEnableOption "PHP LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "PHP LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
description = "PHP LSP server to use";

View file

@ -169,7 +169,7 @@ in {
};
lsp = {
enable = mkEnableOption "Python LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Python LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
description = "Python LSP server to use";

View file

@ -79,7 +79,7 @@ in {
};
lsp = {
enable = mkEnableOption "R LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "R LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
description = "R LSP server to use";

View file

@ -9,6 +9,8 @@
inherit (lib.meta) getExe;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.types) mkGrammarOption diagnostics;
inherit (lib.nvim.lua) expToLua;
inherit (lib.lists) isList;
inherit (lib.types) either listOf package str enum;
cfg = config.vim.languages.ruby;
@ -24,7 +26,25 @@
flags = {
debounce_text_changes = 150,
},
cmd = { "${pkgs.solargraph}/bin/solargraph", "stdio" }
cmd = ${
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''{ "${cfg.lsp.package}/bin/solargraph", "stdio" }''
}
}
'';
};
rubylsp = {
package = pkgs.ruby-lsp;
lspConfig = ''
lspconfig.ruby_lsp.setup {
capabilities = capabilities,
on_attach = default_on_attach,
cmd = ${
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''{ "${cfg.lsp.package}/bin/ruby-lsp" }''
}
}
'';
};
@ -57,7 +77,7 @@ in {
};
lsp = {
enable = mkEnableOption "Ruby LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Ruby LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
type = enum (attrNames servers);

View file

@ -43,7 +43,7 @@ in {
};
lsp = {
enable = mkEnableOption "Rust LSP support (rust-analyzer with extra tools)" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Rust LSP support (rust-analyzer with extra tools)" // {default = config.vim.lsp.enable;};
package = mkOption {
description = "rust-analyzer package, or the command to run as a list of strings";
example = ''[lib.getExe pkgs.jdt-language-server "-data" "~/.cache/jdtls/workspace"]'';

View file

@ -33,7 +33,7 @@ in {
};
lsp = {
enable = mkEnableOption "Scala LSP support (metals)" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Scala LSP support (metals)" // {default = config.vim.lsp.enable;};
package = mkPackageOption pkgs "metals" {
default = ["metals"];
};

View file

@ -79,7 +79,7 @@ in {
};
lsp = {
enable = mkEnableOption "SQL LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "SQL LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
description = "SQL LSP server to use";

View file

@ -77,7 +77,7 @@ in {
};
lsp = {
enable = mkEnableOption "Svelte LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Svelte LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
description = "Svelte LSP server to use";

View file

@ -35,7 +35,7 @@ in {
enable = mkEnableOption "Tailwindcss language support";
lsp = {
enable = mkEnableOption "Tailwindcss LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Tailwindcss LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
description = "Tailwindcss LSP server to use";

View file

@ -20,7 +20,7 @@ in {
};
lsp = {
enable = mkEnableOption "Terraform LSP support (terraform-ls)" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Terraform LSP support (terraform-ls)" // {default = config.vim.lsp.enable;};
package = mkOption {
description = "terraform-ls package";

View file

@ -101,6 +101,7 @@
"eslint.config.js"
"eslint.config.mjs"
".eslintrc"
".eslintrc.cjs"
".eslintrc.json"
".eslintrc.js"
".eslintrc.yml"
@ -120,7 +121,7 @@ in {
};
lsp = {
enable = mkEnableOption "Typescript/Javascript LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Typescript/Javascript LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
description = "Typescript/Javascript LSP server to use";

View file

@ -76,7 +76,7 @@ in {
};
lsp = {
enable = mkEnableOption "Typst LSP support (typst-lsp)" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Typst LSP support (typst-lsp)" // {default = config.vim.lsp.enable;};
server = mkOption {
description = "Typst LSP server to use";

View file

@ -50,7 +50,7 @@ in {
};
lsp = {
enable = mkEnableOption "Vala LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Vala LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
description = "Vala LSP server to use";
type = enum (attrNames servers);

View file

@ -42,7 +42,7 @@ in {
};
lsp = {
enable = mkEnableOption "WGSL LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "WGSL LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
type = enum (attrNames servers);

View file

@ -55,7 +55,7 @@ in {
};
lsp = {
enable = mkEnableOption "YAML LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "YAML LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
type = enum (attrNames servers);

View file

@ -72,7 +72,7 @@ in {
};
lsp = {
enable = mkEnableOption "Zig LSP support" // {default = config.vim.languages.enableLSP;};
enable = mkEnableOption "Zig LSP support" // {default = config.vim.lsp.enable;};
server = mkOption {
type = enum (attrNames servers);

View file

@ -6,6 +6,7 @@
}: let
inherit (lib.generators) mkLuaInline;
inherit (lib.modules) mkIf;
inherit (lib.lists) optional;
inherit (lib.strings) optionalString;
inherit (lib.trivial) boolToString;
inherit (lib.nvim.binds) addDescriptionsToMappings;
@ -14,7 +15,10 @@
usingNvimCmp = config.vim.autocomplete.nvim-cmp.enable;
usingBlinkCmp = config.vim.autocomplete.blink-cmp.enable;
self = import ./module.nix {inherit config lib pkgs;};
conformCfg = config.vim.formatter.conform-nvim;
conformFormatOnSave = conformCfg.enable && conformCfg.setupOpts.format_on_save != null;
augroup = "nvf_lsp";
mappingDefinitions = self.options.vim.lsp.mappings;
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
mkBinding = binding: action:
@ -29,24 +33,59 @@ in {
sourcePlugins = ["cmp-nvim-lsp"];
};
augroups = [{name = augroup;}];
autocmds =
if cfg.inlayHints.enable
then [
{
callback = mkLuaInline ''
function(event)
local bufnr = event.buf
local client = vim.lsp.get_client_by_id(event.data.client_id)
if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({ bufnr = bufnr }), { bufnr = bufnr })
(optional cfg.inlayHints.enable {
group = augroup;
event = ["LspAttach"];
desc = "LSP on-attach enable inlay hints autocmd";
callback = mkLuaInline ''
function(event)
local bufnr = event.buf
local client = vim.lsp.get_client_by_id(event.data.client_id)
if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({ bufnr = bufnr }), { bufnr = bufnr })
end
end
'';
})
++ (optional (!conformFormatOnSave) {
group = augroup;
event = ["BufWritePre"];
desc = "LSP on-attach create format on save autocmd";
callback = mkLuaInline ''
function(ev)
if vim.b.disableFormatSave or not vim.g.formatsave then
return
end
local bufnr = ev.buf
${optionalString cfg.null-ls.enable ''
-- prefer null_ls formatter
do
local clients = vim.lsp.get_clients({
bufnr = bufnr,
name = "null-ls",
method = "textDocument/formatting",
})
if clients[1] then
vim.lsp.buf.format({ bufnr = bufnr, id = clients[1].id })
return
end
end
'';
desc = "LSP on-attach enable inlay hints autocmd";
event = ["LspAttach"];
}
]
else [];
''}
local clients = vim.lsp.get_clients({
bufnr = bufnr,
method = "textDocument/formatting",
})
if clients[1] then
vim.lsp.buf.format({ bufnr = bufnr, id = clients[1].id })
end
end
'';
});
pluginRC.lsp-setup = ''
vim.g.formatsave = ${boolToString cfg.formatOnSave};
@ -74,60 +113,9 @@ in {
${mkBinding mappings.toggleFormatOnSave "function() vim.b.disableFormatSave = not vim.b.disableFormatSave end"}
end
-- Enable formatting
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
format_callback = function(client, bufnr)
if vim.g.formatsave then
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
vim.api.nvim_create_autocmd("BufWritePre", {
group = augroup,
buffer = bufnr,
callback = function()
${
if config.vim.lsp.null-ls.enable
then ''
if vim.b.disableFormatSave then
return
end
local function is_null_ls_formatting_enabled(bufnr)
local file_type = vim.api.nvim_buf_get_option(bufnr, "filetype")
local generators = require("null-ls.generators").get_available(
file_type,
require("null-ls.methods").internal.FORMATTING
)
return #generators > 0
end
if is_null_ls_formatting_enabled(bufnr) then
vim.lsp.buf.format({
bufnr = bufnr,
filter = function(client)
return client.name == "null-ls"
end
})
else
vim.lsp.buf.format({
bufnr = bufnr,
})
end
''
else "
vim.lsp.buf.format({
bufnr = bufnr,
})
"
}
end,
})
end
end
${optionalString config.vim.ui.breadcrumbs.enable ''local navic = require("nvim-navic")''}
default_on_attach = function(client, bufnr)
attach_keymaps(client, bufnr)
format_callback(client, bufnr)
${optionalString config.vim.ui.breadcrumbs.enable ''
-- let navic attach to buffers
if client.server_capabilities.documentSymbolProvider then
@ -138,6 +126,7 @@ in {
local capabilities = vim.lsp.protocol.make_client_capabilities()
${optionalString usingNvimCmp ''
-- TODO(horriblename): migrate to vim.lsp.config['*']
-- HACK: copied from cmp-nvim-lsp. If we ever lazy load lspconfig we
-- should re-evaluate whether we can just use `default_capabilities`
capabilities = {

View file

@ -14,8 +14,6 @@ in {
config = mkIf cfg.lspconfig.enable (mkMerge [
{
vim = {
lsp.enable = true;
startPlugins = ["nvim-lspconfig"];
pluginRC.lspconfig = entryAfter ["lsp-setup"] ''

View file

@ -3,11 +3,12 @@
inherit (lib.nvim.binds) mkMappingOption;
in {
options.vim.lsp = {
enable = mkEnableOption "LSP, also enabled automatically through null-ls and lspconfig options";
formatOnSave = mkEnableOption "format on save";
inlayHints = {
enable = mkEnableOption "inlay hints";
};
mappings = {
goToDefinition =
mkMappingOption "Go to definition"

View file

@ -109,7 +109,7 @@ in {
type = nullOr str;
default = null;
description = ''
The indicatotor icon to use for the current buffer.
The indicator icon to use for the current buffer.
::: {.warning}
This **must** be omitted while style is not `icon`

View file

@ -2,6 +2,7 @@
imports = [
# treesitter extras
./ts-context
./ts-textobjects
./treesitter.nix
./config.nix

View file

@ -0,0 +1,23 @@
{
config,
lib,
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.nvim.lua) toLuaObject;
inherit (lib.nvim.dag) entryAfter;
inherit (config.vim) treesitter;
cfg = treesitter.textobjects;
in {
config = mkIf (treesitter.enable && cfg.enable) {
vim = {
startPlugins = ["nvim-treesitter-textobjects"];
# set up treesitter-textobjects after Treesitter, whose config we're adding to.
pluginRC.treesitter-textobjects = entryAfter ["treesitter"] ''
require("nvim-treesitter.configs").setup({textobjects = ${toLuaObject cfg.setupOpts}})
'';
};
};
}

View file

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

View file

@ -0,0 +1,21 @@
{lib, ...}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in {
options.vim.treesitter.textobjects = {
enable = mkEnableOption "Treesitter textobjects";
setupOpts =
mkPluginSetupOption "treesitter-textobjects" {}
// {
example = {
select = {
enable = true;
lookahead = true;
keymaps = {
af = "@function.outer";
};
};
};
};
};
}

View file

@ -4,7 +4,7 @@
...
}: let
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) nullOr listOf enum bool str int either;
inherit (lib.types) nullOr listOf enum bool str int;
inherit (lib.modules) mkRenamedOptionModule;
inherit (lib.nvim.types) mkPluginSetupOption borderType;
mkSimpleIconOption = default:
@ -74,7 +74,7 @@ in {
::: {.note}
This will pass `draw_empty` to the `nvim_navic` winbar
component, which causes the component to be drawn even
if it's empty
if it's empty.
:::
'';
};
@ -86,145 +86,163 @@ in {
close = mkOption {
type = str;
default = "<esc>";
description = "keybinding to close Navbuddy UI";
description = "Close and return the cursor to its original location.";
};
nextSibling = mkOption {
type = str;
default = "j";
description = "keybinding to navigate to the next sibling node";
description = "Navigate to the next sibling node.";
};
previousSibling = mkOption {
type = str;
default = "k";
description = "keybinding to navigate to the previous sibling node";
description = "Navigate to the previous sibling node.";
};
parent = mkOption {
type = str;
default = "h";
description = "keybinding to navigate to the parent node";
description = "Navigate to the parent node.";
};
children = mkOption {
type = str;
default = "l";
description = "keybinding to navigate to the child node";
description = "Navigate to the child node.";
};
root = mkOption {
type = str;
default = "0";
description = "keybinding to navigate to the root node";
description = "Navigate to the root node.";
};
visualName = mkOption {
type = str;
default = "v";
description = "visual selection of name";
description = "Select the name visually.";
};
visualScope = mkOption {
type = str;
default = "V";
description = "visual selection of scope";
description = "Select the scope visually.";
};
yankName = mkOption {
type = str;
default = "y";
description = "yank the name to system clipboard";
description = "Yank the name to system clipboard.";
};
yankScope = mkOption {
type = str;
default = "Y";
description = "yank the scope to system clipboard";
description = "Yank the scope to system clipboard.";
};
insertName = mkOption {
type = str;
default = "i";
description = "insert at start of name";
description = "Insert at the start of name.";
};
insertScope = mkOption {
type = str;
default = "I";
description = "insert at start of scope";
description = "Insert at the start of scope.";
};
appendName = mkOption {
type = str;
default = "a";
description = "insert at end of name";
description = "Insert at the end of name.";
};
appendScope = mkOption {
type = str;
default = "A";
description = "insert at end of scope";
description = "Insert at the end of scope.";
};
rename = mkOption {
type = str;
default = "r";
description = "rename the node";
description = "Rename the node.";
};
delete = mkOption {
type = str;
default = "d";
description = "delete the node";
description = "Delete the node.";
};
foldCreate = mkOption {
type = str;
default = "f";
description = "create a new fold";
description = "Create a new fold of the node.";
};
foldDelete = mkOption {
type = str;
default = "F";
description = "delete the current fold";
description = "Delete the current fold of the node.";
};
comment = mkOption {
type = str;
default = "c";
description = "comment the node";
description = "Comment the node.";
};
select = mkOption {
type = str;
default = "<enter>";
description = "goto selected symbol";
description = "Goto the node.";
};
moveDown = mkOption {
type = str;
default = "J";
description = "move focused node down";
description = "Move the node down.";
};
moveUp = mkOption {
type = str;
default = "K";
description = "move focused node up";
description = "Move the node up.";
};
togglePreview = mkOption {
type = str;
default = "s";
description = "Toggle the preview.";
};
vsplit = mkOption {
type = str;
default = "<C-v>";
description = "Open the node in a vertical split.";
};
hsplit = mkOption {
type = str;
default = "<C-s>";
description = "Open the node in a horizontal split.";
};
telescope = mkOption {
type = str;
default = "t";
description = "fuzzy finder at current level";
description = "Start fuzzy finder at the current level.";
};
help = mkOption {
type = str;
default = "g?";
description = "open mapping help window";
description = "Open the mappings help window.";
};
};
@ -232,7 +250,7 @@ in {
useDefaultMappings = mkOption {
type = bool;
default = true;
description = "use default Navbuddy keybindings (disables user-specified keybinds)";
description = "Add the default Navbuddy keybindings in addition to the keybinding added by this module.";
};
window = {
@ -242,13 +260,13 @@ in {
border = mkOption {
type = borderType;
default = config.vim.ui.borders.globalStyle;
description = "border style to use";
description = "The border style to use.";
};
scrolloff = mkOption {
type = nullOr int;
default = null;
description = "Scrolloff value within navbuddy window";
description = "The scrolloff value within a navbuddy window.";
};
sections = {
@ -265,7 +283,7 @@ in {
border = mkOption {
type = borderType;
default = config.vim.ui.borders.globalStyle;
description = "border style to use for the left section of Navbuddy UI";
description = "The border style to use for the left section of the Navbuddy UI.";
};
};
@ -282,7 +300,7 @@ in {
border = mkOption {
type = borderType;
default = config.vim.ui.borders.globalStyle;
description = "border style to use for the middle section of Navbuddy UI";
description = "The border style to use for the middle section of the Navbuddy UI.";
};
};
@ -292,13 +310,13 @@ in {
border = mkOption {
type = borderType;
default = config.vim.ui.borders.globalStyle;
description = "border style to use for the right section of Navbuddy UI";
description = "The border style to use for the right section of the Navbuddy UI.";
};
preview = mkOption {
type = enum ["leaf" "always" "never"];
default = "leaf";
description = "display mode of the preview on the right section";
description = "The display mode of the preview on the right section.";
};
};
};
@ -317,13 +335,13 @@ in {
auto_attach = mkOption {
type = bool;
default = true;
description = "Whether to attach to LSP server manually";
description = "Whether to attach to LSP server manually.";
};
preference = mkOption {
type = nullOr (listOf str);
default = null;
description = "list of lsp server names in order of preference";
description = "The preference list ranking LSP servers.";
};
};
@ -331,25 +349,25 @@ in {
followNode = mkOption {
type = bool;
default = true;
description = "keep the current node in focus on the source buffer";
description = "Whether to keep the current node in focus in the source buffer.";
};
highlight = mkOption {
type = bool;
default = true;
description = "highlight the currently focused node";
description = "Whether to highlight the currently focused node in the source buffer.";
};
reorient = mkOption {
type = enum ["smart" "top" "mid" "none"];
default = "smart";
description = "reorient buffer after changing nodes";
description = "The mode for reorienting the source buffer after moving nodes.";
};
scrolloff = mkOption {
type = nullOr int;
default = null;
description = "scrolloff value when navbuddy is open";
description = "The scrolloff value in the source buffer when Navbuddy is open.";
};
};

View file

@ -64,6 +64,11 @@ in {
${cfg.navbuddy.mappings.moveDown} = mkLuaInline "actions.move_down()";
${cfg.navbuddy.mappings.moveUp} = mkLuaInline "actions.move_up()";
${cfg.navbuddy.mappings.togglePreview} = mkLuaInline "actions.toggle_preview()";
${cfg.navbuddy.mappings.vsplit} = mkLuaInline "actions.vsplit()";
${cfg.navbuddy.mappings.hsplit} = mkLuaInline "actions.hsplit()";
${cfg.navbuddy.mappings.telescope} = mkLuaInline ''
actions.telescope({
layout_strategy = "horizontal",

View file

@ -51,7 +51,7 @@
doCheck = false;
};
inherit (inputs.self.legacyPackages.${pkgs.stdenv.system}) blink-cmp avante-nvim;
inherit (inputs.self.packages.${pkgs.stdenv.system}) blink-cmp avante-nvim;
};
buildConfigPlugins = plugins:
@ -62,17 +62,14 @@
filter (f: f != null) plugins
);
# built (or "normalized") plugins that are modified
builtStartPlugins = buildConfigPlugins config.vim.startPlugins;
builtOptPlugins = map (package: package // {optional = true;}) (
buildConfigPlugins config.vim.optPlugins
);
# Wrap the user's desired (unwrapped) Neovim package with arguments that'll be used to
# generate a wrapped Neovim package.
neovim-wrapped = inputs.mnw.lib.wrap pkgs {
neovim-wrapped = inputs.mnw.lib.wrap {inherit pkgs;} {
neovim = config.vim.package;
plugins = builtStartPlugins ++ builtOptPlugins;
plugins = {
start = buildConfigPlugins config.vim.startPlugins;
opt = buildConfigPlugins config.vim.optPlugins;
};
appName = "nvf";
extraBinPath = config.vim.extraPackages;
initLua = config.vim.builtLuaConfigRC;