Coder Social home page Coder Social logo

nix-community / nixvim Goto Github PK

View Code? Open in Web Editor NEW
1.2K 12.0 177.0 69.09 MB

Configure Neovim with Nix! [maintainer=@pta2002, @traxys, @GaetanLepage]

Home Page: https://nix-community.github.io/nixvim

License: MIT License

Nix 100.00%
neovim nix nixos nixos-module vim nix-community-buildbot

nixvim's People

Contributors

adalessa avatar alexnortung avatar alisonjenkins avatar andrevmatos avatar anriha avatar b-m-f avatar budimanjojo avatar builditluc avatar foo-dogsquared avatar gaetanlepage avatar garaiza-93 avatar github-actions[bot] avatar hmajid2301 avatar matildeopbravo avatar mikaelfangel avatar mrtnvgr avatar photonquantum avatar pta2002 avatar ptonner avatar redyf avatar rummik avatar shyproton avatar siph avatar tanish2002 avatar tarantoj avatar tilmanmixyz avatar traxys avatar truenaho avatar wolbyte avatar zachcoyle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nixvim's Issues

Broken config on nixos-stable

Hello, I have just tried to update nixvim in my personal flake. However it seems to be broken, when using the home manager module.

I am getting the following errors

Error detected while processing /nix/store/hgclrlyxzazx8b5324qcrkrbm5zfjq25-init.vim:
line    6:
E185: Cannot find color scheme 'nord'
line  396:
E5108: Error executing lua [string ":lua"]:20: module 'cmp' not found:
        no field package.preload['cmp']
        no file '/nix/store/vmln39q308xpq0awd1b5j84i8l58l857-luajit-2.1.0-2022-04-05-env/share/lua/5.1/cmp.lua'
        no file '/nix/store/vmln39q308xpq0awd1b5j84i8l58l857-luajit-2.1.0-2022-04-05-env/share/lua/5.1/cmp/init.lua'
        no file '/nix/store/vmln39q308xpq0awd1b5j84i8l58l857-luajit-2.1.0-2022-04-05-env/lib/lua/5.1/cmp.so'
stack traceback:
        [C]: in function 'require'
        [string ":lua"]:20: in main chunk

I also noticed that the config file is no longer saved in the $HOME/.config/ directory, why is that?

Anyway, I will continue using an older version until we can fix some of these issues.

error: stack overflow (possible infinite recursion)

After upgrading the nixvim flake I get the following error during nixos-rebuild build

"locked": {
        "lastModified": 1674327176,
        "narHash": "sha256-q+HpspHrO5XZnMShBJdLHjHVsCoaWN/Tis7OzRwaF3w=",
        "lastModified": 1674160777,
        "narHash": "sha256-ozE4FVz+UB+5pTiNjhYanS/y52lwXhv8mWzAugbIHak=",
        "owner": "pta2002",
        "repo": "nixvim",
        "rev": "23327700e2a16a3434920d26cb61d90b48478fe7",
        "rev": "d2f714c40ec9bcb20f91a8124f33c81f0576bb68",
        "type": "github"
      },

The second one works, the first gives the error.

error: stack overflow (possible infinite recursion)

Discord/community?

I'm trying to use your framework to nix-ify my vim configs, and was curious if you guys have a contributor discord, or some way to contact knowlegeable users. I'm concerned opening a issue for every noobish question would be a bit much.

Home manager won't build if no config is set in nixvim

Plugin affected: What plugin does this bug relate to (if applicable)
Nixpkgs channel: 22.11
Home-manager version: 22.11

Description

If I have the nixvim module added in my home-manager config and I do not use any options from nixvim, home-manager will fail to build with an error:

error: The option `programs.nixvim' is used but not defined.
(use '--show-trace' to show detailed location information)

This happened as I removed my config from my files, but didn't remove the module import yet.

use without HM or nixos

I would like to use nixvim in a prototype runnable flake "env" project https://github.com/aquiferma/noter (see discussion 1). For this, I need a myNeoVim package with config/customizations baked in.

There is a broader design need at the ecosystem level to define an ergonomic relationship between flakes and the module system outside the context of HM/nixos, but nixvim seems an OK place to pick up the conversation.

It seems like a "quick fix" might be to inline or maybe wrap one of the programs.neovim modules 23.

Also probably worth a look, @syberant's nix-neovim flake 4, which IIUC inlines its own module system for config, and only calls pkgs.wrappedNeoVim.

Footnotes

  1. https://github.com/aquiferma/noter/issues/2

  2. https://github.com/nix-community/home-manager/blob/master/modules/programs/neovim.nix

  3. https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/programs/neovim.nix

  4. https://github.com/syberant/nix-neovim/blob/main/flake.nix

Options broken after #167

Plugin affected: None
Nixpkgs channel: 22.11.20221211.dfef2e6 (Raccoon)
Home-manager version: 22.11

Description

After updating my home-manager config (adding some packages to my system), I found neovim throwing errors for the options.

Error detected while processing /home/zero/.config/nvim/init.lua:
E5113: Error while calling lua chunk: vim/_meta.lua:0: Invalid option type 'boolean' for 'syntax', should be string
stack traceback:
        [C]: in function 'error'
        vim/_meta.lua: in function ''
        vim/_meta.lua: in function ''
        vim/_meta.lua: in function '_set'
        vim/_meta.lua: in function '__newindex'
        /home/zero/.config/nvim/init.lua:44: in main chunk

And saying options doesn't exist

Error detected while processing /home/zero/.config/nvim/init.lua:
E5113: Error while calling lua chunk: vim/_meta.lua:0: no such option: 'noswapfile'
stack traceback:
        [C]: in function 'nvim_get_option_info'
        vim/_meta.lua: in function '__index'
        vim/_meta.lua: in function ''
        vim/_meta.lua: in function '__newindex'
        /home/zero/.config/nvim/init.lua:44: in main chunk

I found that setting my revision for fetchGit to 96c77f1 fixes it (last commit before #167), and setting the revision to 6e54dc1 then the issue appears.

This doesn't look good for stability.

Config

Relevant config

options = {
      encoding = "utf8";
      syntax = true;

      number = true;
      relativenumber = true;

      noerrorbells = true;
      novisualbell = true;
      noswapfile = true;

      history = 1000;
      undodir = "~/.cache/nvim_undo/";

      shiftwidth = 4;

      timeout = true;
      timeoutlen = 300;
    };

Error when using nixos Module

I am getting error: The option 'programs.neovim.extraConfigLua' does not exist. when importing the module using flakes with inputs.nixvim.nixosModules.nixvim. This happens, even when not adding

programs.nixvim.enable = true

Using homeManager works without issues.

Could it be that
https://github.com/pta2002/nixvim/blob/f534819885f4cf8a878f4411a5e72e807f135acf/nixvim.nix#L260-L265

should reference programs.nixvim instead of programs.neovim? The official nixos neovim module does not have extraConfigLua and this probably causes the error.

$VIMRUNTIME not set on NixOS

Plugin affected: N/A
Nixpkgs channel: 22.05 (github:NixOS/nixpkgs/0faaf0a9bb6dedb69bfd43ac06fb27fadc476c51)
Home-manager version: N/A

Description

E484: Can't open file /etc/nvim/syntax/syntax.vim on startup, and others when opened in vim mode. No help files present. running :help returns E433: No tags file and E149: Sorry, no help for help.txt

I beleive this is related to :echo $VIMRUNTIME returning /etc/nvim instead of something more sensible like
/nix/store/7vaavg9j2q0xg6w1wr42hir1vbsh2b90-neovim-0.7.0/share/nvim/runtime

Seems like it might be the same bug from #40 and #45?

Config

programs.nixvim={
    enable = true;
    #vimAlias = false;
    #viAlias = false;
    options = {
        nocompatible = true;

        # Default indenting
        smartindent = true;
        tabstop = 4;
        shiftwidth = 4;
        expandtab = true;
        softtabstop = 4;

        number = true;
        ruler  = true;
        hlsearch = true;
        syntax = true;
        
        background = "dark";
        colorcolumn = 80;



      };
  }

Switching to init.lua completely broke nixvim

Plugin affected: *
Nixpkgs channel: unstable
Home-manager version: master

Description

Before 3849a1d, everything seemed fine. Now, the generated init.lua is 10 lines long, filled with 10 empty lines.

Config

  programs.nixvim = {

    enable = true;
    colorschemes.gruvbox = {
      enable = true;
      contrastLight = "hard";
      contrastDark = "hard";
    };

    options = {
      number = true;
      shiftwidth = 2;
      tabstop = 2;
      guifont = "FiraCode\ Nerd\ Font\ Mono:h14";
    };

    plugins = {
      lsp = {
        enable = true;
        servers.rnix-lsp.enable = true;
        servers.rust-analyzer.enable = true;
        servers.jsonls.enable = true;
      };

      nvim-tree = {
        enable = true;
        openOnSetup = true;
        openOnTab = true;
      };

      telescope = {
        enable = true;
      };

      nvim-cmp = {
        formatting = {
          format = ''
            					require("lspkind").cmp_format({
            						mode="symbol",
            						maxwidth = 50,
            						ellipsis_char = "..."
            					})
            					'';
        };

        auto_enable_sources = true;
        snippet = {
          expand = ''
            	   function(args)
            	     require("luasnip").lsp_expand(args.body)
            	   end
            	 '';
        };
        enable = true;
        sources = [
          { name = "nvim_lsp"; }
          {
            name = "luasnip";
            option = {
              show_autosnippets = true;
            };
          }
          { name = "path"; }
          { name = "buffer"; }
        ];

      };
      barbar.enable = true;
    };

    globals.mapleader = " ";
    extraPlugins = with pkgs.vimPlugins; [
      which-key-nvim
      leap-nvim
      vim-flutter
      plenary-nvim
      fidget-nvim
      luasnip
      lspkind-nvim
    ];

    extraConfigLua = (builtins.readFile ./nvim-extra-lua.lua);
  };
}

init.lua

Hi! First of all, thanks for making this awesome project!

I was wondering if there were any plans to simply use an init.lua rather than an init.vim, since the majority of the config is in lua there are lua alternatives for most, if not all of vim configuration. From a user standpoint, it would make the resulting nvim config file easier to read. There wouldn't be any need navigate through the various lua blocks, and I think syntax highlighting would also work properly (at least in my config, the nested lua syntax highlighting is always messed up). Thanks!

Interrested in merging?

Hi, I really like your project, but had missing some plugins so I started to implement some of them in a fork.
On the way I also changed some of your work like some helper functions and for example a lot of the cmp module and therefore don't want to create a merge request directly, but wanted to ask you if you even want my work, or if you prefer your way of doing things.
But I feel like at least some of my work could be beneficial to your work.

If you are interested but feel like I changed some things to the worse, I am open for any feedback.
Either way, I will implement more and more modules, and would be happy if other people could benefit from my work as well

Documentation isn't generated

Plugin affected: docs
Nixpkgs channel: n/a
Home-manager version: n/a

Description

When generating HTML documentation, the last stage of nmd fails with the following error:

Writing options.html for appendix(ch-options)
I/O error : Is a directory
I/O error : Is a directory

Now, I honestly have zero idea why this isn't working. It seems to be happening on this line, but I can't figure out why, or what it is complaining about being a directory.

"The option is used but not defined" on nix-darwin

Nixpkgs channel: master
Home-manager version: master

Description

When trying to use this module at all, I get the following error message

building the system configuration...
error: The option `home-manager.users.aordonez.programs.nixvim' is used but not defined.
(use '--show-trace' to show detailed location information)

Even with a very simple flake.nix which I will supply below.

Not sure if I'm doing something wrong on my side, but from referencing other people's nix configs who are using this flake on nixos, I don't believe I'm doing anything differently other than being on macos

Config

{
  description = "";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/master";

    darwin.url = "github:lnl7/nix-darwin/master";
    darwin.inputs.nixpkgs.follows = "nixpkgs";

    home-manager.url = "github:nix-community/home-manager";
    home-manager.inputs.nixpkgs.follows = "nixpkgs";

    nixvim.url = "github:pta2002/nixvim";
  };

  outputs = { self, nixpkgs, darwin, home-manager, ... }@inputs:
    {
      darwinConfigurations.gon = darwin.lib.darwinSystem {
        system = "aarch64-darwin";
        specialArgs = { inherit inputs; };
        modules = [
          home-manager.darwinModules.home-manager
          {
            nix.extraOptions = ''
              experimental-features = nix-command flakes
            '';
          }
          {
            users.users.aordonez = {
              name = "aordonez";
            };
            home-manager.users.aordonez = {

              home.stateVersion = "22.11";
              imports = [ inputs.nixvim.homeManagerModules.nixvim ];
            };
          }
        ];
      };
    };
}

Error: Infinite recursion encountered

Plugin affected: nixvim home-manager module
Nixpkgs channel: unstable
Home-manager version: (if applicable)
Nixvim version: db8a2c0

Description

Even a simple import will cause the following stack trace:

error: infinite recursion encountered

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:478:28:

          477|         builtins.addErrorContext (context name)
          478|           (args.${name} or config._module.args.${name})
             |                            ^
          479|       ) (lib.functionArgs f);while evaluating the module argument `nixvim' in "/nix/store/2x17848qwkzd5rqf1gl78g0x2hrkiz7l-source/vim.nix":

       … while calling anonymous lambda

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:476:44:

          475|       context = name: ''while evaluating the module argument `${name}' in "${key}":'';
          476|       extraArgs = builtins.mapAttrs (name: _:
             |                                            ^
          477|         builtins.addErrorContext (context name)from call sitewhile calling 'isFunction'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/trivial.nix:448:16:

          447|   */
          448|   isFunction = f: builtins.isFunction f ||
             |                ^
          449|     (f ? __functor && isFunction (f.__functor f));from call site

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:355:12:

          354|       loadModule = args: fallbackFile: fallbackKey: m:
          355|         if isFunction m || isAttrs m then
             |            ^
          356|           unifyModuleSyntax fallbackFile fallbackKey (applyModuleArgsIfFunction fallbackKey m args)while calling 'loadModule'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:354:53:

          353|       # Like unifyModuleSyntax, but also imports paths and calls functions if necessary
          354|       loadModule = args: fallbackFile: fallbackKey: m:
             |                                                     ^
          355|         if isFunction m || isAttrs m then

       … from call site

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:395:22:

          394|           let
          395|             module = loadModule args parentFile "${parentKey}:anon-${toString n}" x;
             |                      ^
          396|             collectedImports = collectStructuredModules module._file module.key module.imports args;while evaluating the attribute 'disabled'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:390:13:

          389|           collectResults = modules: {
          390|             disabled = concatLists (catAttrs "disabled" modules);
             |             ^
          391|             inherit modules;while evaluating the attribute 'disabled'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:390:13:

          389|           collectResults = modules: {
          390|             disabled = concatLists (catAttrs "disabled" modules);
             |             ^
          391|             inherit modules;while evaluating the attribute 'disabled'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:390:13:

          389|           collectResults = modules: {
          390|             disabled = concatLists (catAttrs "disabled" modules);
             |             ^
          391|             inherit modules;while calling anonymous lambda

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:414:31:

          413|           disabledKeys = map moduleKey disabled;
          414|           keyFilter = filter (attrs: ! elem attrs.key disabledKeys);
             |                               ^
          415|         in map (attrs: attrs.module) (builtins.genericClosure {from call sitewhile calling 'filterModules'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:408:36:

          407|       # modules recursively. It returns the final list of unique-by-key modules
          408|       filterModules = modulesPath: { disabled, modules }:
             |                                    ^
          409|         letfrom call site

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:421:7:

          420|     in modulesPath: initialModules: args:
          421|       filterModules modulesPath (collectStructuredModules unknownModule "" initialModules args);
             |       ^
          422|

       … while calling anonymous lambda

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:420:37:

          419|
          420|     in modulesPath: initialModules: args:
             |                                     ^
          421|       filterModules modulesPath (collectStructuredModules unknownModule "" initialModules args);from call site

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:253:25:

          252|       merged =
          253|         let collected = collectModules
             |                         ^
          254|           (specialArgs.modulesPath or "")while calling 'reverseList'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/lists.nix:394:17:

          393|   */
          394|   reverseList = xs:
             |                 ^
          395|     let l = length xs; in genList (n: elemAt xs (l - n - 1)) l;from call site

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:257:33:

          256|           ({ inherit lib options config specialArgs; } // specialArgs);
          257|         in mergeModules prefix (reverseList collected);
             |                                 ^
          258|

       … while calling 'byName'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:537:25:

          536|       */
          537|       byName = attr: f: modules:
             |                         ^
          538|         zipAttrsWith (n: concatLists)from call site

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:554:21:

          553|       # an attrset 'name' => list of submodules that declare ‘name’.
          554|       declsByName = byName "options" (module: option:
             |                     ^
          555|           [{ inherit (module) _file; options = option; }]while evaluating the attribute 'matchedOptions'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:632:14:

          631|     in {
          632|       inherit matchedOptions;
             |              ^
          633|

       … while calling 'mapAttrsRecursiveCond'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/attrsets.nix:524:5:

          523|     # Attribute set to recursively map over.
          524|     set:
             |     ^
          525|     letfrom call site

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:265:28:

          264|           # For definitions that have an associated option
          265|           declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options;
             |                            ^
          266|

       … while evaluating the attribute 'config'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:341:9:

          340|         options = checked options;
          341|         config = checked (removeAttrs config [ "_module" ]);
             |         ^
          342|         _module = checked (config._module);while calling 'merge'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/types.nix:742:22:

          741|         check = x: isAttrs x || isFunction x || path.check x;
          742|         merge = loc: defs:
             |                      ^
          743|           (base.extendModules {from call site

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:760:59:

          759|       if isDefined then
          760|         if all (def: type.check def.value) defsFinal then type.merge loc defsFinal
             |                                                           ^
          761|         else let allInvalid = filter (def: ! type.check def.value) defsFinal;while evaluating the attribute 'value'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:771:27:

          770|     optionalValue =
          771|       if isDefined then { value = mergedValue; }
             |                           ^
          772|       else {};while calling anonymous lambda

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/types.nix:522:22:

          521|       merge = loc: defs:
          522|         mapAttrs (n: v: v.value) (filterAttrs (n: v: v ? value) (zipAttrsWith (name: defs:
             |                      ^
          523|             (mergeDefinitions (loc ++ [name]) elemType defs).optionalValuefrom call sitewhile calling 'flip'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/trivial.nix:138:16:

          137|   */
          138|   flip = f: a: b: f b a;
             |                ^
          139|

       … from call site

       at /nix/store/3ykv6iilczdsz2830r5dn0wjcs87nm9v-source/nixos/common.nix:104:7:

          103|     assertions = flatten (flip mapAttrsToList cfg.users (user: config:
          104|       flip map config.assertions (assertion: {
             |       ^
          105|         inherit (assertion) assertion;while calling anonymous lambda

       at /nix/store/3ykv6iilczdsz2830r5dn0wjcs87nm9v-source/nixos/common.nix:103:64:

          102|
          103|     assertions = flatten (flip mapAttrsToList cfg.users (user: config:
             |                                                                ^
          104|       flip map config.assertions (assertion: {from call site

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/attrsets.nix:478:16:

          477|     attrs:
          478|     map (name: f name attrs.${name}) (attrNames attrs);
             |                ^
          479|

       … while calling anonymous lambda

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/attrsets.nix:478:10:

          477|     attrs:
          478|     map (name: f name attrs.${name}) (attrNames attrs);
             |          ^
          479|

       … from call sitewhile calling 'flatten'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/lists.nix:138:13:

          137|   */
          138|   flatten = x:
             |             ^
          139|     if isList xfrom call site

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/lists.nix:140:24:

          139|     if isList x
          140|     then concatMap (y: flatten y) x
             |                        ^
          141|     else [x];while calling anonymous lambda

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/lists.nix:140:21:

          139|     if isList x
          140|     then concatMap (y: flatten y) x
             |                     ^
          141|     else [x];from call site

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/lists.nix:140:10:

          139|     if isList x
          140|     then concatMap (y: flatten y) x
             |          ^
          141|     else [x];while calling 'flatten'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/lists.nix:138:13:

          137|   */
          138|   flatten = x:
             |             ^
          139|     if isList xfrom call site

       at /nix/store/3ykv6iilczdsz2830r5dn0wjcs87nm9v-source/nixos/common.nix:103:18:

          102|
          103|     assertions = flatten (flip mapAttrsToList cfg.users (user: config:
             |                  ^
          104|       flip map config.assertions (assertion: {while evaluating the attribute 'content'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:881:14:

          880|     { _type = "if";
          881|       inherit condition content;
             |              ^
          882|     };while calling 'dischargeProperties'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:810:25:

          809|   */
          810|   dischargeProperties = def:
             |                         ^
          811|     if def._type or "" == "merge" then

       … from call site

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:816:11:

          815|         if def.condition then
          816|           dischargeProperties def.content
             |           ^
          817|         elsewhile calling 'dischargeProperties'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:810:25:

          809|   */
          810|   dischargeProperties = def:
             |                         ^
          811|     if def._type or "" == "merge" then

       … from call site

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:739:137:

          738|         defs' = concatMap (m:
          739|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
             |                                                                                                                                         ^
          740|         ) defs;while evaluating definitions from `/nix/store/3ykv6iilczdsz2830r5dn0wjcs87nm9v-source/nixos/common.nix':

       … while calling anonymous lambda

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:738:28:

          737|         # Process mkMerge and mkIf properties.
          738|         defs' = concatMap (m:
             |                            ^
          739|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))from call site

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:738:17:

          737|         # Process mkMerge and mkIf properties.
          738|         defs' = concatMap (m:
             |                 ^
          739|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))while evaluating the attribute 'values'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:851:7:

          850|     in {
          851|       values = concatMap (def: if getPrio def == highestPrio then [(strip def)] else []) defs;
             |       ^
          852|       inherit highestPrio;while evaluating the attribute 'values'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:752:9:

          751|       in {
          752|         values = defs''';
             |         ^
          753|         inherit (defs'') highestPrio;while evaluating the attribute 'mergedValue'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:758:5:

          757|     # Type-check the remaining definitions, and merge them. Or throw if no definitions.
          758|     mergedValue =
             |     ^
          759|       if isDefined thenwhile evaluating the option `assertions':

       … while evaluating the attribute 'value'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:723:9:

          722|     in warnDeprecation opt //
          723|       { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          724|         inherit (res.defsFinal') highestPrio;while calling anonymous lambda

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:265:72:

          264|           # For definitions that have an associated option
          265|           declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options;
             |                                                                        ^
          266|

       … from call site

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/attrsets.nix:532:20:

          531|               then recurse (path ++ [name]) value
          532|               else f (path ++ [name]) value;
             |                    ^
          533|         in mapAttrs g;while calling 'g'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/attrsets.nix:529:19:

          528|           g =
          529|             name: value:
             |                   ^
          530|             if isAttrs value && cond valuefrom call sitewhile calling 'fold''

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/lists.nix:56:15:

           55|       len = length list;
           56|       fold' = n:
             |               ^
           57|         if n == lenfrom call site

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/lists.nix:60:8:

           59|         else op (elemAt list n) (fold' (n + 1));
           60|     in fold' 0;
             |        ^
           61|

       … while calling 'foldr'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/lists.nix:53:20:

           52|   */
           53|   foldr = op: nul: list:
             |                    ^
           54|     letfrom call site

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/nixos/modules/system/activation/top-level.nix:123:12:

          122|   # Replace runtime dependencies
          123|   system = foldr ({ oldDependency, newDependency }: drv:
             |            ^
          124|       pkgs.replaceDependency { inherit oldDependency newDependency drv; }while evaluating the attribute 'value'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:563:44:

          562|       defnsByName' = byName "config" (module: value:
          563|           [{ inherit (module) file; inherit value; }]
             |                                            ^
          564|         ) configs;while calling 'dischargeProperties'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:810:25:

          809|   */
          810|   dischargeProperties = def:
             |                         ^
          811|     if def._type or "" == "merge" thenfrom call site

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:739:137:

          738|         defs' = concatMap (m:
          739|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
             |                                                                                                                                         ^
          740|         ) defs;while evaluating definitions from `/nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/nixos/modules/system/activation/top-level.nix':

       … while calling anonymous lambda

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:738:28:

          737|         # Process mkMerge and mkIf properties.
          738|         defs' = concatMap (m:
             |                            ^
          739|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))from call site

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:738:17:

          737|         # Process mkMerge and mkIf properties.
          738|         defs' = concatMap (m:
             |                 ^
          739|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))while evaluating the attribute 'values'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:851:7:

          850|     in {
          851|       values = concatMap (def: if getPrio def == highestPrio then [(strip def)] else []) defs;
             |       ^
          852|       inherit highestPrio;while evaluating the attribute 'values'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:752:9:

          751|       in {
          752|         values = defs''';
             |         ^
          753|         inherit (defs'') highestPrio;while evaluating the attribute 'mergedValue'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:758:5:

          757|     # Type-check the remaining definitions, and merge them. Or throw if no definitions.
          758|     mergedValue =
             |     ^
          759|       if isDefined thenwhile evaluating the option `system.build.toplevel':

       … while evaluating the attribute 'value'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:723:9:

          722|     in warnDeprecation opt //
          723|       { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          724|         inherit (res.defsFinal') highestPrio;while calling anonymous lambda

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/modules.nix:265:72:

          264|           # For definitions that have an associated option
          265|           declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options;
             |                                                                        ^
          266|

       … from call site

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/attrsets.nix:532:20:

          531|               then recurse (path ++ [name]) value
          532|               else f (path ++ [name]) value;
             |                    ^
          533|         in mapAttrs g;while calling 'g'

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/attrsets.nix:529:19:

          528|           g =
          529|             name: value:
             |                   ^
          530|             if isAttrs value && cond valuefrom call sitewhile calling anonymous lambda

       at /nix/store/yq25kfsb7visb44srd694z5rwmpcb05k-source/lib/attrsets.nix:710:24:

          709|     let f = attrPath:
          710|       zipAttrsWith (n: values:
             |                        ^
          711|         let here = attrPath ++ [n]; infrom call site

Config

Your nixvim config

{pkgs, lib, nixvim, ...}: {home-manager.users.usr1 = {
   imports = [
      nixvim.homeManagerModules.nixvim
   ];
};

Cssls, jsonls, etc. - wrong cmd

Plugin affected: lsp
Nixpkgs channel: all
Home-manager version: all

Description

The lsps that are using vscode language servers extracted are using a wrong path for the cmd, it is a pretty easy fix, just reporting it so we can fix it later.

null-ls: add ability to specify custom servers

  programs.nixvim = {
      plugins.null-ls = {
        enable = true;
        sources.formatting.black.enable = true;
        sources.formatting.prettier.enable = true;
        sources.diagnostics.shellcheck.enable = true;
      };

      extraPlugins = with pkgs.vimPlugins; [
        null-ls-nvim
      ];
      extraPackages = [
        pkgs.shfmt
      ];

      extraConfigLua = ''
        require('null-ls').setup {
          sources = {
            require('null-ls').builtins.formatting.shfmt.with({
              -- Indent with 4 spaces, simplify the code, indent switch cases,
              -- add space after redirection
              extra_args = { '-i', '4', '-s', '-ci', '-sr' },
            }),
          },
        }
    '';
  };

When I open a shell script and try to format it, it doesn't work.
The null-ls formatter isn't recognized.
Error: [LSP] Format request failed, no matching language servers.
I do see the diagnostics from shellcheck.
I think this is because inside nvim/init.lua: I see the nixvim generated null-ls generated way before the one I set in extraConfigLua, and only the first is executed...?
For now I do all null-ls inside extraConfigLua, without plugins.null-ls.
Could we add something to insert lua inside null-ls? plugins.null-ls.manualsources ?

When I do everything inside extraConfigLua it does work.

  programs.nixvim = {
     extraPlugins = with pkgs.vimPlugins; [
        null-ls-nvim
     ];
      extraPackages = [
        pkgs.shfmt
      ];

      extraConfigLua = ''
        require('null-ls').setup {
          sources = {
            require('null-ls').builtins.formatting.shfmt.with({
              -- Indent with 4 spaces, simplify the code, indent switch cases,
              -- add space after redirection
              extra_args = { '-i', '4', '-s', '-ci', '-sr' },
            }),
            require("null-ls").builtins.formatting.prettier,
            require("null-ls").builtins.formatting.black,
            require("null-ls").builtins.diagnostics.shellcheck
          },
        }
    '';
  };

I could make a pull request to just add shfmt to nixvim, but I don't see a way to configure the extra_args inside plugins.null-ls.

indent-blakline / nvim-colorize not found???

screenshot_2023-02-10-211913
screenshot_2023-02-10-212119

    nixvim = {
      extraPackages = with pkgs; [
        ripgrep
        fd
      ];
      extraPlugins = with pkgs.vimPlugins; [
        vim-nix
        rnvimr
        mkdir-nvim
      ];
      enable = true;
      viAlias = true;
      vimAlias = true;
      options = {
	autoindent = true;              
	number = true;                  
        syntax = true;                   
	mouse = "a";                 
	clipboard = "unnamedplus";   
	ttyfast = true;                 
	swapfile = false;              
	backup = false;               
        completeopt = "menu,menuone,noselect";
  	writebackup = false;           
	undodir = ".nixvim/undo";   
	undofile = true;		    
	undoreload = 10000;	    
  	scrolloff = 10;            
        termguicolors = true;
      };
      colorschemes.base16 = {
        enable = true;
        useTruecolor = true;
      };
      plugins = {
#        indent-blankline = {
#          enable = true;
#          useTreesitterScope = true;
#          useTreesitter = true;
#        };
#        nvim-colorizer = {
#          enable = true;
#        };
        trouble = {
          enable = true;
          icons = true;
        };
        nvim-cmp = {
          enable = true;
          auto_enable_sources = true;
          sources = [
            { name = "nvim_lsp"; }
            { name = "path"; }
            { name = "buffer"; }
          ];
          mapping = {
            "<CR>" = "cmp.mapping.confirm({ select = true })";
            "<Tab>" = {
            modes = [ "i" "s" ];
            action = ''
              function(fallback)
                if cmp.visible() then
                  cmp.select_next_item()
                else
                  fallback()
                end
              end
            '';
            };
          };
        };
        treesitter-context = {
          enable = true;
        };
        treesitter-refactor = {
          enable = true;
        };
        treesitter = {
          enable = true;
          folding = true;
          indent = true;
          nixGrammars = true;
        };
        bufferline = {
          enable = true;
          alwaysShowBufferline = true;
        };
      	lualine = {
          enable = true;
          alwaysDivideMiddle = true;
        };
        nix = {
          enable = true;
        };
        lsp = {
          enable = true;
          servers = {
            gdscript.enable = true;
            jsonls.enable = true;
            rnix-lsp.enable = true;
          };
        };
        lsp-lines = {
          enable = true;
        };
      };
    };

barbar: typo, "closeable" should be "closable"

Plugin affected: barbar
Nixpkgs channel: unstable
Home-manager version: 23.05-pre

Description

The docs for barbar specify that closable is the name for the config option that controls if tabs are closeable. However, in nixvim, the config option for this is listed as closeable.

I have opened a PR for the fix: #228

Error with treesitter plugin

Hi,
I'm getting the following error:

Line   65:
Parser dir ' /nix/store/vhlasav5vp7c83ck32gq6csf205i06gg-vim-pack-dir/pack/myNeovimPackages/start/nvim-treesitter/parser ' should be read/write (see README on how to configure an alternative install location) /nix/store/vhlasav5vp7c83ck32gq6csf205i06gg-vim-pack-dir/pack/myNeovimPackages/start/nvim-treesitter/parser '

My config is the following:

programs.nixvim = {
        enable = true;
        colorschemes.base16 = {
          enable = true;
          colorscheme = "gruvbox-dark-medium";
        };
        plugins.gitgutter = {
          enable = true;
        };
        plugins.lsp = {
          enable = true;
          servers.rnix-lsp.enable = true;
          servers.pyright.enable = true;
        };

        plugins.nix.enable = true;
        plugins.airline.enable = true;
        plugins.airline.powerline = true;
        plugins.treesitter.enable = true;
        plugins.nvim-autopairs.enable = true;
        plugins.undotree.enable = true;
        plugins.startify = {
          enable = true;
          useUnicode = true;
        };
        plugins.treesitter.ensureInstalled = [
          "bash"
          "cpp"
          "css"
          "go"
          "html"
          "java"
          "json"
          "latex"
          "lua"
          "make"
          "nix"
          "python"
          "regex"
          "rust"
          "yaml"
        ];
        options = {
          number = true; # Show line numbers
          shiftwidth = 2; # Tab width should be 2
          mouse = "a";
          tabstop = 2;
          expandtab = true;
          smarttab = true;
          autoindent = true;
          cindent = true;
          linebreak = true;
          hidden = true;
        };
        extraPlugins = with pkgs.vimPlugins; [
          vim-autoformat
        ];
        maps = {
          normal."<F3>" = ":Autoformat<CR>";
        };
      };

This happens on 88fb867 (current master)

Config isn't honored/loaded + config parsing issues

Nixpkgs channel: Version 22.11

Description

When using the nixos module and generating a config at /etc/nvim/sysinit.lua I would expect the settings to be honored when I open nvim.

However no settings are loaded when I open nvim.
If I directly open nvim with the config file via nvim -u /etc/nvim/sysinit.lua I do get lua parsing errors.

The first error is:

Error detected while processing /etc/nvim/sysinit.lua:
E5113: Error while calling lua chunk: /etc/nvim/sysinit.lua:10: invalid value for option
stack traceback:
        [C]: in function '__newindex'
        /etc/nvim/sysinit.lua:10: in main chunk

which seems to relate to commit hash 4ddd3969

If you change L10 from vim.o[k] = v to vim.opt[k] = v we make it pass this error.

The next error once we reload nvim with the fixed config is:

Error detected while processing /tmp/sysinit.lua:
E5113: Error while calling lua chunk: /tmp/sysinit.lua:61: module 'lspconfig' not found:
        no field package.preload['lspconfig']
        no file '/nix/store/xnxyn0bp80pf2jk58a72za679ajlcp32-luajit-2.1.0-2022-10-04-env/share/lua/5.1/lspconfig.lua'
        no file '/nix/store/xnxyn0bp80pf2jk58a72za679ajlcp32-luajit-2.1.0-2022-10-04-env/share/lua/5.1/lspconfig/init.lua'
        no file '/nix/store/xnxyn0bp80pf2jk58a72za679ajlcp32-luajit-2.1.0-2022-10-04-env/lib/lua/5.1/lspconfig.so'
stack traceback:
        [C]: in function 'require'
        /tmp/sysinit.lua:61: in main chunk

Which I assume is from not having access to the set of
plugins, vim runtime, etc in some manner.

Config

{ pkgs, config, ... }:

{
  programs = {
    nixvim = {
      enable = true;
      viAlias = true;
      vimAlias = true;
      options = {
        mouse = "a";
        termguicolors = true;
        background = "dark";
        ignorecase = true;
        swapfile = false;
        showmatch = true;
        hlsearch = true;
        wildmode = [ "longest" "list" ];
        expandtab = true;
        tabstop = 4;
        shiftwidth = 4;
      };
      extraConfigVim = ''
        set completeopt=menuone,noinsert,noselect
        set shortmess+=c
        set whichwrap+=<,>,h,l,[,]
        au BufRead,BufNewFile *.md setlocal textwidth=80
        au BufRead,BufNewFile *.yaml setlocal textwidth=80 shiftwidth=2 cc=80
        au BufRead,BufNewFile *.yml setlocal textwidth=80 shiftwidth=2 cc=80
        au BufRead,BufNewFile *.sls setlocal textwidth=80 shiftwidth=2 cc=80
        au BufRead,BufNewFile *.sh setlocal textwidth=80 shiftwidth=2 cc=80
        au BufRead,BufNewFile *.nix setlocal textwidth=80 shiftwidth=2 cc=80
        au BufRead,BufNewFile *.js setlocal textwidth=80 shiftwidth=2 cc=80
        au BufRead,BufNewFile *.ts setlocal textwidth=80 shiftwidth=2 cc=80
        au BufRead,BufNewFile *.lua setlocal textwidth=80 shiftwidth=2 cc=80                                                    
        au BufRead,BufNewFile *.py setlocal textwidth=80 shiftwidth=4 cc=88                                                     
        au BufRead,BufNewFile *.rs setlocal textwidth=80 shiftwidth=4 cc=80
        au BufRead,BufNewFile *.c setlocal textwidth=80 shiftwidth=4 cc=80
        au BufRead,BufNewFile *.go setlocal textwidth=80 shiftwidth=4 cc=80
        au BufWrite *.rs :Autoformat
        au BufWrite *.nix :Autoformat
      '';
      plugins = {
        lsp = {
          enable = true;
          servers = {
            rnix-lsp = { enable = true; };
            rust-analyzer = { enable = true; };
          };
        };
      };
    };
  };
}

Automatically infer extraPlugins used, if your config contains specific functions

Automatically infer extraPlugins, based on functions or commands used in config.

Introduction

When writing a large configuration for neovim, it might be hard to keep track of where you are using specific commands from plugins.
Let's say I want to use vim-bbye which provides the :Bdelete command, you may have specified that you use the command from multiple places (maybe bufferline, keymaps, etc.). It may then be hard to remember all the places that you are trying to use this plugin's commands, thus it will be harder to know when to removed a plugin, when you are no longer using it.

How could this change for the user?

The goal of this issue is to in some cases eliminate the need to put some plugins in the extraPlugins array, by automatically finding the dependencies (through some kind of command set).

For example if I wanted to use vim-bbye, I would not need to add it to extraPlugins if I am using it's commands from for example a bufferline plugin.

Solution

I am really not sure how this could be solved or if it is even feasible. However I really like the idea from a user perspective.

Idea 1

Being able to use some kind of imports in nix and use those instead of strings.

Before:

{
  plugins.bufferline =
    {
      closeCommand = "Bdelete %d";
    };
  extraPlugins = [ pkgs.vimPlugins.vim-bbye ];
}

after:

{
  plugins.bufferline =
    let
      Bdelete = import nixvim.commands.Bdelete;
    in
    {
      closeCommand = "${Bdelete} %d";
    };
}

However I don't really think this could work as imports don't have side effects and I don't think we can really trigger it in any way.


On the other side, we might be able to get around this if we restructure the way the config is built. I am thinking that the config would be built using strings and some other type for commands in a large array.

Or instead of using a large array, it may insert some special characters that we can then look for and replace with the actual command and then add the plugin.

Idea 2

I don't really like this idea and I believe it may not be feasible, but it might get something working without major restructuring.
After building the config, look through the entire config string for any occurence of a command and add the respective plugin.


I certainly believe this kind of functionality is possible and should be opt-in (which it is by design in idea 1).

I would really like some feedback for this issue, what do you think of the current ideas? Would there be a better way of doing it?

What do you think @pta2002 @GaetanLepage @traxys

nixvim.build seems not to exist, perhaps it was renamed to makeNixvim?

Plugin affected: N/A
Nixpkgs channel: N/A
Home-manager version: N/A

Description

In reading through the source code, it looks like at some point a function name may have been changed without totally updating the documentation. function nixvim.build may have been renamed to nixvim.makeNixvim on line 50 in file flake.nix

Trouble options

Plugin: Trouble
This plugin is already present, but would it be possible to expose autoOpen / autoClose or some sort of extraConfig?

Fails `nix flake check`

Nixpkgs channel: 22.05

Description

Running nix flake check --no-write-lock-file fails with the following error:

error: attribute 'helpers' missing

       at /nix/store/46v5hkwaa7aadrdn3gadlcx8ckrv3brj-source/lib/modules.nix:469:28:

          468|         builtins.addErrorContext (context name)
          469|           (args.${name} or config._module.args.${name})
             |                            ^
          470|       ) (lib.functionArgs f);
(use '--show-trace' to show detailed location information)

The same error is returned when running without --no-write-lock-file, however it updates flake.lock

NixVim improvents!

This serves as a tracking issue for all planned improvements to be made to NixVim.

Documentation

  • Better, per-module documentation
  • Documentation search
  • Document every option

Features

  • Support package option for every plugin (#58)
  • Support defining keybinds in every plugin
  • Support pinning treesitter versions (to fix bugs with the invalid nodes)
  • Support which-key - can use the maps option to automatically populate it
  • Support autocommands (initially, just extraConfigLua and extraConfigVim are fine, but I'd really like to be able to set per-plugin options for this eventually)
  • Use vim.keybind.set to define mappings
  • Allow lazy-loading of plugins (#421)
  • Have some form of in-editor documentation (e.g., a :NixVim command which shows a page showing currently enabled options and documentation)
  • Automated testing

bufferline: `diagnostics_indicator` expects a function

Plugin affected: bufferline
Nixpkgs channel: 22.05 (though this seems to persist into unstable)
Home-manager version: 22.05

Description

Error detected while processing /nix/store/z19xva0gra1bb071aj4lcbklm5fa8d0k-home-manager-files/.config/nvim/init.lua:

E5112: Error while creating lua chunk: ...j4lcbklm5fa8d0k-home-manager-files/.config/nvim/init.lua:81: unfinished str
ing near ''function(count, level)'

Relevant lines from init.lua:

require('bufferline').setup{['options'] = {['diagnostics'] = 'nvim_lsp',['diagnostics_indicator'] = 'function(count, level)
  local icon = level:match("error") and " " or ""
  return " " .. icon .. count
end
'}}

plugins.bufferline.diagnosticsIndicator seems to pass as a string to diagnostics_indicator, but the documentation indicates it should receive a function that returns a string

https://github.com/akinsho/bufferline.nvim/blob/d631817de1b52c7b1947e25ec8b7638492914768/doc/bufferline.txt#L259-L262

Config

{
  # ...
  plugins.bufferline = {
    enable = true;
    diagnostics = "nvim_lsp";
    diagnosticsIndicator = ''
      function(count, level)
        local icon = level:match("error") and " " or ""
        return " " .. icon .. count
      end
    '';
  };
  # ...
}

Add `package` options for plugins

It would be nice if I could change which version of a plugin to use (pinning or using unstable/stable) while using nixvim.

I would like to be able to do this in the same manner as in most NixOS modules in nixpkgs handles this, by adding a package option.

Support neovim 0.7 features

Neovim 0.7 has just come out, and there are a few features which would be a great fit for nixvim:

  • support for autocomands - now with a lua API, so it's way easier to support
  • support lua keybinds (use vim.keymap.set)
  • support highlight groups
  • support `filetype.lua

I plan to begin working on these in the following weeks - none of them should be particularly difficult

Enabling `tokyonight` triggers a startup error

Plugin affected: tokyonight

Description

Trying to build nixvim as a flake just to try it out, the default config with just the colorscheme set to tokyonight prints an error:

Error detected while processing /nix/store/mg2k27nxv61p40ld55hw9zd2kz23gqm2-init.lua:
E5113: Error while calling lua chunk: /nix/store/mg2k27nxv61p40ld55hw9zd2kz23gqm2-init.lua:17: Vim(colorscheme):E5113
: Error while calling lua chunk: ...imPackages/start/tokyonight.nvim/lua/tokyonight/util.lua:50: attempt to call meth
od 'lower' (a nil value)
stack traceback:
        ...imPackages/start/tokyonight.nvim/lua/tokyonight/util.lua:50: in function 'highlight'
        ...imPackages/start/tokyonight.nvim/lua/tokyonight/util.lua:95: in function 'syntax'
        ...imPackages/start/tokyonight.nvim/lua/tokyonight/util.lua:165: in function 'load'
        ...imPackages/start/tokyonight.nvim/lua/tokyonight/init.lua:12: in function 'load'
        ...mplugin-tokyonight.nvim-2022-09-07/colors/tokyonight.lua:1: in main chunk
        [C]: in function 'cmd'
        /nix/store/mg2k27nxv61p40ld55hw9zd2kz23gqm2-init.lua:17: in main chunk
stack traceback:
        [C]: in function 'cmd'
        /nix/store/mg2k27nxv61p40ld55hw9zd2kz23gqm2-init.lua:17: in main chunk

This is reproducible on both my macOS and Linux systems

Config

{
  description = "A very basic flake";

  inputs.nixvim.url = "github:pta2002/nixvim";
  inputs.flake-utils.url = "github:numtide/flake-utils";

  outputs = {
    self,
    nixpkgs,
    nixvim,
    flake-utils,
  }: let
    config = {
      colorschemes.tokyonight.enable = true;
    };
  in
    flake-utils.lib.eachDefaultSystem (system: let
	  nixvim' = nixvim.legacyPackages."${system}";
      nvim = nixvim'.makeNixvim config;
    in {
      packages = {
        inherit nvim;
        default = nvim;
      };
    });
}

Extract all available sources from null ls

null-ls has a large number of builtins, and it's going to be complicated to support all of them.

We could try and use the scripts they use to extract the documentation, and maybe use something like 'nix-index' in order to find the correct packages to use.

Set globals before plugin setup 🌠

With #25 hopefully soon getting merged there will be a need to set globals before the plugin setup.
An example from the nvim-cmp wiki: https://github.com/hrsh7th/nvim-cmp/wiki/Menu-Appearance#how-to-add-visual-studio-code-codicons-to-the-menu
Currently we cannot achieve this, since globals are set up after plugin setup.

solution 1 (best) ✅✅✅

Move the logic that sets globals before the plugin setups.
I think this would be the best solution as long as it won't break anything.

solution 2 ✅

Make a new option that lets the user set globals that will be set before plugin setups.

I can make a PR for any of the solutions if one of them are okay 🤓

Incorrect code being generated when LSP is enabled

-- LSP {{{
local __lspServers = {'rnix','rust_analyzer'}
local __lspOnAttach = function(client)

end
local __lspCapabilities = function

end

for i,server in ipairs(__lspServers) do
  if type(server) == "string" then
    require('lspconfig')[server].setup {
      on_attach = __lspOnAttach
      capabilities = __lspCapabilities
    }
  else
    require('lspconfig')[server.name].setup(server.extraOptions)
  end
end
-- }}}

here's all the generated code.

With this config:

plugins.lsp = {
  enable = true;
  servers = {
    rust-analyzer.enable = true;
    rnix-lsp.enable = true;
  };
};

Whenever I open vim it shows me this error, and doesn't load any of my lua config:

Error detected while processing /home/nix/.config/nvim/init.vim:
line  127:
E5107: Error loading lua [string ":lua"]:8: '(' expected near 'end'

Any help would be appreciated

Cheers

Set colorscheme after setting lua globals

Plugin affected: most colorschemes (specifically nord)
Nixpkgs channel: 22.05
Home-manager version: 22.05

Description

Before the large refactor, the nord color scheme worked fine. But now variables set has no effect.
For example setting borders and contrast on the nord colorscheme does nothing when neovim is started. since the colorscheme command is called before the globals has been set.

A fix was already made for this in #23 (https://github.com/pta2002/nixvim/pull/23/files#diff-224c83bb3598476e7aaabf84b7de2b5932e06057286163935b93f8db58e1a3acR211-R216)

It should be noted that the variables are set, since using the command :colorscheme nord after neovim starts will display the colorscheme with the variables defined in the config.

Config

{
...
    colorschemes.nord = {
      enable = true;
      borders = true;
      contrast = true;
    };
...
}

Better way to manage telescope extensions

Currently, telescope extensions are all inside of the telescope.nix file. That means this file will get bigger and bigger the more extensions we add to it.

I would suggest we use separate files for the extensions just like with the lsp plugins. Would that be a good idea?

Generate literal lua code as a dict value

Hello,
I need to generate some lua code as a dictionary value. The only way to represent that in nix code is through a string, but that's always made a string in the resulting lua code. The docs for the plugin I'm adding are here. Both fader and resizer have this problem

Any help would be appreciated

Cheers

Treesitter issues

Ideally, treesitter grammars should be installed through Nix, but even with the experimental nixGrammars setting, this isn't happening and for some reason it's downloading and managing the grammars by itself. This leads to issues when updating, because now the grammars were built for an older config and might not work anymore.

lsp-lines error

Attempting to use lsp-lines by enabling it results in a runtime error when you start neovim.

config:

plugins.lsp-lines.enable = true;

Error:

Error detected while processing /nix/store/x63x75izcri00gqir1r5ib1snmnhdj14-init.vim:
line  399:
E5108: Error executing lua [string ":lua"]:77: attempt to call field 'setup' (a nil value)
stack traceback:
        [string ":lua"]:77: in main chunk

It seems like require('lsp_lines') resolves to a nil value.

helpers: `toLuaObject` fails to escape strings containing `'`

Plugin affected: many
Nixpkgs channel: 22.05
Home-manager version: 22.05

Description

It looks like the issue is toLuaObject is using escapeShellArg, which doesn't properly handle escaping strings in this situation.

https://github.com/pta2002/nixvim/blob/c320be04c82914933fe94f64282e646d97d342d4/plugins/helpers.nix#L23-L25

When given the string "<cmd>lua require('gitsigns').blame_line{full=true}<cr>"
it outputs '<cmd>lua require('\''gitsigns'\'').blame_line{full=true}<cr>'

This results in the following error when starting Neovim:

Error detected while processing /nix/store/77xmlnk9bfjw7xd811rf8yipw0jkc2kv-home-manager-files/.config/nvim/init.lua:
E5112: Error while creating lua chunk: ...1rf8yipw0jkc2kv-home-manager-files/.config/nvim/init.lua:92: '}' expected near '\'

Config

{
  programs.nixvim.maps.normal."<leader>hb" = "<cmd>lua require('gitsigns').blame_line{full=true}<cr>";
}

No config generated on `nixpkgs-22.11` and `nix-darwin`

Nixpkgs channel: unstable

Hi! I am working on getting nix-darwin set up on my computer from a completely fresh install, and as part of that I want to use this awesome package to set up my nvim config. I am using flakes, so I have put nixvim in the outputs.

{
  inputs = {
    # nix-darwin stuff....
    
    nixvim.url = github:pta2002/nixvim;
  };

  outputs = { self, nixvim, ... }: {
    darwinConfigurations."myHostName" = darwin.lib.darwinSystem {
      system = "aarch64-darwin";
      modules = [
        nixvim.nixosModules.nixvim
        ./hosts/myHostName/default.nix
      ];
    };
  };
}

And in ./hosts/myHostName/default.nix, I have put

programs.nixvim = {
  enable = true;
  colorschemes.gruvbox.enable = true;
  options = {
    number = true;
    relativenumber = true;
  };
};

I can run darwin-rebuild switch --flake . perfectly fine without any errors, but when I look in ~/.config/ there is no nvim folder and when I run nvim, none of my settings are applied.

I am fairly new to the world of nix (I had been using home-manager for about half a year before now switching to a fresh nix-darwin with flakes), so I am almost certainly missing something obvious, but if someone could help me out that would be greatly appreciated.

If you would like to see my entire configuration, you can find it here: https://git.sr.ht/~gaetgu/maconfig/tree

Nixos Module Broken

Hi y'all. I'm not super experienced with Nix, so this may just be something that I don't quite understand, but I could not use this because I was getting errors along the lines of

> substituteStream(): WARNING: pattern 'Name=Neovim' doesn't match anything in file '/nix/store/mv12ajfnyndzdc1isj0kgmwdjm61n023-neovim-0.7.0/share/applications/nvim.desktop'
> /nix/store/zwrxbc3d1kzgnkqg0i0zn0fgakcw212a-hook/nix-support/setup-hook: line 110: /nix/store/fgicl65q7nz56jd5ngd5glsblgb1lq53-neovim-0.7.0/bin/nvim-python3: Permission denied

I Finally found this: https://discourse.nixos.org/t/help-needed-neovim-completions-fail-to-build/14223, and fixed the problem by setting package = pkgs.neovim-unwrapped. Shouldn't this be a default, if it doesn't work out-of-the-box? I don't entirely understand why this happens, though, so maybe I'm just mistaken.

Cannot set map options

When I try to change something in the maps option nix says the option does not exist.

My nixvim config:

maps = {
  normal."<leader>m" = {
    silent = true;
    action = "<cmd>make<CR>";
  };
};

the error message:

error: The option `home-manager.users.builditluc.programs.nixvim.maps.normal.<leader>m.action' does not exist. Definition values:
       - In `/Users/builditluc/.config/nixpkgs/home.nix': "<cmd>make<CR>"

       However there are no options defined in `home-manager.users.builditluc.programs.nixvim.maps.normal.<leader>m'. Are you sure you've
       declared your options properly? This can happen if you e.g. declared your options in `types.submodule'
       under `config' rather than `options'.

Usage with Nix-colors

I'm currently using nix-colors for managing my color schemes, and I have been trying to use the vim colorscheme function that nix-colors provides in order to use it. However, whenever I use it in my config for nixvim, I get the same error of error: colorscheme gruvbox-dark-hard not found. What do I need to do to fix this?

Support setting ftconfig

There should be a way to set config specific to certain filetypes using ftplugin files, for both performance and convenience. For examples for setting mappings that are only relevant on certain filetypes.

I am willing to implement it, but I'd like to discuss the design first, hence this issue.

The first challenge is how to organise the options, since mostly we want to pretty much duplicate all the options for filetype specific commands, so we would need to find a way to keep it both ergonomic to use but hopefully without too much nix wizardry.

The second one is that this feature is not supported by the neovim infrastructure in nixpkgs which this plugin is based on. One possible workaround would be to put it in functions in init.vim that are then autocalled. It would allow working on this on nixvim side while in parallel trying to extend things on the nixpkgs side.

commit `a38d531b` breaks configs that declare variables in pre and uses it in post.

Plugin affected: all?
Nixpkgs channel: 22.05

Description

commit a38d531 breaks my config. I am using the extraConfigLuaPre options, where I define some variables. In extraConfigLuaPost I am using those variables. But in the aforementioned commit it seems to break this funcitonality, since the lua part is now split in two.

I have tried to change my config, to use global variables (not sure if I am doing it correctly), but then I am having issues with my cmp mappings.

I can see why it was chosen to be separated into two different lua sections and I am not sure if we should do something about it.

Config

nixvim config

Ability for users to hook into the setup function's table

Some modules does not provide all options or when they are updated they need to be maintained to provide those options. This can be quite annoying in some instances and can maybe even force the user to rewrite their config in extraLuaConfig.
This is because there is no way the user can append anything to the setup object.

To deal with this problem we could make a new option for each module (e.g. extraSetupAttrs) which would be an attribute set that could easily be merged with other attribute sets before calling toLuaObject. However this could be a quite large task, so if you have any other suggestions, please comment them.

Treesitter - invalid node type

Plugin affected:
Treesitter
Nixpkgs channel:
Unstable
Home-manager version:
Unstable

Description

Some languages return "invalid node type" from treesitter, e.g. typescript. Others, though, work perfectly fine, and return no errors.

Trying to run treesitter with nixGrammars = false; returns read-only filesystem issues, and adding a custom parser directory causes treesitter to reinstall parsers every time nvim is started.

Config

nixvim.nix

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.