From de4b14a35ddfec396058f6756b8e4ff28a2b7564 Mon Sep 17 00:00:00 2001 From: alsaiduq-lab Date: Mon, 30 Jun 2025 13:23:10 -0600 Subject: [PATCH] refactored --- home-manager/modules/nvim.nix | 84 +++++++++++------------------------ 1 file changed, 25 insertions(+), 59 deletions(-) diff --git a/home-manager/modules/nvim.nix b/home-manager/modules/nvim.nix index b833912..33a92b4 100644 --- a/home-manager/modules/nvim.nix +++ b/home-manager/modules/nvim.nix @@ -1,72 +1,38 @@ { config, pkgs, + lib, ... -}: { +}: let + gitDir = "${pkgs.git}/bin/git"; + nvim = "${config.home.homeDirectory}/.config/nvim"; +in { + programs.neovim = { + enable = true; + extraPython3Packages = ps: [ps.pynvim]; + }; + home.packages = with pkgs; [ - neovim - gnugrep git luajit luaPackages.luarocks - gopls - haskell-language-server - jdt-language-server - clang-tools - vscode-langservers-extracted - marksman - nil - taplo - yaml-language-server - sqls - alejandra - stylua - shfmt - yamlfmt - luaPackages.luacheck - yamllint - hadolint - shellcheck - cppcheck - rubocop - phpPackages.php-codesniffer - phpPackages.phpstan - checkstyle - tflint - sqlfluff tree-sitter - luajitPackages.jsregexp - jq - curl - unzip ]; - home.sessionVariables = { - LUA_PATH = "${pkgs.luajit}/share/lua/5.1/?.lua;${pkgs.luajit}/share/lua/5.1/?/init.lua;;"; - LUA_CPATH = "${pkgs.luajit}/lib/lua/5.1/?.so;;"; - }; + home.sessionPath = ["$HOME/.local/share/nvim/mason/bin"]; - home.sessionPath = [ - "$HOME/.local/share/nvim/mason/bin" - ]; - - xdg.configFile."nvim" = let - nvimConfigPath = "${config.home.homeDirectory}/.config/nvim"; - # nvimDotfiles = builtins.fetchGit { - # url = "https://github.com/alsaiduq-lab/nvim-dotfiles.git"; - # ref = "master"; - # rev = "71155b4a4b63d9974f1bc3b66303d6f7e5e06871"; - # }; - in { - source = pkgs.emptyDirectory; - recursive = true; - enable = !builtins.pathExists nvimConfigPath; - onChange = '' - echo "Neovim config at ${nvimConfigPath} was ${ - if builtins.pathExists nvimConfigPath - then "skipped (already exists)" - else "installed" - }" - ''; - }; + home.activation.nvimConfig = lib.hm.dag.entryAfter ["writeBoundary"] '' + if [ ! -d "${nvim}/.git" ]; then + ${gitDir} clone --depth 1 \ + https://github.com/alsaiduq-lab/nvim-dotfiles.git "${nvim}" + echo "Neovim config at ${nvim} was installed" + else + if ${gitDir} -C "${nvim}" pull --ff-only origin master \ + | grep -q 'Already up to date.'; then + echo "Neovim config at ${nvim} is unchanged" + else + echo "Neovim config at ${nvim} was updated" + fi + fi + ''; }