mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-11-10 15:35:30 +00:00
Merge
This commit is contained in:
commit
d8829a9de9
41 changed files with 1031 additions and 337 deletions
278
modules/plugins/assistant/codecompanion/codecompanion-nvim.nix
Normal file
278
modules/plugins/assistant/codecompanion/codecompanion-nvim.nix
Normal file
|
|
@ -0,0 +1,278 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkOption mkEnableOption;
|
||||
inherit (lib.types) int str enum nullOr attrs;
|
||||
inherit (lib.nvim.types) mkPluginSetupOption luaInline;
|
||||
in {
|
||||
options.vim.assistant = {
|
||||
codecompanion-nvim = {
|
||||
enable = mkEnableOption "complementary neovim plugin for codecompanion.nvim";
|
||||
|
||||
setupOpts = mkPluginSetupOption "codecompanion-nvim" {
|
||||
opts = {
|
||||
send_code = mkEnableOption "code from being sent to the LLM.";
|
||||
|
||||
log_level = mkOption {
|
||||
type = enum ["DEBUG" "INFO" "ERROR" "TRACE"];
|
||||
default = "ERROR";
|
||||
description = "Change the level of logging.";
|
||||
};
|
||||
|
||||
language = mkOption {
|
||||
type = str;
|
||||
default = "English";
|
||||
description = "Specify which language an LLM should respond in.";
|
||||
};
|
||||
};
|
||||
|
||||
display = {
|
||||
diff = {
|
||||
enabled =
|
||||
mkEnableOption ""
|
||||
// {
|
||||
default = true;
|
||||
description = "a diff view to see the changes made by the LLM.";
|
||||
};
|
||||
|
||||
close_chat_at = mkOption {
|
||||
type = int;
|
||||
default = 240;
|
||||
description = ''
|
||||
Close an open chat buffer if the
|
||||
total columns of your display are less than...
|
||||
'';
|
||||
};
|
||||
|
||||
layout = mkOption {
|
||||
type = enum ["vertical" "horizontal"];
|
||||
default = "vertical";
|
||||
description = "Type of split for default provider.";
|
||||
};
|
||||
|
||||
provider = mkOption {
|
||||
type = enum ["default" "mini_diff"];
|
||||
default = "default";
|
||||
description = "The preferred kind of provider.";
|
||||
};
|
||||
};
|
||||
|
||||
inline = {
|
||||
layout = mkOption {
|
||||
type = enum ["vertical" "horizontal" "buffer"];
|
||||
default = "vertical";
|
||||
description = "Customize how output is created in new buffer.";
|
||||
};
|
||||
};
|
||||
|
||||
chat = {
|
||||
auto_scroll = mkEnableOption "automatic page scrolling.";
|
||||
|
||||
show_settings = mkEnableOption ''
|
||||
LLM settings to appear at the top of the chat buffer.
|
||||
'';
|
||||
|
||||
start_in_insert_mode = mkEnableOption ''
|
||||
opening the chat buffer in insert mode.
|
||||
'';
|
||||
|
||||
show_header_separator = mkEnableOption ''
|
||||
header separators in the chat buffer.
|
||||
|
||||
Set this to false if you're using an
|
||||
external markdown formatting plugin.
|
||||
'';
|
||||
|
||||
show_references =
|
||||
mkEnableOption ""
|
||||
// {
|
||||
default = true;
|
||||
description = "references in the chat buffer.";
|
||||
};
|
||||
|
||||
show_token_count =
|
||||
mkEnableOption ""
|
||||
// {
|
||||
default = true;
|
||||
description = "the token count for each response.";
|
||||
};
|
||||
|
||||
intro_message = mkOption {
|
||||
type = str;
|
||||
default = "Welcome to CodeCompanion ✨! Press ? for options.";
|
||||
description = "Message to appear in chat buffer.";
|
||||
};
|
||||
|
||||
separator = mkOption {
|
||||
type = str;
|
||||
default = "─";
|
||||
description = ''
|
||||
The separator between the
|
||||
different messages in the chat buffer.
|
||||
'';
|
||||
};
|
||||
|
||||
icons = {
|
||||
pinned_buffer = mkOption {
|
||||
type = str;
|
||||
default = " ";
|
||||
description = "The icon to represent a pinned buffer.";
|
||||
};
|
||||
|
||||
watched_buffer = mkOption {
|
||||
type = str;
|
||||
default = "👀 ";
|
||||
description = "The icon to represent a watched buffer.";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
action_palette = {
|
||||
width = mkOption {
|
||||
type = int;
|
||||
default = 95;
|
||||
description = "Width of the action palette.";
|
||||
};
|
||||
|
||||
height = mkOption {
|
||||
type = int;
|
||||
default = 10;
|
||||
description = "Height of the action palette.";
|
||||
};
|
||||
|
||||
prompt = mkOption {
|
||||
type = str;
|
||||
default = "Prompt ";
|
||||
description = "Prompt used for interactive LLM calls.";
|
||||
};
|
||||
|
||||
provider = mkOption {
|
||||
type = enum ["default" "telescope" "mini_pick"];
|
||||
default = "default";
|
||||
description = "Provider used for the action palette.";
|
||||
};
|
||||
|
||||
opts = {
|
||||
show_default_actions =
|
||||
mkEnableOption ""
|
||||
// {
|
||||
default = true;
|
||||
description = "showing default actions in the action palette.";
|
||||
};
|
||||
|
||||
show_default_prompt_library =
|
||||
mkEnableOption ""
|
||||
// {
|
||||
default = true;
|
||||
description = ''
|
||||
showing default prompt library in the action palette.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
adapters = mkOption {
|
||||
type = nullOr luaInline;
|
||||
default = null;
|
||||
description = "An adapter is what connects Neovim to an LLM.";
|
||||
};
|
||||
|
||||
strategies = {
|
||||
chat = {
|
||||
adapter = mkOption {
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
description = "Adapter used for the chat strategy.";
|
||||
};
|
||||
|
||||
keymaps = mkOption {
|
||||
type = nullOr attrs;
|
||||
default = null;
|
||||
description = "Define or override the default keymaps.";
|
||||
};
|
||||
|
||||
variables = mkOption {
|
||||
type = nullOr luaInline;
|
||||
default = null;
|
||||
description = ''
|
||||
Define your own variables
|
||||
to share specific content.
|
||||
'';
|
||||
};
|
||||
|
||||
slash_commands = mkOption {
|
||||
type = nullOr luaInline;
|
||||
default = null;
|
||||
description = ''
|
||||
Slash Commands (invoked with /) let you dynamically
|
||||
insert context into the chat buffer,
|
||||
such as file contents or date/time.
|
||||
'';
|
||||
};
|
||||
|
||||
tools = mkOption {
|
||||
type = nullOr attrs;
|
||||
default = null;
|
||||
description = ''
|
||||
Configure tools to perform specific
|
||||
tasks when invoked by an LLM.
|
||||
'';
|
||||
};
|
||||
|
||||
roles = mkOption {
|
||||
type = nullOr luaInline;
|
||||
default = null;
|
||||
description = ''
|
||||
The chat buffer places user and LLM responses under a H2 header.
|
||||
These can be customized in the configuration.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
inline = {
|
||||
adapter = mkOption {
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
description = "Adapter used for the inline strategy.";
|
||||
};
|
||||
|
||||
variables = mkOption {
|
||||
type = nullOr luaInline;
|
||||
default = null;
|
||||
description = ''
|
||||
Define your own variables
|
||||
to share specific content.
|
||||
'';
|
||||
};
|
||||
|
||||
keymaps = {
|
||||
accept_change = {
|
||||
n = mkOption {
|
||||
type = str;
|
||||
default = "ga";
|
||||
description = "Accept the suggested change.";
|
||||
};
|
||||
};
|
||||
|
||||
reject_change = {
|
||||
n = mkOption {
|
||||
type = str;
|
||||
default = "gr";
|
||||
description = "Reject the suggested change.";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
prompt_library = mkOption {
|
||||
type = nullOr attrs;
|
||||
default = null;
|
||||
description = ''
|
||||
A prompt library is a collection of prompts
|
||||
that can be used in the action palette.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
27
modules/plugins/assistant/codecompanion/config.nix
Normal file
27
modules/plugins/assistant/codecompanion/config.nix
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
|
||||
cfg = config.vim.assistant.codecompanion-nvim;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim = {
|
||||
startPlugins = [
|
||||
"plenary-nvim"
|
||||
];
|
||||
|
||||
lazy.plugins = {
|
||||
codecompanion-nvim = {
|
||||
package = "codecompanion-nvim";
|
||||
setupModule = "codecompanion";
|
||||
inherit (cfg) setupOpts;
|
||||
};
|
||||
};
|
||||
|
||||
treesitter.enable = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
6
modules/plugins/assistant/codecompanion/default.nix
Normal file
6
modules/plugins/assistant/codecompanion/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./config.nix
|
||||
./codecompanion-nvim.nix
|
||||
];
|
||||
}
|
||||
|
|
@ -37,6 +37,12 @@ in {
|
|||
inherit (cfg) setupOpts;
|
||||
after = mkIf cfg.cmp.enable "require('copilot_cmp').setup()";
|
||||
|
||||
event = [
|
||||
{
|
||||
event = "User";
|
||||
pattern = "LazyFile";
|
||||
}
|
||||
];
|
||||
cmd = ["Copilot" "CopilotAuth" "CopilotDetach" "CopilotPanel" "CopilotStop"];
|
||||
keys = [
|
||||
(mkLuaKeymap ["n"] cfg.mappings.panel.accept (wrapPanelBinding ''require("copilot.panel").accept'' cfg.mappings.panel.accept) "[copilot] Accept suggestion" {})
|
||||
|
|
|
|||
|
|
@ -2,5 +2,6 @@
|
|||
imports = [
|
||||
./chatgpt
|
||||
./copilot
|
||||
./codecompanion
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption mkOption literalMD;
|
||||
inherit (lib.types) listOf str either attrsOf submodule enum anything int nullOr;
|
||||
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;
|
||||
|
|
@ -21,8 +21,9 @@
|
|||
freeformType = anything;
|
||||
options = {
|
||||
module = mkOption {
|
||||
type = str;
|
||||
description = "module of the provider";
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
description = "Provider module.";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
@ -40,7 +41,7 @@ in {
|
|||
providers = mkOption {
|
||||
type = attrsOf providerType;
|
||||
default = {};
|
||||
description = "Settings for completion providers";
|
||||
description = "Settings for completion providers.";
|
||||
};
|
||||
|
||||
transform_items = mkOption {
|
||||
|
|
@ -63,6 +64,12 @@ in {
|
|||
default = [];
|
||||
description = "List of sources to enable for cmdline. Null means use default source list.";
|
||||
};
|
||||
|
||||
keymap = mkOption {
|
||||
type = keymapType;
|
||||
default = {};
|
||||
description = "blink.cmp cmdline keymap";
|
||||
};
|
||||
};
|
||||
|
||||
completion = {
|
||||
|
|
@ -74,6 +81,16 @@ in {
|
|||
description = "Delay before auto show triggers";
|
||||
};
|
||||
};
|
||||
|
||||
menu.auto_show = mkOption {
|
||||
type = bool;
|
||||
default = true;
|
||||
description = ''
|
||||
Manages the appearance of the completion menu. You may prevent the menu
|
||||
from automatically showing by this option to `false` and manually showing
|
||||
it with the show keymap command.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
keymap = mkOption {
|
||||
|
|
@ -103,7 +120,25 @@ in {
|
|||
fuzzy = {
|
||||
prebuilt_binaries = {
|
||||
download = mkBool false ''
|
||||
Auto-downloads prebuilt binaries. Do not enable, it doesn't work on nix
|
||||
Auto-downloads prebuilt binaries.
|
||||
|
||||
::: .{warning}
|
||||
Do not enable this option, as it does **not work** on Nix!
|
||||
:::
|
||||
'';
|
||||
};
|
||||
|
||||
implementation = mkOption {
|
||||
type = enum ["lua" "prefer_rust" "rust" "prefer_rust_with_warning"];
|
||||
default = "prefer_rust";
|
||||
description = ''
|
||||
fuzzy matcher implementation for Blink.
|
||||
|
||||
* `"lua"`: slower, Lua native fuzzy matcher implementation
|
||||
* `"rust": use the SIMD fuzzy matcher, 'frizbee'
|
||||
* `"prefer_rust"`: use the rust implementation, but fall back to lua
|
||||
* `"prefer_rust_with_warning"`: use the rust implementation, and fall back to lua
|
||||
if it is not available after emitting a warning.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
|
@ -122,12 +157,14 @@ in {
|
|||
sourcePlugins = let
|
||||
sourcePluginType = submodule {
|
||||
options = {
|
||||
enable = mkEnableOption "this source";
|
||||
package = mkOption {
|
||||
type = pluginType;
|
||||
description = ''
|
||||
`blink-cmp` source plugin package.
|
||||
'';
|
||||
};
|
||||
|
||||
module = mkOption {
|
||||
type = str;
|
||||
description = ''
|
||||
|
|
@ -136,7 +173,6 @@ in {
|
|||
Should be present in the source's documentation.
|
||||
'';
|
||||
};
|
||||
enable = mkEnableOption "this source";
|
||||
};
|
||||
};
|
||||
in
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@
|
|||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.strings) optionalString;
|
||||
inherit (lib.generators) mkLuaInline;
|
||||
inherit (lib.attrsets) attrValues filterAttrs;
|
||||
inherit (lib.lists) map optional;
|
||||
inherit (lib.attrsets) attrValues filterAttrs mapAttrsToList;
|
||||
inherit (lib.lists) map optional elem;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
inherit (builtins) concatStringsSep typeOf tryEval attrNames mapAttrs;
|
||||
|
||||
|
|
@ -24,7 +24,22 @@
|
|||
|
||||
enabledBlinkSources = filterAttrs (_source: definition: definition.enable) cfg.sourcePlugins;
|
||||
blinkSourcePlugins = map (definition: definition.package) (attrValues enabledBlinkSources);
|
||||
|
||||
blinkBuiltins = [
|
||||
"path"
|
||||
"lsp"
|
||||
"snippets"
|
||||
"buffer"
|
||||
"omni"
|
||||
];
|
||||
in {
|
||||
assertions =
|
||||
mapAttrsToList (provider: definition: {
|
||||
assertion = elem provider blinkBuiltins || definition.module != null;
|
||||
message = "`config.vim.autocomplete.blink-cmp.setupOpts.sources.providers.${provider}.module` is `null`: non-builtin providers must set `module`.";
|
||||
})
|
||||
cfg.setupOpts.sources.providers;
|
||||
|
||||
vim = mkIf cfg.enable {
|
||||
startPlugins = ["blink-compat"] ++ blinkSourcePlugins ++ (optional cfg.friendly-snippets.enable "friendly-snippets");
|
||||
lazy.plugins = {
|
||||
|
|
|
|||
|
|
@ -60,12 +60,6 @@ in {
|
|||
enableSharedCmpSources = true;
|
||||
|
||||
nvim-cmp = {
|
||||
sources = {
|
||||
nvim-cmp = null;
|
||||
buffer = "[Buffer]";
|
||||
path = "[Path]";
|
||||
};
|
||||
|
||||
sourcePlugins = ["cmp-buffer" "cmp-path"];
|
||||
|
||||
setupOpts = {
|
||||
|
|
|
|||
|
|
@ -98,14 +98,16 @@ in {
|
|||
|
||||
sources = mkOption {
|
||||
type = attrsOf (nullOr str);
|
||||
default = {};
|
||||
default = {
|
||||
nvim-cmp = null;
|
||||
buffer = "[Buffer]";
|
||||
path = "[Path]";
|
||||
};
|
||||
example = {
|
||||
nvim-cmp = null;
|
||||
buffer = "[Buffer]";
|
||||
};
|
||||
description = "The list of sources used by nvim-cmp";
|
||||
example = literalExpression ''
|
||||
{
|
||||
nvim-cmp = null;
|
||||
buffer = "[Buffer]";
|
||||
}
|
||||
'';
|
||||
};
|
||||
|
||||
sourcePlugins = mkOption {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ in {
|
|||
vim = {
|
||||
startPlugins = ["nvim-lint"];
|
||||
pluginRC.nvim-lint = entryAnywhere ''
|
||||
require("lint").setup(${toLuaObject cfg.setupOpts})
|
||||
require("lint").linters_by_ft = ${toLuaObject cfg.linters_by_ft}
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,27 +1,25 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkOption mkEnableOption;
|
||||
inherit (lib.types) attrsOf listOf str;
|
||||
inherit (lib.nvim.types) mkPluginSetupOption;
|
||||
in {
|
||||
options.vim.diagnostics.nvim-lint = {
|
||||
enable = mkEnableOption "asynchronous linter plugin for Neovim [nvim-lint]";
|
||||
setupOpts = mkPluginSetupOption "nvim-lint" {
|
||||
linters_by_ft = mkOption {
|
||||
type = attrsOf (listOf str);
|
||||
default = {};
|
||||
example = {
|
||||
text = ["vale"];
|
||||
markdown = ["vale"];
|
||||
};
|
||||
|
||||
description = ''
|
||||
Map of filetype to formatters. This option takes a set of
|
||||
`key = value` format where the `value` will be converted
|
||||
to its Lua equivalent. You are responsible for passing the
|
||||
correct Nix data types to generate a correct Lua value that
|
||||
conform is able to accept.
|
||||
'';
|
||||
# nvim-lint does not have a setup table.
|
||||
linters_by_ft = mkOption {
|
||||
type = attrsOf (listOf str);
|
||||
default = {};
|
||||
example = {
|
||||
text = ["vale"];
|
||||
markdown = ["vale"];
|
||||
};
|
||||
description = ''
|
||||
Map of filetype to formatters. This option takes a set of `key = value`
|
||||
format where the `value` will be converted to its Lua equivalent
|
||||
through `toLuaObject. You are responsible for passing the correct Nix
|
||||
data types to generate a correct Lua value that conform is able to
|
||||
accept.
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,6 +72,16 @@
|
|||
ls_sources,
|
||||
null_ls.builtins.diagnostics.eslint_d.with({
|
||||
command = "${getExe pkg}",
|
||||
condition = function(utils)
|
||||
return utils.root_has_file({
|
||||
"eslint.config.js",
|
||||
"eslint.config.mjs",
|
||||
".eslintrc",
|
||||
".eslintrc.json",
|
||||
".eslintrc.js",
|
||||
".eslintrc.yml",
|
||||
})
|
||||
end,
|
||||
})
|
||||
)
|
||||
'';
|
||||
|
|
|
|||
51
modules/plugins/languages/cue.nix
Normal file
51
modules/plugins/languages/cue.nix
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.options) mkEnableOption mkOption;
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.types) package;
|
||||
inherit (lib.nvim.types) mkGrammarOption;
|
||||
|
||||
cfg = config.vim.languages.cue;
|
||||
in {
|
||||
options.vim.languages.cue = {
|
||||
enable = mkEnableOption "CUE language support";
|
||||
|
||||
treesitter = {
|
||||
enable = mkEnableOption "CUE treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||
|
||||
package = mkGrammarOption pkgs "cue";
|
||||
};
|
||||
|
||||
lsp = {
|
||||
enable = mkEnableOption "CUE LSP support" // {default = config.vim.languages.enableLSP;};
|
||||
|
||||
package = mkOption {
|
||||
type = package;
|
||||
default = pkgs.cue;
|
||||
description = "cue lsp implementation";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
(mkIf cfg.treesitter.enable {
|
||||
vim.treesitter.enable = true;
|
||||
vim.treesitter.grammars = [cfg.treesitter.package];
|
||||
})
|
||||
|
||||
(mkIf cfg.lsp.enable {
|
||||
vim.lsp.lspconfig.enable = true;
|
||||
vim.lsp.lspconfig.sources.cue-lsp = ''
|
||||
lspconfig.cue.setup {
|
||||
capabilities = capabilities,
|
||||
on_attach = default_on_attach,
|
||||
cmd = {"${cfg.lsp.package}/bin/cue", "lsp"},
|
||||
}
|
||||
'';
|
||||
})
|
||||
]);
|
||||
}
|
||||
|
|
@ -5,6 +5,8 @@ in {
|
|||
./asm.nix
|
||||
./astro.nix
|
||||
./bash.nix
|
||||
./cue.nix
|
||||
./dart.nix
|
||||
./clang.nix
|
||||
./csharp.nix
|
||||
./css.nix
|
||||
|
|
@ -12,6 +14,10 @@ in {
|
|||
./elixir.nix
|
||||
./gleam.nix
|
||||
./go.nix
|
||||
./hcl.nix
|
||||
./helm.nix
|
||||
./kotlin.nix
|
||||
./html.nix
|
||||
./haskell.nix
|
||||
./hcl.nix
|
||||
./html.nix
|
||||
|
|
|
|||
89
modules/plugins/languages/helm.nix
Normal file
89
modules/plugins/languages/helm.nix
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) attrNames;
|
||||
inherit (lib.options) mkEnableOption mkOption;
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.lists) isList;
|
||||
inherit (lib.types) enum either listOf package str;
|
||||
inherit (lib.nvim.types) mkGrammarOption;
|
||||
inherit (lib.nvim.lua) expToLua;
|
||||
|
||||
cfg = config.vim.languages.helm;
|
||||
yamlCfg = config.vim.languages.yaml;
|
||||
|
||||
helmCmd =
|
||||
if isList cfg.lsp.package
|
||||
then cfg.lsp.package
|
||||
else ["${cfg.lsp.package}/bin/helm_ls" "serve"];
|
||||
yamlCmd =
|
||||
if isList yamlCfg.lsp.package
|
||||
then builtins.elemAt yamlCfg.lsp.package 0
|
||||
else "${yamlCfg.lsp.package}/bin/yaml-language-server";
|
||||
|
||||
defaultServer = "helm-ls";
|
||||
servers = {
|
||||
helm-ls = {
|
||||
package = pkgs.helm-ls;
|
||||
lspConfig = ''
|
||||
lspconfig.helm_ls.setup {
|
||||
capabilities = capabilities,
|
||||
on_attach = default_on_attach,
|
||||
cmd = ${expToLua helmCmd},
|
||||
settings = {
|
||||
['helm-ls'] = {
|
||||
yamlls = {
|
||||
path = "${yamlCmd}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
in {
|
||||
options.vim.languages.helm = {
|
||||
enable = mkEnableOption "Helm language support";
|
||||
|
||||
treesitter = {
|
||||
enable = mkEnableOption "Helm treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||
package = mkGrammarOption pkgs "helm";
|
||||
};
|
||||
|
||||
lsp = {
|
||||
enable = mkEnableOption "Helm LSP support" // {default = config.vim.languages.enableLSP;};
|
||||
|
||||
server = mkOption {
|
||||
description = "Helm LSP server to use";
|
||||
type = enum (attrNames servers);
|
||||
default = defaultServer;
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
description = "Helm LSP server package";
|
||||
type = either package (listOf str);
|
||||
default = servers.${cfg.lsp.server}.package;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
(mkIf cfg.treesitter.enable {
|
||||
vim.treesitter.enable = true;
|
||||
vim.treesitter.grammars = [cfg.treesitter.package];
|
||||
})
|
||||
|
||||
(mkIf cfg.lsp.enable {
|
||||
vim.lsp.lspconfig.enable = true;
|
||||
vim.lsp.lspconfig.sources.helm-lsp = servers.${cfg.lsp.server}.lspConfig;
|
||||
})
|
||||
|
||||
{
|
||||
# Enables filetype detection
|
||||
vim.startPlugins = [pkgs.vimPlugins.vim-helm];
|
||||
}
|
||||
]);
|
||||
}
|
||||
|
|
@ -64,6 +64,26 @@
|
|||
}
|
||||
'';
|
||||
};
|
||||
|
||||
intelephense = {
|
||||
package = pkgs.intelephense;
|
||||
lspConfig = ''
|
||||
lspconfig.intelephense.setup{
|
||||
capabilities = capabilities,
|
||||
on_attach = default_on_attach,
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then expToLua cfg.lsp.package
|
||||
else ''
|
||||
{
|
||||
"${getExe cfg.lsp.package}",
|
||||
"--stdio"
|
||||
},
|
||||
''
|
||||
}
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
in {
|
||||
options.vim.languages.php = {
|
||||
|
|
|
|||
|
|
@ -72,6 +72,16 @@
|
|||
ls_sources,
|
||||
null_ls.builtins.diagnostics.eslint_d.with({
|
||||
command = "${getExe pkg}",
|
||||
condition = function(utils)
|
||||
return utils.root_has_file({
|
||||
"eslint.config.js",
|
||||
"eslint.config.mjs",
|
||||
".eslintrc",
|
||||
".eslintrc.json",
|
||||
".eslintrc.js",
|
||||
".eslintrc.yml",
|
||||
})
|
||||
end,
|
||||
})
|
||||
)
|
||||
'';
|
||||
|
|
|
|||
|
|
@ -123,6 +123,16 @@
|
|||
ls_sources,
|
||||
null_ls.builtins.diagnostics.eslint_d.with({
|
||||
command = "${getExe pkg}",
|
||||
condition = function(utils)
|
||||
return utils.root_has_file({
|
||||
"eslint.config.js",
|
||||
"eslint.config.mjs",
|
||||
".eslintrc",
|
||||
".eslintrc.json",
|
||||
".eslintrc.js",
|
||||
".eslintrc.yml",
|
||||
})
|
||||
end,
|
||||
})
|
||||
)
|
||||
'';
|
||||
|
|
|
|||
|
|
@ -14,14 +14,27 @@
|
|||
|
||||
cfg = config.vim.languages.yaml;
|
||||
|
||||
onAttach =
|
||||
if config.vim.languages.helm.lsp.enable
|
||||
then ''
|
||||
on_attach = function(client, bufnr)
|
||||
local filetype = vim.bo[bufnr].filetype
|
||||
if filetype == "helm" then
|
||||
client.stop()
|
||||
end
|
||||
end''
|
||||
else "on_attach = default_on_attach";
|
||||
|
||||
defaultServer = "yaml-language-server";
|
||||
servers = {
|
||||
yaml-language-server = {
|
||||
package = pkgs.nodePackages.yaml-language-server;
|
||||
lspConfig = ''
|
||||
|
||||
|
||||
lspconfig.yamlls.setup {
|
||||
capabilities = capabilities;
|
||||
on_attach = default_on_attach;
|
||||
capabilities = capabilities,
|
||||
${onAttach},
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then expToLua cfg.lsp.package
|
||||
|
|
|
|||
|
|
@ -3,51 +3,24 @@
|
|||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.strings) optionalString;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetLuaBinding;
|
||||
inherit (lib.modules) mkIf mkDefault;
|
||||
|
||||
cfg = config.vim.lsp;
|
||||
self = import ./lspsaga.nix {inherit lib;};
|
||||
|
||||
mappingDefinitions = self.options.vim.lsp.lspsaga.mappings;
|
||||
mappings = addDescriptionsToMappings cfg.lspsaga.mappings mappingDefinitions;
|
||||
in {
|
||||
config = mkIf (cfg.enable && cfg.lspsaga.enable) {
|
||||
vim = {
|
||||
startPlugins = ["lspsaga-nvim"];
|
||||
lazy.plugins.lspsaga-nvim = {
|
||||
package = "lspsaga-nvim";
|
||||
setupModule = "lspsaga";
|
||||
inherit (cfg.lspsaga) setupOpts;
|
||||
|
||||
maps = {
|
||||
visual = mkSetLuaBinding mappings.codeAction "require('lspsaga.codeaction').range_code_action";
|
||||
normal = mkMerge [
|
||||
(mkSetLuaBinding mappings.lspFinder "require('lspsaga.provider').lsp_finder")
|
||||
(mkSetLuaBinding mappings.renderHoveredDoc "require('lspsaga.hover').render_hover_doc")
|
||||
|
||||
(mkSetLuaBinding mappings.smartScrollUp "function() require('lspsaga.action').smart_scroll_with_saga(-1) end")
|
||||
(mkSetLuaBinding mappings.smartScrollDown "function() require('lspsaga.action').smart_scroll_with_saga(1) end")
|
||||
|
||||
(mkSetLuaBinding mappings.rename "require('lspsaga.rename').rename")
|
||||
(mkSetLuaBinding mappings.previewDefinition "require('lspsaga.provider').preview_definition")
|
||||
|
||||
(mkSetLuaBinding mappings.showLineDiagnostics "require('lspsaga.diagnostic').show_line_diagnostics")
|
||||
(mkSetLuaBinding mappings.showCursorDiagnostics "require('lspsaga.diagnostic').show_cursor_diagnostics")
|
||||
|
||||
(mkSetLuaBinding mappings.nextDiagnostic "require('lspsaga.diagnostic').navigate('next')")
|
||||
(mkSetLuaBinding mappings.previousDiagnostic "require('lspsaga.diagnostic').navigate('prev')")
|
||||
|
||||
(mkSetLuaBinding mappings.codeAction "require('lspsaga.codeaction').code_action")
|
||||
(mkIf (!cfg.lspSignature.enable) (mkSetLuaBinding mappings.signatureHelp "require('lspsaga.signaturehelp').signature_help"))
|
||||
];
|
||||
event = ["LspAttach"];
|
||||
};
|
||||
|
||||
pluginRC.lspsaga = entryAnywhere ''
|
||||
require('lspsaga').init_lsp_saga({
|
||||
${optionalString config.vim.ui.borders.plugins.lspsaga.enable ''
|
||||
border_style = '${config.vim.ui.borders.plugins.lspsaga.style}',
|
||||
''}
|
||||
})
|
||||
'';
|
||||
# Optional dependencies, pretty useful to enhance default functionality of
|
||||
# Lspsaga.
|
||||
treesitter.enable = mkDefault true;
|
||||
visuals.nvim-web-devicons.enable = mkDefault true;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,29 +1,32 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption;
|
||||
inherit (lib.nvim.binds) mkMappingOption;
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkRemovedOptionModule;
|
||||
inherit (lib.options) mkOption mkEnableOption;
|
||||
inherit (lib.nvim.types) borderType mkPluginSetupOption;
|
||||
in {
|
||||
imports = [
|
||||
(mkRemovedOptionModule ["vim" "lsp" "lspsaga" "mappings"] ''
|
||||
Lspsaga mappings have been removed from nvf, as the original author has made
|
||||
very drastic changes to the API after taking back ownership, and the fork we
|
||||
used is now archived. Please refer to Lspsaga documentation to add keybinds
|
||||
for functionality you have used.
|
||||
|
||||
<https://nvimdev.github.io/lspsaga>
|
||||
'')
|
||||
];
|
||||
|
||||
options.vim.lsp.lspsaga = {
|
||||
enable = mkEnableOption "LSP Saga";
|
||||
|
||||
mappings = {
|
||||
lspFinder = mkMappingOption "LSP Finder [LSPSaga]" "<leader>lf";
|
||||
renderHoveredDoc = mkMappingOption "Rendered hovered docs [LSPSaga]" "<leader>lh";
|
||||
|
||||
smartScrollUp = mkMappingOption "Smart scroll up [LSPSaga]" "<C-f>";
|
||||
smartScrollDown = mkMappingOption "Smart scroll up [LSPSaga]" "<C-b>";
|
||||
|
||||
rename = mkMappingOption "Rename [LSPSaga]" "<leader>lr";
|
||||
previewDefinition = mkMappingOption "Preview definition [LSPSaga]" "<leader>ld";
|
||||
|
||||
showLineDiagnostics = mkMappingOption "Show line diagnostics [LSPSaga]" "<leader>ll";
|
||||
showCursorDiagnostics = mkMappingOption "Show cursor diagnostics [LSPSaga]" "<leader>lc";
|
||||
|
||||
nextDiagnostic = mkMappingOption "Next diagnostic [LSPSaga]" "<leader>ln";
|
||||
previousDiagnostic = mkMappingOption "Previous diagnostic [LSPSaga]" "<leader>lp";
|
||||
|
||||
codeAction = mkMappingOption "Code action [LSPSaga]" "<leader>ca";
|
||||
|
||||
signatureHelp = mkMappingOption "Signature help [LSPSaga]" "<leader>ls";
|
||||
setupOpts = mkPluginSetupOption "lspsaga" {
|
||||
border_style = mkOption {
|
||||
type = borderType;
|
||||
default = config.vim.ui.borders.globalStyle;
|
||||
description = "Border type, see {command}`:help nvim_open_win`";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,13 +10,13 @@
|
|||
cfg = config.vim.minimap.minimap-vim;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = [
|
||||
pkgs.code-minimap
|
||||
"minimap-vim"
|
||||
];
|
||||
vim = {
|
||||
startPlugins = ["minimap-vim"];
|
||||
extraPackages = [pkgs.code-minimap];
|
||||
|
||||
vim.binds.whichKey.register = pushDownDefault {
|
||||
"<leader>m" = "+Minimap";
|
||||
binds.whichKey.register = pushDownDefault {
|
||||
"<leader>m" = "+Minimap";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,11 +102,7 @@ in {
|
|||
|
||||
setupOpts = mkPluginSetupOption "colorizer" {
|
||||
filetypes = mkOption {
|
||||
description = ''
|
||||
Filetypes to enable on and their option overrides.
|
||||
|
||||
"*" means enable on all filetypes. Filetypes prefixed with "!" are disabled.
|
||||
'';
|
||||
type = attrsOf settingSubmodule;
|
||||
default = {};
|
||||
example = {
|
||||
"*" = {};
|
||||
|
|
@ -115,13 +111,21 @@ in {
|
|||
AARRGGBB = false;
|
||||
};
|
||||
};
|
||||
type = attrsOf settingSubmodule;
|
||||
description = ''
|
||||
Filetypes to enable on and their option overrides.
|
||||
|
||||
`"*"` means enable on all filetypes. Filetypes prefixed with `"!"` are disabled.
|
||||
'';
|
||||
};
|
||||
|
||||
user_default_options = mkOption {
|
||||
description = "Default options";
|
||||
default = {};
|
||||
type = settingSubmodule;
|
||||
default = {};
|
||||
description = ''
|
||||
`user_default_options` is the second parameter to nvim-colorizer's setup function.
|
||||
|
||||
Anything set here is the inverse of the previous setup configuration.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
./nix-develop
|
||||
./outline
|
||||
./preview
|
||||
./snacks-nvim
|
||||
./surround
|
||||
./telescope
|
||||
./wakatime
|
||||
|
|
|
|||
20
modules/plugins/utility/snacks-nvim/config.nix
Normal file
20
modules/plugins/utility/snacks-nvim/config.nix
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
|
||||
cfg = config.vim.utility.snacks-nvim;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim = {
|
||||
startPlugins = ["snacks-nvim"];
|
||||
pluginRC.snacks-nvim = entryAnywhere ''
|
||||
require("snacks").setup(${toLuaObject cfg.setupOpts});
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
6
modules/plugins/utility/snacks-nvim/default.nix
Normal file
6
modules/plugins/utility/snacks-nvim/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./config.nix
|
||||
./snacks-nvim.nix
|
||||
];
|
||||
}
|
||||
12
modules/plugins/utility/snacks-nvim/snacks-nvim.nix
Normal file
12
modules/plugins/utility/snacks-nvim/snacks-nvim.nix
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption;
|
||||
inherit (lib.nvim.types) mkPluginSetupOption;
|
||||
in {
|
||||
options.vim.utility.snacks-nvim = {
|
||||
enable = mkEnableOption ''
|
||||
collection of QoL plugins for Neovim [snacks-nvim]
|
||||
'';
|
||||
|
||||
setupOpts = mkPluginSetupOption "snacks-nvim" {};
|
||||
};
|
||||
}
|
||||
|
|
@ -14,10 +14,11 @@ in {
|
|||
vim = {
|
||||
lazy.plugins.nvim-surround = {
|
||||
package = "nvim-surround";
|
||||
|
||||
setupModule = "nvim-surround";
|
||||
inherit (cfg) setupOpts;
|
||||
|
||||
event = ["BufReadPre" "BufNewFile"];
|
||||
|
||||
keys = [
|
||||
(mkLznKey "i" cfg.setupOpts.keymaps.insert)
|
||||
(mkLznKey "i" cfg.setupOpts.keymaps.insert_line)
|
||||
|
|
|
|||
|
|
@ -37,9 +37,13 @@ in {
|
|||
type = bool;
|
||||
default = false;
|
||||
description = ''
|
||||
nvim-surround: add/change/delete surrounding delimiter pairs with ease.
|
||||
Note that the default mappings deviate from upstream to avoid conflicts
|
||||
with nvim-leap.
|
||||
Whether to enable nvim-surround, Neovim plugin to add/change/delete
|
||||
surrounding delimiter pairs with ease.
|
||||
|
||||
::: {.note}
|
||||
The default mappings deviate from upstream to avoid conflicts with nvim-leap.
|
||||
You may change those in your configuration if you do not use nvim-leap
|
||||
:::
|
||||
'';
|
||||
};
|
||||
setupOpts = mkPluginSetupOption "nvim-surround" {
|
||||
|
|
@ -61,7 +65,9 @@ in {
|
|||
useVendoredKeybindings = mkOption {
|
||||
type = bool;
|
||||
default = true;
|
||||
description = "Use alternative set of keybindings that avoids conflicts with other popular plugins, e.g. nvim-leap";
|
||||
description = ''
|
||||
Use alternative set of keybindings that avoids conflicts with other popular plugins, e.g. nvim-leap
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,9 +6,8 @@
|
|||
...
|
||||
}: let
|
||||
inherit (pkgs) vimPlugins;
|
||||
inherit (lib.strings) isString;
|
||||
inherit (lib.lists) filter map;
|
||||
inherit (builtins) path;
|
||||
inherit (lib.trivial) flip;
|
||||
inherit (builtins) path filter isString;
|
||||
|
||||
getPin = name: ((pkgs.callPackages ../../../npins/sources.nix {}) // config.vim.pluginOverrides).${name};
|
||||
|
||||
|
|
@ -76,13 +75,6 @@
|
|||
buildConfigPlugins config.vim.optPlugins
|
||||
);
|
||||
|
||||
# additional Lua and Python3 packages, mapped to their respective functions
|
||||
# to conform to the format mnw expects. end user should
|
||||
# only ever need to pass a list of packages, which are modified
|
||||
# here
|
||||
extraLuaPackages = ps: map (x: ps.${x}) config.vim.luaPackages;
|
||||
extraPython3Packages = ps: map (x: ps.${x}) config.vim.python3Packages;
|
||||
|
||||
# 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 {
|
||||
|
|
@ -92,9 +84,17 @@
|
|||
extraBinPath = config.vim.extraPackages;
|
||||
initLua = config.vim.builtLuaConfigRC;
|
||||
luaFiles = config.vim.extraLuaFiles;
|
||||
providers = {
|
||||
python3 = {
|
||||
enable = config.vim.withPython3;
|
||||
extraPackages = ps: map (flip builtins.getAttr ps) config.vim.python3Packages;
|
||||
};
|
||||
ruby.enable = config.vim.withRuby;
|
||||
nodeJs.enable = config.vim.withNodeJs;
|
||||
};
|
||||
aliases = lib.optional config.vim.viAlias "vi" ++ lib.optional config.vim.vimAlias "vim";
|
||||
|
||||
inherit (config.vim) viAlias vimAlias withRuby withNodeJs withPython3;
|
||||
inherit extraLuaPackages extraPython3Packages;
|
||||
extraLuaPackages = ps: map (flip builtins.getAttr ps) config.vim.luaPackages;
|
||||
};
|
||||
|
||||
dummyInit = pkgs.writeText "nvf-init.lua" config.vim.builtLuaConfigRC;
|
||||
|
|
|
|||
|
|
@ -134,6 +134,15 @@ in {
|
|||
startPlugins = ["lz-n" "lzn-auto-require"];
|
||||
|
||||
optPlugins = pluginPackages;
|
||||
augroups = [{name = "nvf_lazy_file_hooks";}];
|
||||
autocmds = [
|
||||
{
|
||||
event = ["BufReadPost" "BufNewFile" "BufWritePre"];
|
||||
group = "nvf_lazy_file_hooks";
|
||||
command = "doautocmd User LazyFile";
|
||||
once = true;
|
||||
}
|
||||
];
|
||||
|
||||
lazy.builtLazyConfig = ''
|
||||
require('lz.n').load(${toLuaObject lznSpecs})
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@
|
|||
};
|
||||
|
||||
event = mkOption {
|
||||
type = nullOr (oneOf [str (listOf str) lznEvent]);
|
||||
type = nullOr (oneOf [str lznEvent (listOf (either str lznEvent))]);
|
||||
default = null;
|
||||
description = "Lazy-load on event";
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue