Compare commits

...

10 Commits

13 changed files with 282 additions and 94 deletions

View File

@ -47,7 +47,7 @@
nixosModules.neovim-flake has been deprecated.
Please use the nixosModules.nvf instead
''
self.nixosModules.neovim-flake;
self.nixosModules.nvf;
nvf = {
imports = [(import ./flake/modules/nixos.nix self.packages inputs)];

View File

@ -25,7 +25,7 @@ inputs: {
# check can be disabled while calling this file is called
# to avoid checking in all modules
nvimModules = import ./modules.nix {
inherit check pkgs;
inherit pkgs check;
lib = extendedLib;
};

View File

@ -1,7 +1,7 @@
{
check ? true,
pkgs,
lib,
check ? true,
}: let
inherit (lib.modules) mkDefault;
inherit (lib.lists) concatLists;
@ -10,6 +10,7 @@
# Contains configuration for core neovim features
# such as spellchecking, mappings, and the init script (init.vim).
neovim = map (p: ./neovim + "/${p}") [
"global"
"init"
"mappings"
];

View File

@ -0,0 +1,12 @@
{lib, ...}: let
inherit (lib.lists) concatLists;
inherit (lib.filesystem) listFilesRecursive;
in {
imports = concatLists [
# Configuration options for Neovim UI
(listFilesRecursive ./ui)
# vim.diagnostics
[./diagnostics.nix]
];
}

View File

@ -0,0 +1,115 @@
{
config,
lib,
...
}: let
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) str bool enum either;
in {
options.vim.diagnostics = {
virtual_text = mkOption {
type = bool;
default = true;
description = ''
Whether to use virtual text for diagnostics.
If multiple diagnostics are set for a namespace, one
prefix per diagnostic + the last diagnostic message
are shown.
'';
};
update_in_insert = mkOption {
type = bool;
default = false;
description = ''
Whether to update diagnostics in insert mode.
This is useful for slow diagnostics sources, but can
also cause lag in insert mode.
'';
};
underline = mkOption {
type = bool;
default = true;
description = ''
Whether to underline diagnostics.
'';
};
severity_sort = mkOption {
type = bool;
default = false;
description = ''
Whether to sort diagnostics by severity.
This affects the order in which signs and
virtual text are displayed. When true, higher
severities are displayed before lower severities (e.g.
ERROR is displayed before WARN)
'';
};
float = {
focusable = mkOption {
type = bool;
default = false;
description = ''
Whether the floating window is focusable.
When true, the floating window can be focused and
interacted with. When false, the floating window is
not focusable and will not receive input.
'';
};
border = mkOption {
type = enum ["none" "single" "double" "rounded" "solid" "shadow"];
default = config.vim.ui.border.globalStyle;
description = ''
The border style of the floating window.
Possible values:
- none
- single
- double
- rounded
- solid
- shadow
See `:h nvim_open_win` for the available border
styles and their definitions.
'';
};
source = mkOption {
type = either bool (enum ["always" "if_many"]);
default = "auto";
description = ''
The source of the floating window.
Possible values:
- auto: Use the same source as the diagnostics
window.
- window: Use the window source.
- buffer: Use the buffer source.
'';
};
prefix = mkOption {
type = str;
default = "";
description = ''
Prefix string for each diagnostic in the floating window
'';
};
suffix = mkOption {
type = str;
default = "";
description = ''
Suffix string for each diagnostic in the floating window
'';
};
};
};
}

View File

@ -0,0 +1,51 @@
{
config,
lib,
...
}: let
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.attrsets) mapAttrs;
inherit (lib.lists) optionals;
inherit (lib.types) enum;
cfg = config.vim.ui.borders;
# See `:h nvim_open_win` for the available border styles
# this list can be updated if additional styles are added.
defaultStyles = ["none" "single" "double" "rounded" "solid" "shadow"];
in {
options.vim.ui.borders = {
enable = mkEnableOption "visible borders for windows that support configurable borders";
# TODO: support configurable border elements with a lua table converted from a list of str
# e.g. [ "╔" "═" "╗" "║" "╝" "═" "╚" "║" ]
globalStyle = mkOption {
type = enum defaultStyles;
default = "single";
description = ''
The global border style to use.
'';
};
plugins = let
mkPluginStyleOption = name: {
enable = mkEnableOption "borders for the ${name} plugin" // {default = cfg.enable;};
style = mkOption {
type = enum (defaultStyles ++ optionals (name != "which-key") ["shadow"]);
default = cfg.globalStyle;
description = "The border style to use for the ${name} plugin";
};
};
in
mapAttrs (_: mkPluginStyleOption) {
# despite not having it listed in example configuration, which-key does support the rounded type
# additionally, it supports a "shadow" type that is similar to none but is of higher contrast
which-key = "which-key";
lspsaga = "lspsaga";
nvim-cmp = "nvim-cmp";
lsp-signature = "lsp-signature";
code-action-menu = "code-actions-menu";
};
};
}

