|
| 1 | +{ |
| 2 | + fd, lemminx, makeWrapper, |
| 3 | + gcc, ripgrep, tree-sitter, |
| 4 | + lib, fetchurl, runtimeShell, |
| 5 | + nil, coreutils, vscode-js-debug, |
| 6 | + curl, gitMinimal, neovim-unwrapped, |
| 7 | + gnutar, runCommand, lua-language-server, |
| 8 | + gnumake, wrapNeovim, yaml-language-server, |
| 9 | + vscode-langservers-extracted, |
| 10 | +}: |
| 11 | + |
| 12 | +let |
| 13 | + luarcSchemaVersion = "v3.18.2"; |
| 14 | + luaLSVscodeLuaBaseUrl = "https://raw.githubusercontent.com/LuaLS/vscode-lua/refs/tags/${luarcSchemaVersion}"; |
| 15 | + luarcSchema = fetchurl { |
| 16 | + url = "${luaLSVscodeLuaBaseUrl}/setting/schema.json"; |
| 17 | + sha256 = "sha256-9iIVguhV85jc7sESYwEnkxEH849HFEtv/SaXwLQBH4Q="; |
| 18 | + }; |
| 19 | + luarcSchemaLicense = fetchurl { |
| 20 | + url = "${luaLSVscodeLuaBaseUrl}/LICENSE"; |
| 21 | + sha256 = "sha256-cHSCTv/fzh1DUBOflSpHBnFhB+ImldbVEyeCzeG40SY="; |
| 22 | + }; |
| 23 | + |
| 24 | + runtimePrograms = [ |
| 25 | + fd gnutar gitMinimal |
| 26 | + gcc gnumake tree-sitter |
| 27 | + nil lemminx vscode-js-debug |
| 28 | + curl ripgrep lua-language-server |
| 29 | + yaml-language-server |
| 30 | + vscode-langservers-extracted |
| 31 | + ]; |
| 32 | + |
| 33 | + patchedNeovim = neovim-unwrapped.overrideAttrs (old: { |
| 34 | + postPatch = (old.postPatch or "") + '' |
| 35 | + substituteInPlace src/nvim/version.c \ |
| 36 | + --replace-fail '"│ ╲ ││",' '"h i ",' \ |
| 37 | + --replace-fail '"││╲╲││",' '"hhh v v i mmm",' \ |
| 38 | + --replace-fail '"││ ╲ │",' '"h h v i mmm",' \ |
| 39 | + --replace-fail 'N_(NVIM_VERSION_LONG),' '"hvim " NVIM_VERSION_MEDIUM,' |
| 40 | + substituteInPlace src/nvim/version.c \ |
| 41 | + --replace-fail " int attr = 0;" " int attr = *p == 'h' ? string_attr : (*p == ' ' ? 0 : special_attr);" |
| 42 | + ''; |
| 43 | + }); |
| 44 | + |
| 45 | + wrappedNeovim = wrapNeovim patchedNeovim { |
| 46 | + extraName = "-hvim"; |
| 47 | + wrapperArgs = [ |
| 48 | + "--set" "NVIM_APPNAME" "hvim" |
| 49 | + "--suffix" "PATH" ":" (lib.makeBinPath runtimePrograms) |
| 50 | + ]; |
| 51 | + }; |
| 52 | +in |
| 53 | + |
| 54 | +runCommand "hvim-${lib.getVersion neovim-unwrapped}" |
| 55 | + { |
| 56 | + meta = { |
| 57 | + mainProgram = "hvim"; |
| 58 | + description = "A personal Neovim wrapper built with Nix."; |
| 59 | + homepage = "https://github.com/hooreique/hvim"; |
| 60 | + license = lib.licenses.mit; |
| 61 | + }; |
| 62 | + nativeBuildInputs = [ makeWrapper ]; |
| 63 | + } |
| 64 | + '' |
| 65 | + mkdir -p "$out/bin" |
| 66 | + mkdir -p "$out/share" |
| 67 | + mkdir -p "$out/share/licenses/hvim" |
| 68 | + cp "${./LICENSE}" "$out/share/licenses/hvim/LICENSE" |
| 69 | + cp "${luarcSchemaLicense}" "$out/share/licenses/hvim/LuaLS-vscode-lua-LICENSE" |
| 70 | + cp "${luarcSchema}" "$out/share/luarc-schema.json" |
| 71 | + cat > "$out/share/luarc.hvim-config.json" <<EOF |
| 72 | + { |
| 73 | + "\''$schema": "file://$out/share/luarc-schema.json", |
| 74 | + "runtime": { |
| 75 | + "version": "LuaJIT" |
| 76 | + }, |
| 77 | + "workspace": { |
| 78 | + "library": [ |
| 79 | + "${patchedNeovim}/share/nvim/runtime/lua", |
| 80 | + "${patchedNeovim}/share/nvim/runtime/lua/vim/lsp" |
| 81 | + ] |
| 82 | + } |
| 83 | + } |
| 84 | + EOF |
| 85 | + makeWrapper "${wrappedNeovim}/bin/nvim" "$out/bin/hvim" --prefix PATH : "$out/bin" |
| 86 | + cat > "$out/bin/hvim-luarc" <<EOF |
| 87 | + #!${runtimeShell} |
| 88 | + exec ${coreutils}/bin/cat "$out/share/luarc.hvim-config.json" |
| 89 | + EOF |
| 90 | + chmod +x "$out/bin/hvim-luarc" |
| 91 | + '' |
0 commit comments