1
Fork 0

Migrate more neovim modules to nix

This commit is contained in:
Matei Adriel 2023-12-04 09:06:02 +01:00
parent e6f397f4be
commit a456fe3781
No known key found for this signature in database
7 changed files with 94 additions and 75 deletions

View file

@ -1722,11 +1722,11 @@
"nixpkgs": "nixpkgs_6"
},
"locked": {
"lastModified": 1695137077,
"narHash": "sha256-wJ8EpYjsqrR4GFAF67wJKmZd4q86KuODWAag4acQL5Q=",
"lastModified": 1699966122,
"narHash": "sha256-zEN3ET7jfXpIKYeYh/z4xekOBOoaFS+n0q3oL3sVh+0=",
"owner": "nix-community",
"repo": "nixd",
"rev": "e8f144ca50fe71e74d247e5308ae7ce122f0a0e6",
"rev": "b3bb9ea7cd3c2f07c89779a474d6468b2c11e303",
"type": "github"
},
"original": {

View file

@ -227,12 +227,9 @@
let
mkHomeConfig = { system, hostname }:
home-manager.lib.homeManagerConfiguration {
inherit system;
pkgs = nixpkgs.legacyPackages.${system};
extraSpecialArgs = specialArgs system;
modules = [
./home/${hostname}.nix
];
modules = [ ./home/${hostname}.nix ];
};
in
{

View file

@ -36,6 +36,7 @@
"mini.files": { "branch": "main", "commit": "dea80a8147aa4e3025c34d2e2aaa6f2aeb7b21dd" },
"mini.operators": { "branch": "main", "commit": "15f137f28412517e2248d39cf0663bd3a87aa24a" },
"mini.surround": { "branch": "main", "commit": "9d1956b576d7051da3a483b251dfc778121c60db" },
"neoconf": { "branch": "main", "commit": "64437787dba70fce50dad7bfbb97d184c5bc340f" },
"neoconf.nvim": { "branch": "main", "commit": "08f146d53e075055500dca35e93281faff95716b" },
"neodev.nvim": { "branch": "main", "commit": "9a5c0f0de5c15fba52d4fb83d425d3f4fa7abfa1" },
"neogit": { "branch": "master", "commit": "e4c428239928425829cb5247e430f26d25d5788e" },
@ -48,7 +49,7 @@
"nvim-comment": { "branch": "main", "commit": "e9ac16ab056695cad6461173693069ec070d2b23" },
"nvim-lspconfig": { "branch": "master", "commit": "a981d4447b92c54a4d464eb1a76b799bc3f9a771" },
"nvim-tree.lua": { "branch": "master", "commit": "18c7a3119839adc4599d838726deae662859c8b2" },
"nvim-treesitter": { "branch": "master", "commit": "93ee00cd9daf8d2e3fbaa2a18b8b9adcb4471b16" },
"nvim-treesitter": { "branch": "master", "commit": "0791b5ebb590a2d44e20640c52679df1fc42e8ab" },
"nvim-treesitter-context": { "branch": "master", "commit": "a17c31268b56d53624fdc9cb03a225d4a17cabdb" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "9e519b6146512c8e2e702faf8ac48420f4f5deec" },
"nvim-web-devicons": { "branch": "master", "commit": "ab899311f8ae00a47eae8e0879506cead8eb1561" },

View file

@ -1,30 +0,0 @@
local M = {
"ThePrimeagen/harpoon",
}
local function bindHarpoon(key, index)
vim.keymap.set("n", "<C-s>" .. key, function()
require("harpoon.ui").nav_file(index)
end, { desc = "Harpoon file " .. index })
end
function M.init()
vim.keymap.set("n", "<leader>H", function()
require("harpoon.mark").add_file()
end, { desc = "Add file to [h]arpoon" })
vim.keymap.set("n", "<C-a>", function()
require("harpoon.ui").toggle_quick_menu()
end, { desc = "Toggle harpoon quickmenu" })
bindHarpoon("q", 1)
bindHarpoon("w", 2)
bindHarpoon("e", 3)
bindHarpoon("r", 4)
bindHarpoon("a", 5)
bindHarpoon("s", 6)
bindHarpoon("d", 7)
bindHarpoon("f", 8)
bindHarpoon("z", 9)
end
return M

View file

@ -1,12 +0,0 @@
return {
"folke/neoconf.nvim",
cmd = "Neoconf",
opts = {
-- import existing settings from other plugins
import = {
vscode = true, -- local .vscode/settings.json
coc = false, -- global/local coc-settings.json
nlsp = false, -- global/local nlsp-settings.nvim json settings
},
},
}

View file

@ -168,7 +168,7 @@ in
let
# God knows what this does
# https://github.com/glacambre/firenvim/blob/87c9f70d3e6aa2790982aafef3c696dbe962d35b/autoload/firenvim.vim#L592
firenvim_init = pkgs.writeText "firenvim_init.vim" ''
firenvim_init = pkgs.writeText "firenvim_init.vim" /* vim */ ''
let g:firenvim_i=[]
let g:firenvim_o=[]
let g:Firenvim_oi={i,d,e->add(g:firenvim_i,d)}
@ -177,7 +177,7 @@ in
let g:started_by_firenvim = v:true
'';
firenvim_file_loaded = pkgs.writeText "firenvim_file_loaded.vim" ''
firenvim_file_loaded = pkgs.writeText "firenvim_file_loaded.vim" /* vim */ ''
try
call firenvim#run()
catch /Unknown function/
@ -215,11 +215,13 @@ in
# {{{ Nvim-tree
satellite.neovim.lazy.nvim-tree = {
package = "kyazdani42/nvim-tree.lua";
setup = true;
cond = nlib.blacklistEnv [ "vscode" "firenvim" ];
keys.mapping = "<C-n>";
keys.desc = "Toggle [n]vim-tree";
keys.action = "<cmd>NvimTreeToggle<cr>";
cond = nlib.blacklistEnv [ "vscode" "firenvim" ];
};
# }}}
# {{{ Lualine
@ -272,7 +274,7 @@ in
keys =
let keybind = mode: mapping: action: desc: {
inherit mapping desc mode;
action = nlib.lua ''function () require("flash").${action}() end'';
action = nlib.thunk /* lua */ ''require("flash").${action}()'';
};
in
[
@ -295,7 +297,6 @@ in
cond = nlib.blacklistEnv [ "vscode" ];
event = "BufReadPost";
opts.log_level = nlib.lua "vim.log.levels.DEBUG";
opts.format_on_save.lsp_fallback = true;
opts.formatters_by_ft = {
lua = [ "stylua" ];
@ -304,5 +305,54 @@ in
};
};
# }}}
# {{{ Neoconf
satellite.neovim.lazy.neoconf = {
package = "folke/neoconf.nvim";
name = "neoconf";
cmd = "Neoconf";
opts.import = {
vscode = true; # local .vscode/settings.json
coc = false; # global/local coc-settings.json
nlsp = false; # global/local nlsp-settings.nvim json settings
};
};
# }}}
# {{{ Harpoon
satellite.neovim.lazy.harpoon = {
package = "ThePrimeagen/harpoon";
keys =
let goto = key: index: {
desc = "Goto harpoon file ${toString index}";
mapping = "<c-s>${key}";
action = nlib.thunk
/* lua */ ''require("harpoon.ui").nav_file(${toString index})'';
};
in
[
{
desc = "Add file to [h]arpoon";
mapping = "<leader>H";
action = nlib.thunk
/* lua */ ''require("harpoon.mark").add_file()'';
}
{
desc = "Toggle harpoon quickmenu";
mapping = "<c-a>";
action = nlib.thunk
/* lua */ ''require("harpoon.ui").toggle_quick_menu()'';
}
(goto "q" 1)
(goto "w" 2)
(goto "e" 3)
(goto "r" 4)
(goto "a" 5)
(goto "s" 6)
(goto "d" 7)
(goto "f" 8)
(goto "z" 9)
];
};
# }}}
# }}}
}

View file

@ -7,6 +7,8 @@ let
# {{{ Custom types
myTypes = {
zeroOrMore = t: types.nullOr (types.either t (types.listOf t));
luaCode = types.nullOr (types.oneOf [
types.str
types.path
@ -30,11 +32,6 @@ let
(types.listOf myTypes.luaValue)
]);
fileTypes = types.nullOr (types.oneOf [
types.str
(types.listOf types.str)
]);
# {{{ Key type
lazyKey = types.oneOf [
types.str
@ -42,6 +39,7 @@ let
(_: {
options.mapping = lib.mkOption {
type = types.str;
description = "The lhs of the neovim mapping";
};
options.action = lib.mkOption {
@ -49,22 +47,25 @@ let
types.str
myTypes.luaLiteral
]);
description = "The rhs of the neovim mapping";
};
options.ft = lib.mkOption {
default = null;
type = myTypes.fileTypes;
type = myTypes.zeroOrMore types.str;
description = "Filetypes on which this keybind should take effect";
};
options.mode = lib.mkOption {
default = null;
type = types.nullOr types.str;
description = "The vim modes the mapping should take effect in";
};
options.desc = lib.mkOption {
default = null;
type = types.nullOr types.str;
description = "Description for the current keymapping";
};
}))
];
@ -116,11 +117,13 @@ let
dependencies.lua = lib.mkOption {
default = [ ];
type = types.listOf lazyModule;
description = "Lazy.nvim module dependencies";
};
dependencies.nix = lib.mkOption {
default = [ ];
type = types.listOf types.package;
description = "Nix packages to give nvim access to";
};
cond = lib.mkOption {
@ -139,19 +142,22 @@ let
event = lib.mkOption {
default = null;
type = types.nullOr (types.oneOf [
types.str
(types.listOf types.str)
]);
type = myTypes.zeroOrMore types.str;
description = "Event on which the module should be lazy loaded";
};
ft = lib.mkOption {
default = null;
type = myTypes.fileTypes;
type = myTypes.zeroOrMore types.str;
description = "Filetypes on which the module should be lazy loaded";
};
cmd = lib.mkOption {
default = null;
type = myTypes.zeroOrMore types.str;
description = "Comands on which to load this plugin";
};
init = lib.mkOption {
default = null;
type = myTypes.luaCode;
@ -172,11 +178,8 @@ let
keys = lib.mkOption {
default = null;
type =
types.nullOr (types.oneOf [
myTypes.lazyKey
(types.listOf myTypes.lazyKey)
]);
type = myTypes.zeroOrMore myTypes.lazyKey;
description = "Keybinds to lazy-load the module on";
};
};
}));
@ -246,6 +249,7 @@ let
lib.isList
(luaEncoders.listOf encoder);
oneOrMany = encoder: luaEncoders.listOfOr encoder encoder;
zeroOrMany = encoder: luaEncoders.nullOr (luaEncoders.oneOrMany encoder);
oneOrManyAsList = encoder: luaEncoders.map
(given: if lib.isList given then given else [ given ])
(luaEncoders.listOf encoder);
@ -368,6 +372,14 @@ in
type = types.functionTo myTypes.luaLiteral;
description = "Generate a lazy.cond predicate which disables a module if one of the given envs is active";
};
thunk = lib.mkOption {
default = given: cfg.lib.lua ''
function() return ${given} end
'';
type = types.functionTo myTypes.luaLiteral;
description = "Wrap a lua expression into a lua function";
};
};
env = {
@ -398,7 +410,7 @@ in
lib.strings.stringToCharacters
(e.listAsOneOrMany e.string));
desc = e.nullOr e.string;
ft = e.nullOr (e.oneOrMany e.string);
ft = e.zeroOrMany e.string;
});
lazyObjectEncoder = e.bind
@ -414,8 +426,9 @@ in
cond = e.nullOr (e.luaCode "cond");
config = e.const (e.nullOr (e.boolOr (e.luaCode "config")) opts.setup);
init = e.nullOr (e.luaCode "init");
event = e.nullOr (e.oneOrMany e.string);
ft = e.nullOr (e.oneOrMany e.string);
event = e.zeroOrMany e.string;
cmd = e.zeroOrMany e.string;
ft = e.zeroOrMany e.string;
keys = e.nullOr (e.oneOrManyAsList lazyKeyEncoder);
passthrough = e.anything;
opts = e.anything;