nixvim icon indicating copy to clipboard operation
nixvim copied to clipboard

[BUG] nixvimInjections don't seem to work on nightly

Open jonboh opened this issue 1 year ago • 1 comments

Field Description
Plugin treesitter
Nixpkgs unstable

  • [x] I have read the FAQ and my bug is not listed there.

Description

The nixvimInjections option does not work on nighlty builds of neovim. The extraConfigLua regions do not get properly highlighted as lua code. A minor thing, but I thought it worth to report :)

Minimal, Reproducible Example (MRE)

I'm able to reproduce the behavior with this minimal flake:

{
  description = "A nixvim configuration";

  inputs = {
    nixvim.url = "github:nix-community/nixvim";
    flake-utils.url = "github:numtide/flake-utils";
    nixneovimplugins.url = "github:NixNeovim/NixNeovimPlugins";
    neovim-nightly-overlay.url = "github:nix-community/neovim-nightly-overlay";
  };

  outputs = {
    nixpkgs,
    nixvim,
    flake-utils,
    nixneovimplugins,
    ...
  } @ inputs:
    flake-utils.lib.eachDefaultSystem (system: let
      pkgs-nightly = import nixpkgs {
        inherit system;
        overlays = [
          nixneovimplugins.overlays.default
          inputs.neovim-nightly-overlay.overlay
        ];
      };
      pkgs = import nixpkgs {
        inherit system;
        overlays = [
          nixneovimplugins.overlays.default
        ];
      };
      nixvim' = nixvim.legacyPackages.${system};
      inject = nixvim'.makeNixvimWithModule {
        inherit pkgs;
        module = {
          plugins.treesitter = {
            enable = true;
            nixvimInjections = true;
          };
        };
      };
      inject-nightly = nixvim'.makeNixvimWithModule {
        pkgs = pkgs-nightly;
        module = {
          plugins.treesitter = {
            enable = true;
            nixvimInjections = true;
          };
        };
      };
    in {
      packages = {
        inherit inject;
        inherit inject-nightly;
      };
    });
}

nix run ".#inject" and nix run ".#inject-nightly" for the different versions. Opening any file with extraConfigLua should show that the nighly version does not properly highlight those regions.

jonboh avatar Mar 31 '24 09:03 jonboh

Can confirm this for current nixpkgs-unstable with Neovim v0.10.0.

elohmeier avatar Jun 09 '24 03:06 elohmeier

Should be fixed in #1843

traxys avatar Jul 19 '24 17:07 traxys

This still doesn't work for me on latest nixvim and nixpkgs.

zvolin avatar Aug 27 '24 22:08 zvolin

@zvolin you may be interested in this discussion: https://github.com/nix-community/nixvim/discussions/2093

TL;DR: the injections are working, but can be a little finicky when it comes to whitespace.

Also: ensure you have set plugins.treesitter.settings.highlight.enable = true.

MattSturgeon avatar Aug 27 '24 22:08 MattSturgeon

thanks, highlight.enable = true did the job. I think it was working without it few months ago.

zvolin avatar Aug 27 '24 23:08 zvolin

thanks, highlight.enable = true did the job. I think it was working without it few months ago.

We used to default to enabling them but changed to respecting plugin defaults as we’ve been refactoring. Treesitter doesn’t enable anything by default apparently.

khaneliman avatar Aug 27 '24 23:08 khaneliman

I have the same issue. I also tried adding custom injections in after/queries/yaml/injections.scm and queries/yaml/injections.scm both through extraFiles and manually but nothing worked - treesitter doesn't pick any of the files up, like they don't exist

dzervas avatar Sep 10 '25 06:09 dzervas