From f9d225416fb94a8369e1ce099dd8d7eaf5771657 Mon Sep 17 00:00:00 2001 From: "Gustavo \"Guz\" L de Mello" Date: Sun, 14 Dec 2025 20:52:55 -0300 Subject: [PATCH] feat(plugins,nix): godot integration --- flake.lock | 13 ++++++ flake.nix | 97 ++++++++++++++++++++++++++++++++++++++++- lua/dot/plugins.lua | 15 +++++-- package.nix | 19 ++++---- scripts/godot-neovim.sh | 48 ++++++++++++-------- 5 files changed, 160 insertions(+), 32 deletions(-) diff --git a/flake.lock b/flake.lock index ae8efbc..3f058d1 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,17 @@ { "nodes": { + "godotdev": { + "flake": false, + "locked": { + "narHash": "sha256-q8Ej78SeZkVt5LxLdJJopVYY1qFdKaObkmZzwJFv1cE=", + "type": "file", + "url": "file:///home/guz/.projects/guz013-godotdev-nvim" + }, + "original": { + "type": "file", + "url": "file:///home/guz/.projects/guz013-godotdev-nvim" + } + }, "mdfmt": { "flake": false, "locked": { @@ -34,6 +46,7 @@ }, "root": { "inputs": { + "godotdev": "godotdev", "mdfmt": "mdfmt", "nixpkgs": "nixpkgs" } diff --git a/flake.nix b/flake.nix index 6dd91a9..5701ede 100644 --- a/flake.nix +++ b/flake.nix @@ -6,6 +6,12 @@ url = "github:moorereason/mdfmt"; flake = false; }; + + godotdev = { + # url = "github:Mathijs-Bakker/godotdev.nvim"; + url = "git+file:///home/guz/.projects/guz013-godotdev-nvim"; + flake = false; + }; }; outputs = { self, @@ -41,10 +47,87 @@ }: { neovim = pkgs.callPackage ./package.nix { mdfmt = self.packages.${pkgs.system}.mdfmt; + godotdev = self.packages.${pkgs.system}.godotdev; }; - godot-neovim = pkgs.writeShellApplication { - name = "godot-neovim"; + godotdev = pkgs.vimUtils.buildVimPlugin { + pname = "godotdev.nvim"; + version = "v0.2.3"; + src = inputs.godotdev; + }; + gh-actions-language-server = pkgs.callPackage ({ + stdenv, + lib, + makeBinaryWrapper, + buildNpmPackage, + bun, + nodejs, + npmHooks, + ... + }: let + pname = "gh-actions-language-server"; + src = fetchGit { + url = "https://github.com/lttb/gh-actions-language-server"; + rev = "0287d3081d7b74fef88824ca3bd6e9a44323a54d"; }; + packageJson = lib.importJSON "${src}/package.json"; + version = packageJson.version; + node_modules = stdenv.mkDerivation { + inherit src version; + pname = "${pname}-node_modules"; + nativeBuildInputs = [bun]; + dontConfigure = true; + buildPhase = '' + bun install --no-progress --frozen-lockfile + ''; + installPhase = '' + mkdir -p $out/node_modules + cp -R ./node_modules/* $out/node_modules + ls -la $out/node_modules + ''; + dontFixup = true; + dontPathShebangs = true; + outputHash = "sha256-HfMP9OI07CpiOQw5xkpcRPKPv/MflU1FjtSMOuCkYtg="; + outputHashAlgo = "sha256"; + outputHashMode = "recursive"; + }; + in + stdenv.mkDerivation { + inherit pname src version; + buildInputs = [bun nodejs]; + nativeBuildInputs = [makeBinaryWrapper]; + + dontConfigure = true; + + buildPhase = '' + runHook preBuild + + ln -s "${node_modules}/node_modules" ./ + bun run build:node + + runHook postBuild + ''; + installPhase = '' + runHook preInstall + + mkdir -p $out + mv ./bin/$pname $out/$pname + makeBinaryWrapper ${lib.getExe nodejs} $out/bin/$pname \ + --prefix PATH : ${lib.makeBinPath [nodejs]} \ + --add-flags "$out/$pname" + + runHook postInstall + ''; + # installPhase = '' + # runHook preInstall + # + # mkdir -p $out/bin + # makeBinaryWrapper ${lib.getExe nodejs} $out/bin/$pname \ + # --prefix PATH : "${lib.makeBinPath [nodejs]}" + # --add-flags "$out/$pname" + # + # runHook postInstall + # ''; + }) {}; mdfmt = pkgs.buildGoModule { name = "mdfmt"; src = inputs.mdfmt; @@ -90,6 +173,7 @@ type = with types; bool; default = true; }; + integrations.godot.enable = mkEnableOption ""; }; config = mkIf cfg.enable { environment.variables = { @@ -104,6 +188,10 @@ yazi = config.programs.yazi.package; })) ] + ++ (optionals cfg.integrations.godot.enable [ + self.packages."${pkgs.system}".godot-neovim + ]); + # Disable NixOS's Neovim programs.neovim.enable = mkForce false; }; @@ -136,6 +224,7 @@ type = with types; bool; default = true; }; + integrations.godot.enable = mkEnableOption ""; }; config = mkIf cfg.enable { home.sessionVariables = { @@ -151,6 +240,10 @@ yazi = config.programs.yazi.package; })) ] + ++ (optionals cfg.integrations.godot.enable [ + self.packages."${pkgs.system}".godot-neovim + ]); + programs.bash.shellAliases = mkIf cfg.vimdiffAlias {vimdiff = "nvim -d";}; programs.fish.shellAliases = mkIf cfg.vimdiffAlias {vimdiff = "nvim -d";}; programs.zsh.shellAliases = mkIf cfg.vimdiffAlias {vimdiff = "nvim -d";}; diff --git a/lua/dot/plugins.lua b/lua/dot/plugins.lua index 0aeb0d1..fd65a1d 100644 --- a/lua/dot/plugins.lua +++ b/lua/dot/plugins.lua @@ -8,6 +8,7 @@ lze.load({ -- Language Server Protocol { "nvim-lspconfig", + dep_of = { "godotdev" }, ---@param plugin lze.Plugin lsp = function(plugin) local config = plugin.lsp or {} @@ -27,6 +28,7 @@ lze.load({ after = function() require("dot.debugger") end, + dep_of = { "godotdev.nvim" }, on_require = { "dap", "dapui" }, }, { "nvim-dap-ui", dep_of = "nvim-dap" }, @@ -180,7 +182,7 @@ lze.load({ -- Treesitter (Syntax Highlighting) { "nvim-treesitter", - dep_of = "indent-blankline.nvim", + dep_of = { "godotdev", "indent-blankline.nvim" }, on_require = "nvim-treesitter", }, { "nvim-treesitter-textobjects", dep_of = "nvim-treesitter" }, @@ -249,7 +251,14 @@ lze.load({ end, }, { - "godot.nvim", - cmd = { "GodotDebug", "GodotBreakAtCursor", "GodotStep", "GodotQuit", "GodotContinue" }, + "godotdev.nvim", + after = function() + require("godotdev").setup({ + autostart_editor_server = true, + }) + end, + cmd = { "GodotReconnectLSP", "GodotStartEditorServer" }, + ft = { "gd", "gdscript", "gdshader", "gdscript3" }, + on_require = "godotdev", }, }) diff --git a/package.nix b/package.nix index bf2282c..fdda366 100644 --- a/package.nix +++ b/package.nix @@ -4,6 +4,14 @@ neovim ? pkgs.neovim, mdfmt ? null, yazi ? pkgs.yazi, + godotdev ? (pkgs.vimUtils.buildVimPlugin { + pname = "godotdev.nvim"; + version = "v0.2.3"; + src = fetchGit { + url = "https://github.com/Mathijs-Bakker/godotdev.nvim"; + rev = "79d9315988b7772c03a1cabb6f31f5287c849e2b"; + }; + }), ... }: let dot-nvim = pkgs.vimUtils.buildVimPlugin { @@ -86,14 +94,7 @@ in rev = "be7b03748f59b6602502baf08e7f7736cc7279a5"; }; }) - (pkgs.vimUtils.buildVimPlugin { - pname = "godot.nvim"; - version = "v0.4.4"; - src = fetchGit { - url = "https://github.com/Lommix/godot.nvim"; - rev = "349b6b088c15447843fc21b60ba7267b8b49d821"; - }; - }) + godotdev ]; # inherit start opt; }; @@ -105,6 +106,7 @@ in vscode-langservers-extracted # cssls, eslint, html, jsonls, typescript + docker-language-server emmet-language-server golangci-lint-langserver gopls @@ -115,6 +117,7 @@ in nil rust-analyzer tailwindcss-language-server + typescript-language-server ] ++ [ # INFO: Formatters diff --git a/scripts/godot-neovim.sh b/scripts/godot-neovim.sh index 21924d9..7cb253f 100644 --- a/scripts/godot-neovim.sh +++ b/scripts/godot-neovim.sh @@ -3,10 +3,10 @@ # Script provided by Mathijs Bakker's godotdev.nvim, licensed under the Apache # License Version 2.0. # -# A copy of the original script can be found at +# A copy of the original script can be found at # https://github.com/Mathijs-Bakker/godotdev.nvim/blob/79d9315988b7772c03a1cabb6f31f5287c849e2b/doc/neovim-external-editor-setup.md#installation # -# A copy of the original license can be found at +# A copy of the original license can be found at # https://github.com/Mathijs-Bakker/godotdev.nvim/blob/79d9315988b7772c03a1cabb6f31f5287c849e2b/LICENSE # Godot → Neovim launcher with GUI terminal focus @@ -28,8 +28,7 @@ else shift fi -SOCKET="${SOCKET:=/tmp/godot.pipe}" # Neovim socket path -NVR="${NVR:=/Library/Frameworks/Python.framework/Versions/3.8/bin/nvr}" +SOCKET="${SOCKET:=/tmp/godot.nvim}" # Neovim socket path OPEN_MODE="window" LINE="" @@ -40,36 +39,47 @@ FILE="" # ----------------------------- while [[ $# -gt 0 ]]; do case "$1" in - --tab) OPEN_MODE="tab"; shift ;; - --vsplit) OPEN_MODE="vsplit"; shift ;; - +[0-9]*) LINE="${1#+}"; shift ;; - *) FILE="$1"; shift ;; + --tab) + OPEN_MODE="tab" + shift + ;; + --vsplit) + OPEN_MODE="vsplit" + shift + ;; + +[0-9]*) + LINE="${1#+}" + shift + ;; + *) + FILE="$1" + shift + ;; esac done -[ -z "$FILE" ] && exit 0 +[ "$FILE" = "" ] && exit 0 # ----------------------------- # Open file in Neovim or jump to buffer # ----------------------------- -if $NVR --servername "$SOCKET" --remote-expr \ - "bufexists(fnamemodify('$FILE', ':p'))" | grep -q 1; then - CMD=":buffer $(basename "$FILE")" +if nvr --servername "$SOCKET" --remote-expr \ + "bufexists(fnamemodify('$FILE', ':p'))" | grep -q 1; then + CMD=":buffer $(basename "$FILE")" else case "$OPEN_MODE" in - window) CMD=":e $FILE" ;; - tab) CMD=":tabedit $FILE" ;; - vsplit) CMD=":vsplit $FILE" ;; + window) CMD=":e $FILE" ;; + tab) CMD=":tabedit $FILE" ;; + vsplit) CMD=":vsplit $FILE" ;; esac fi -[ -n "$LINE" ] && CMD="$CMD | call cursor($LINE,1)" +[ "$LINE" != "" ] && CMD="$CMD | call cursor($LINE,1)" CMD="$CMD | normal! zz" -$NVR --servername "$SOCKET" --remote-send "${CMD}" +nvr --servername "$SOCKET" --remote-send "${CMD}" # ----------------------------- # Focus GUI terminal (Hyprland) # ----------------------------- -hyprctl dispatch focuswindow class:$GODOT_TERMINAL - +hyprctl dispatch focuswindow "class:$GODOT_TERMINAL"