mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-09-07 10:51:36 +00:00
Merge branch 'main' into telescope-ext
This commit is contained in:
commit
f2531e456c
105 changed files with 3657 additions and 4148 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"
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
120
modules/plugins/completion/blink-cmp/blink-cmp.nix
Normal file
120
modules/plugins/completion/blink-cmp/blink-cmp.nix
Normal file
|
@ -0,0 +1,120 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption mkOption literalMD;
|
||||
inherit (lib.types) listOf str either attrsOf submodule enum anything int nullOr;
|
||||
inherit (lib.generators) mkLuaInline;
|
||||
inherit (lib.nvim.types) mkPluginSetupOption luaInline;
|
||||
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 = str;
|
||||
description = "module of the provider";
|
||||
};
|
||||
};
|
||||
};
|
||||
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.";
|
||||
};
|
||||
|
||||
cmdline = mkOption {
|
||||
type = nullOr (listOf str);
|
||||
default = [];
|
||||
description = "List of sources to enable for cmdline. Null means use default source list.";
|
||||
};
|
||||
|
||||
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.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
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";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
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. Do not enable, it doesn't work on nix
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
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>";
|
||||
};
|
||||
};
|
||||
}
|
91
modules/plugins/completion/blink-cmp/config.nix
Normal file
91
modules/plugins/completion/blink-cmp/config.nix
Normal file
|
@ -0,0 +1,91 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.strings) optionalString;
|
||||
inherit (lib.generators) mkLuaInline;
|
||||
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;
|
||||
in {
|
||||
vim = mkIf cfg.enable {
|
||||
startPlugins = ["blink-compat"];
|
||||
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 = ''
|
||||
${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);
|
||||
providers =
|
||||
mapAttrs (name: _: {
|
||||
inherit name;
|
||||
module = "blink.compat.source";
|
||||
})
|
||||
cmpCfg.sources;
|
||||
};
|
||||
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 ''
|
||||
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,103 @@
|
|||
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 = {
|
||||
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)
|
||||
'';
|
||||
};
|
||||
})
|
||||
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)
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
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").setup(${toLuaObject cfg.setupOpts})
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
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
|
||||
];
|
||||
}
|
27
modules/plugins/diagnostics/nvim-lint/nvim-lint.nix
Normal file
27
modules/plugins/diagnostics/nvim-lint/nvim-lint.nix
Normal file
|
@ -0,0 +1,27 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkOption mkEnableOption;
|
||||
inherit (lib.types) attrsOf listOf str;
|
||||
inherit (lib.nvim.types) mkPluginSetupOption;
|
||||
in {
|
||||
options.vim.diagnostics.nvim-lint = {
|
||||
enable = mkEnableOption "asynchronous linter plugin for Neovim [nvim-lint]";
|
||||
setupOpts = mkPluginSetupOption "nvim-lint" {
|
||||
linters_by_ft = mkOption {
|
||||
type = attrsOf (listOf str);
|
||||
default = {};
|
||||
example = {
|
||||
text = ["vale"];
|
||||
markdown = ["vale"];
|
||||
};
|
||||
|
||||
description = ''
|
||||
Map of filetype to formatters. This option takes a set of
|
||||
`key = value` format where the `value` will be converted
|
||||
to its Lua equivalent. You are responsible for passing the
|
||||
correct Nix data types to generate a correct Lua value that
|
||||
conform is able to accept.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
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]" "co";
|
||||
theirs = mkMappingOption "Choose Theirs [Git-Conflict]" "ct";
|
||||
both = mkMappingOption "Choose Both [Git-Conflict]" "cb";
|
||||
none = mkMappingOption "Choose None [Git-Conflict]" "c0";
|
||||
prevConflict = mkMappingOption "Go to the previous Conflict [Git-Conflict]" "]x";
|
||||
nextConflict = mkMappingOption "Go to the next Conflict [Git-Conflict]" "[x";
|
||||
};
|
||||
};
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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";
|
||||
|
@ -139,6 +174,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 = {
|
||||
|
|
|
@ -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})
|
||||
'';
|
||||
|
|
|
@ -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
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
in {
|
||||
config = mkIf (cfg.enable && cfg.lspsaga.enable) {
|
||||
vim = {
|
||||
startPlugins = ["lspsaga"];
|
||||
startPlugins = ["lspsaga-nvim"];
|
||||
|
||||
maps = {
|
||||
visual = mkSetLuaBinding mappings.codeAction "require('lspsaga.codeaction').range_code_action";
|
||||
|
|
|
@ -14,7 +14,7 @@ in {
|
|||
{
|
||||
vim = {
|
||||
startPlugins = [
|
||||
"none-ls"
|
||||
"none-ls-nvim"
|
||||
"plenary-nvim"
|
||||
];
|
||||
|
||||
|
|
|
@ -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"];
|
||||
|
|
|
@ -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}
|
||||
|
|
|
@ -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"];
|
||||
};
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
./binds
|
||||
./ccc
|
||||
./diffview
|
||||
./fzf-lua
|
||||
./gestures
|
||||
./icon-picker
|
||||
./images
|
||||
|
@ -13,8 +14,7 @@
|
|||
./surround
|
||||
./telescope
|
||||
./wakatime
|
||||
./surround
|
||||
./preview
|
||||
./fzf-lua
|
||||
./yanky-nvim
|
||||
./leetcode-nvim
|
||||
];
|
||||
}
|
||||
|
|
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";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -38,7 +38,7 @@ in {
|
|||
default = false;
|
||||
description = ''
|
||||
nvim-surround: add/change/delete surrounding delimiter pairs with ease.
|
||||
Note that the default mappings deviate from upstreeam to avoid conflicts
|
||||
Note that the default mappings deviate from upstream to avoid conflicts
|
||||
with nvim-leap.
|
||||
'';
|
||||
};
|
||||
|
|
|
@ -99,12 +99,6 @@
|
|||
type = float;
|
||||
default = 0.55;
|
||||
};
|
||||
|
||||
results_width = mkOption {
|
||||
description = "";
|
||||
type = float;
|
||||
default = 0.8;
|
||||
};
|
||||
};
|
||||
|
||||
vertical = {
|
||||
|
|
32
modules/plugins/utility/yanky-nvim/config.nix
Normal file
32
modules/plugins/utility/yanky-nvim/config.nix
Normal file
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.lists) optionals concatLists;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
|
||||
cfg = config.vim.utility.yanky-nvim;
|
||||
usingSqlite = cfg.setupOpts.ring.storage == "sqlite";
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim = {
|
||||
# TODO: this could probably be lazyloaded. I'm not yet sure which event is
|
||||
# ideal, so it's loaded normally for now.
|
||||
startPlugins = concatLists [
|
||||
["yanky-nvim"]
|
||||
|
||||
# If using the sqlite backend, sqlite-lua must be loaded
|
||||
# alongside yanky.
|
||||
(optionals usingSqlite [pkgs.vimPlugins.sqlite-lua])
|
||||
];
|
||||
|
||||
pluginRC.yanky-nvim = entryAnywhere ''
|
||||
require("yanky").setup(${toLuaObject cfg.setupOpts});
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
6
modules/plugins/utility/yanky-nvim/default.nix
Normal file
6
modules/plugins/utility/yanky-nvim/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./config.nix
|
||||
./yanky-nvim.nix
|
||||
];
|
||||
}
|
28
modules/plugins/utility/yanky-nvim/yanky-nvim.nix
Normal file
28
modules/plugins/utility/yanky-nvim/yanky-nvim.nix
Normal file
|
@ -0,0 +1,28 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption mkOption;
|
||||
inherit (lib.types) enum;
|
||||
in {
|
||||
options.vim.utility.yanky-nvim = {
|
||||
enable = mkEnableOption ''
|
||||
improved Yank and Put functionalities for Neovim [yanky-nvim]
|
||||
'';
|
||||
|
||||
setupOpts = {
|
||||
ring.storage = mkOption {
|
||||
type = enum ["shada" "sqlite" "memory"];
|
||||
default = "shada";
|
||||
example = "sqlite";
|
||||
description = ''
|
||||
storage mode for ring values.
|
||||
|
||||
- shada: this will save pesistantly using Neovim ShaDa feature.
|
||||
This means that history will be persisted between each session of Neovim.
|
||||
- memory: each Neovim instance will have his own history and it will be
|
||||
lost between sessions.
|
||||
- sqlite: more reliable than `shada`, requires `sqlite.lua` as a dependency.
|
||||
nvf will add this dependency to `PATH` automatically.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -13,7 +13,7 @@
|
|||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim = {
|
||||
startPlugins = ["cellular-automaton"];
|
||||
startPlugins = ["cellular-automaton-nvim"];
|
||||
|
||||
maps.normal = mkBinding cfg.mappings.makeItRain "<cmd>CellularAutomaton make_it_rain<CR>" "Make it rain";
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim = {
|
||||
startPlugins = ["highlight-undo"];
|
||||
startPlugins = ["highlight-undo-nvim"];
|
||||
|
||||
pluginRC.highlight-undo = entryAnywhere ''
|
||||
require("highlight-undo").setup(${toLuaObject cfg.setupOpts})
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim = {
|
||||
startPlugins = ["indent-blankline"];
|
||||
startPlugins = ["indent-blankline-nvim"];
|
||||
|
||||
pluginRC.indent-blankline = entryAnywhere ''
|
||||
require("ibl").setup(${toLuaObject cfg.setupOpts})
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
cfg = config.vim.visuals.rainbow-delimiters;
|
||||
in {
|
||||
vim = mkIf cfg.enable {
|
||||
startPlugins = ["rainbow-delimiters"];
|
||||
startPlugins = ["rainbow-delimiters-nvim"];
|
||||
|
||||
pluginRC.rainbow-delimiters = entryAnywhere ''
|
||||
vim.g.rainbow_delimiters = ${toLuaObject cfg.setupOpts}
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim = {
|
||||
startPlugins = ["tiny-devicons-auto-colors" "nvim-web-devicons"];
|
||||
startPlugins = ["tiny-devicons-auto-colors-nvim" "nvim-web-devicons"];
|
||||
|
||||
pluginRC.tiny-devicons-auto-colors = entryAnywhere ''
|
||||
require("tiny-devicons-auto-colors").setup(${toLuaObject cfg.setupOpts})
|
||||
|
|
|
@ -1,29 +1,27 @@
|
|||
{
|
||||
inputs,
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}
|
||||
: let
|
||||
}: let
|
||||
inherit (pkgs) vimPlugins;
|
||||
inherit (lib.strings) isString;
|
||||
inherit (lib.lists) filter map;
|
||||
inherit (builtins) path;
|
||||
|
||||
# alias to the internal configuration
|
||||
vimOptions = config.vim;
|
||||
getPin = name: ((pkgs.callPackages ../../../npins/sources.nix {}) // config.vim.pluginOverrides).${name};
|
||||
|
||||
noBuildPlug = pname: let
|
||||
input = inputs."plugin-${pname}";
|
||||
version = input.shortRev or input.shortDirtyRev or "dirty";
|
||||
pin = getPin pname;
|
||||
version = pin.revision or "dirty";
|
||||
in {
|
||||
# vim.lazy.plugins relies on pname, so we only set that here
|
||||
# version isn't needed for anything, but inherit it anyway for correctness
|
||||
inherit pname version;
|
||||
outPath = path {
|
||||
name = "${pname}-0-unstable-${version}";
|
||||
path = input.outPath;
|
||||
path = pin.outPath;
|
||||
};
|
||||
passthru.vimPlugin = false;
|
||||
};
|
||||
|
@ -32,12 +30,12 @@
|
|||
# if the plugin is nvim-treesitter, warn the user to use buildTreesitterPlug
|
||||
# instead
|
||||
buildPlug = attrs: let
|
||||
input = inputs."plugin-${attrs.pname}";
|
||||
pin = getPin attrs.pname;
|
||||
in
|
||||
pkgs.vimUtils.buildVimPlugin (
|
||||
{
|
||||
version = input.shortRev or input.shortDirtyRev or "dirty";
|
||||
src = input.outPath;
|
||||
version = pin.revision or "dirty";
|
||||
src = pin.outPath;
|
||||
}
|
||||
// attrs
|
||||
);
|
||||
|
@ -45,7 +43,7 @@
|
|||
buildTreesitterPlug = grammars: vimPlugins.nvim-treesitter.withPlugins (_: grammars);
|
||||
|
||||
pluginBuilders = {
|
||||
nvim-treesitter = buildTreesitterPlug vimOptions.treesitter.grammars;
|
||||
nvim-treesitter = buildTreesitterPlug config.vim.treesitter.grammars;
|
||||
flutter-tools-patched = buildPlug {
|
||||
pname = "flutter-tools";
|
||||
patches = [./patches/flutter-tools.patch];
|
||||
|
@ -61,42 +59,45 @@
|
|||
"flutter-tools.dev_tools"
|
||||
];
|
||||
};
|
||||
inherit (inputs.self.legacyPackages.${pkgs.stdenv.system}) blink-cmp;
|
||||
};
|
||||
|
||||
buildConfigPlugins = plugins:
|
||||
map (
|
||||
plug:
|
||||
if (isString plug)
|
||||
then pluginBuilders.${plug} or (noBuildPlug plug)
|
||||
else plug
|
||||
) (filter (f: f != null) plugins);
|
||||
map (plug:
|
||||
if (isString plug)
|
||||
then pluginBuilders.${plug} or (noBuildPlug plug)
|
||||
else plug) (
|
||||
filter (f: f != null) plugins
|
||||
);
|
||||
|
||||
# built (or "normalized") plugins that are modified
|
||||
builtStartPlugins = buildConfigPlugins vimOptions.startPlugins;
|
||||
builtOptPlugins = map (package: package // {optional = true;}) (buildConfigPlugins vimOptions.optPlugins);
|
||||
builtStartPlugins = buildConfigPlugins config.vim.startPlugins;
|
||||
builtOptPlugins = map (package: package // {optional = true;}) (
|
||||
buildConfigPlugins config.vim.optPlugins
|
||||
);
|
||||
|
||||
# additional Lua and Python3 packages, mapped to their respective functions
|
||||
# to conform to the format mnw expects. end user should
|
||||
# only ever need to pass a list of packages, which are modified
|
||||
# here
|
||||
extraLuaPackages = ps: map (x: ps.${x}) vimOptions.luaPackages;
|
||||
extraPython3Packages = ps: map (x: ps.${x}) vimOptions.python3Packages;
|
||||
extraLuaPackages = ps: map (x: ps.${x}) config.vim.luaPackages;
|
||||
extraPython3Packages = ps: map (x: ps.${x}) config.vim.python3Packages;
|
||||
|
||||
# Wrap the user's desired (unwrapped) Neovim package with arguments that'll be used to
|
||||
# generate a wrapped Neovim package.
|
||||
neovim-wrapped = inputs.mnw.lib.wrap pkgs {
|
||||
neovim = vimOptions.package;
|
||||
neovim = config.vim.package;
|
||||
plugins = builtStartPlugins ++ builtOptPlugins;
|
||||
appName = "nvf";
|
||||
extraBinPath = vimOptions.extraPackages;
|
||||
initLua = vimOptions.builtLuaConfigRC;
|
||||
luaFiles = vimOptions.extraLuaFiles;
|
||||
extraBinPath = config.vim.extraPackages;
|
||||
initLua = config.vim.builtLuaConfigRC;
|
||||
luaFiles = config.vim.extraLuaFiles;
|
||||
|
||||
inherit (vimOptions) viAlias vimAlias withRuby withNodeJs withPython3;
|
||||
inherit (config.vim) viAlias vimAlias withRuby withNodeJs withPython3;
|
||||
inherit extraLuaPackages extraPython3Packages;
|
||||
};
|
||||
|
||||
dummyInit = pkgs.writeText "nvf-init.lua" vimOptions.builtLuaConfigRC;
|
||||
dummyInit = pkgs.writeText "nvf-init.lua" config.vim.builtLuaConfigRC;
|
||||
# Additional helper scripts for printing and displaying nvf configuration
|
||||
# in your commandline.
|
||||
printConfig = pkgs.writers.writeDashBin "nvf-print-config" "cat ${dummyInit}";
|
||||
|
@ -109,10 +110,10 @@
|
|||
paths = [neovim-wrapped printConfig printConfigPath];
|
||||
postBuild = "echo Helpers added";
|
||||
|
||||
# Allow evaluating vimOptions, i.e., config.vim from the packages' passthru
|
||||
# Allow evaluating config.vim, i.e., config.vim from the packages' passthru
|
||||
# attribute. For example, packages.x86_64-linux.neovim.passthru.neovimConfig
|
||||
# will return the configuration in full.
|
||||
passthru.neovimConfig = vimOptions;
|
||||
passthru.neovimConfig = config.vim;
|
||||
|
||||
meta =
|
||||
neovim-wrapped.meta
|
||||
|
|
|
@ -140,5 +140,21 @@ in {
|
|||
example = ''["pynvim"]'';
|
||||
description = "List of python packages to install";
|
||||
};
|
||||
|
||||
pluginOverrides = mkOption {
|
||||
type = attrsOf package;
|
||||
default = {};
|
||||
example = ''
|
||||
{
|
||||
lazydev-nvim = pkgs.fetchFromGitHub {
|
||||
owner = "folke";
|
||||
repo = "lazydev.nvim";
|
||||
rev = "";
|
||||
hash = "";
|
||||
};
|
||||
}
|
||||
'';
|
||||
description = "Attribute set of plugins to override default values";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue