mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-11-04 12:42:21 +00:00
Merge branch 'NotAShelf:main' into feat-ruff
This commit is contained in:
commit
08037dbdce
158 changed files with 5676 additions and 4527 deletions
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
self,
|
||||
inputs,
|
||||
lib,
|
||||
}: {
|
||||
|
|
@ -23,7 +24,7 @@
|
|||
specialArgs =
|
||||
extraSpecialArgs
|
||||
// {
|
||||
inherit inputs;
|
||||
inherit self inputs;
|
||||
modulesPath = toString ./.;
|
||||
};
|
||||
modules = concatLists [
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
inherit (lib.nvim.config) batchRenameOptions;
|
||||
|
||||
renamedVimOpts = batchRenameOptions ["vim"] ["vim" "options"] {
|
||||
# 2024-12-01
|
||||
colourTerm = "termguicolors";
|
||||
mouseSupport = "mouse";
|
||||
cmdHeight = "cmdheight";
|
||||
|
|
@ -15,6 +16,9 @@
|
|||
autoIndent = "autoindent";
|
||||
wordWrap = "wrap";
|
||||
showSignColumn = "signcolumn";
|
||||
|
||||
# 2025-02-07
|
||||
scrollOff = "scrolloff";
|
||||
};
|
||||
in {
|
||||
imports = concatLists [
|
||||
|
|
@ -93,9 +97,15 @@ in {
|
|||
|
||||
# 2024-12-02
|
||||
(mkRenamedOptionModule ["vim" "enableEditorconfig"] ["vim" "globals" "editorconfig"])
|
||||
|
||||
# 2025-02-06
|
||||
(mkRemovedOptionModule ["vim" "disableArrows"] ''
|
||||
Top-level convenience options are now in the process of being removed from nvf as
|
||||
their behaviour was abstract, and confusing. Please use 'vim.options' or 'vim.luaConfigRC'
|
||||
to replicate previous behaviour.
|
||||
'')
|
||||
]
|
||||
|
||||
# 2024-12-01
|
||||
# Migrated via batchRenameOptions. Further batch renames must be below this line.
|
||||
renamedVimOpts
|
||||
];
|
||||
|
|
|
|||
|
|
@ -23,7 +23,9 @@
|
|||
"completion"
|
||||
"dashboard"
|
||||
"debugger"
|
||||
"diagnostics"
|
||||
"filetree"
|
||||
"formatter"
|
||||
"git"
|
||||
"languages"
|
||||
"lsp"
|
||||
|
|
|
|||
185
modules/neovim/init/autocmds.nix
Normal file
185
modules/neovim/init/autocmds.nix
Normal file
|
|
@ -0,0 +1,185 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.options) mkOption mkEnableOption literalExpression;
|
||||
inherit (lib.lists) filter;
|
||||
inherit (lib.strings) optionalString;
|
||||
inherit (lib.types) nullOr submodule listOf str bool;
|
||||
inherit (lib.nvim.types) luaInline;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
inherit (lib.nvim.dag) entryAfter;
|
||||
|
||||
autocommandType = submodule {
|
||||
options = {
|
||||
enable =
|
||||
mkEnableOption ""
|
||||
// {
|
||||
default = true;
|
||||
description = "Whether to enable this autocommand";
|
||||
};
|
||||
|
||||
event = mkOption {
|
||||
type = nullOr (listOf str);
|
||||
default = null;
|
||||
example = ["BufRead" "BufWritePre"];
|
||||
description = "The event(s) that trigger the autocommand.";
|
||||
};
|
||||
|
||||
pattern = mkOption {
|
||||
type = nullOr (listOf str);
|
||||
default = null;
|
||||
example = ["*.lua" "*.vim"];
|
||||
description = "The file pattern(s) that determine when the autocommand applies).";
|
||||
};
|
||||
|
||||
callback = mkOption {
|
||||
type = nullOr luaInline;
|
||||
default = null;
|
||||
example = literalExpression ''
|
||||
mkLuaInline '''
|
||||
function()
|
||||
print("Saving a Lua file...")
|
||||
end
|
||||
''''
|
||||
'';
|
||||
description = "The file pattern(s) that determine when the autocommand applies.";
|
||||
};
|
||||
|
||||
command = mkOption {
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
description = "Vim command string instead of a Lua function.";
|
||||
};
|
||||
|
||||
group = mkOption {
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
example = "MyAutoCmdGroup";
|
||||
description = "An optional autocommand group to manage related autocommands.";
|
||||
};
|
||||
|
||||
desc = mkOption {
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
example = "Notify when saving a Lua file";
|
||||
description = "A description for the autocommand.";
|
||||
};
|
||||
|
||||
once = mkOption {
|
||||
type = bool;
|
||||
default = false;
|
||||
description = "Whether autocommand run only once.";
|
||||
};
|
||||
|
||||
nested = mkOption {
|
||||
type = bool;
|
||||
default = false;
|
||||
description = "Whether to allow nested autocommands to trigger.";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
autogroupType = submodule {
|
||||
options = {
|
||||
enable =
|
||||
mkEnableOption ""
|
||||
// {
|
||||
default = true;
|
||||
description = "Whether to enable this autogroup";
|
||||
};
|
||||
|
||||
name = mkOption {
|
||||
type = str;
|
||||
example = "MyAutoCmdGroup";
|
||||
description = "The name of the autocommand group.";
|
||||
};
|
||||
|
||||
clear = mkOption {
|
||||
type = bool;
|
||||
default = true;
|
||||
description = ''
|
||||
Whether to clear existing autocommands in this group before defining new ones.
|
||||
This helps avoid duplicate autocommands.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
cfg = config.vim;
|
||||
in {
|
||||
options.vim = {
|
||||
augroups = mkOption {
|
||||
type = listOf autogroupType;
|
||||
default = [];
|
||||
description = ''
|
||||
A list of Neovim autogroups, which are used to organize and manage related
|
||||
autocommands together. Groups allow multiple autocommands to be cleared
|
||||
or redefined collectively, preventing duplicate definitions.
|
||||
|
||||
Each autogroup consists of a name, a boolean indicating whether to clear
|
||||
existing autocommands, and a list of associated autocommands.
|
||||
'';
|
||||
};
|
||||
|
||||
autocmds = mkOption {
|
||||
type = listOf autocommandType;
|
||||
default = [];
|
||||
description = ''
|
||||
A list of Neovim autocommands to be registered.
|
||||
|
||||
Each entry defines an autocommand, specifying events, patterns, optional
|
||||
callbacks, commands, groups, and execution settings.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
vim = let
|
||||
enabledAutocommands = filter (cmd: cmd.enable) cfg.autocmds;
|
||||
enabledAutogroups = filter (au: au.enable) cfg.augroups;
|
||||
in {
|
||||
luaConfigRC = {
|
||||
augroups = entryAfter ["pluginConfigs"] (optionalString (enabledAutogroups != []) ''
|
||||
local nvf_autogroups = {}
|
||||
for _, group in ipairs(${toLuaObject enabledAutogroups}) do
|
||||
if group.name then
|
||||
nvf_autogroups[group.name] = { clear = group.clear }
|
||||
end
|
||||
end
|
||||
|
||||
for group_name, options in pairs(nvf_autogroups) do
|
||||
vim.api.nvim_create_augroup(group_name, options)
|
||||
end
|
||||
'');
|
||||
|
||||
autocmds = entryAfter ["pluginConfigs"] (optionalString (enabledAutocommands != []) ''
|
||||
local nvf_autocommands = ${toLuaObject enabledAutocommands}
|
||||
for _, autocmd in ipairs(nvf_autocommands) do
|
||||
vim.api.nvim_create_autocmd(
|
||||
autocmd.event,
|
||||
{
|
||||
group = autocmd.group,
|
||||
pattern = autocmd.pattern,
|
||||
buffer = autocmd.buffer,
|
||||
desc = autocmd.desc,
|
||||
callback = autocmd.callback,
|
||||
command = autocmd.command,
|
||||
once = autocmd.once,
|
||||
nested = autocmd.nested
|
||||
}
|
||||
)
|
||||
end
|
||||
'');
|
||||
};
|
||||
};
|
||||
|
||||
assertions = [
|
||||
{
|
||||
assertion = builtins.all (cmd: (cmd.command == null || cmd.callback == null)) cfg.autocmds;
|
||||
message = "An autocommand cannot have both 'command' and 'callback' defined at the same time.";
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
@ -16,12 +16,6 @@
|
|||
cfg = config.vim;
|
||||
in {
|
||||
options.vim = {
|
||||
disableArrows = mkOption {
|
||||
type = bool;
|
||||
default = false;
|
||||
description = "Set to prevent arrow keys from moving cursor";
|
||||
};
|
||||
|
||||
hideSearchHighlight = mkOption {
|
||||
type = bool;
|
||||
default = false;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./autocmds.nix
|
||||
./basic.nix
|
||||
./debug.nix
|
||||
./highlight.nix
|
||||
|
|
|
|||
|
|
@ -26,34 +26,6 @@
|
|||
in {
|
||||
config = {
|
||||
vim.keymaps = mkMerge [
|
||||
(
|
||||
mkIf cfg.disableArrows [
|
||||
{
|
||||
key = "<up>";
|
||||
mode = ["n" "i"];
|
||||
action = "<nop>";
|
||||
noremap = false;
|
||||
}
|
||||
{
|
||||
key = "<down>";
|
||||
mode = ["n" "i"];
|
||||
action = "<nop>";
|
||||
noremap = false;
|
||||
}
|
||||
{
|
||||
key = "<left>";
|
||||
mode = ["n" "i"];
|
||||
action = "<nop>";
|
||||
noremap = false;
|
||||
}
|
||||
{
|
||||
key = "<right>";
|
||||
mode = ["n" "i"];
|
||||
action = "<nop>";
|
||||
noremap = false;
|
||||
}
|
||||
]
|
||||
)
|
||||
(
|
||||
pipe cfg.maps
|
||||
[
|
||||
|
|
|
|||
|
|
@ -30,17 +30,19 @@
|
|||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim = {
|
||||
startPlugins = [
|
||||
"chatgpt"
|
||||
];
|
||||
startPlugins = ["chatgpt-nvim"];
|
||||
|
||||
pluginRC.chagpt = entryAnywhere ''
|
||||
require("chatgpt").setup(${toLuaObject cfg.setupOpts})
|
||||
'';
|
||||
maps.normal = mkMerge [
|
||||
(mkSetBinding mappings.chatGpt "<cmd>ChatGPT<CR>")
|
||||
maps
|
||||
];
|
||||
maps.visual = maps;
|
||||
|
||||
maps = {
|
||||
visual = maps;
|
||||
normal = mkMerge [
|
||||
(mkSetBinding mappings.chatGpt "<cmd>ChatGPT<CR>")
|
||||
maps
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
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
|
||||
];
|
||||
}
|
||||
|
|
@ -2,5 +2,6 @@
|
|||
imports = [
|
||||
./chatgpt
|
||||
./copilot
|
||||
./codecompanion
|
||||
];
|
||||
}
|
||||
|
|
|
|||
219
modules/plugins/completion/blink-cmp/blink-cmp.nix
Normal file
219
modules/plugins/completion/blink-cmp/blink-cmp.nix
Normal file
|
|
@ -0,0 +1,219 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption mkOption literalMD;
|
||||
inherit (lib.types) bool listOf str either attrsOf submodule enum anything int nullOr;
|
||||
inherit (lib.generators) mkLuaInline;
|
||||
inherit (lib.nvim.types) mkPluginSetupOption luaInline pluginType;
|
||||
inherit (lib.nvim.binds) mkMappingOption;
|
||||
inherit (lib.nvim.config) mkBool;
|
||||
|
||||
keymapType = submodule {
|
||||
freeformType = attrsOf (listOf (either str luaInline));
|
||||
options = {
|
||||
preset = mkOption {
|
||||
type = enum ["default" "none" "super-tab" "enter"];
|
||||
default = "none";
|
||||
description = "keymap presets";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
providerType = submodule {
|
||||
freeformType = anything;
|
||||
options = {
|
||||
module = mkOption {
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
description = "Provider module.";
|
||||
};
|
||||
};
|
||||
};
|
||||
in {
|
||||
options.vim.autocomplete.blink-cmp = {
|
||||
enable = mkEnableOption "blink.cmp";
|
||||
setupOpts = mkPluginSetupOption "blink.cmp" {
|
||||
sources = {
|
||||
default = mkOption {
|
||||
type = listOf str;
|
||||
default = ["lsp" "path" "snippets" "buffer"];
|
||||
description = "Default list of sources to enable for completion.";
|
||||
};
|
||||
|
||||
providers = mkOption {
|
||||
type = attrsOf providerType;
|
||||
default = {};
|
||||
description = "Settings for completion providers.";
|
||||
};
|
||||
|
||||
transform_items = mkOption {
|
||||
type = nullOr luaInline;
|
||||
default = mkLuaInline "function(_, items) return items end";
|
||||
defaultText = ''
|
||||
Our default does nothing. If you want blink.cmp's default, which
|
||||
lowers the score for snippets, set this option to null.
|
||||
'';
|
||||
description = ''
|
||||
Function to use when transforming the items before they're returned
|
||||
for all providers.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
cmdline = {
|
||||
sources = mkOption {
|
||||
type = nullOr (listOf str);
|
||||
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 = {
|
||||
documentation = {
|
||||
auto_show = mkBool true "Show documentation whenever an item is selected";
|
||||
auto_show_delay_ms = mkOption {
|
||||
type = int;
|
||||
default = 200;
|
||||
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 {
|
||||
type = keymapType;
|
||||
default = {};
|
||||
description = "blink.cmp keymap";
|
||||
example = literalMD ''
|
||||
```nix
|
||||
vim.autocomplete.blink-cmp.setupOpts.keymap = {
|
||||
preset = "none";
|
||||
|
||||
"<Up>" = ["select_prev" "fallback"];
|
||||
"<C-n>" = [
|
||||
(lib.generators.mkLuaInline ''''
|
||||
function(cmp)
|
||||
if some_condition then return end -- runs the next command
|
||||
return true -- doesn't run the next command
|
||||
end,
|
||||
'''')
|
||||
"select_next"
|
||||
];
|
||||
};
|
||||
```
|
||||
'';
|
||||
};
|
||||
|
||||
fuzzy = {
|
||||
prebuilt_binaries = {
|
||||
download = mkBool false ''
|
||||
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.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
mappings = {
|
||||
complete = mkMappingOption "Complete [blink.cmp]" "<C-Space>";
|
||||
confirm = mkMappingOption "Confirm [blink.cmp]" "<CR>";
|
||||
next = mkMappingOption "Next item [blink.cmp]" "<Tab>";
|
||||
previous = mkMappingOption "Previous item [blink.cmp]" "<S-Tab>";
|
||||
close = mkMappingOption "Close [blink.cmp]" "<C-e>";
|
||||
scrollDocsUp = mkMappingOption "Scroll docs up [blink.cmp]" "<C-d>";
|
||||
scrollDocsDown = mkMappingOption "Scroll docs down [blink.cmp]" "<C-f>";
|
||||
};
|
||||
|
||||
sourcePlugins = let
|
||||
sourcePluginType = submodule {
|
||||
options = {
|
||||
enable = mkEnableOption "this source";
|
||||
package = mkOption {
|
||||
type = pluginType;
|
||||
description = ''
|
||||
`blink-cmp` source plugin package.
|
||||
'';
|
||||
};
|
||||
|
||||
module = mkOption {
|
||||
type = str;
|
||||
description = ''
|
||||
Value of {option}`vim.autocomplete.blink-cmp.setupOpts.sources.providers.<name>.module`.
|
||||
|
||||
Should be present in the source's documentation.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
mkOption {
|
||||
type = submodule {
|
||||
freeformType = attrsOf sourcePluginType;
|
||||
options = let
|
||||
defaultSourcePluginOption = name: package: module: {
|
||||
package = mkOption {
|
||||
type = pluginType;
|
||||
default = package;
|
||||
description = ''
|
||||
`blink-cmp` ${name} source plugin package.
|
||||
'';
|
||||
};
|
||||
module = mkOption {
|
||||
type = str;
|
||||
default = module;
|
||||
description = ''
|
||||
Value of {option}`vim.autocomplete.blink-cmp.setupOpts.sources.providers.${name}.module`.
|
||||
'';
|
||||
};
|
||||
enable = mkEnableOption "${name} source";
|
||||
};
|
||||
in {
|
||||
# emoji completion after :
|
||||
emoji = defaultSourcePluginOption "emoji" "blink-emoji-nvim" "blink-emoji";
|
||||
# spelling suggestions as completions
|
||||
spell = defaultSourcePluginOption "spell" "blink-cmp-spell" "blink-cmp-spell";
|
||||
# words from nearby files
|
||||
ripgrep = defaultSourcePluginOption "ripgrep" "blink-ripgrep-nvim" "blink-ripgrep";
|
||||
};
|
||||
};
|
||||
default = {};
|
||||
description = ''
|
||||
`blink.cmp` sources.
|
||||
|
||||
Attribute names must be source names used in {option}`vim.autocomplete.blink-cmp.setupOpts.sources.default`.
|
||||
'';
|
||||
};
|
||||
|
||||
friendly-snippets.enable = mkEnableOption "friendly-snippets for blink to source from automatically";
|
||||
};
|
||||
}
|
||||
128
modules/plugins/completion/blink-cmp/config.nix
Normal file
128
modules/plugins/completion/blink-cmp/config.nix
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.strings) optionalString;
|
||||
inherit (lib.generators) mkLuaInline;
|
||||
inherit (lib.attrsets) attrValues filterAttrs mapAttrsToList;
|
||||
inherit (lib.lists) map optional elem;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
inherit (builtins) concatStringsSep typeOf tryEval attrNames mapAttrs;
|
||||
|
||||
cfg = config.vim.autocomplete.blink-cmp;
|
||||
cmpCfg = config.vim.autocomplete.nvim-cmp;
|
||||
inherit (cfg) mappings;
|
||||
|
||||
getPluginName = plugin:
|
||||
if typeOf plugin == "string"
|
||||
then plugin
|
||||
else if (plugin ? pname && (tryEval plugin.pname).success)
|
||||
then plugin.pname
|
||||
else plugin.name;
|
||||
|
||||
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 = {
|
||||
blink-cmp = {
|
||||
package = "blink-cmp";
|
||||
setupModule = "blink.cmp";
|
||||
inherit (cfg) setupOpts;
|
||||
|
||||
# TODO: lazy disabled until lspconfig is lazy loaded
|
||||
#
|
||||
# event = ["InsertEnter" "CmdlineEnter"];
|
||||
|
||||
after =
|
||||
# lua
|
||||
''
|
||||
${optionalString config.vim.lazy.enable
|
||||
(concatStringsSep "\n" (map
|
||||
(package: "require('lz.n').trigger_load(${toLuaObject (getPluginName package)})")
|
||||
cmpCfg.sourcePlugins))}
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
autocomplete = {
|
||||
enableSharedCmpSources = true;
|
||||
blink-cmp.setupOpts = {
|
||||
sources = {
|
||||
default =
|
||||
[
|
||||
"lsp"
|
||||
"path"
|
||||
"snippets"
|
||||
"buffer"
|
||||
]
|
||||
++ (attrNames cmpCfg.sources)
|
||||
++ (attrNames enabledBlinkSources);
|
||||
providers =
|
||||
mapAttrs (name: _: {
|
||||
inherit name;
|
||||
module = "blink.compat.source";
|
||||
})
|
||||
cmpCfg.sources
|
||||
// (mapAttrs (name: definition: {
|
||||
inherit name;
|
||||
inherit (definition) module;
|
||||
})
|
||||
enabledBlinkSources);
|
||||
};
|
||||
snippets = mkIf config.vim.snippets.luasnip.enable {
|
||||
preset = "luasnip";
|
||||
};
|
||||
|
||||
keymap = {
|
||||
${mappings.complete} = ["show" "fallback"];
|
||||
${mappings.close} = ["hide" "fallback"];
|
||||
${mappings.scrollDocsUp} = ["scroll_documentation_up" "fallback"];
|
||||
${mappings.scrollDocsDown} = ["scroll_documentation_down" "fallback"];
|
||||
${mappings.confirm} = ["accept" "fallback"];
|
||||
|
||||
${mappings.next} = [
|
||||
"select_next"
|
||||
"snippet_forward"
|
||||
(mkLuaInline
|
||||
# lua
|
||||
''
|
||||
function(cmp)
|
||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
has_words_before = col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
||||
|
||||
if has_words_before then
|
||||
return cmp.show()
|
||||
end
|
||||
end
|
||||
'')
|
||||
"fallback"
|
||||
];
|
||||
${mappings.previous} = [
|
||||
"select_prev"
|
||||
"snippet_backward"
|
||||
"fallback"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
6
modules/plugins/completion/blink-cmp/default.nix
Normal file
6
modules/plugins/completion/blink-cmp/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./blink-cmp.nix
|
||||
./config.nix
|
||||
];
|
||||
}
|
||||
34
modules/plugins/completion/config.nix
Normal file
34
modules/plugins/completion/config.nix
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||
inherit (builtins) typeOf tryEval;
|
||||
|
||||
cfg = config.vim.autocomplete;
|
||||
getPluginName = plugin:
|
||||
if typeOf plugin == "string"
|
||||
then plugin
|
||||
else if (plugin ? pname && (tryEval plugin.pname).success)
|
||||
then plugin.pname
|
||||
else plugin.name;
|
||||
in {
|
||||
config.vim = mkIf cfg.enableSharedCmpSources {
|
||||
startPlugins = ["rtp-nvim"];
|
||||
lazy.plugins =
|
||||
mapListToAttrs (package: {
|
||||
name = getPluginName package;
|
||||
value = {
|
||||
inherit package;
|
||||
lazy = true;
|
||||
after = ''
|
||||
local path = vim.fn.globpath(vim.o.packpath, 'pack/*/opt/${getPluginName package}')
|
||||
require("rtp_nvim").source_after_plugin_dir(path)
|
||||
'';
|
||||
};
|
||||
})
|
||||
cfg.nvim-cmp.sourcePlugins;
|
||||
};
|
||||
}
|
||||
|
|
@ -1,5 +1,9 @@
|
|||
{
|
||||
imports = [
|
||||
./module.nix
|
||||
./config.nix
|
||||
|
||||
./nvim-cmp
|
||||
./blink-cmp
|
||||
];
|
||||
}
|
||||
|
|
|
|||
7
modules/plugins/completion/module.nix
Normal file
7
modules/plugins/completion/module.nix
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption;
|
||||
in {
|
||||
options.vim.autocomplete = {
|
||||
enableSharedCmpSources = mkEnableOption "sources shared by blink.cmp and nvim-cmp";
|
||||
};
|
||||
}
|
||||
|
|
@ -24,114 +24,97 @@
|
|||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim = {
|
||||
startPlugins = ["rtp-nvim"];
|
||||
lazy.plugins = mkMerge [
|
||||
(mapListToAttrs (package: {
|
||||
name = getPluginName package;
|
||||
value = {
|
||||
inherit package;
|
||||
lazy = true;
|
||||
after = ''
|
||||
local path = vim.fn.globpath(vim.o.packpath, 'pack/*/opt/${getPluginName package}')
|
||||
require("rtp_nvim").source_after_plugin_dir(path)
|
||||
lazy.plugins = {
|
||||
nvim-cmp = {
|
||||
package = "nvim-cmp";
|
||||
after = ''
|
||||
${optionalString luasnipEnable "local luasnip = require('luasnip')"}
|
||||
local cmp = require("cmp")
|
||||
|
||||
local kinds = require("cmp.types").lsp.CompletionItemKind
|
||||
local deprio = function(kind)
|
||||
return function(e1, e2)
|
||||
if e1:get_kind() == kind then
|
||||
return false
|
||||
end
|
||||
if e2:get_kind() == kind then
|
||||
return true
|
||||
end
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
cmp.setup(${toLuaObject cfg.setupOpts})
|
||||
|
||||
${optionalString config.vim.lazy.enable
|
||||
(concatStringsSep "\n" (map
|
||||
(package: "require('lz.n').trigger_load(${toLuaObject (getPluginName package)})")
|
||||
cfg.sourcePlugins))}
|
||||
'';
|
||||
|
||||
event = ["InsertEnter" "CmdlineEnter"];
|
||||
};
|
||||
};
|
||||
|
||||
autocomplete = {
|
||||
enableSharedCmpSources = true;
|
||||
|
||||
nvim-cmp = {
|
||||
sourcePlugins = ["cmp-buffer" "cmp-path"];
|
||||
|
||||
setupOpts = {
|
||||
sources = map (s: {name = s;}) (attrNames cfg.sources);
|
||||
|
||||
window = mkIf borders.enable {
|
||||
completion.border = borders.style;
|
||||
documentation.border = borders.style;
|
||||
};
|
||||
|
||||
formatting.format = cfg.format;
|
||||
|
||||
# `cmp` and `luasnip` are defined above, in the `nvim-cmp` section
|
||||
mapping = {
|
||||
${mappings.complete} = mkLuaInline "cmp.mapping.complete()";
|
||||
${mappings.close} = mkLuaInline "cmp.mapping.abort()";
|
||||
${mappings.scrollDocsUp} = mkLuaInline "cmp.mapping.scroll_docs(-4)";
|
||||
${mappings.scrollDocsDown} = mkLuaInline "cmp.mapping.scroll_docs(4)";
|
||||
${mappings.confirm} = mkLuaInline "cmp.mapping.confirm({ select = true })";
|
||||
|
||||
${mappings.next} = mkLuaInline ''
|
||||
cmp.mapping(function(fallback)
|
||||
local has_words_before = function()
|
||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
||||
end
|
||||
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
${optionalString luasnipEnable ''
|
||||
elseif luasnip.locally_jumpable(1) then
|
||||
luasnip.jump(1)
|
||||
''}
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end)
|
||||
'';
|
||||
|
||||
${mappings.previous} = mkLuaInline ''
|
||||
cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
${optionalString luasnipEnable ''
|
||||
elseif luasnip.locally_jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
''}
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end)
|
||||
'';
|
||||
};
|
||||
})
|
||||
cfg.sourcePlugins)
|
||||
{
|
||||
nvim-cmp = {
|
||||
package = "nvim-cmp";
|
||||
after = ''
|
||||
${optionalString luasnipEnable "local luasnip = require('luasnip')"}
|
||||
local cmp = require("cmp")
|
||||
|
||||
local kinds = require("cmp.types").lsp.CompletionItemKind
|
||||
local deprio = function(kind)
|
||||
return function(e1, e2)
|
||||
if e1:get_kind() == kind then
|
||||
return false
|
||||
end
|
||||
if e2:get_kind() == kind then
|
||||
return true
|
||||
end
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
cmp.setup(${toLuaObject cfg.setupOpts})
|
||||
|
||||
${optionalString config.vim.lazy.enable
|
||||
(concatStringsSep "\n" (map
|
||||
(package: "require('lz.n').trigger_load(${toLuaObject (getPluginName package)})")
|
||||
cfg.sourcePlugins))}
|
||||
'';
|
||||
|
||||
event = ["InsertEnter" "CmdlineEnter"];
|
||||
};
|
||||
}
|
||||
];
|
||||
|
||||
autocomplete.nvim-cmp = {
|
||||
sources = {
|
||||
nvim-cmp = null;
|
||||
buffer = "[Buffer]";
|
||||
path = "[Path]";
|
||||
};
|
||||
|
||||
sourcePlugins = ["cmp-buffer" "cmp-path"];
|
||||
|
||||
setupOpts = {
|
||||
sources = map (s: {name = s;}) (attrNames cfg.sources);
|
||||
|
||||
window = mkIf borders.enable {
|
||||
completion.border = borders.style;
|
||||
documentation.border = borders.style;
|
||||
};
|
||||
|
||||
formatting.format = cfg.format;
|
||||
|
||||
# `cmp` and `luasnip` are defined above, in the `nvim-cmp` section
|
||||
mapping = {
|
||||
${mappings.complete} = mkLuaInline "cmp.mapping.complete()";
|
||||
${mappings.close} = mkLuaInline "cmp.mapping.abort()";
|
||||
${mappings.scrollDocsUp} = mkLuaInline "cmp.mapping.scroll_docs(-4)";
|
||||
${mappings.scrollDocsDown} = mkLuaInline "cmp.mapping.scroll_docs(4)";
|
||||
${mappings.confirm} = mkLuaInline "cmp.mapping.confirm({ select = true })";
|
||||
|
||||
${mappings.next} = mkLuaInline ''
|
||||
cmp.mapping(function(fallback)
|
||||
local has_words_before = function()
|
||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
||||
end
|
||||
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
${optionalString luasnipEnable ''
|
||||
elseif luasnip.locally_jumpable(1) then
|
||||
luasnip.jump(1)
|
||||
''}
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end)
|
||||
'';
|
||||
|
||||
${mappings.previous} = mkLuaInline ''
|
||||
cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
${optionalString luasnipEnable ''
|
||||
elseif luasnip.locally_jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
''}
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end)
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,23 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption;
|
||||
inherit (lib.options) mkEnableOption mkOption;
|
||||
inherit (lib.types) listOf attrsOf anything nullOr enum;
|
||||
in {
|
||||
options.vim.dashboard.alpha = {
|
||||
enable = mkEnableOption "fast and fully programmable greeter for neovim [alpha.mvim]";
|
||||
enable = mkEnableOption "fast and fully programmable greeter for neovim [alpha.nvim]";
|
||||
theme = mkOption {
|
||||
type = nullOr (enum ["dashboard" "startify" "theta"]);
|
||||
default = "dashboard";
|
||||
description = "Alpha default theme to use";
|
||||
};
|
||||
layout = mkOption {
|
||||
type = listOf (attrsOf anything);
|
||||
default = [];
|
||||
description = "Alpha dashboard layout";
|
||||
};
|
||||
opts = mkOption {
|
||||
type = attrsOf anything;
|
||||
default = {};
|
||||
description = "Optional global options";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,8 +5,11 @@
|
|||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
|
||||
cfg = config.vim.dashboard.alpha;
|
||||
themeDefined = cfg.theme != null;
|
||||
layoutDefined = cfg.layout != [];
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = [
|
||||
|
|
@ -14,207 +17,30 @@ in {
|
|||
"nvim-web-devicons"
|
||||
];
|
||||
|
||||
# the entire credit for this dashboard configuration to https://github.com/Rishabh672003
|
||||
# honestly, excellent work
|
||||
vim.pluginRC.alpha = entryAnywhere ''
|
||||
local alpha = require("alpha")
|
||||
local plenary_path = require("plenary.path")
|
||||
local dashboard = require("alpha.themes.dashboard")
|
||||
local cdir = vim.fn.getcwd()
|
||||
local if_nil = vim.F.if_nil
|
||||
|
||||
local nvim_web_devicons = {
|
||||
enabled = true,
|
||||
highlight = true,
|
||||
}
|
||||
|
||||
local function get_extension(fn)
|
||||
local match = fn:match("^.+(%..+)$")
|
||||
local ext = ""
|
||||
if match ~= nil then
|
||||
ext = match:sub(2)
|
||||
end
|
||||
return ext
|
||||
end
|
||||
|
||||
local function icon(fn)
|
||||
local nwd = require("nvim-web-devicons")
|
||||
local ext = get_extension(fn)
|
||||
return nwd.get_icon(fn, ext, { default = true })
|
||||
end
|
||||
|
||||
local function file_button(fn, sc, short_fn)
|
||||
short_fn = short_fn or fn
|
||||
local ico_txt
|
||||
local fb_hl = {}
|
||||
|
||||
if nvim_web_devicons.enabled then
|
||||
local ico, hl = icon(fn)
|
||||
local hl_option_type = type(nvim_web_devicons.highlight)
|
||||
if hl_option_type == "boolean" then
|
||||
if hl and nvim_web_devicons.highlight then
|
||||
table.insert(fb_hl, { hl, 0, 3 })
|
||||
end
|
||||
end
|
||||
if hl_option_type == "string" then
|
||||
table.insert(fb_hl, { nvim_web_devicons.highlight, 0, 3 })
|
||||
end
|
||||
ico_txt = ico .. " "
|
||||
else
|
||||
ico_txt = ""
|
||||
end
|
||||
local file_button_el = dashboard.button(sc, ico_txt .. short_fn, "<cmd>e " .. fn .. " <CR>")
|
||||
local fn_start = short_fn:match(".*[/\\]")
|
||||
if fn_start ~= nil then
|
||||
table.insert(fb_hl, { "Comment", #ico_txt - 2, #fn_start + #ico_txt })
|
||||
end
|
||||
file_button_el.opts.hl = fb_hl
|
||||
return file_button_el
|
||||
end
|
||||
|
||||
local default_mru_ignore = { "gitcommit" }
|
||||
|
||||
local mru_opts = {
|
||||
ignore = function(path, ext)
|
||||
return (string.find(path, "COMMIT_EDITMSG")) or (vim.tbl_contains(default_mru_ignore, ext))
|
||||
end,
|
||||
}
|
||||
|
||||
--- @param start number
|
||||
--- @param cwd string optional
|
||||
--- @param items_number number optional number of items to generate, default = 10
|
||||
local function mru(start, cwd, items_number, opts)
|
||||
opts = opts or mru_opts
|
||||
items_number = if_nil(items_number, 15)
|
||||
|
||||
local oldfiles = {}
|
||||
for _, v in pairs(vim.v.oldfiles) do
|
||||
if #oldfiles == items_number then
|
||||
break
|
||||
end
|
||||
local cwd_cond
|
||||
if not cwd then
|
||||
cwd_cond = true
|
||||
else
|
||||
cwd_cond = vim.startswith(v, cwd)
|
||||
end
|
||||
local ignore = (opts.ignore and opts.ignore(v, get_extension(v))) or false
|
||||
if (vim.fn.filereadable(v) == 1) and cwd_cond and not ignore then
|
||||
oldfiles[#oldfiles + 1] = v
|
||||
end
|
||||
end
|
||||
local target_width = 35
|
||||
|
||||
local tbl = {}
|
||||
for i, fn in ipairs(oldfiles) do
|
||||
local short_fn
|
||||
if cwd then
|
||||
short_fn = vim.fn.fnamemodify(fn, ":.")
|
||||
else
|
||||
short_fn = vim.fn.fnamemodify(fn, ":~")
|
||||
end
|
||||
|
||||
if #short_fn > target_width then
|
||||
short_fn = plenary_path.new(short_fn):shorten(1, { -2, -1 })
|
||||
if #short_fn > target_width then
|
||||
short_fn = plenary_path.new(short_fn):shorten(1, { -1 })
|
||||
end
|
||||
end
|
||||
|
||||
local shortcut = tostring(i + start - 1)
|
||||
|
||||
local file_button_el = file_button(fn, shortcut, short_fn)
|
||||
tbl[i] = file_button_el
|
||||
end
|
||||
return {
|
||||
type = "group",
|
||||
val = tbl,
|
||||
opts = {},
|
||||
}
|
||||
end
|
||||
|
||||
local default_header = {
|
||||
type = "text",
|
||||
val = {
|
||||
|
||||
[[███ ██ ███████ ██████ ██ ██ ██ ███ ███]],
|
||||
[[████ ██ ██ ██ ██ ██ ██ ██ ████ ████]],
|
||||
[[██ ██ ██ █████ ██ ██ ██ ██ ██ ██ ████ ██]],
|
||||
[[██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██]],
|
||||
[[██ ████ ███████ ██████ ████ ██ ██ ██]],
|
||||
|
||||
-- [[ __ ]],
|
||||
-- [[ ___ ___ ___ __ __ /\_\ ___ ___ ]],
|
||||
-- [[ / _ `\ / __`\ / __`\/\ \/\ \\/\ \ / __` __`\ ]],
|
||||
-- [[/\ \/\ \/\ __//\ \_\ \ \ \_/ |\ \ \/\ \/\ \/\ \ ]],
|
||||
-- [[\ \_\ \_\ \____\ \____/\ \___/ \ \_\ \_\ \_\ \_\]],
|
||||
-- [[ \/_/\/_/\/____/\/___/ \/__/ \/_/\/_/\/_/\/_/]],
|
||||
},
|
||||
opts = {
|
||||
position = "center",
|
||||
hl = "Type",
|
||||
-- wrap = "overflow";
|
||||
},
|
||||
}
|
||||
|
||||
local section_mru = {
|
||||
type = "group",
|
||||
val = {
|
||||
{
|
||||
type = "text",
|
||||
val = "Recent files",
|
||||
opts = {
|
||||
hl = "SpecialComment",
|
||||
shrink_margin = false,
|
||||
position = "center",
|
||||
},
|
||||
},
|
||||
{ type = "padding", val = 1 },
|
||||
{
|
||||
type = "group",
|
||||
val = function()
|
||||
return { mru(0, cdir) }
|
||||
end,
|
||||
opts = { shrink_margin = false },
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
local buttons = {
|
||||
type = "group",
|
||||
val = {
|
||||
{ type = "text", val = "Quick links", opts = { hl = "SpecialComment", position = "center" } },
|
||||
{ type = "padding", val = 1 },
|
||||
-- TODO: buttons should be added based on whether or not the relevant plugin is available
|
||||
dashboard.button("e", " New file", "<cmd>ene<CR>"), -- available all the time
|
||||
dashboard.button("SPC F", " Find file"), -- telescope
|
||||
dashboard.button("SPC ff", " Live grep"), -- telescope
|
||||
dashboard.button("SPC p", " Projects"), -- any project
|
||||
dashboard.button("q", " Quit", "<cmd>qa<CR>"), -- available all the time
|
||||
},
|
||||
position = "center",
|
||||
}
|
||||
|
||||
local config = {
|
||||
layout = {
|
||||
{ type = "padding", val = 2 },
|
||||
default_header,
|
||||
{ type = "padding", val = 2 },
|
||||
section_mru,
|
||||
{ type = "padding", val = 2 },
|
||||
buttons,
|
||||
},
|
||||
opts = {
|
||||
margin = 5,
|
||||
setup = function()
|
||||
vim.cmd([[
|
||||
autocmd alpha_temp DirChanged * lua require('alpha').redraw()
|
||||
]])
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
||||
alpha.setup(config)
|
||||
vim.pluginRC.alpha = let
|
||||
setupOpts =
|
||||
if themeDefined
|
||||
then lib.generators.mkLuaInline "require'alpha.themes.${cfg.theme}'.config"
|
||||
else {
|
||||
inherit (cfg) layout opts;
|
||||
};
|
||||
in ''
|
||||
require('alpha').setup(${toLuaObject setupOpts})
|
||||
'';
|
||||
|
||||
assertions = [
|
||||
{
|
||||
assertion = themeDefined || layoutDefined;
|
||||
message = ''
|
||||
One of 'theme' or 'layout' should be defined in Alpha configuration.
|
||||
'';
|
||||
}
|
||||
{
|
||||
assertion = !(themeDefined && layoutDefined);
|
||||
message = ''
|
||||
'theme' and 'layout' cannot be defined at the same time.
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
3
modules/plugins/diagnostics/default.nix
Normal file
3
modules/plugins/diagnostics/default.nix
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
imports = [./nvim-lint];
|
||||
}
|
||||
20
modules/plugins/diagnostics/nvim-lint/config.nix
Normal file
20
modules/plugins/diagnostics/nvim-lint/config.nix
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
|
||||
cfg = config.vim.diagnostics.nvim-lint;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim = {
|
||||
startPlugins = ["nvim-lint"];
|
||||
pluginRC.nvim-lint = entryAnywhere ''
|
||||
require("lint").linters_by_ft(${toLuaObject cfg.linters_by_ft})
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
6
modules/plugins/diagnostics/nvim-lint/default.nix
Normal file
6
modules/plugins/diagnostics/nvim-lint/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./nvim-lint.nix
|
||||
./config.nix
|
||||
];
|
||||
}
|
||||
25
modules/plugins/diagnostics/nvim-lint/nvim-lint.nix
Normal file
25
modules/plugins/diagnostics/nvim-lint/nvim-lint.nix
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkOption mkEnableOption;
|
||||
inherit (lib.types) attrsOf listOf str;
|
||||
in {
|
||||
options.vim.diagnostics.nvim-lint = {
|
||||
enable = mkEnableOption "asynchronous linter plugin for Neovim [nvim-lint]";
|
||||
|
||||
# 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.
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
20
modules/plugins/formatter/conform-nvim/config.nix
Normal file
20
modules/plugins/formatter/conform-nvim/config.nix
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
|
||||
cfg = config.vim.formatter.conform-nvim;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim = {
|
||||
startPlugins = ["conform-nvim"];
|
||||
pluginRC.conform-nvim = entryAnywhere ''
|
||||
require("conform").setup(${toLuaObject cfg.setupOpts})
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
56
modules/plugins/formatter/conform-nvim/conform-nvim.nix
Normal file
56
modules/plugins/formatter/conform-nvim/conform-nvim.nix
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
{
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.options) mkOption mkEnableOption literalExpression;
|
||||
inherit (lib.types) attrs enum;
|
||||
inherit (lib.nvim.types) mkPluginSetupOption;
|
||||
inherit (lib.nvim.lua) mkLuaInline;
|
||||
in {
|
||||
options.vim.formatter.conform-nvim = {
|
||||
enable = mkEnableOption "lightweight yet powerful formatter plugin for Neovim [conform-nvim]";
|
||||
setupOpts = mkPluginSetupOption "conform.nvim" {
|
||||
formatters_by_ft = mkOption {
|
||||
type = attrs;
|
||||
default = {};
|
||||
example = {lua = ["stylua"];};
|
||||
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.
|
||||
'';
|
||||
};
|
||||
|
||||
default_format_opts = mkOption {
|
||||
type = attrs;
|
||||
default = {lsp_format = "fallback";};
|
||||
description = "Default values when calling `conform.format()`";
|
||||
};
|
||||
|
||||
format_on_save = mkOption {
|
||||
type = attrs;
|
||||
default = {
|
||||
lsp_format = "fallback";
|
||||
timeout_ms = 500;
|
||||
};
|
||||
description = ''
|
||||
Table that will be passed to `conform.format()`. If this
|
||||
is set, Conform will run the formatter on save.
|
||||
'';
|
||||
};
|
||||
|
||||
format_after_save = mkOption {
|
||||
type = 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.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
6
modules/plugins/formatter/conform-nvim/default.nix
Normal file
6
modules/plugins/formatter/conform-nvim/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./conform-nvim.nix
|
||||
./config.nix
|
||||
];
|
||||
}
|
||||
3
modules/plugins/formatter/default.nix
Normal file
3
modules/plugins/formatter/default.nix
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
imports = [./conform-nvim];
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@ in {
|
|||
imports = [
|
||||
./gitsigns
|
||||
./vim-fugitive
|
||||
./git-conflict
|
||||
];
|
||||
|
||||
options.vim.git = {
|
||||
|
|
@ -13,6 +14,7 @@ in {
|
|||
Enabling this option will enable the following plugins:
|
||||
* gitsigns
|
||||
* vim-fugitive
|
||||
* git-conflict
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
|||
40
modules/plugins/git/git-conflict/config.nix
Normal file
40
modules/plugins/git/git-conflict/config.nix
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetBinding;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
|
||||
cfg = config.vim.git.git-conflict;
|
||||
|
||||
self = import ./git-conflict.nix {inherit lib config;};
|
||||
gcMappingDefinitions = self.options.vim.git.git-conflict.mappings;
|
||||
|
||||
gcMappings = addDescriptionsToMappings cfg.mappings gcMappingDefinitions;
|
||||
in {
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
{
|
||||
vim = {
|
||||
startPlugins = ["git-conflict-nvim"];
|
||||
|
||||
maps = {
|
||||
normal = mkMerge [
|
||||
(mkSetBinding gcMappings.ours "<Plug>(git-conflict-ours)")
|
||||
(mkSetBinding gcMappings.theirs "<Plug>(git-conflict-theirs)")
|
||||
(mkSetBinding gcMappings.both "<Plug>(git-conflict-both)")
|
||||
(mkSetBinding gcMappings.none "<Plug>(git-conflict-none)")
|
||||
(mkSetBinding gcMappings.prevConflict "<Plug>(git-conflict-prev-conflict)")
|
||||
(mkSetBinding gcMappings.nextConflict "<Plug>(git-conflict-next-conflict)")
|
||||
];
|
||||
};
|
||||
|
||||
pluginRC.git-conflict = entryAnywhere ''
|
||||
require('git-conflict').setup(${toLuaObject ({default_mappings = false;} // cfg.setupOpts)})
|
||||
'';
|
||||
};
|
||||
}
|
||||
]);
|
||||
}
|
||||
6
modules/plugins/git/git-conflict/default.nix
Normal file
6
modules/plugins/git/git-conflict/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./config.nix
|
||||
./git-conflict.nix
|
||||
];
|
||||
}
|
||||
23
modules/plugins/git/git-conflict/git-conflict.nix
Normal file
23
modules/plugins/git/git-conflict/git-conflict.nix
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.options) mkEnableOption;
|
||||
inherit (lib.nvim.binds) mkMappingOption;
|
||||
inherit (lib.nvim.types) mkPluginSetupOption;
|
||||
in {
|
||||
options.vim.git.git-conflict = {
|
||||
enable = mkEnableOption "git-conflict" // {default = config.vim.git.enable;};
|
||||
setupOpts = mkPluginSetupOption "git-conflict" {};
|
||||
|
||||
mappings = {
|
||||
ours = mkMappingOption "Choose Ours [Git-Conflict]" "<leader>co";
|
||||
theirs = mkMappingOption "Choose Theirs [Git-Conflict]" "<leader>ct";
|
||||
both = mkMappingOption "Choose Both [Git-Conflict]" "<leader>cb";
|
||||
none = mkMappingOption "Choose None [Git-Conflict]" "<leader>c0";
|
||||
prevConflict = mkMappingOption "Go to the previous Conflict [Git-Conflict]" "]x";
|
||||
nextConflict = mkMappingOption "Go to the next Conflict [Git-Conflict]" "[x";
|
||||
};
|
||||
};
|
||||
}
|
||||
22
modules/plugins/hydra/config.nix
Normal file
22
modules/plugins/hydra/config.nix
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
cfg = config.vim.hydra;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim = {
|
||||
startPlugins = [];
|
||||
lazy.plugins.hydra = {
|
||||
package = "hydra.nvim";
|
||||
setupModule = "hydra";
|
||||
inherit (cfg) setupOpts;
|
||||
|
||||
event = ["DeferredUIEnter"];
|
||||
cmd = ["MCstart" "MCvisual" "MCclear" "MCpattern" "MCvisualPattern" "MCunderCursor"];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
6
modules/plugins/hydra/default.nix
Normal file
6
modules/plugins/hydra/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./hydra.nix
|
||||
./config.nix
|
||||
];
|
||||
}
|
||||
7
modules/plugins/hydra/hydra.nix
Normal file
7
modules/plugins/hydra/hydra.nix
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption;
|
||||
in {
|
||||
options.vim.utility.hydra = {
|
||||
enable = mkEnableOption "utility for creating custom submodes and menus [nvimtools/hydra.nvim]";
|
||||
};
|
||||
}
|
||||
|
|
@ -75,8 +75,8 @@
|
|||
};
|
||||
|
||||
extraServerPlugins = {
|
||||
omnisharp = ["omnisharp-extended"];
|
||||
csharp_ls = ["csharpls-extended"];
|
||||
omnisharp = ["omnisharp-extended-lsp-nvim"];
|
||||
csharp_ls = ["csharpls-extended-lsp-nvim"];
|
||||
};
|
||||
|
||||
cfg = config.vim.languages.csharp;
|
||||
|
|
|
|||
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"},
|
||||
}
|
||||
'';
|
||||
})
|
||||
]);
|
||||
}
|
||||
|
|
@ -137,7 +137,7 @@ in {
|
|||
vim.startPlugins =
|
||||
if ftcfg.enableNoResolvePatch
|
||||
then ["flutter-tools-patched"]
|
||||
else ["flutter-tools"];
|
||||
else ["flutter-tools-nvim"];
|
||||
|
||||
vim.pluginRC.flutter-tools = entryAnywhere ''
|
||||
require('flutter-tools').setup {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ in {
|
|||
./asm.nix
|
||||
./astro.nix
|
||||
./bash.nix
|
||||
./cue.nix
|
||||
./dart.nix
|
||||
./clang.nix
|
||||
./css.nix
|
||||
|
|
@ -12,6 +13,7 @@ in {
|
|||
./gleam.nix
|
||||
./go.nix
|
||||
./hcl.nix
|
||||
./helm.nix
|
||||
./kotlin.nix
|
||||
./html.nix
|
||||
./haskell.nix
|
||||
|
|
@ -39,6 +41,7 @@ in {
|
|||
./nu.nix
|
||||
./odin.nix
|
||||
./wgsl.nix
|
||||
./yaml.nix
|
||||
./ruby.nix
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ in {
|
|||
})
|
||||
|
||||
(mkIf cfg.elixir-tools.enable {
|
||||
vim.startPlugins = ["elixir-tools"];
|
||||
vim.startPlugins = ["elixir-tools-nvim"];
|
||||
vim.pluginRC.elixir-tools = entryAnywhere ''
|
||||
local elixir = require("elixir")
|
||||
local elixirls = require("elixir.elixirls")
|
||||
|
|
|
|||
|
|
@ -34,6 +34,43 @@
|
|||
};
|
||||
};
|
||||
|
||||
defaultFormat = "gofmt";
|
||||
formats = {
|
||||
gofmt = {
|
||||
package = pkgs.go;
|
||||
nullConfig = ''
|
||||
table.insert(
|
||||
ls_sources,
|
||||
null_ls.builtins.formatting.gofmt.with({
|
||||
command = "${cfg.format.package}/bin/gofmt",
|
||||
})
|
||||
)
|
||||
'';
|
||||
};
|
||||
gofumpt = {
|
||||
package = pkgs.gofumpt;
|
||||
nullConfig = ''
|
||||
table.insert(
|
||||
ls_sources,
|
||||
null_ls.builtins.formatting.gofumpt.with({
|
||||
command = "${cfg.format.package}/bin/gofumpt",
|
||||
})
|
||||
)
|
||||
'';
|
||||
};
|
||||
golines = {
|
||||
package = pkgs.golines;
|
||||
nullConfig = ''
|
||||
table.insert(
|
||||
ls_sources,
|
||||
null_ls.builtins.formatting.golines.with({
|
||||
command = "${cfg.format.package}/bin/golines",
|
||||
})
|
||||
)
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
defaultDebugger = "delve";
|
||||
debuggers = {
|
||||
delve = {
|
||||
|
|
@ -67,6 +104,22 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
format = {
|
||||
enable = mkEnableOption "Go formatting" // {default = config.vim.languages.enableFormat;};
|
||||
|
||||
type = mkOption {
|
||||
description = "Go formatter to use";
|
||||
type = enum (attrNames formats);
|
||||
default = defaultFormat;
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
description = "Go formatter package";
|
||||
type = package;
|
||||
default = formats.${cfg.format.type}.package;
|
||||
};
|
||||
};
|
||||
|
||||
dap = {
|
||||
enable = mkOption {
|
||||
description = "Enable Go Debug Adapter via nvim-dap-go plugin";
|
||||
|
|
@ -99,6 +152,11 @@ in {
|
|||
vim.lsp.lspconfig.sources.go-lsp = servers.${cfg.lsp.server}.lspConfig;
|
||||
})
|
||||
|
||||
(mkIf cfg.format.enable {
|
||||
vim.lsp.null-ls.enable = true;
|
||||
vim.lsp.null-ls.sources.go-format = formats.${cfg.format.type}.nullConfig;
|
||||
})
|
||||
|
||||
(mkIf cfg.dap.enable {
|
||||
vim = {
|
||||
startPlugins = ["nvim-dap-go"];
|
||||
|
|
|
|||
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];
|
||||
}
|
||||
]);
|
||||
}
|
||||
|
|
@ -8,7 +8,6 @@
|
|||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.meta) getExe;
|
||||
inherit (lib.lists) isList;
|
||||
inherit (lib.strings) optionalString;
|
||||
inherit (lib.types) either listOf package str;
|
||||
inherit (lib.nvim.types) mkGrammarOption;
|
||||
inherit (lib.nvim.lua) expToLua;
|
||||
|
|
@ -16,6 +15,12 @@
|
|||
|
||||
cfg = config.vim.languages.lua;
|
||||
in {
|
||||
imports = [
|
||||
(lib.mkRemovedOptionModule ["vim" "languages" "lua" "lsp" "neodev"] ''
|
||||
neodev has been replaced by lazydev
|
||||
'')
|
||||
];
|
||||
|
||||
options.vim.languages.lua = {
|
||||
enable = mkEnableOption "Lua language support";
|
||||
treesitter = {
|
||||
|
|
@ -32,7 +37,7 @@ in {
|
|||
default = pkgs.lua-language-server;
|
||||
};
|
||||
|
||||
neodev.enable = mkEnableOption "neodev.nvim integration, useful for neovim plugin developers";
|
||||
lazydev.enable = mkEnableOption "lazydev.nvim integration, useful for neovim plugin developers";
|
||||
};
|
||||
};
|
||||
|
||||
|
|
@ -49,7 +54,6 @@ in {
|
|||
lspconfig.lua_ls.setup {
|
||||
capabilities = capabilities;
|
||||
on_attach = default_on_attach;
|
||||
${optionalString cfg.lsp.neodev.enable "before_init = require('neodev.lsp').before_init;"}
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then expToLua cfg.lsp.package
|
||||
|
|
@ -59,10 +63,15 @@ in {
|
|||
'';
|
||||
})
|
||||
|
||||
(mkIf cfg.lsp.neodev.enable {
|
||||
vim.startPlugins = ["neodev-nvim"];
|
||||
vim.pluginRC.neodev = entryBefore ["lua-lsp"] ''
|
||||
require("neodev").setup({})
|
||||
(mkIf cfg.lsp.lazydev.enable {
|
||||
vim.startPlugins = ["lazydev-nvim"];
|
||||
vim.pluginRC.lazydev = entryBefore ["lua-lsp"] ''
|
||||
require("lazydev").setup({
|
||||
enabled = function(root_dir)
|
||||
return not vim.uv.fs_stat(root_dir .. "/.luarc.json")
|
||||
end,
|
||||
library = { { path = "''${3rd}/luv/library", words = { "vim%.uv" } } },
|
||||
})
|
||||
'';
|
||||
})
|
||||
]))
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@
|
|||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.lists) isList;
|
||||
inherit (lib.strings) optionalString;
|
||||
inherit (lib.types) enum either listOf package str;
|
||||
inherit (lib.types) anything attrsOf enum either listOf nullOr package str;
|
||||
inherit (lib.nvim.types) mkGrammarOption diagnostics;
|
||||
inherit (lib.nvim.lua) expToLua;
|
||||
inherit (lib.nvim.lua) expToLua toLuaObject;
|
||||
inherit (lib.nvim.languages) diagnosticsToLua;
|
||||
|
||||
cfg = config.vim.languages.nix;
|
||||
|
|
@ -59,6 +59,41 @@
|
|||
}
|
||||
'';
|
||||
};
|
||||
|
||||
nixd = {
|
||||
package = pkgs.nixd;
|
||||
internalFormatter = true;
|
||||
lspConfig = ''
|
||||
lspconfig.nixd.setup{
|
||||
capabilities = capabilities,
|
||||
${
|
||||
if cfg.format.enable
|
||||
then useFormat
|
||||
else noFormat
|
||||
},
|
||||
cmd = ${packageToCmd cfg.lsp.package "nixd"},
|
||||
${optionalString cfg.format.enable ''
|
||||
settings = {
|
||||
nixd = {
|
||||
${optionalString (cfg.format.type == "alejandra")
|
||||
''
|
||||
formatting = {
|
||||
command = {"${cfg.format.package}/bin/alejandra", "--quiet"},
|
||||
},
|
||||
''}
|
||||
${optionalString (cfg.format.type == "nixfmt")
|
||||
''
|
||||
formatting = {
|
||||
command = {"${cfg.format.package}/bin/nixfmt"},
|
||||
},
|
||||
''}
|
||||
options = ${toLuaObject cfg.lsp.options},
|
||||
},
|
||||
},
|
||||
''}
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
defaultFormat = "alejandra";
|
||||
|
|
@ -86,8 +121,6 @@
|
|||
)
|
||||
'';
|
||||
};
|
||||
|
||||
nixpkgs-fmt = null; # removed
|
||||
};
|
||||
|
||||
defaultDiagnosticsProvider = ["statix" "deadnix"];
|
||||
|
|
@ -139,6 +172,12 @@ in {
|
|||
type = either package (listOf str);
|
||||
default = servers.${cfg.lsp.server}.package;
|
||||
};
|
||||
|
||||
options = mkOption {
|
||||
type = nullOr (attrsOf anything);
|
||||
default = null;
|
||||
description = "Options to pass to nixd LSP server";
|
||||
};
|
||||
};
|
||||
|
||||
format = {
|
||||
|
|
@ -178,7 +217,6 @@ in {
|
|||
${concatStringsSep ", " (attrNames formats)}
|
||||
'';
|
||||
}
|
||||
|
||||
{
|
||||
assertion = cfg.lsp.server != "rnix";
|
||||
message = ''
|
||||
|
|
|
|||
|
|
@ -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 = {
|
||||
|
|
|
|||
|
|
@ -62,6 +62,15 @@ in {
|
|||
description = "Options to pass to rust analyzer";
|
||||
type = str;
|
||||
default = "";
|
||||
example = ''
|
||||
['rust-analyzer'] = {
|
||||
cargo = {allFeature = true},
|
||||
checkOnSave = true,
|
||||
procMacro = {
|
||||
enable = true,
|
||||
},
|
||||
},
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
|
|
@ -142,6 +151,9 @@ in {
|
|||
then expToLua cfg.lsp.package
|
||||
else ''{"${cfg.lsp.package}/bin/rust-analyzer"}''
|
||||
},
|
||||
default_settings = {
|
||||
${cfg.lsp.opts}
|
||||
},
|
||||
on_attach = function(client, bufnr)
|
||||
default_on_attach(client, bufnr)
|
||||
local opts = { noremap=true, silent=true, buffer = bufnr }
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@
|
|||
ls_sources,
|
||||
null_ls.builtins.formatting.prettier.with({
|
||||
command = "${cfg.format.package}/bin/prettier",
|
||||
filetypes = { "typescript" },
|
||||
filetypes = { "typescript", "javascript" },
|
||||
})
|
||||
)
|
||||
'';
|
||||
|
|
@ -230,7 +230,7 @@ in {
|
|||
|
||||
# Extensions
|
||||
(mkIf cfg.extensions."ts-error-translator".enable {
|
||||
vim.startPlugins = ["ts-error-translator"];
|
||||
vim.startPlugins = ["ts-error-translator-nvim"];
|
||||
vim.pluginRC.ts-error-translator = entryAnywhere ''
|
||||
require("ts-error-translator").setup(${toLuaObject cfg.extensions.ts-error-translator.setupOpts})
|
||||
'';
|
||||
|
|
|
|||
85
modules/plugins/languages/yaml.nix
Normal file
85
modules/plugins/languages/yaml.nix
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
{
|
||||
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.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,
|
||||
${onAttach},
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then expToLua cfg.lsp.package
|
||||
else ''{"${cfg.lsp.package}/bin/yaml-language-server", "--stdio"}''
|
||||
},
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
in {
|
||||
options.vim.languages.yaml = {
|
||||
enable = mkEnableOption "YAML language support";
|
||||
|
||||
treesitter = {
|
||||
enable = mkEnableOption "YAML treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||
|
||||
package = mkGrammarOption pkgs "yaml";
|
||||
};
|
||||
|
||||
lsp = {
|
||||
enable = mkEnableOption "YAML LSP support" // {default = config.vim.languages.enableLSP;};
|
||||
|
||||
server = mkOption {
|
||||
type = enum (attrNames servers);
|
||||
default = defaultServer;
|
||||
description = "YAML LSP server to use";
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
type = either package (listOf str);
|
||||
default = servers.${cfg.lsp.server}.package;
|
||||
description = "YAML 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.yaml-lsp = servers.${cfg.lsp.server}.lspConfig;
|
||||
})
|
||||
]);
|
||||
}
|
||||
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
cfg = config.vim.lsp;
|
||||
usingNvimCmp = config.vim.autocomplete.nvim-cmp.enable;
|
||||
usingBlinkCmp = config.vim.autocomplete.blink-cmp.enable;
|
||||
self = import ./module.nix {inherit config lib pkgs;};
|
||||
|
||||
mappingDefinitions = self.options.vim.lsp.mappings;
|
||||
|
|
@ -22,7 +23,7 @@
|
|||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim = {
|
||||
autocomplete.nvim-cmp = {
|
||||
autocomplete.nvim-cmp = mkIf usingNvimCmp {
|
||||
sources = {nvim_lsp = "[LSP]";};
|
||||
sourcePlugins = ["cmp-nvim-lsp"];
|
||||
};
|
||||
|
|
@ -170,6 +171,10 @@ in {
|
|||
},
|
||||
}
|
||||
''}
|
||||
|
||||
${optionalString usingBlinkCmp ''
|
||||
capabilities = require('blink.cmp').get_lsp_capabilities()
|
||||
''}
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -10,9 +10,19 @@
|
|||
cfg = config.vim.lsp;
|
||||
in {
|
||||
config = mkIf (cfg.enable && cfg.lspSignature.enable) {
|
||||
assertions = [
|
||||
{
|
||||
assertion = !config.vim.autocomplete.blink-cmp.enable;
|
||||
message = ''
|
||||
lsp-signature does not work with blink.cmp. Please use blink.cmp's builtin signature feature:
|
||||
|
||||
vim.autocomplete.blink-cmp.setupOpts.signature.enabled = true;
|
||||
'';
|
||||
}
|
||||
];
|
||||
vim = {
|
||||
startPlugins = [
|
||||
"lsp-signature"
|
||||
"lsp-signature-nvim"
|
||||
];
|
||||
|
||||
lsp.lspSignature.setupOpts = {
|
||||
|
|
|
|||
|
|
@ -8,27 +8,39 @@
|
|||
inherit (lib.nvim.lua) toLuaObject;
|
||||
|
||||
cfg = config.vim.lsp.lspkind;
|
||||
usingCmp = config.vim.autocomplete.nvim-cmp.enable;
|
||||
usingBlink = config.vim.autocomplete.blink-cmp.enable;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
assertions = [
|
||||
{
|
||||
assertion = config.vim.autocomplete.nvim-cmp.enable;
|
||||
assertion = usingCmp || usingBlink;
|
||||
message = ''
|
||||
While lspkind supports Neovim's native lsp upstream, using that over
|
||||
nvim-cmp isn't recommended, nor supported by nvf.
|
||||
nvim-cmp/blink.cmp isn't recommended, nor supported by nvf.
|
||||
|
||||
Please migrate to nvim-cmp if you want to use lspkind.
|
||||
Please migrate to nvim-cmp/blink.cmp if you want to use lspkind.
|
||||
'';
|
||||
}
|
||||
];
|
||||
|
||||
vim = {
|
||||
startPlugins = ["lspkind"];
|
||||
startPlugins = ["lspkind-nvim"];
|
||||
|
||||
lsp.lspkind.setupOpts.before = config.vim.autocomplete.nvim-cmp.format;
|
||||
autocomplete.nvim-cmp.setupOpts.formatting.format = mkForce (mkLuaInline ''
|
||||
require("lspkind").cmp_format(${toLuaObject cfg.setupOpts})
|
||||
'');
|
||||
autocomplete = {
|
||||
nvim-cmp = mkIf usingCmp {
|
||||
setupOpts.formatting.format = mkForce (mkLuaInline ''
|
||||
require("lspkind").cmp_format(${toLuaObject cfg.setupOpts})
|
||||
'');
|
||||
};
|
||||
|
||||
blink-cmp = mkIf usingBlink {
|
||||
setupOpts.appearance.kind_icons = mkLuaInline ''
|
||||
require("lspkind").symbol_map
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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"];
|
||||
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`";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ in {
|
|||
{
|
||||
vim = {
|
||||
startPlugins = [
|
||||
"none-ls"
|
||||
"none-ls-nvim"
|
||||
"plenary-nvim"
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -57,8 +57,8 @@ in {
|
|||
};
|
||||
|
||||
mappings = {
|
||||
viewToggle = mkMappingOption "Open or close the docs view panel" "lvt";
|
||||
viewUpdate = mkMappingOption "Manually update the docs view panel" "lvu";
|
||||
viewToggle = mkMappingOption "Open or close the docs view panel" "<leader>lvt";
|
||||
viewUpdate = mkMappingOption "Manually update the docs view panel" "<leader>lvu";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,13 +15,12 @@
|
|||
mappings = addDescriptionsToMappings cfg.otter-nvim.mappings mappingDefinitions;
|
||||
in {
|
||||
config = mkIf (cfg.enable && cfg.otter-nvim.enable) {
|
||||
assertions = [
|
||||
{
|
||||
assertion = !config.vim.utility.ccc.enable;
|
||||
message = ''
|
||||
ccc and otter have a breaking conflict. It's been reported upstream. Until it's fixed, disable one of them
|
||||
'';
|
||||
}
|
||||
warnings = [
|
||||
# TODO: remove warning when we update to nvim 0.11
|
||||
(mkIf config.vim.utility.ccc.enable ''
|
||||
ccc and otter occasionally have small conflicts that will disappear with nvim 0.11.
|
||||
In the meantime, otter handles it by throwing a warning, but both plugins will work.
|
||||
'')
|
||||
];
|
||||
vim = {
|
||||
startPlugins = ["otter-nvim"];
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
inherit (lib.types) bool str nullOr;
|
||||
inherit (lib.modules) mkRenamedOptionModule;
|
||||
inherit (lib.nvim.types) mkPluginSetupOption;
|
||||
|
||||
autocompleteCfg = config.vim.autocomplete;
|
||||
in {
|
||||
imports = let
|
||||
renamedSetupOption = oldPath: newPath:
|
||||
|
|
@ -42,7 +44,7 @@ in {
|
|||
# If using nvim-cmp, otherwise set to false
|
||||
type = bool;
|
||||
description = "If using nvim-cmp, otherwise set to false";
|
||||
default = config.vim.autocomplete.nvim-cmp.enable;
|
||||
default = autocompleteCfg.nvim-cmp.enable || autocompleteCfg.blink-cmp.enable;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -13,9 +13,7 @@ in {
|
|||
config = mkIf cfg.enable (mkMerge [
|
||||
{
|
||||
vim = {
|
||||
startPlugins = [
|
||||
"orgmode-nvim"
|
||||
];
|
||||
startPlugins = ["orgmode"];
|
||||
|
||||
binds.whichKey.register = pushDownDefault {
|
||||
"<leader>o" = "+Notes";
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ in {
|
|||
config = mkIf cfg.enable {
|
||||
vim = {
|
||||
startPlugins = [
|
||||
"todo-comments"
|
||||
"todo-comments-nvim"
|
||||
];
|
||||
|
||||
maps.normal = mkMerge [
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ in {
|
|||
vim = {
|
||||
startPlugins =
|
||||
[
|
||||
"nvim-session-manager"
|
||||
"neovim-session-manager"
|
||||
"plenary-nvim"
|
||||
]
|
||||
++ optionals cfg.usePicker ["dressing-nvim"];
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.types) nullOr str bool;
|
||||
inherit (lib) mkEnableOption mkOption types mkRenamedOptionModule;
|
||||
inherit (lib.options) mkOption mkEnableOption;
|
||||
inherit (lib.modules) mkRenamedOptionModule;
|
||||
inherit (lib.strings) isString;
|
||||
inherit (lib.types) nullOr str bool int enum listOf either;
|
||||
inherit (lib.generators) mkLuaInline;
|
||||
inherit (lib.nvim.types) luaInline mkPluginSetupOption;
|
||||
in {
|
||||
imports = let
|
||||
renameSetupOpt = oldPath: newPath:
|
||||
|
|
@ -50,68 +54,100 @@ in {
|
|||
usePicker = mkOption {
|
||||
type = bool;
|
||||
default = true;
|
||||
description = "Whether or not we should use dressing.nvim to build a session picker UI";
|
||||
description = ''
|
||||
Whether we should use `dressing.nvim` to build a session picker UI
|
||||
'';
|
||||
};
|
||||
|
||||
setupOpts = {
|
||||
setupOpts = mkPluginSetupOption "which-key" {
|
||||
path_replacer = mkOption {
|
||||
type = types.str;
|
||||
type = str;
|
||||
default = "__";
|
||||
description = "The character to which the path separator will be replaced for session files";
|
||||
description = ''
|
||||
The character to which the path separator will be replaced for session files
|
||||
'';
|
||||
};
|
||||
|
||||
colon_replacer = mkOption {
|
||||
type = types.str;
|
||||
type = str;
|
||||
default = "++";
|
||||
description = "The character to which the colon symbol will be replaced for session files";
|
||||
description = ''
|
||||
The character to which the colon symbol will be replaced for session files
|
||||
'';
|
||||
};
|
||||
|
||||
autoload_mode = mkOption {
|
||||
type = types.enum ["Disabled" "CurrentDir" "LastSession"];
|
||||
type = either (enum ["Disabled" "CurrentDir" "LastSession"]) luaInline;
|
||||
# Variable 'sm' is defined in the pluginRC of nvim-session-manager. The
|
||||
# definition is as follows: `local sm = require('session_manager.config')`
|
||||
apply = val:
|
||||
if isString val
|
||||
then mkLuaInline "sm.AutoloadMode.${val}"
|
||||
else val;
|
||||
default = "LastSession";
|
||||
description = "Define what to do when Neovim is started without arguments. Possible values: Disabled, CurrentDir, LastSession";
|
||||
description = ''
|
||||
Define what to do when Neovim is started without arguments.
|
||||
|
||||
Takes either one of `"Disabled"`, `"CurrentDir"`, `"LastSession` in which case the value
|
||||
will be inserted into `sm.AutoloadMode.<value>`, or an inline Lua value.
|
||||
'';
|
||||
};
|
||||
|
||||
max_path_length = mkOption {
|
||||
type = types.nullOr types.int;
|
||||
type = nullOr int;
|
||||
default = 80;
|
||||
description = "Shorten the display path if length exceeds this threshold. Use 0 if don't want to shorten the path at all";
|
||||
description = ''
|
||||
Shorten the display path if length exceeds this threshold.
|
||||
|
||||
Use `0` if don't want to shorten the path at all
|
||||
'';
|
||||
};
|
||||
|
||||
autosave_last_session = mkOption {
|
||||
type = types.bool;
|
||||
type = bool;
|
||||
default = true;
|
||||
description = "Automatically save last session on exit and on session switch";
|
||||
description = ''
|
||||
Automatically save last session on exit and on session switch
|
||||
'';
|
||||
};
|
||||
|
||||
autosave_ignore_not_normal = mkOption {
|
||||
type = types.bool;
|
||||
type = bool;
|
||||
default = true;
|
||||
description = "Plugin will not save a session when no buffers are opened, or all of them aren't writable or listed";
|
||||
description = ''
|
||||
Plugin will not save a session when no buffers are opened, or all of them are
|
||||
not writable or listed
|
||||
'';
|
||||
};
|
||||
|
||||
autosave_ignore_dirs = mkOption {
|
||||
type = types.listOf types.str;
|
||||
type = listOf str;
|
||||
default = [];
|
||||
description = "A list of directories where the session will not be autosaved";
|
||||
};
|
||||
|
||||
autosave_ignore_filetypes = mkOption {
|
||||
type = types.listOf types.str;
|
||||
type = listOf str;
|
||||
default = ["gitcommit"];
|
||||
description = "All buffers of these file types will be closed before the session is saved";
|
||||
description = ''
|
||||
All buffers of these file types will be closed before the session is saved
|
||||
'';
|
||||
};
|
||||
|
||||
autosave_ignore_buftypes = mkOption {
|
||||
type = types.listOf types.str;
|
||||
type = listOf str;
|
||||
default = [];
|
||||
description = "All buffers of these buffer types will be closed before the session is saved";
|
||||
description = ''
|
||||
All buffers of these buffer types will be closed before the session is saved
|
||||
'';
|
||||
};
|
||||
|
||||
autosave_only_in_session = mkOption {
|
||||
type = types.bool;
|
||||
type = bool;
|
||||
default = false;
|
||||
description = "Always autosaves session. If true, only autosaves after a session is active";
|
||||
description = ''
|
||||
Always autosaves session. If `true`, only autosaves after a session is active
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ in {
|
|||
after = cfg.loaders;
|
||||
};
|
||||
startPlugins = cfg.providers;
|
||||
autocomplete.nvim-cmp = {
|
||||
autocomplete.nvim-cmp = mkIf config.vim.autocomplete.nvim-cmp.enable {
|
||||
sources = {luasnip = "[LuaSnip]";};
|
||||
sourcePlugins = ["cmp-luasnip"];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ in {
|
|||
})
|
||||
(mkIf cfg.enable {
|
||||
vim = {
|
||||
startPlugins = ["lualine"];
|
||||
startPlugins = ["lualine-nvim"];
|
||||
pluginRC.lualine = entryAnywhere ''
|
||||
local lualine = require('lualine')
|
||||
lualine.setup ${toLuaObject cfg.setupOpts}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,17 @@
|
|||
"codedark"
|
||||
"dracula"
|
||||
"everforest"
|
||||
"github_dark"
|
||||
"github_light"
|
||||
"github_dark_dimmed"
|
||||
"github_dark_default"
|
||||
"github_light_default"
|
||||
"github_dark_high_contrast"
|
||||
"github_light_high_contrast"
|
||||
"github_dark_colorblind"
|
||||
"github_light_colorblind"
|
||||
"github_dark_tritanopia"
|
||||
"github_light_tritanopia"
|
||||
"gruvbox"
|
||||
"gruvbox_dark"
|
||||
"gruvbox_light"
|
||||
|
|
|
|||
|
|
@ -195,4 +195,20 @@ in {
|
|||
vim.cmd.colorscheme("nord")
|
||||
'';
|
||||
};
|
||||
github = {
|
||||
setup = {
|
||||
style ? "dark",
|
||||
transparent ? false,
|
||||
...
|
||||
}: ''
|
||||
require('github-theme').setup({
|
||||
options = {
|
||||
transparent = ${boolToString transparent},
|
||||
},
|
||||
})
|
||||
|
||||
vim.cmd[[colorscheme github_${style}]]
|
||||
'';
|
||||
styles = ["dark" "light" "dark_dimmed" "dark_default" "light_default" "dark_high_contrast" "light_high_contrast" "dark_colorblind" "light_colorblind" "dark_tritanopia" "light_tritanopia"];
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,8 @@ in {
|
|||
vim = {
|
||||
startPlugins = ["nvim-treesitter"];
|
||||
|
||||
autocomplete.nvim-cmp = {
|
||||
# cmp-treesitter doesn't work on blink.cmp
|
||||
autocomplete.nvim-cmp = mkIf config.vim.autocomplete.nvim-cmp.enable {
|
||||
sources = {treesitter = "[Treesitter]";};
|
||||
sourcePlugins = ["cmp-treesitter"];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,22 +4,20 @@
|
|||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
|
||||
cfg = config.vim.ui.illuminate;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = ["vim-illuminate"];
|
||||
vim = {
|
||||
startPlugins = ["vim-illuminate"];
|
||||
|
||||
vim.pluginRC.vim-illuminate = entryAnywhere ''
|
||||
require('illuminate').configure({
|
||||
filetypes_denylist = {
|
||||
'dirvish',
|
||||
'fugitive',
|
||||
'NvimTree',
|
||||
'TelescopePrompt',
|
||||
},
|
||||
})
|
||||
'';
|
||||
# vim-illuminate does not have a setup function. It is instead called 'configure'
|
||||
# and does what you expect from a setup function. Wild.
|
||||
pluginRC.vim-illuminate = entryAnywhere ''
|
||||
require('illuminate').configure(${toLuaObject cfg.setupOpts})
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,19 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption;
|
||||
inherit (lib.options) mkOption mkEnableOption;
|
||||
inherit (lib.types) listOf str;
|
||||
inherit (lib.nvim.types) mkPluginSetupOption;
|
||||
in {
|
||||
options.vim.ui.illuminate = {
|
||||
enable = mkEnableOption "automatically highlight other uses of the word under the cursor [vim-illuminate]";
|
||||
enable = mkEnableOption ''
|
||||
automatically highlight other uses of the word under the cursor [vim-illuminate]
|
||||
'';
|
||||
|
||||
setupOpts = mkPluginSetupOption "vim-illuminate" {
|
||||
filetypes_denylist = mkOption {
|
||||
type = listOf str;
|
||||
default = ["dirvish" "fugitive" "NvimTree" "TelescopePrompt"];
|
||||
description = "Filetypes to not illuminate, this overrides `filetypes_allowlist`";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim = {
|
||||
startPlugins = ["smartcolumn"];
|
||||
startPlugins = ["smartcolumn-nvim"];
|
||||
|
||||
pluginRC.smartcolumn = entryAnywhere ''
|
||||
require("smartcolumn").setup(${toLuaObject cfg.setupOpts})
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim = {
|
||||
startPlugins = ["which-key"];
|
||||
startPlugins = ["which-key-nvim"];
|
||||
|
||||
pluginRC.whichkey = entryAnywhere ''
|
||||
local wk = require("which-key")
|
||||
|
|
|
|||
|
|
@ -9,9 +9,7 @@
|
|||
cfg = config.vim.utility.ccc;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = [
|
||||
"ccc"
|
||||
];
|
||||
vim.startPlugins = ["ccc-nvim"];
|
||||
|
||||
vim.pluginRC.ccc = entryAnywhere ''
|
||||
local ccc = require("ccc")
|
||||
|
|
|
|||
|
|
@ -1,19 +1,27 @@
|
|||
{
|
||||
imports = [
|
||||
./outline
|
||||
./binds
|
||||
./ccc
|
||||
./diffview
|
||||
./direnv
|
||||
./fzf-lua
|
||||
./gestures
|
||||
./motion
|
||||
./new-file-template
|
||||
./telescope
|
||||
./harpoon
|
||||
./icon-picker
|
||||
./images
|
||||
./telescope
|
||||
./diffview
|
||||
./wakatime
|
||||
./surround
|
||||
./leetcode-nvim
|
||||
./mkdir
|
||||
./motion
|
||||
./multicursors
|
||||
./new-file-template
|
||||
./nix-develop
|
||||
./outline
|
||||
./preview
|
||||
./fzf-lua
|
||||
./snacks-nvim
|
||||
./surround
|
||||
./telescope
|
||||
./wakatime
|
||||
./yanky-nvim
|
||||
./yazi-nvim
|
||||
];
|
||||
}
|
||||
|
|
|
|||
13
modules/plugins/utility/direnv/config.nix
Normal file
13
modules/plugins/utility/direnv/config.nix
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
|
||||
cfg = config.vim.utility.direnv;
|
||||
in {
|
||||
vim = mkIf cfg.enable {
|
||||
startPlugins = ["direnv-vim"];
|
||||
};
|
||||
}
|
||||
6
modules/plugins/utility/direnv/default.nix
Normal file
6
modules/plugins/utility/direnv/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./config.nix
|
||||
./direnv.nix
|
||||
];
|
||||
}
|
||||
5
modules/plugins/utility/direnv/direnv.nix
Normal file
5
modules/plugins/utility/direnv/direnv.nix
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption;
|
||||
in {
|
||||
options.vim.utility.direnv.enable = mkEnableOption "syncing nvim shell environment with direnv's using `direnv.vim`";
|
||||
}
|
||||
41
modules/plugins/utility/harpoon/config.nix
Normal file
41
modules/plugins/utility/harpoon/config.nix
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
{
|
||||
options,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.nvim.binds) pushDownDefault mkKeymap;
|
||||
|
||||
cfg = config.vim.navigation.harpoon;
|
||||
|
||||
keys = cfg.mappings;
|
||||
inherit (options.vim.navigation.harpoon) mappings;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim = {
|
||||
startPlugins = ["plenary-nvim"];
|
||||
|
||||
lazy.plugins.harpoon = {
|
||||
package = "harpoon";
|
||||
setupModule = "harpoon";
|
||||
inherit (cfg) setupOpts;
|
||||
|
||||
cmd = ["Harpoon"];
|
||||
|
||||
keys = [
|
||||
(mkKeymap "n" keys.markFile "<Cmd>lua require('harpoon'):list():add()<CR>" {desc = mappings.markFile.description;})
|
||||
(mkKeymap "n" keys.listMarks "<Cmd>lua require('harpoon').ui:toggle_quick_menu(require('harpoon'):list())<CR>" {desc = mappings.listMarks.description;})
|
||||
(mkKeymap "n" keys.file1 "<Cmd>lua require('harpoon'):list():select(1)<CR>" {desc = mappings.file1.description;})
|
||||
(mkKeymap "n" keys.file2 "<Cmd>lua require('harpoon'):list():select(2)<CR>" {desc = mappings.file2.description;})
|
||||
(mkKeymap "n" keys.file3 "<Cmd>lua require('harpoon'):list():select(3)<CR>" {desc = mappings.file3.description;})
|
||||
(mkKeymap "n" keys.file4 "<Cmd>lua require('harpoon'):list():select(4)<CR>" {desc = mappings.file4.description;})
|
||||
];
|
||||
};
|
||||
|
||||
binds.whichKey.register = pushDownDefault {
|
||||
"<leader>a" = "Harpoon Mark";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
6
modules/plugins/utility/harpoon/default.nix
Normal file
6
modules/plugins/utility/harpoon/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./harpoon.nix
|
||||
./config.nix
|
||||
];
|
||||
}
|
||||
53
modules/plugins/utility/harpoon/harpoon.nix
Normal file
53
modules/plugins/utility/harpoon/harpoon.nix
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption mkOption;
|
||||
inherit (lib.types) bool;
|
||||
inherit (lib.nvim.binds) mkMappingOption;
|
||||
inherit (lib.nvim.types) mkPluginSetupOption luaInline;
|
||||
inherit (lib.generators) mkLuaInline;
|
||||
in {
|
||||
options.vim.navigation.harpoon = {
|
||||
mappings = {
|
||||
markFile = mkMappingOption "Mark file [Harpoon]" "<leader>a";
|
||||
listMarks = mkMappingOption "List marked files [Harpoon]" "<C-e>";
|
||||
file1 = mkMappingOption "Go to marked file 1 [Harpoon]" "<C-j>";
|
||||
file2 = mkMappingOption "Go to marked file 2 [Harpoon]" "<C-k>";
|
||||
file3 = mkMappingOption "Go to marked file 3 [Harpoon]" "<C-l>";
|
||||
file4 = mkMappingOption "Go to marked file 4 [Harpoon]" "<C-;>";
|
||||
};
|
||||
|
||||
enable = mkEnableOption "Quick bookmarks on keybinds [Harpoon]";
|
||||
|
||||
setupOpts = mkPluginSetupOption "Harpoon" {
|
||||
defaults = {
|
||||
save_on_toggle = mkOption {
|
||||
type = bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Any time the ui menu is closed then we will save the
|
||||
state back to the backing list, not to the fs
|
||||
'';
|
||||
};
|
||||
sync_on_ui_close = mkOption {
|
||||
type = bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Any time the ui menu is closed then the state of the
|
||||
list will be sync'd back to the fs
|
||||
'';
|
||||
};
|
||||
key = mkOption {
|
||||
type = luaInline;
|
||||
default = mkLuaInline ''
|
||||
function()
|
||||
return vim.loop.cwd()
|
||||
end
|
||||
'';
|
||||
description = ''
|
||||
How the out list key is looked up. This can be useful
|
||||
when using worktrees and using git remote instead of file path
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
26
modules/plugins/utility/leetcode-nvim/config.nix
Normal file
26
modules/plugins/utility/leetcode-nvim/config.nix
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
|
||||
cfg = config.vim.utility.leetcode-nvim;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim = {
|
||||
startPlugins = [
|
||||
"leetcode-nvim"
|
||||
"plenary-nvim"
|
||||
"fzf-lua"
|
||||
"nui-nvim"
|
||||
];
|
||||
|
||||
lazy.plugins.leetcode-nvim = {
|
||||
package = "leetcode-nvim";
|
||||
setupModule = "leetcode";
|
||||
inherit (cfg) setupOpts;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
6
modules/plugins/utility/leetcode-nvim/default.nix
Normal file
6
modules/plugins/utility/leetcode-nvim/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./leetcode-nvim.nix
|
||||
./config.nix
|
||||
];
|
||||
}
|
||||
74
modules/plugins/utility/leetcode-nvim/leetcode-nvim.nix
Normal file
74
modules/plugins/utility/leetcode-nvim/leetcode-nvim.nix
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkOption mkEnableOption;
|
||||
inherit (lib.types) enum str bool;
|
||||
inherit (lib.generators) mkLuaInline;
|
||||
inherit (lib.nvim.types) mkPluginSetupOption luaInline;
|
||||
in {
|
||||
options.vim.utility = {
|
||||
leetcode-nvim = {
|
||||
enable = mkEnableOption "complementary neovim plugin for leetcode.nvim";
|
||||
|
||||
setupOpts = mkPluginSetupOption "leetcode-nvim" {
|
||||
logging = mkEnableOption "logging for leetcode.nvim status notifications." // {default = true;};
|
||||
image_support = mkEnableOption "question description images using image.nvim (image-nvim must be enabled).";
|
||||
|
||||
lang = mkOption {
|
||||
type = enum [
|
||||
"cpp"
|
||||
"java"
|
||||
"python"
|
||||
"python3"
|
||||
"c"
|
||||
"csharp"
|
||||
"javascript"
|
||||
"typescript"
|
||||
"php"
|
||||
"swift"
|
||||
"kotlin"
|
||||
"dart"
|
||||
"golang"
|
||||
"ruby"
|
||||
"scala"
|
||||
"rust"
|
||||
"racket"
|
||||
"erlang"
|
||||
"elixir"
|
||||
"bash"
|
||||
];
|
||||
default = "python3";
|
||||
description = "Language to start your session with";
|
||||
};
|
||||
|
||||
arg = mkOption {
|
||||
type = str;
|
||||
default = "leetcode.nvim";
|
||||
description = "Argument for Neovim";
|
||||
};
|
||||
|
||||
cn = {
|
||||
enabled = mkEnableOption "leetcode.cn instead of leetcode.com";
|
||||
translator = mkEnableOption "translator" // {default = true;};
|
||||
translate_problems = mkEnableOption "translation for problem questions" // {default = true;};
|
||||
};
|
||||
|
||||
storage = {
|
||||
home = mkOption {
|
||||
type = luaInline;
|
||||
default = mkLuaInline "vim.fn.stdpath(\"data\") .. \"/leetcode\"";
|
||||
description = "Home storage directory";
|
||||
};
|
||||
|
||||
cache = mkOption {
|
||||
type = luaInline;
|
||||
default = mkLuaInline "vim.fn.stdpath(\"cache\") .. \"/leetcode\"";
|
||||
description = "Cache storage directory";
|
||||
};
|
||||
};
|
||||
|
||||
plugins = {
|
||||
non_standalone = mkEnableOption "leetcode.nvim in a non-standalone mode";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
12
modules/plugins/utility/mkdir/config.nix
Normal file
12
modules/plugins/utility/mkdir/config.nix
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
cfg = config.vim.utility.mkdir;
|
||||
in {
|
||||
vim = mkIf cfg.enable {
|
||||
startPlugins = ["mkdir-nvim"];
|
||||
};
|
||||
}
|
||||
6
modules/plugins/utility/mkdir/default.nix
Normal file
6
modules/plugins/utility/mkdir/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./config.nix
|
||||
./mkdir.nix
|
||||
];
|
||||
}
|
||||
7
modules/plugins/utility/mkdir/mkdir.nix
Normal file
7
modules/plugins/utility/mkdir/mkdir.nix
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption;
|
||||
in {
|
||||
options.vim.utility.mkdir.enable = mkEnableOption ''
|
||||
parent directory creation when editing a nested path that does not exist using `mkdir.nvim`
|
||||
'';
|
||||
}
|
||||
36
modules/plugins/utility/multicursors/config.nix
Normal file
36
modules/plugins/utility/multicursors/config.nix
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
cfg = config.vim.utility.multicursors;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim = {
|
||||
startPlugins = ["hydra-nvim"];
|
||||
lazy.plugins."multicursors-nvim" = {
|
||||
package = "multicursors-nvim";
|
||||
setupModule = "multicursors";
|
||||
inherit (cfg) setupOpts;
|
||||
|
||||
event = ["DeferredUIEnter"];
|
||||
cmd = ["MCstart" "MCvisual" "MCclear" "MCpattern" "MCvisualPattern" "MCunderCursor"];
|
||||
keys = [
|
||||
{
|
||||
mode = ["v" "n"];
|
||||
key = "<leader>mcs";
|
||||
action = ":MCstart<cr>";
|
||||
desc = "Create a selection for selected text or word under the cursor [multicursors.nvim]";
|
||||
}
|
||||
{
|
||||
mode = ["v" "n"];
|
||||
key = "<leader>mcp";
|
||||
action = ":MCpattern<cr>";
|
||||
desc = "Create a selection for pattern entered [multicursors.nvim]";
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
6
modules/plugins/utility/multicursors/default.nix
Normal file
6
modules/plugins/utility/multicursors/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./multicursors.nix
|
||||
./config.nix
|
||||
];
|
||||
}
|
||||
138
modules/plugins/utility/multicursors/multicursors.nix
Normal file
138
modules/plugins/utility/multicursors/multicursors.nix
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkOption mkEnableOption;
|
||||
inherit (lib.types) attrsOf nullOr bool int str submodule;
|
||||
inherit (lib.nvim.types) mkPluginSetupOption;
|
||||
|
||||
hintConfig = {
|
||||
options = {
|
||||
float_opts = mkOption {
|
||||
description = "The options for the floating hint window";
|
||||
type = submodule {
|
||||
options = {
|
||||
border = mkOption {
|
||||
type = str;
|
||||
default = "none";
|
||||
description = "The border style for the hint window";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
position = mkOption {
|
||||
type = str;
|
||||
default = "bottom";
|
||||
description = "The position of the hint window";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
generateHints = {
|
||||
options = {
|
||||
normal = mkOption {
|
||||
type = bool;
|
||||
default = true;
|
||||
description = "Generate hints for the normal mode";
|
||||
};
|
||||
|
||||
insert = mkOption {
|
||||
type = bool;
|
||||
default = true;
|
||||
description = "Generate hints for the insert mode";
|
||||
};
|
||||
|
||||
extend = mkOption {
|
||||
type = bool;
|
||||
default = true;
|
||||
description = "Generate hints for the extend mode";
|
||||
};
|
||||
|
||||
config = mkOption {
|
||||
description = "The configuration for generating hints for multicursors.nvim";
|
||||
type = submodule {
|
||||
options = {
|
||||
column_count = mkOption {
|
||||
type = nullOr int;
|
||||
default = null;
|
||||
description = "The number of columns to use for the hint window";
|
||||
};
|
||||
|
||||
max_hint_length = mkOption {
|
||||
type = int;
|
||||
default = 25;
|
||||
description = "The maximum length of the hint";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
default = {
|
||||
column_count = null;
|
||||
max_hint_length = 25;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
in {
|
||||
options.vim.utility.multicursors = {
|
||||
enable = mkEnableOption "vscode like multiple cursors [multicursor.nvim]";
|
||||
|
||||
setupOpts = mkPluginSetupOption "multicursors" {
|
||||
DEBUG_MODE = mkOption {
|
||||
type = bool;
|
||||
default = false;
|
||||
description = "Enable debug mode.";
|
||||
};
|
||||
|
||||
create_commands = mkOption {
|
||||
type = bool;
|
||||
default = true;
|
||||
description = "Create Multicursor user commands";
|
||||
};
|
||||
|
||||
updatetime = mkOption {
|
||||
type = int;
|
||||
default = 50;
|
||||
description = "The time in milliseconds to wait before updating the cursor in insert mode";
|
||||
};
|
||||
|
||||
nowait = mkOption {
|
||||
type = bool;
|
||||
default = true;
|
||||
description = "Don't wait for the cursor to move before updating the cursor";
|
||||
};
|
||||
|
||||
mode_keys = mkOption {
|
||||
type = attrsOf str;
|
||||
default = {
|
||||
insert = "i";
|
||||
append = "a";
|
||||
change = "c";
|
||||
extend = "e";
|
||||
};
|
||||
description = "The keys to use for each mode";
|
||||
};
|
||||
|
||||
hint_config = mkOption {
|
||||
type = submodule hintConfig;
|
||||
default = {
|
||||
float_opts.border = "none";
|
||||
position = "bottom";
|
||||
};
|
||||
description = "The configuration for the hint window";
|
||||
};
|
||||
|
||||
generate_hints = mkOption {
|
||||
type = submodule generateHints;
|
||||
default = {
|
||||
normal = true;
|
||||
insert = true;
|
||||
extend = true;
|
||||
config = {
|
||||
column_count = null;
|
||||
max_hint_length = 25;
|
||||
};
|
||||
};
|
||||
description = "The configuration for generating hints";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
12
modules/plugins/utility/nix-develop/config.nix
Normal file
12
modules/plugins/utility/nix-develop/config.nix
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
cfg = config.vim.utility.nix-develop;
|
||||
in {
|
||||
vim = mkIf cfg.enable {
|
||||
startPlugins = ["nix-develop-nvim"];
|
||||
};
|
||||
}
|
||||
6
modules/plugins/utility/nix-develop/default.nix
Normal file
6
modules/plugins/utility/nix-develop/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./config.nix
|
||||
./nix-develop.nix
|
||||
];
|
||||
}
|
||||
5
modules/plugins/utility/nix-develop/nix-develop.nix
Normal file
5
modules/plugins/utility/nix-develop/nix-develop.nix
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption;
|
||||
in {
|
||||
options.vim.utility.nix-develop.enable = mkEnableOption "in-neovim `nix develop`, `nix shell`, and more using `nix-develop.nvim`";
|
||||
}
|
||||
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 upstreeam 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
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,11 +87,6 @@
|
|||
type = float;
|
||||
default = 0.55;
|
||||
};
|
||||
results_width = mkOption {
|
||||
description = "";
|
||||
type = float;
|
||||
default = 0.8;
|
||||
};
|
||||
};
|
||||
vertical = {
|
||||
mirror = mkOption {
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue