Files
nvim/neovim.nix

185 lines
4.3 KiB
Nix
Raw Normal View History

{
inputs,
symlinkJoin,
2024-12-05 19:20:23 -03:00
makeWrapper,
runCommandLocal,
pkgs,
lib,
yazi ? pkgs.yazi,
}: let
nvimPkg = pkgs.neovim-unwrapped;
yaziPkg = yazi;
2024-12-05 19:20:23 -03:00
startPlugins = with pkgs;
with vimPlugins; [
blink-cmp
2024-12-05 19:24:51 -03:00
catppuccin-nvim
indent-blankline-nvim
lze
nvim-lspconfig
2024-12-05 19:25:19 -03:00
nvim-treesitter.withAllGrammars
nvim-treesitter-textobjects
nvim-treesitter-textsubjects
2024-12-06 20:22:33 -03:00
(vimUtils.buildVimPlugin {
name = "dot013.nvim";
src = ./.;
})
];
2024-12-05 19:20:23 -03:00
optPlugins = with pkgs;
with pkgs.vimPlugins; [
2024-12-06 20:47:55 -03:00
auto-save-nvim
2024-12-07 12:21:53 -03:00
auto-session
2024-12-06 20:48:11 -03:00
cloak-nvim
conform-nvim
2024-12-07 14:38:01 -03:00
comment-nvim
2024-12-06 20:22:33 -03:00
friendly-snippets
2024-12-07 12:22:25 -03:00
gitsigns-nvim
2024-12-05 19:23:23 -03:00
harpoon2
2024-12-05 19:24:51 -03:00
lualine-nvim
2024-12-06 20:22:33 -03:00
luasnip
2024-12-05 19:23:45 -03:00
marks-nvim
2024-12-08 10:24:37 -03:00
nvim-autopairs
2024-12-06 20:21:17 -03:00
nvim-dap
2024-12-06 20:21:32 -03:00
nvim-dap-go
2024-12-06 20:21:17 -03:00
nvim-dap-ui
nvim-dap-virtual-text
2024-12-08 10:24:53 -03:00
nvim-ts-autotag
2024-12-05 19:24:51 -03:00
nvim-web-devicons
telescope-nvim
telescope-fzf-native-nvim
2024-12-05 19:24:06 -03:00
tmux-nvim
(vimUtils.buildVimPlugin {
pname = "nvim-emmet";
version = "v0.4.4";
src = fetchGit {
url = "https://github.com/olrtg/nvim-emmet";
rev = "cde4fb2968704aae5c18b7f8a9bc2508767bb78d";
};
})
# Probably can be replaced by local functions in the config
(vimUtils.buildVimPlugin {
pname = "tfm.nvim";
version = "2024-04-23";
src = fetchGit {
url = "https://github.com/Rolv-Apneseth/tfm.nvim";
rev = "fb0de2c96bf303216ac5d91ce9bdb7f430030f8b";
};
})
];
languageServers = with pkgs; [
emmet-language-server
2024-12-05 19:28:11 -03:00
deno
gopls
2024-12-05 19:27:38 -03:00
htmx-lsp
lua-language-server
2024-12-05 19:29:22 -03:00
nil
2024-12-05 19:28:11 -03:00
tailwindcss-language-server
2024-12-05 19:27:38 -03:00
templ
2024-12-05 19:31:22 -03:00
typescript-language-server
rust-analyzer
vscode-langservers-extracted
];
packages = with pkgs; [
lf
2024-12-08 19:39:38 -03:00
ripgrep
jq
2024-12-08 19:39:38 -03:00
inputs.go-grip.packages.${pkgs.system}.default
yaziPkg
];
2024-12-05 19:20:23 -03:00
foldPlugins = builtins.foldl' (acc: next: acc ++ [next] ++ (foldPlugins (next.dependencies or []))) [];
startPluginsWithDeps = lib.unique (foldPlugins startPlugins);
optPluginsWithDeps = lib.unique (foldPlugins optPlugins);
packpath = let
2024-12-05 19:20:23 -03:00
packageName = "dot013";
in
runCommandLocal "packpath" {} ''
mkdir -p $out/pack/${packageName}/{start,opt}
2024-12-05 19:20:23 -03:00
${lib.concatMapStringsSep "\n"
(plugin: "ln -vsfT ${plugin} $out/pack/${packageName}/start/${lib.getName plugin}")
startPluginsWithDeps}
2024-12-05 19:20:23 -03:00
${lib.concatMapStringsSep "\n"
(plugin: "ln -vsfT ${plugin} $out/pack/${packageName}/opt/${lib.getName plugin}")
optPluginsWithDeps}
'';
initLua = let
luaPackages = lp: [];
luaEnv = nvimPkg.lua.withPackages luaPackages;
inherit (nvimPkg.lua.pkgs.luaLib) genLuaPathAbsStr genLuaCPathAbsStr;
2024-12-05 19:20:23 -03:00
in
pkgs.writeText "init.lua" ''
-- Don't use LUA_PATH and LUA_CPATH, since they leak into the LSP
package.path = "${genLuaPathAbsStr luaEnv};" .. package.path
package.cpath = "${genLuaCPathAbsStr luaEnv};" .. package.cpath
2024-12-05 19:20:23 -03:00
-- No remote plugins
vim.g.loaded_node_provider = 0
vim.g.loaded_perl_provider = 0
vim.g.loaded_python_provider = 0
vim.g.loaded_python3_provider = 0
vim.g.loaded_ruby_provider = 0
2024-12-05 19:20:23 -03:00
require("dot013")
'';
2024-12-09 16:30:00 -03:00
nvim-derivation = symlinkJoin {
2024-12-05 19:20:23 -03:00
name = "neovim-custom";
pname = "nvim";
paths = let
wrappedNvim = pkgs.writeShellScriptBin "nvim" ''
export PATH=${lib.makeBinPath (languageServers ++ packages)}:$PATH
${lib.getExe nvimPkg} "$@"
'';
in [wrappedNvim];
2024-12-05 19:20:23 -03:00
nativeBuildInputs = [makeWrapper];
2024-12-05 19:20:23 -03:00
postBuild = ''
wrapProgram $out/bin/nvim \
--add-flags '-u' \
--add-flags '${initLua}' \
--add-flags '--cmd' \
--add-flags "'set packpath^=${packpath} | set runtimepath^=${packpath}'" \
--set-default NVIM_APPNAME nvim-custom
'';
passthru = {
inherit packpath;
};
meta = {
mainProgram = "nvim";
};
2024-12-09 16:30:00 -03:00
};
in
pkgs.stdenv.mkDerivation rec {
name = "Neovim";
pname = "nvim";
buildCommand = let
desktopEntry = pkgs.makeDesktopItem {
name = pname;
desktopName = name;
exec = "${lib.getExe nvim-derivation}";
terminal = true;
};
in ''
mkdir -p $out/bin
2024-12-09 16:30:00 -03:00
cp ${lib.getExe nvim-derivation} $out/bin
mkdir -p $out/share/applications
cp ${desktopEntry}/share/applications/${pname}.desktop $out/share/applications/${pname}.desktop
'';
2024-12-05 19:20:23 -03:00
}