View File

@ -0,0 +1,32 @@
{lib, ...}: let
inherit (lib.options) mkOption;
inherit (lib.types) str;
in {
options.vim.ui.icons = {
diagnostics = {
ERROR = mkOption {
type = str;
default = " ";
description = "The icon to use for error messages";
};
WARN = mkOption {
type = str;
default = " ";
description = "The icon to use for warning messages";
};
INFO = mkOption {
type = str;
default = " ";
description = "The icon to use for info messages";
};
HINT = mkOption {
type = str;
default = " ";
description = "The icon to use for hint messages";
};
};
};
}

View File

@ -5,6 +5,7 @@
}: let
inherit (lib.modules) mkIf mkMerge;
inherit (lib.attrsets) mapAttrs;
inherit (lib.trivial) boolToString;
inherit (lib.nvim.dag) entryAnywhere entryAfter entryBetween;
cfg = config.vim.lsp;
@ -12,26 +13,36 @@ in {
config = mkIf cfg.null-ls.enable (mkMerge [
{
vim = {
startPlugins = [
"none-ls"
"plenary-nvim"
];
# null-ls implies LSP already being set up
# since it will hook into LSPs to receive information
lsp.enable = true;
startPlugins = ["none-ls"];
luaConfigRC.null_ls-setup = entryAnywhere ''
local null_ls = require("null-ls")
local null_helpers = require("null-ls.helpers")
local null_methods = require("null-ls.methods")
local ls_sources = {}
'';
luaConfigRC = {
# early setup for null-ls
null_ls-setup = entryAnywhere ''
local null_ls = require("null-ls")
local null_helpers = require("null-ls.helpers")
local null_methods = require("null-ls.methods")
local ls_sources = {}
'';
luaConfigRC.null_ls = entryAfter ["null_ls-setup" "lsp-setup"] ''
require('null-ls').setup({
debug = false,
diagnostics_format = "[#{m}] #{s} (#{c})",
debounce = 250,
default_timeout = 5000,
sources = ls_sources,
on_attach = default_on_attach
})
'';
# null-ls setup
null_ls = entryAfter ["null_ls-setup" "lsp-setup"] ''
require('null-ls').setup({
debug = ${boolToString cfg.null-ls.debug},
diagnostics_format = "${cfg.null-ls.diagnostics_format}",
debounce = ${toString cfg.null-ls.debounce},
default_timeout = ${toString cfg.null-ls.default_timeout},
sources = ls_sources,
on_attach = default_on_attach
})
'';
};
};
}
{

View File

@ -1,10 +1,30 @@
{lib, ...}: let
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) attrsOf str;
inherit (lib.types) attrsOf str int;
in {
options.vim.lsp.null-ls = {
enable = mkEnableOption "null-ls, also enabled automatically";
debug = mkEnableOption "debugging information for `null-ls";
diagnostics_format = mkOption {
type = str;
default = "[#{m}] #{s} (#{c})";
description = "Diagnostic output format for null-ls";
};
debounce = mkOption {
type = int;
default = 250;
description = "Default debounce";
};
default_timeout = mkOption {
type = int;
default = 5000;
description = "Default timeout value, in miliseconds";
};
sources = mkOption {
description = "null-ls sources";
type = attrsOf str;

View File

@ -1,46 +0,0 @@
{
config,
lib,
...
}: let
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.lists) optionals;
inherit (lib.types) enum;
cfg = config.vim.ui.borders;
defaultStyles = ["none" "single" "double" "rounded"];
in {
options.vim.ui.borders = {
enable = mkEnableOption "visible borders for most windows";
globalStyle = mkOption {
type = enum defaultStyles;
default = "rounded";
description = ''
The global border style to use.
'';
};
# TODO: make per-plugin borders configurable
plugins = let
mkPluginStyleOption = name: {
enable = mkEnableOption "borders for the ${name} plugin" // {default = cfg.enable;};
style = mkOption {
type = enum (defaultStyles ++ optionals (name != "which-key") ["shadow"]);
default = cfg.globalStyle;
description = "The border style to use for the ${name} plugin";
};
};
in {
# despite not having it listed in example configuration, which-key does support the rounded type
# additionally, it supports a "shadow" type that is similar to none but is of higher contrast
which-key = mkPluginStyleOption "which-key";
lspsaga = mkPluginStyleOption "lspsaga";
nvim-cmp = mkPluginStyleOption "nvim-cmp";
lsp-signature = mkPluginStyleOption "lsp-signature";
code-action-menu = mkPluginStyleOption "code-actions-menu";
};
};
}

View File

@ -1,5 +0,0 @@
{
imports = [
./borders.nix
];
}

View File

@ -1,12 +1,11 @@
{
imports = [
./noice
./modes
./notifications
./smartcolumn
./breadcrumbs
./colorizer
./illuminate
./breadcrumbs
./borders
./modes
./noice
./notifications
./smartcolumn
];
}

View File

@ -3,7 +3,7 @@
lib,
...
}: let
inherit (lib.options) mkOption mkEnableOption literalExpression;
inherit (lib.options) mkOption mkEnableOption literalMD;
inherit (lib.types) package bool str listOf attrsOf;
inherit (lib.nvim.types) pluginsOpt extraPluginType;
in {
@ -38,7 +38,7 @@ in {
startPlugins = pluginsOpt {
default = ["plenary-nvim"];
example = literalExpression ''
example = ''
[pkgs.vimPlugins.telescope-nvim]
'';
@ -54,7 +54,7 @@ in {
optPlugins = pluginsOpt {
default = [];
example = literalExpression ''
example = ''
[pkgs.vimPlugins.vim-ghost]
'';
description = ''
@ -80,7 +80,8 @@ in {
your custom plugins using nvf's modified DAG library.
'';
example = literalExpression ''
example = literalMD ''
```nix
with pkgs.vimPlugins; {
aerial = {
package = aerial-nvim;
@ -93,13 +94,14 @@ in {
after = ["aerial"]; # place harpoon configuration after aerial
};
}
```
'';
};
extraPackages = mkOption {
type = listOf package;
default = [];
example = literalExpression ''[pkgs.fzf pkgs.ripgrep]'';
example = ''[pkgs.fzf pkgs.ripgrep]'';
description = ''
List of additional packages to make available to the Neovim
wrapper.
@ -107,7 +109,7 @@ in {
};
# this defaults to `true` in the wrapper
# and since we passs this value to the wrapper
# and since we pass this value to the wrapper
# with an inherit, it should be `true` here as well
withRuby =
mkEnableOption ''
@ -118,29 +120,25 @@ in {
};
withNodeJs = mkEnableOption ''
NodeJs support in the Neovim wrapper.
NodeJs support in the Neovim wrapper
'';
luaPackages = mkOption {
type = listOf str;
default = [];
example = literalExpression ''["magick" "serpent"]'';
description = ''
List of lua packages to install.
'';
example = ''["magick" "serpent"]'';
description = "List of lua packages to install";
};
withPython3 = mkEnableOption ''
Python3 support in the Neovim wrapper.
Python3 support in the Neovim wrapper
'';
python3Packages = mkOption {
type = listOf str;
default = [];
example = literalExpression ''["pynvim"]'';
description = ''
List of python packages to install.
'';
example = ''["pynvim"]'';
description = "List of python packages to install";
};
};
}