{"id":13682468,"url":"https://github.com/NixNeovim/NixNeovim","last_synced_at":"2025-04-30T09:32:45.554Z","repository":{"id":56780502,"uuid":"524374346","full_name":"NixNeovim/NixNeovim","owner":"NixNeovim","description":"Configure Neovim with Nix!","archived":false,"fork":false,"pushed_at":"2024-08-23T13:37:39.000Z","size":1318,"stargazers_count":124,"open_issues_count":9,"forks_count":16,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-08-23T15:11:52.771Z","etag":null,"topics":["neovim","nix","nixos","nixos-module","vim"],"latest_commit_sha":null,"homepage":"","language":"Nix","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"pta2002/nixvim","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NixNeovim.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-08-13T11:03:23.000Z","updated_at":"2024-08-23T13:37:42.000Z","dependencies_parsed_at":"2024-02-26T18:28:56.737Z","dependency_job_id":"143756f4-a7a2-4f68-a4ae-7614860e2fda","html_url":"https://github.com/NixNeovim/NixNeovim","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NixNeovim%2FNixNeovim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NixNeovim%2FNixNeovim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NixNeovim%2FNixNeovim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NixNeovim%2FNixNeovim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NixNeovim","download_url":"https://codeload.github.com/NixNeovim/NixNeovim/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224206079,"owners_count":17273384,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["neovim","nix","nixos","nixos-module","vim"],"created_at":"2024-08-02T13:01:46.461Z","updated_at":"2024-11-12T02:30:48.537Z","avatar_url":"https://github.com/NixNeovim.png","language":"Nix","funding_links":["https://www.buymeacoffee.com/jooooscha"],"categories":["Nix","Editors and IDEs"],"sub_categories":[],"readme":"\n# NixNeovim - A Neovim configuration module for NixOS\n\nThis flake provides modules for NixOS and Home Manager, which provide the `nixneovim` configuration options.\nUsing `nixneovim`, you can configure Neovim, including plugins, through nix.\nThis makes your Neovim config reproducible, and easier to manage.\n\n#### Forked\n\nThis was originally based on [pta2002/nixvim](https://github.com/pta2002/nixvim).\nHowever, today, it shares very little code, approaches problems very differently, and is completely independent.\n\n## Get Ready\n\nTo use the modules, add this flake to the inputs of your nix configuration.\n\n```nix\ninputs.nixneovim.url = \"github:nixneovim/nixneovim\";\n```\n\nThen, apply the overlay and import the modules.\nThis is needed, because NixNeovim uses [NixNeovimPlugins](https://github.com/NixNeovim/NixNeovimPlugins) to get access to more Neovim plugins.\n\n```nix\n{\nnixpkgs.overlays = [\n    nixneovim.overlays.default\n];\n}\n```\n\nAnd import the module to your Home Manager (recommended) or NixOS configuration.\nDepending on your nixos version, you have to import different modules.\nIn particular, the `default` and `homeManager` modules only work with the Nixpkgs/HomeManager `unstable` releases.\nWhen you use Nixos/HomeManager XX.XX, please import `homeManager-XX-XX` or `nixos-XX-XX`.\n\nFor example, when using Home Manager please use:\n```nix\nhome-manager = {\n  users.\u003cuser\u003e = {\n    imports = [\n      nixneovim.nixosModules.default # with Home Manager unstable\n      # nixneovim.nixosModules.homeManager-XX-XX # with Home Manager XX.XX\n    ];\n    programs.nixneovim.enable = true;.\n  };\n};\n```\nand when you do not use Home Manager please use:\n```nix\nimports = [\n    nixneovim.nixosModules.default # with Home Manager unstable\n    # nixneovim.nixosModules.homeManager-22-11 # with Home Manager 22.11\n    # nixneovim.nixosModules.nixos # without Home Manager\n];\n}\n```\n\n## Documentation\n\nAll options are documented at: [NixNeovim Documentation](https://nixneovim.github.io/NixNeovim/options.html).\nAlternatively, you can use this search: [NixNeovim Options Search](https://nixneovim.github.io/nixneovim-option-search/).\n\nFinally, you can generate the docs using `nix build .#docs`.\n\n## Example Config\n\nImporting the modules gives you access to the `programs.nixneovim` config.\nA wiki for all options will be available in the near future.\n\n```nix\n{\n  programs.nixneovim = {\n    enable = true;\n    extraConfigVim = ''\n      # you can add your old config to make the switch easier\n      ${lib.strings.fileContents ./init.vim}\n      # or with lua\n      lua \u003c\u003c EOF\n        ${lib.strings.fileContents ./init.lua}\n      EOF\n    '';\n    \n    # to install plugins just activate their modules\n    plugins = {\n      lspconfig = {\n        enable = true;\n        servers = {\n          hls.enable = true;\n          rust-analyzer.enable = true;\n        };\n      };\n      treesitter = {\n        enable = true;\n        indent = true;\n      };\n      mini = {\n        enable = true;\n        ai.enable = true;\n        jump.enable = true;\n      };\n    };\n\n    # Not all plugins have own modules\n    # You can add missing plugins here\n    # `pkgs.vimExtraPlugins` is added by the overlay you added at the beginning\n    # For a list of available plugins, look here: [available plugins](https://github.com/NixNeovim/NixNeovimPlugins/blob/main/plugins.md)\n    extraPlugins = [ pkgs.vimExtraPlugins.\u003cplugin\u003e ];\n  };\n}\n```\n\n### Reduce size of `init.lua`\n\nWarning: Using this is currently discouraged as it can cause build failures. I am working on it.\n\nBy default, NixNeovim prints all config to `init.lua` in order to have a more stable config.\nYou can turn this off by setting `nixneovim.usePluginDefaults`.\nThis way, NixNeovim will only print the configs you have changed.\n\nSetting `nixneovim.usePluginDefaults` to `true` reduces the size of your `init.lua` but can lead to unexpected changes of your setup,\nwhen a plugin author decides to change their defaults.\n\n## Key mappings\n\nYou can define your key mappings using the `mappings` option.\n\n```nix\n{\n  programs.nixneovim = {\n    mappings = {\n      normalVisualOp = {\n        \";\" = \"':'\"; # vimscript between ' '\n      };\n      normal = {\n        \"\u003cleader\u003em\" = {\n          action = \"'\u003ccmd\u003emake\u003ccr\u003e'\"; # vimscript between ' '\n          silent = true;\n        };\n        \"\u003cleader\u003eh\" = \"function() print(\\\"hi\\\") end\"; # Lua code without ' '\n      };\n    };\n  };\n}\n```\n\nThis uses `vim.keymap.set` under the hood.\nTherefore, you can specify lua functions directly.\nHowever, this also means, when writing vimscript, you have to put that between extra quotation marks.\n\nThis is equivalent to:\n\n```lua\nvim.keymap.set(\"\", \";\", ':')\nvim.keymap.set(\"n\", \"\u003cleader\u003em\", '\u003ccmd\u003emake\u003ccr\u003e', { silent = true })\nvim.keymap.set(\"n\", \"\u003cleader\u003eh\", function() print(\"hi\") end)\n```\n\nFirst, you specify the mode; you can choose between the keywords below.\n\n| NixNeovim      | Neovim | Description                                  |\n|----------------|--------|----------------------------------------------|\n| normalVisualOp | \"\"     | Normal, visual, select, and operator-pending |\n| normal         | \"n\"    | Normal                                       |\n| insertCommand  | \"!\"    | Insert and command-line                      |\n| insert         | \"i\"    | Insert                                       |\n| command        | \"c\"    | Command-line                                 |\n| visual         | \"v\"    | Visual and Select                            |\n| visualOnly     | \"x\"    | Visual                                       |\n| select         | \"s\"    | Select                                       |\n| operator       | \"o\"    | Operator-pending                             |\n| terminal       | \"t\"    | Terminal                                     |\n| lang           | \"l\"    | Insert, command-line, and lang-arg           |\n\nWhen specifying the mapping with an attribute set you can set the following options.\n\n| NixNeovim | Default | VimScript                                |\n|-----------|---------|------------------------------------------|\n| silent    | false   | `\u003csilent\u003e`                               |\n| nowait    | false   | `\u003csilent\u003e`                               |\n| script    | false   | `\u003cscript\u003e`                               |\n| expr      | false   | `\u003cexpr\u003e`                                 |\n| unique    | false   | `\u003cunique\u003e`                               |\n| noremap   | true    | Use the 'noremap' variant of the mapping |\n| action    |         | Action to execute                        |\n\n## Augroups\n\nYou can define augroups with the `augroups` option.\n\n```nix\n{\n  programs.nixneovim = {\n    augroups = {\n      highlightOnYank = {\n        autocmds = [{\n          event = \"TextYankPost\";\n          pattern = \"*\";\n          # Or use `vimCallback` with a vimscript function name\n          # Or use `command` if you want to run a normal vimscript command\n          luaCallback = ''\n            vim.highlight.on_yank {\n              higroup = (\n                vim.fn['hlexists'] 'HighlightedyankRegion' \u003e 0 and 'HighlightedyankRegion' or 'IncSearch'\n              ),\n              timeout = 200,\n            }\n          '';\n        }];\n      };\n    };\n  };\n}\n```\n\n### Supported language servers\n\nUntil we find a better way of documenting this, you can find a list of supported language servers here: [servers.nix](./src/plugins/_lspconfig-modules/servers.nix)\n\n## Contribution\n\nContributions are very welcome.\nThey help improve this project and keep it up to date.\n\n### Adding a module\n\n- Look at the automatically generated issues. Those are plugins available in the original repo, but not yet in this. Start with those, if you like\n- Copy `plugin_template.nix` or `plugin_template_minimal.nix`\n- Add the following information:\n    - `name`\n    - `pluginUrl`\n    - `moduleOptions`\n    - `extraPlugins`\n- If not otherwise specified, `mkLuaPlugin` will add the following string to `init.vim`:\n    - `extraConfigLua = \"require('${name}').setup ${toLuaObject pluginOptions}\";`\n    - This can be disabled with `defaultRequire = false`\n\n### Adding options to a module\n\n- When using the `plugin_template.nix` you add options to the `moduleOptions` attribute set.\n\n```nix\n{\n  moduleOptions = with helpers; {\n    mappings = mkOption {\n      type = types.attrs;\n      default = { };\n    };\n    enableAuto = boolOption false \"Enable auto expanding snippets\";\n  };\n}\n```\n\n- In `helper/custom_options.nix` we have defined several functions for basic plugin options like bool, strings or integer.\n- In particular, ther are:\n    - `boolOption, intOption, strOption, attrsOption, enumOption`\n\n#### Auto generate module options\n\n⚠️ This is script is under active development and is heavily changed and exented in [this PR](https://github.com/NixNeovim/NixNeovim/pull/80). Please be careful ⚠️\n\n- With `nix run .#configparser` you can convert a Lua setup configs to nix module options (you might need to update the submodule with `git submodule update tree-sitter-lua`).\n- For example, you can input the following Lua configs (taken from [NvimTree](https://github.com/nvim-tree/nvim-tree.lua); Example-comment added)\n\n```zsh\nnix run .#configparser \u003c\u003cEOF\nrequire(\"nvim-tree\").setup({\n  sort_by = \"case_sensitive\",\n  view = {\n    -- Example comment\n    width = 30,\n  },\n  renderer = {\n    group_empty = true,\n  },\n  filters = {\n    dotfiles = true,\n  },\n})\nEOF\n```\n\n- The output will be\n\n```nix\n {\n   sort_by = strOption \"case_sensitive\" \"\";\n   view = {\n     # Example comment\n     width = intOption 30 \"Example comment\";\n   };\n   renderer = {\n     group_empty = boolOption true \"\";\n   };\n   filters = {\n     dotfiles = boolOption true \"\";\n   };\n }\n```\n\nThe output is best-effort and will likely contain errors.\nFor example, the script cannot detect if a variable is a string or an `enum`.\nTherefore, you likely have to edit and correct the output before you add it to the module.\n\n## Options\n\n```nix\n{\n  programs.nixneovim = {\n    options = {\n      number = true;         # Show line numbers\n      relativenumber = true; # Show relative line numbers\n\n      shiftwidth = 2;        # Tab width should be 2\n    };\n  };\n}\n```\n\nPlease note that to, for example, disable numbers you would not set\n`options.nonumber` to true, you'd set `options.number` to false.\n\n## Globals\n\nSometimes you might want to define a global variable, for example to set the\nleader key. This is easy with the `globals` attribute:\n\n```nix\n{\n  programs.nixvim = {\n    globals.mapleader = \",\"; # Sets the leader key to comma\n  };\n}\n```\n\n## Support me personally\n\n\u003ca href=\"https://www.buymeacoffee.com/jooooscha\" target=\"_blank\"\u003e\u003cimg src=\"https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png\" alt=\"Buy Me A Coffee\" style=\"height: 60px !important;width: 217px !important;\" \u003e\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FNixNeovim%2FNixNeovim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FNixNeovim%2FNixNeovim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FNixNeovim%2FNixNeovim/lists"}