mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-09-09 11:51:35 +00:00
change: fix release note
This commit is contained in:
commit
03f477ad93
9 changed files with 275 additions and 31 deletions
|
@ -2,6 +2,7 @@
|
|||
imports = [
|
||||
./basic.nix
|
||||
./debug.nix
|
||||
./highlight.nix
|
||||
./spellcheck.nix
|
||||
];
|
||||
}
|
||||
|
|
119
modules/neovim/init/highlight.nix
Normal file
119
modules/neovim/init/highlight.nix
Normal file
|
@ -0,0 +1,119 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.options) mkOption;
|
||||
inherit (lib.types) nullOr attrsOf listOf submodule bool ints str enum;
|
||||
inherit (lib.strings) hasPrefix concatLines;
|
||||
inherit (lib.attrsets) mapAttrsToList;
|
||||
inherit (lib.nvim.dag) entryBetween;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
inherit (lib.nvim.types) hexColor;
|
||||
|
||||
mkColorOption = target:
|
||||
mkOption {
|
||||
type = nullOr hexColor;
|
||||
default = null;
|
||||
example = "#ebdbb2";
|
||||
description = ''
|
||||
The ${target} color to use. Written as color name or hex "#RRGGBB".
|
||||
'';
|
||||
};
|
||||
|
||||
mkBoolOption = name:
|
||||
mkOption {
|
||||
type = nullOr bool;
|
||||
default = null;
|
||||
example = false;
|
||||
description = "Whether to enable ${name}";
|
||||
};
|
||||
|
||||
cfg = config.vim.highlight;
|
||||
in {
|
||||
options.vim.highlight = mkOption {
|
||||
type = attrsOf (submodule {
|
||||
# See :h nvim_set_hl
|
||||
options = {
|
||||
bg = mkColorOption "background";
|
||||
fg = mkColorOption "foreground";
|
||||
sp = mkColorOption "special";
|
||||
blend = mkOption {
|
||||
type = nullOr (ints.between 0 100);
|
||||
default = null;
|
||||
description = "Blend as an integer between 0 and 100";
|
||||
};
|
||||
bold = mkBoolOption "bold";
|
||||
standout = mkBoolOption "standout";
|
||||
underline = mkBoolOption "underline";
|
||||
undercurl = mkBoolOption "undercurl";
|
||||
underdouble = mkBoolOption "underdouble";
|
||||
underdotted = mkBoolOption "underdotted";
|
||||
underdashed = mkBoolOption "underdashed";
|
||||
strikethrough = mkBoolOption "strikethrough";
|
||||
italic = mkBoolOption "italic";
|
||||
reverse = mkBoolOption "reverse";
|
||||
nocombine = mkBoolOption "nocombine";
|
||||
link = mkOption {
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
description = "The name of another highlight group to link to";
|
||||
};
|
||||
default = mkOption {
|
||||
type = nullOr bool;
|
||||
default = null;
|
||||
description = "Don't override existing definition";
|
||||
};
|
||||
ctermfg = mkOption {
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
description = "The cterm foreground color to use";
|
||||
};
|
||||
ctermbg = mkOption {
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
description = "The cterm background color to use";
|
||||
};
|
||||
cterm = mkOption {
|
||||
type = nullOr (listOf (enum [
|
||||
"bold"
|
||||
"underline"
|
||||
"undercurl"
|
||||
"underdouble"
|
||||
"underdotted"
|
||||
"underdashed"
|
||||
"strikethrough"
|
||||
"reverse"
|
||||
"inverse"
|
||||
"italic"
|
||||
"standout"
|
||||
"altfont"
|
||||
"nocombine"
|
||||
"NONE"
|
||||
]));
|
||||
default = null;
|
||||
description = "The cterm arguments to use. See ':h highlight-args'";
|
||||
};
|
||||
force = mkBoolOption "force update";
|
||||
};
|
||||
});
|
||||
default = {};
|
||||
example = {
|
||||
SignColumn = {
|
||||
bg = "#282828";
|
||||
};
|
||||
};
|
||||
description = "Custom highlights to apply";
|
||||
};
|
||||
|
||||
config = {
|
||||
vim.luaConfigRC.highlight = let
|
||||
highlights =
|
||||
mapAttrsToList (
|
||||
name: value: ''vim.api.nvim_set_hl(0, ${toLuaObject name}, ${toLuaObject value})''
|
||||
)
|
||||
cfg;
|
||||
in
|
||||
entryBetween ["lazyConfigs" "pluginConfigs" "extraPluginConfigs"] ["theme"] (concatLines highlights);
|
||||
};
|
||||
}
|
|
@ -8,10 +8,12 @@
|
|||
inherit (lib.options) mkEnableOption mkOption;
|
||||
inherit (lib.modules) mkIf mkMerge mkDefault;
|
||||
inherit (lib.lists) isList;
|
||||
inherit (lib.types) either listOf package str enum;
|
||||
inherit (lib.types) bool either listOf package str enum;
|
||||
inherit (lib.nvim.lua) expToLua;
|
||||
inherit (lib.nvim.types) mkGrammarOption;
|
||||
|
||||
cfg = config.vim.languages.zig;
|
||||
|
||||
defaultServer = "zls";
|
||||
servers = {
|
||||
zls = {
|
||||
|
@ -31,7 +33,35 @@
|
|||
};
|
||||
};
|
||||
|
||||
cfg = config.vim.languages.zig;
|
||||
# TODO: dap.adapter.lldb is duplicated when enabling the
|
||||
# vim.languages.clang.dap module. This does not cause
|
||||
# breakage... but could be cleaner.
|
||||
defaultDebugger = "lldb-vscode";
|
||||
debuggers = {
|
||||
lldb-vscode = {
|
||||
package = pkgs.lldb;
|
||||
dapConfig = ''
|
||||
dap.adapters.lldb = {
|
||||
type = 'executable',
|
||||
command = '${cfg.dap.package}/bin/lldb-dap',
|
||||
name = 'lldb'
|
||||
}
|
||||
dap.configurations.zig = {
|
||||
{
|
||||
name = 'Launch',
|
||||
type = 'lldb',
|
||||
request = 'launch',
|
||||
program = function()
|
||||
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
||||
end,
|
||||
cwd = "''${workspaceFolder}",
|
||||
stopOnEntry = false,
|
||||
args = {},
|
||||
},
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
in {
|
||||
options.vim.languages.zig = {
|
||||
enable = mkEnableOption "Zig language support";
|
||||
|
@ -56,6 +86,26 @@ in {
|
|||
default = pkgs.zls;
|
||||
};
|
||||
};
|
||||
|
||||
dap = {
|
||||
enable = mkOption {
|
||||
type = bool;
|
||||
default = config.vim.languages.enableDAP;
|
||||
description = "Enable Zig Debug Adapter";
|
||||
};
|
||||
|
||||
debugger = mkOption {
|
||||
type = enum (attrNames debuggers);
|
||||
default = defaultDebugger;
|
||||
description = "Zig debugger to use";
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
type = package;
|
||||
default = debuggers.${cfg.dap.debugger}.package;
|
||||
description = "Zig debugger package.";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
|
@ -77,5 +127,12 @@ in {
|
|||
globals.zig_fmt_autosave = mkDefault 0;
|
||||
};
|
||||
})
|
||||
|
||||
(mkIf cfg.dap.enable {
|
||||
vim = {
|
||||
debugger.nvim-dap.enable = true;
|
||||
debugger.nvim-dap.sources.zig-debugger = debuggers.${cfg.dap.debugger}.dapConfig;
|
||||
};
|
||||
})
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.strings) optionalString;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
|
||||
|
@ -12,13 +13,29 @@ in {
|
|||
config = mkIf (cfg.enable && cfg.lightbulb.enable) {
|
||||
vim = {
|
||||
startPlugins = ["nvim-lightbulb"];
|
||||
|
||||
pluginRC.lightbulb = entryAnywhere ''
|
||||
vim.api.nvim_command('autocmd CursorHold,CursorHoldI * lua require\'nvim-lightbulb\'.update_lightbulb()')
|
||||
|
||||
-- Enable trouble diagnostics viewer
|
||||
require'nvim-lightbulb'.setup(${toLuaObject cfg.lightbulb.setupOpts})
|
||||
local nvim_lightbulb = require("nvim-lightbulb")
|
||||
nvim_lightbulb.setup(${toLuaObject cfg.lightbulb.setupOpts})
|
||||
${optionalString cfg.lightbulb.autocmd.enable ''
|
||||
vim.api.nvim_create_autocmd(${toLuaObject cfg.lightbulb.autocmd.events}, {
|
||||
pattern = ${toLuaObject cfg.lightbulb.autocmd.pattern},
|
||||
callback = function()
|
||||
nvim_lightbulb.update_lightbulb()
|
||||
end,
|
||||
})
|
||||
''}
|
||||
'';
|
||||
};
|
||||
|
||||
warnings = [
|
||||
# This could have been an assertion, but the chances of collision is very low and asserting here
|
||||
# might be too dramatic. Let's only warn the user, *in case* this occurs and is not intended. No
|
||||
# error will be thrown if 'lightbulb.setupOpts.autocmd.enable' has not been set by the user.
|
||||
(mkIf (cfg.lightbulb.autocmd.enable -> (cfg.lightbulb.setupOpts.autocmd.enabled or false)) ''
|
||||
Both 'vim.lsp.lightbulb.autocmd.enable' and 'vim.lsp.lightbulb.setupOpts.autocmd.enable' are set
|
||||
simultaneously. This might have performance implications due to frequent updates. Please set only
|
||||
one option to handle nvim-lightbulb autocmd.
|
||||
'')
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,11 +1,29 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption;
|
||||
inherit (lib.nvim.types) mkPluginSetupOption;
|
||||
inherit (lib.options) mkOption mkEnableOption;
|
||||
inherit (lib.types) listOf str either;
|
||||
inherit (lib.nvim.types) mkPluginSetupOption luaInline;
|
||||
in {
|
||||
options.vim.lsp = {
|
||||
lightbulb = {
|
||||
enable = mkEnableOption "Lightbulb for code actions. Requires an emoji font";
|
||||
setupOpts = mkPluginSetupOption "nvim-lightbulb" {};
|
||||
autocmd = {
|
||||
enable = mkEnableOption "updating lightbulb glyph automatically" // {default = true;};
|
||||
events = mkOption {
|
||||
type = listOf str;
|
||||
default = ["CursorHold" "CursorHoldI"];
|
||||
description = "Events on which to update nvim-lightbulb glyphs";
|
||||
};
|
||||
|
||||
pattern = mkOption {
|
||||
type = either str luaInline;
|
||||
default = "*";
|
||||
description = ''
|
||||
File patterns or buffer names to match, determining which files or buffers trigger
|
||||
glyph updates.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue