Compare commits
No commits in common. "070fc5fb8134451970649ceab112cd9dd097b868" and "37a93b29ee7d210d7843b330f288bf99098b6698" have entirely different histories.
070fc5fb81
...
37a93b29ee
8 changed files with 304 additions and 59 deletions
63
flake.lock
63
flake.lock
|
@ -71,6 +71,27 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"codeium-nvim": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1693966170,
|
||||
"narHash": "sha256-maRkkUCzjSXK04ts+Io0WFBV1MxR7dCw8I6TV03Dpbs=",
|
||||
"owner": "jcdickinson",
|
||||
"repo": "codeium.nvim",
|
||||
"rev": "6a8cbce54c41e0c305b5f77721f61b2ddd4b6c6d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "jcdickinson",
|
||||
"repo": "codeium.nvim",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"darwin": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
|
@ -203,6 +224,21 @@
|
|||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1667395993,
|
||||
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_2": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
|
@ -220,7 +256,7 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_2": {
|
||||
"flake-utils_3": {
|
||||
"inputs": {
|
||||
"systems": "systems_3"
|
||||
},
|
||||
|
@ -238,7 +274,7 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_3": {
|
||||
"flake-utils_4": {
|
||||
"inputs": {
|
||||
"systems": "systems_4"
|
||||
},
|
||||
|
@ -530,7 +566,7 @@
|
|||
},
|
||||
"neovim-flake": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils_2",
|
||||
"flake-utils": "flake-utils_3",
|
||||
"nixpkgs": [
|
||||
"neovim-nightly-overlay",
|
||||
"nixpkgs"
|
||||
|
@ -598,21 +634,6 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nix-lazy-nvim": {
|
||||
"locked": {
|
||||
"lastModified": 1694868321,
|
||||
"narHash": "sha256-LHPQkD+7ltdo77gpFQOnr8QAgYPdtFf9pm/Alwrs570=",
|
||||
"ref": "refs/heads/main",
|
||||
"rev": "1dc6361600111b1c46f6e85221334c8c47f88200",
|
||||
"revCount": 4,
|
||||
"type": "git",
|
||||
"url": "https://git.moritzboeh.me/moritz/NixLazy.nvim"
|
||||
},
|
||||
"original": {
|
||||
"type": "git",
|
||||
"url": "https://git.moritzboeh.me/moritz/NixLazy.nvim"
|
||||
}
|
||||
},
|
||||
"nix-super": {
|
||||
"inputs": {
|
||||
"flake-compat": "flake-compat_2",
|
||||
|
@ -834,7 +855,7 @@
|
|||
"pre-commit-hooks": {
|
||||
"inputs": {
|
||||
"flake-compat": "flake-compat_3",
|
||||
"flake-utils": "flake-utils_3",
|
||||
"flake-utils": "flake-utils_4",
|
||||
"gitignore": "gitignore",
|
||||
"nixpkgs": "nixpkgs_7",
|
||||
"nixpkgs-stable": "nixpkgs-stable"
|
||||
|
@ -876,7 +897,8 @@
|
|||
"agenix": "agenix",
|
||||
"arkenfox-userjs": "arkenfox-userjs",
|
||||
"asus-touchpad-numpad-driver": "asus-touchpad-numpad-driver",
|
||||
"flake-utils": "flake-utils",
|
||||
"codeium-nvim": "codeium-nvim",
|
||||
"flake-utils": "flake-utils_2",
|
||||
"hmts-nvim": "hmts-nvim",
|
||||
"home-manager": "home-manager_2",
|
||||
"hypr-contrib": "hypr-contrib",
|
||||
|
@ -885,7 +907,6 @@
|
|||
"master": "master",
|
||||
"neovim-nightly-overlay": "neovim-nightly-overlay",
|
||||
"nil": "nil",
|
||||
"nix-lazy-nvim": "nix-lazy-nvim",
|
||||
"nix-super": "nix-super",
|
||||
"nixpkgs": "nixpkgs_6",
|
||||
"nvim-treesitter": "nvim-treesitter",
|
||||
|
|
|
@ -53,7 +53,8 @@
|
|||
actions-preview-nvim.flake = false;
|
||||
actions-preview-nvim.url = "github:aznhe21/actions-preview.nvim";
|
||||
|
||||
nix-lazy-nvim.url = "git+https://git.moritzboeh.me/moritz/NixLazy.nvim";
|
||||
codeium-nvim.url = "github:jcdickinson/codeium.nvim";
|
||||
codeium-nvim.inputs.nixpkgs.follows = "nixpkgs";
|
||||
|
||||
# Hyprland
|
||||
hypr-contrib.url = "github:hyprwm/contrib";
|
||||
|
@ -126,7 +127,6 @@
|
|||
useGlobalPkgs = true;
|
||||
useUserPackages = true;
|
||||
extraSpecialArgs = { inherit inputs self; };
|
||||
sharedModules = [ inputs.nix-lazy-nvim.homeManagerModules.default ];
|
||||
};
|
||||
}
|
||||
inputs.agenix.nixosModules.age
|
||||
|
|
|
@ -3,11 +3,242 @@
|
|||
with lib;
|
||||
let
|
||||
cfg = config.my.programs.nvim;
|
||||
toLua = value: with builtins;
|
||||
if value == null then "nil" else
|
||||
if isBool value then boolToString value else
|
||||
if isInt value || isFloat value then toString value else
|
||||
if isString value then string value else
|
||||
if isAttrs value then attrs value else
|
||||
if isList value then list value else
|
||||
abort "should never happen (value = ${value})";
|
||||
|
||||
string = str: ''"${toString str}"'';
|
||||
attrs = set:
|
||||
let
|
||||
toKeyword = name: value: "${name} = ${toLua value}";
|
||||
keywords = concatStringsSep ", " (mapAttrsToList toKeyword set);
|
||||
in
|
||||
"{ " + keywords + " }";
|
||||
|
||||
listContent = values: concatStringsSep ", " (map toLua values);
|
||||
list = values: "{ " + listContent values + " }";
|
||||
|
||||
luaList = values: "{" + (concatStringsSep ", " values) + "}";
|
||||
|
||||
keybinding = { key, cmd, func, mode, desc }:
|
||||
let
|
||||
cmdString =
|
||||
if cmd != null then toLua cmd else
|
||||
if func != null then func else
|
||||
abort "Either cmd or function must be set";
|
||||
descString = optionalString (desc != null) "desc = ${toLua desc},";
|
||||
in
|
||||
''{ ${toLua key}, ${cmdString}, mode = ${toLua mode}, ${descString} }'';
|
||||
|
||||
lazySpecFromPlugin =
|
||||
{ cmd
|
||||
, conf
|
||||
, dependencies
|
||||
, enabled
|
||||
, event
|
||||
, ft
|
||||
, init
|
||||
, keys
|
||||
, lazy
|
||||
, opts
|
||||
, plugin
|
||||
, priority
|
||||
}:
|
||||
|
||||
luaList
|
||||
([
|
||||
"dir = ${string plugin}"
|
||||
"name = ${toLua (getName plugin)}"
|
||||
]
|
||||
++ (optional (opts != null) "opts = ${toLua opts}")
|
||||
++ (optional (lazy != null) "lazy = ${toLua lazy}")
|
||||
++ (optional (!enabled) "enabled = ${toLua enabled}")
|
||||
++ (optional (dependencies != [ ]) "dependencies = ${luaList (map lazySpecFromPlugin dependencies)}")
|
||||
++ (optional (init != null) "init = function(plugin)\n${init}\nend")
|
||||
++ (optional (conf != null) "config = function(plugin, opts)\n${conf}\nend")
|
||||
++ (optional (keys != [ ]) "keys = ${luaList (map keybinding keys)}")
|
||||
++ (optional (event != [ ]) "event = ${toLua event}")
|
||||
++ (optional (cmd != [ ]) "cmd = ${toLua cmd}")
|
||||
++ (optional (ft != [ ]) "ft = ${toLua ft}")
|
||||
++ (optional (priority != null) "priority = ${toLua priority}")
|
||||
);
|
||||
lazySpecs = luaList (map lazySpecFromPlugin cfg.plugins);
|
||||
lazy = /* lua */ ''
|
||||
require("lazy").setup(${lazySpecs})
|
||||
'';
|
||||
|
||||
initLua =
|
||||
let
|
||||
text = lib.concatLines [ (builtins.readFile ./options.lua) lazy ];
|
||||
in
|
||||
pkgs.runCommand "init.lua" { inherit text; } ''
|
||||
touch $out
|
||||
echo -n "$text" > $out
|
||||
${getExe pkgs.stylua} $out
|
||||
'';
|
||||
|
||||
in
|
||||
{
|
||||
imports = lib.my.listModulesRec ./plugins;
|
||||
|
||||
options.my.programs.nvim.enable = mkEnableOption "nvim";
|
||||
options.my.programs.nvim = {
|
||||
enable = mkEnableOption "nvim";
|
||||
plugins = mkOption {
|
||||
default = [ ];
|
||||
description = ''
|
||||
List of plugins with config.
|
||||
'';
|
||||
type = with types; listOf (
|
||||
let
|
||||
sub = submodule {
|
||||
options = {
|
||||
conf = mkOption {
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
description = ''
|
||||
Lua function to be executed when the plugin is loaded.
|
||||
'';
|
||||
};
|
||||
opts = mkOption {
|
||||
type =
|
||||
let
|
||||
valueType = nullOr
|
||||
(oneOf [
|
||||
str
|
||||
bool
|
||||
int
|
||||
float
|
||||
(listOf valueType)
|
||||
(attrsOf valueType)
|
||||
]) // {
|
||||
description = "Lua value";
|
||||
};
|
||||
in
|
||||
nullOr (attrsOf valueType);
|
||||
default = null;
|
||||
description = ''
|
||||
Lua table to be passed to te plugin config function.
|
||||
'';
|
||||
};
|
||||
dependencies = mkOption {
|
||||
type = listOf sub;
|
||||
default = [ ];
|
||||
description = ''
|
||||
List of plugins this plugin depends on.
|
||||
'';
|
||||
};
|
||||
init = mkOption {
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
description = ''
|
||||
Lua code to be executed when the plugin is initialized.
|
||||
'';
|
||||
};
|
||||
event = mkOption {
|
||||
type = listOf str;
|
||||
default = [ ];
|
||||
description = ''
|
||||
Event to load the plugin on.
|
||||
'';
|
||||
};
|
||||
lazy = mkOption {
|
||||
type = nullOr bool;
|
||||
default = null;
|
||||
description = ''
|
||||
Whether to load the plugin lazily.
|
||||
'';
|
||||
};
|
||||
plugin = mkOption {
|
||||
type = package;
|
||||
description = ''
|
||||
The plugin package.
|
||||
'';
|
||||
};
|
||||
enabled = mkOption {
|
||||
type = bool;
|
||||
default = true;
|
||||
description = ''
|
||||
Whether to enable the plugin.
|
||||
'';
|
||||
};
|
||||
cmd = mkOption {
|
||||
type = listOf str;
|
||||
default = [ ];
|
||||
description = ''
|
||||
Command to load the plugin.
|
||||
'';
|
||||
};
|
||||
ft = mkOption {
|
||||
type = listOf str;
|
||||
default = [ ];
|
||||
description = ''
|
||||
Filetype to load the plugin on.
|
||||
'';
|
||||
};
|
||||
priority = mkOption {
|
||||
type = nullOr int;
|
||||
default = null;
|
||||
description = ''
|
||||
Priority to load the plugin.
|
||||
'';
|
||||
};
|
||||
keys = mkOption {
|
||||
default = [ ];
|
||||
description = ''
|
||||
List of keybindings.
|
||||
'';
|
||||
type = listOf (submodule {
|
||||
options = {
|
||||
key = mkOption {
|
||||
type = str;
|
||||
description = ''
|
||||
Key to bind.
|
||||
'';
|
||||
};
|
||||
cmd = mkOption {
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
description = ''
|
||||
Command to execute.
|
||||
'';
|
||||
};
|
||||
func = mkOption {
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
description = ''
|
||||
Function to execute.
|
||||
'';
|
||||
};
|
||||
mode = mkOption {
|
||||
type = listOf str;
|
||||
default = [ "n" ];
|
||||
description = ''
|
||||
Mode to bind the key in.
|
||||
'';
|
||||
};
|
||||
desc = mkOption {
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
description = ''
|
||||
Description of the keybinding.
|
||||
'';
|
||||
};
|
||||
};
|
||||
});
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
sub
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
home-manager.users.moritz = {
|
||||
|
@ -19,6 +250,8 @@ in
|
|||
)
|
||||
];
|
||||
|
||||
xdg.configFile."nvim/init.lua".source = initLua;
|
||||
|
||||
programs.neovim = {
|
||||
enable = true;
|
||||
package = pkgs.neovim-nightly;
|
||||
|
@ -26,6 +259,14 @@ in
|
|||
vimdiffAlias = true;
|
||||
withNodeJs = true;
|
||||
withPython3 = true;
|
||||
extraPython3Packages = ps:
|
||||
let
|
||||
plugins = map (getAttr "plugin") cfg.plugins;
|
||||
depAttrName = "python3Dependencies";
|
||||
filtered = filter (hasAttr depAttrName) plugins;
|
||||
funcs = map (getAttr depAttrName) filtered;
|
||||
in
|
||||
foldl (list: f: list ++ (f ps)) [ ] funcs;
|
||||
extraPackages = with pkgs;
|
||||
[
|
||||
alejandra
|
||||
|
@ -47,8 +288,9 @@ in
|
|||
typst-lsp
|
||||
yamlfmt
|
||||
];
|
||||
extraLuaConfig = readFile ./options.lua;
|
||||
lazy.enable = true;
|
||||
plugins = [
|
||||
pkgs.vimPlugins.lazy-nvim
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
{ pkgs, lib, ... }:
|
||||
{ pkgs, ... }:
|
||||
|
||||
with builtins;
|
||||
{
|
||||
config.home-manager.users.moritz.programs.neovim.lazy.plugins = with pkgs.vimPlugins; [
|
||||
config.my.programs.nvim.plugins = with pkgs.vimPlugins; [
|
||||
{
|
||||
plugin = formatter-nvim;
|
||||
cmd = [ "Format" "Fmt" ];
|
||||
|
@ -86,26 +86,13 @@ with builtins;
|
|||
{ plugin = cmp-cmdline; }
|
||||
{ plugin = cmp-nvim-lsp; }
|
||||
{ plugin = cmp_luasnip; }
|
||||
{
|
||||
plugin = codeium-nvim;
|
||||
opts = { };
|
||||
}
|
||||
{ plugin = friendly-snippets; }
|
||||
{ plugin = lspkind-nvim; }
|
||||
{ plugin = luasnip; }
|
||||
{
|
||||
plugin = copilot-cmp;
|
||||
opts = { };
|
||||
dependencies = [
|
||||
{
|
||||
plugin = copilot-lua;
|
||||
opts = {
|
||||
suggestion = { enabled = false; };
|
||||
panel = { enabled = false; };
|
||||
};
|
||||
conf = /* lua */ ''
|
||||
require("copilot").setup(opts)
|
||||
vim.cmd("Copilot disable")
|
||||
'';
|
||||
}
|
||||
];
|
||||
}
|
||||
];
|
||||
}
|
||||
{
|
||||
|
@ -205,6 +192,7 @@ with builtins;
|
|||
];
|
||||
dependencies = [
|
||||
{ plugin = plenary-nvim; }
|
||||
{ plugin = which-key-nvim; }
|
||||
{ plugin = telescope-fzf-native-nvim; }
|
||||
];
|
||||
}
|
||||
|
|
|
@ -2,14 +2,6 @@ local cmp = require("cmp")
|
|||
local luasnip = require("luasnip")
|
||||
require("luasnip.loaders.from_vscode").lazy_load()
|
||||
|
||||
local has_words_before = function()
|
||||
if vim.api.nvim_buf_get_option(0, "buftype") == "prompt" then
|
||||
return false
|
||||
end
|
||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
return col ~= 0 and vim.api.nvim_buf_get_text(0, line - 1, 0, line - 1, col, {})[1]:match("^%s*$") == nil
|
||||
end
|
||||
|
||||
cmp.setup({
|
||||
formatting = {
|
||||
format = require("lspkind").cmp_format({
|
||||
|
@ -17,7 +9,7 @@ cmp.setup({
|
|||
maxwidth = 50, -- prevent the popup from showing more than provided characters
|
||||
ellipsis_char = "...", -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead
|
||||
symbol_map = {
|
||||
Copilot = "",
|
||||
Codeium = "",
|
||||
},
|
||||
}),
|
||||
},
|
||||
|
@ -34,8 +26,8 @@ cmp.setup({
|
|||
["<C-e>"] = cmp.mapping.abort(),
|
||||
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() and has_words_before() then
|
||||
cmp.select_next_item({ behavior = cmp.SelectBehavior.Select })
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.expand_or_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
else
|
||||
|
@ -56,7 +48,7 @@ cmp.setup({
|
|||
{ name = "async_path", priority = 1 },
|
||||
{ name = "buffer", priority = 1 },
|
||||
{ name = "luasnip", priority = 2 },
|
||||
{ name = "copilot", group_index = 3 },
|
||||
{ name = "codeium", priority = 3 },
|
||||
{ name = "nvim_lsp", priority = 4 },
|
||||
},
|
||||
})
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
with builtins;
|
||||
{
|
||||
config.home-manager.users.moritz.programs.neovim.lazy.plugins = with pkgs.vimPlugins; [
|
||||
config.my.programs.nvim.plugins = with pkgs.vimPlugins; [
|
||||
{
|
||||
plugin = nvim-treesitter;
|
||||
event = [ "BufReadPost" "BufNewFile" ];
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
with builtins;
|
||||
{
|
||||
config.home-manager.users.moritz.programs.neovim.lazy.plugins = with pkgs.vimPlugins; [
|
||||
config.my.programs.nvim.plugins = with pkgs.vimPlugins; [
|
||||
{
|
||||
plugin = which-key-nvim;
|
||||
lazy = false;
|
||||
|
|
|
@ -4,6 +4,8 @@ _: prev:
|
|||
with lib.my;
|
||||
{
|
||||
vimPlugins = prev.vimPlugins // {
|
||||
inherit (inputs.codeium-nvim.packages.${prev.system}.vimPlugins) codeium-nvim;
|
||||
|
||||
smartcolumn-nvim = prev.vimUtils.buildVimPluginFrom2Nix {
|
||||
pname = "smartcolumn-nvim";
|
||||
version = mkVersionInput inputs.smartcolumn-nvim;
|
||||
|
|
Loading…
Reference in a new issue