Merge branch 'main' into add-package-option

This commit is contained in:
Alexander Nortung 2023-01-16 21:20:06 +01:00
commit b381c38113
74 changed files with 2083 additions and 713 deletions

View file

@ -56,4 +56,4 @@ workflows:
- build-docs
filters:
branches:
only: main
only: main

View file

@ -22,7 +22,10 @@ lightline plugin:
When we do this, lightline will be set up to a sensible default, and will use
gruvbox as the colorscheme, no extra configuration required!
## Instalation
## Support/Questions
If you have any question, please use the [discussions page](https://github.com/pta2002/nixvim/discussions/categories/q-a)! Alternatively, join the Matrix channel at [#nixvim:matrix.org](https://matrix.to/#/#nixvim:matrix.org)!
## Installation
### Without flakes
NixVim now ships with `flake-compat`, which makes it usable from any system.
@ -37,9 +40,12 @@ let
in
{
imports = [
# For home-manager
nixvim.homeManagerModules.nixvim
# Or, if you're not using home-manager:
# For NixOS
nixvim.nixosModules.nixvim
# For nix-darwin
nixvim.nixDarwinModules.nixvim
];
programs.nixvim.enable = true;
@ -72,28 +78,78 @@ flakes, just add the nixvim input:
```
You can now access the module using `inputs.nixvim.homeManagerModules.nixvim`,
for a home-manager instalation, and `inputs.nixvim.nixosModules.nixvim`, if
you're not using it.
for a home-manager installation, `inputs.nixvim.nixosModules.nixvim`, for NixOS,
and `inputs.nixvim.nixDarwinModules.nixvim` for nix-darwin.
## Usage
NixVim can be used in three ways: through the home-manager and NixOS modules,
and through the `build` function. To use the modules, just import the
`nixvim.homeManagerModules.${system}.nixvim` and
`nixvim.nixosModules.${system}.nixvim` modules, depending on which system
NixVim can be used in four ways: through the home-manager, nix-darwin, and NixOS modules,
and through the `makeNixvim` function. To use the modules, just import the
`nixvim.homeManagerModules.nixvim`, `nixvim.nixDarwinModules.nixvim`, and
`nixvim.nixosModules.nixvim` modules, depending on which system
you're using.
If you want to use it standalone, you can use the `build` function:
If you want to use it standalone, you can use the `makeNixvim` function:
```nix
{ pkgs, nixvim, ... }: {
environment.systemModules = [
(nixvim.build pkgs {
(nixvim.legacyPackages."${system}".makeNixvim {
colorschemes.gruvbox.enable = true;
})
];
}
```
Alternatively if you want a minimal flake to allow building a custom neovim you
can use the following:
```nix
{
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.gruvbox.enable = true;
};
in
flake-utils.lib.eachDefaultSystem (system: let
nixvim' = nixvim.legacyPackages."${system}";
nvim = nixvim'.makeNixvim config;
in {
packages = {
inherit nvim;
default = nvim;
};
});
}
```
You can then run neovim using `nix run .# -- <file>`. This can be useful to test
config changes easily.
### Advanced Usage
You may want more control over the nixvim modules like:
- Splitting your configuration in multiple files
- Adding custom nix modules to enhance nixvim
- Change the nixpkgs used by nixvim
In this case you can use the `makeNixvimWithModule` function.
It takes a set with the following keys:
- `pkgs`: The nixpkgs to use (defaults to the nixpkgs pointed at by the nixvim flake)
- `module`: The nix module definition used to extend nixvim.
This is useful to pass additional module machinery like `options` or `imports`.
## How does it work?
When you build the module (probably using home-manager), it will install all
your plugins and generate a lua config for NeoVim with all the options
@ -104,8 +160,8 @@ Since everything is disabled by default, it will be as snappy as you want it to
be.
# Documentation
Documentation is very much a work-in-progress. It will become available on this
repository's Wiki.
Documentation is available on this project's GitHub Pages page:
[https://pta2002.github.io/nixvim](https://pta2002.github.io/nixvim)
## Plugins
After you have installed NixVim, you will no doubt want to enable some plugins.

35
docs.nix Normal file
View file

@ -0,0 +1,35 @@
{ pkgs, lib, modules, ... }:
let
options = lib.evalModules {
modules = modules;
specialArgs = { inherit pkgs lib; };
};
docs = pkgs.nixosOptionsDoc {
# If we don't do this, we end up with _module.args on the generated options, which we do not want
options = lib.filterAttrs (k: _: k != "_module") options.options;
warningsAreErrors = false;
};
asciidoc = docs.optionsAsciiDoc;
in
pkgs.stdenv.mkDerivation {
name = "nixvim-docs";
src = asciidoc;
buildInputs = [
pkgs.asciidoctor
];
phases = [ "buildPhase" ];
buildPhase = ''
mkdir -p $out/share/doc
cat <<EOF > header.adoc
= NixVim options
This lists all the options available for NixVim.
:toc:
EOF
cat header.adoc $src > tmp.adoc
asciidoctor tmp.adoc -o $out/share/doc/index.html
'';
}

View file

@ -1,48 +0,0 @@
{ pkgs ? import <nixpkgs> { }
, lib ? import <nixpkgs/lib>
, nmdSrc
, nixvimModules ? [ ]
, ...
}:
let
nmd = import nmdSrc { inherit pkgs lib; };
scrubbedPkgsModule = {
imports = [{
_module.args = {
pkgs = lib.mkForce (nmd.scrubDerivations "pkgs" pkgs);
pkgs_i686 = lib.mkForce { };
};
}];
};
buildModulesDocs = args:
nmd.buildModulesDocs ({
moduleRootPaths = [ ./.. ];
mkModuleUrl = path:
"https://github.com/pta2002/nixvim/blob/main/${path}#blob-path";
channelName = "nixvim";
} // args);
nixvimDocs = buildModulesDocs {
modules = [
scrubbedPkgsModule
] ++ nixvimModules;
docBook.id = "nixvim-options";
};
docs = nmd.buildDocBookDocs {
pathName = "";
modulesDocs = [ nixvimDocs ];
documentsDirectory = ./.;
documentType = "book";
chunkToc = ''
<toc>
<d:tocentry xmlns:d="http://docbook.org/ns/docbook" linkend="book-nixvim-manual"><?dbhtml filename="index.html"?>
<d:tocentry linkend="ch-options"><?dbhtml filename="options.html"?></d:tocentry>
<d:tocentry linkend="ch-release-notes"><?dbhtml filename="release-notes.html"?></d:tocentry>
</d:tocentry>
</toc>
'';
};
in
# TODO: Parse this json or something, since docbook isn't working (and it's kind of terrible anyway)
nixvimDocs.json

View file

@ -1,27 +0,0 @@
<refentry xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xi="http://www.w3.org/2001/XInclude">
<refmeta>
<refentrytitle><filename>nixvim.nix</filename></refentrytitle>
<manvolnum>5</manvolnum>
<refmiscinfo class="source">NixVim</refmiscinfo>
<!-- <refmiscinfo class="version"><xi:include href="version.txt" parse="text"/></refmiscinfo> -->
</refmeta>
<refnamediv>
<refname><filename>nixvim.nix</filename></refname>
<refpurpose>NixVim configuration specification</refpurpose>
</refnamediv>
<refsection>
<title>Description</title>
<para>
TODO
</para>
</refsection>
<refsection>
<title>Options</title>
<para>
You can use the following options in your nixvim config
</para>
<xi:include href="./nmd-result/nixvim-options.xml" />
</refsection>
</refentry>

View file

@ -1,11 +0,0 @@
<reference xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xi="http://www.w3.org/2001/XInclude">
<title>NixVim Reference Pages</title>
<info>
<author><personname>NixVim contributors</personname></author>
<copyright><year>2021-2022</year><holder>NixVim contributors</holder>
</copyright>
</info>
<xi:include href="man-nixvim.xml" />
</reference>

View file

@ -1,23 +0,0 @@
<book xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xi="http://www.w3.org/2001/XInclude"
version="5.0"
xml:id="book-home-manager-manual">
<info>
<title>NixVim Manual</title>
</info>
<preface>
<title>Preface</title>
<para>
This manual is meant to serve as the ultimate reference for how to use and install NixVim.
</para>
<para>
If you have any issues, questions, or plugin suggestions please open an issue on the
<link xlink:href="https://github.com/pta2002/nixvim">NixVim GitHub</link>
</para>
</preface>
<appendix xml:id="ch-options">
<title>Configuration Options</title>
<xi:include href="./nmd-result/nixvim-options.xml" />
</appendix>
</book>

View file

@ -1,29 +0,0 @@
# List of plugins for NixVim
## Colorschemes
### Gruvbox
Just set `enable` to use the colorscheme.
```nix
programs.nixvim.colorscheme.gruvbox.enable = true;
```
## Status lines
### Lightline
Lightline is a small and customizable status line for vim. It can be enabled
with `programs.nixvim.plugins.lightline.enable`, and it will try to use the
colorscheme set by the user. If you want to manually override this, set
`programs.nixvim.plugins.lightline.colorscheme` to the name of the colorscheme
to use.
```nix
programs.nixvim.plugins.lightline = {
enable = true; # Enable this plugin
# This can be set to null to reset. Defaults to global colorscheme
colorscheme = "wombat";
# ...
};
```

View file

@ -1,155 +0,0 @@
# base16
Base16 is a set of colorschemes, so it comes with several themes you can choose from:
- 3024
- apathy
- ashes
- atelier-cave-light
- atelier-cave
- atelier-dune-light
- atelier-dune
- atelier-estuary-light
- atelier-estuary
- atelier-forest-light
- atelier-forest
- atelier-heath-light
- atelier-heath
- atelier-lakeside-light
- atelier-lakeside
- atelier-plateau-light
- atelier-plateau
- atelier-savanna-light
- atelier-savanna
- atelier-seaside-light
- atelier-seaside
- atelier-sulphurpool-light
- atelier-sulphurpool
- atlas
- bespin
- black-metal-bathory
- black-metal-burzum
- black-metal-dark-funeral
- black-metal-gorgoroth
- black-metal-immortal
- black-metal-khold
- black-metal-marduk
- black-metal-mayhem
- black-metal-nile
- black-metal-venom
- black-metal
- brewer
- bright
- brogrammer
- brushtrees-dark
- brushtrees
- chalk
- circus
- classic-dark
- classic-light
- codeschool
- cupcake
- cupertino
- darktooth
- default-dark
- default-light
- dracula
- eighties
- embers
- flat
- fruit-soda
- github
- google-dark
- google-light
- grayscale-dark
- grayscale-light
- greenscreen
- gruvbox-dark-hard
- gruvbox-dark-medium
- gruvbox-dark-pale
- gruvbox-dark-soft
- gruvbox-light-hard
- gruvbox-light-medium
- gruvbox-light-soft
- harmonic-dark
- harmonic-light
- heetch-light
- heetch
- helios
- hopscotch
- horizon-dark
- ia-dark
- ia-light
- icy
- irblack
- isotope
- macintosh
- marrakesh
- material-darker
- material-lighter
- material-palenight
- material
- material-vivid
- materia
- mellow-purple
- mexico-light
- mocha
- monokai
- nord
- oceanicnext
- ocean
- onedark
- one-light
- outrun-dark
- papercolor-dark
- papercolor-light
- paraiso
- phd
- pico
- pop
- porple
- railscasts
- rebecca
- seti
- shapeshifter
- snazzy
- solarflare
- solarized-dark
- solarized-light
- spacemacs
- summerfruit-dark
- summerfruit-light
- synth-midnight-dark
- tomorrow-night-eighties
- tomorrow-night
- tomorrow
- tube
- twilight
- unikitty-dark
- unikitty-light
- woodland
- xcode-dusk
- zenburn
More information can be found on the official base16 website, [here](http://chriskempson.com/projects/base16/).
## Options
### `colorschemes.base16.enable`
**Description**: Enables base16
**Type**: `bool`
### `colorschemes.base16.useTruecolor`
**Description**: Whether to use truecolor for the colorschemes. If set to
false, you'll need to set up base16 in your shell.
**Type**: `bool`
**Default**: `true`
### `colorschemes.base16.setUpBar`
**Description**: Whether to install the matching plugin for your statusbar. This does nothing as of yet, waiting for upstream support.
**Type**: `bool`
**Default**: `true`

View file

@ -1,144 +0,0 @@
# gruvbox
This plugin sets up the `gruvbox` colorscheme.
## Options
### `colorschemes.gruvbox.enable`
**Description**: Enable gruvbox
**Type**: `bool`
### `colorschemes.gruvbox.italics`
**Description**: Enable italics
**Type**: `bool`
### `colorschemes.gruvbox.bold`
**Description**: Enable bold
**Type**: `bool`
### `colorschemes.gruvbox.underline`
**Description**: Enable underlined text
**Type**: `bool`
### `colorschemes.gruvbox.undercurl`
**Description**: Enable undercurled text
**Type**: `bool`
### `colorschemes.gruvbox.contrastDark`
**Description**: Contrast for the dark mode
**Type**: `nullOr (enum [ "soft" "medium" "hard" ])`
**Default**: `null`
### `colorschemes.gruvbox.contrastLight`
**Type**: `nullOr (enum [ "soft" "medium" "hard" ])`
**Default**: `null`
**Description**: "Contrast for the light mode";
### `colorschemes.gruvbox.highlightSearchCursor`
**Type**: `nullOr colors`
**Default**: `null`
**Description**: "The cursor background while search is highlighted";
### `colorschemes.gruvbox.numberColumn`
**Description**: The number column background
**Type**: `nullOr colors`
**Default**: `null`
### `colorschemes.gruvbox.signColumn`
**Description**: "The sign column background";
**Type**: `nullOr colors`
**Default**: `null`
### `colorschemes.gruvbox.colorColumn`
**Description**: "The color column background";
**Type**: `nullOr colors`
**Default**: `null`
### `colorschemes.gruvbox.vertSplitColor`
**Description**: "The vertical split background color";
**Type**: `nullOr colors`
**Default**: `null`
### `colorschemes.gruvbox.italicizeComments`
**Description**: "Italicize comments";
**Type**: `bool`
**Default**: `true`
### `colorschemes.gruvbox.italicizeStrings`
**Description**: "Italicize strings";
**Type**: `bool`
**Default**: `false`
### `colorschemes.gruvbox.invertSelection`
**Description**: "Invert the select text";
**Type**: `bool`
**Default**: `true`
### `colorschemes.gruvbox.invertSigns`
**Description**: "Invert GitGutter and Syntastic signs";
**Type**: `bool`
**Default**: `false`
### `colorschemes.gruvbox.invertIndentGuides`
**Description**: "Invert indent guides";
**Type**: `bool`
**Default**: `false`
### `colorschemes.gruvbox.invertTabline`
**Description**: "Invert tabline highlights";
**Type**: `bool`
**Default**: `false`
### `colorschemes.gruvbox.improvedStrings`
**Description**: "Improved strings";
**Type**: `bool`
**Default**: `false`
### `colorschemes.gruvbox.improvedWarnings`
**Description**: "Improved warnings";
**Type**: `bool`
**Default**: `false`
### `colorschemes.gruvbox.transparentBg`
**Description**: Transparent background
**Type**: `bool`
### `colorschemes.gruvbox.trueColor`
**Description**: Enable true color support
**Type**: `bool`

View file

@ -1,6 +0,0 @@
# vim-one
## Options
### `colorschemes.one.enable`
**Description**: Enable vim-one
**Type**: `bool`

View file

@ -1,6 +0,0 @@
# onedark
## Options
### `colorschemes.onedark.enable`
**Description**: Enable onedark
**Type**: `bool`

View file

@ -1,70 +0,0 @@
# tokyonight
This plugin sets up the `tokyonight` colorscheme.
## Options
### `colorschemes.tokyonight.enable`
**Description**: Enable tokyonight
**Type***: `bool`
### `colorschemes.tokyonight.style`
**Description**: Theme style
**Type**: `nullOr (enum [ "storm" "night" "day" ])`
**Default**: `null`
### `colorschemes.tokyonight.terminalColors`
**Description**: Configure the colors used when opening a `:terminal` in Neovim
**Type**: `bool`
### `colorschemes.tokyonight.italicComments`
**Description**: Make comments italic
**Type**: `bool`
### `colorschemes.tokyonight.italicKeywords`
**Description**: Make keywords italic
**Type**: `bool`
### `colorschemes.tokyonight.italicFunctions`
**Description**: Make functions italic
**Type**: `bool`
### `colorschemes.tokyonight.italicVariables`
**Description**: Make variables and identifiers italic
**Type**: `bool`
### `colorschemes.tokyonight.transparent`
**Description**: Enable this to disable setting the background color
**Type**: `bool`
### `colorschemes.tokyonight.hideInactiveStatusline`
**Description**: Enabling this option will hide inactive statuslines and replace them with a thin border
**Type**: `bool`
### `colorschemes.tokyonight.transparentSidebar`
**Description**: Sidebar like windows like NvimTree get a transparent background
**Type**: `bool`
### `colorschemes.tokyonight.darkSidebar`
**Description**: Sidebar like windows like NvimTree get a darker background
**Type**: `bool`
### `colorschemes.tokyonight.darkFloat`
**Description**: Float windows like the lsp diagnostic windows get a darker background
**Type**: `bool`
### `colorschemes.tokyonight.lualineBold`
**Description**: When true, section headers in the lualine theme will be bold
**Type**: `bool`

View file

@ -1,7 +1,7 @@
{ pkgs, ... }:
{
programs.nixvim = {
# This just enables NixVim.
# This just enables NixVim.
# If all you have is this, then there will be little visible difference
# when compared to just installing NeoVim.
enable = true;

78
flake.lock generated
View file

@ -1,12 +1,34 @@
{
"nodes": {
"beautysh": {
"inputs": {
"nixpkgs": [
"nixpkgs"
],
"poetry2nix": "poetry2nix",
"utils": "utils"
},
"locked": {
"lastModified": 1669854260,
"narHash": "sha256-Z8NAL3g4i5LAhxveNGJhrVDHxIBbUf1lVIy/Thr2RMU=",
"owner": "lovesegfault",
"repo": "beautysh",
"rev": "d616eb8d9d05ee4fb33de9c5521d99c3f0695d52",
"type": "github"
},
"original": {
"owner": "lovesegfault",
"repo": "beautysh",
"type": "github"
}
},
"flake-utils": {
"locked": {
"lastModified": 1659877975,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github"
},
"original": {
@ -29,27 +51,51 @@
"type": "indirect"
}
},
"nmdSrc": {
"flake": false,
"poetry2nix": {
"inputs": {
"flake-utils": [
"beautysh",
"utils"
],
"nixpkgs": [
"beautysh",
"nixpkgs"
]
},
"locked": {
"lastModified": 1654807200,
"narHash": "sha256-RNLq09vfj21TyYuUCeD6BNTNC6Ew8bLhQULZytN4Xx8=",
"owner": "rycee",
"repo": "nmd",
"rev": "91dee681dd1c478d6040a00835d73c0f4a4c5c29",
"type": "gitlab"
"lastModified": 1658665240,
"narHash": "sha256-/wkx7D7enyBPRjIkK0w7QxLQhzEkb3UxNQnjyc3FTUI=",
"owner": "nix-community",
"repo": "poetry2nix",
"rev": "8b8edc85d24661d5a6d0d71d6a7011f3e699780f",
"type": "github"
},
"original": {
"owner": "rycee",
"repo": "nmd",
"type": "gitlab"
"owner": "nix-community",
"repo": "poetry2nix",
"type": "github"
}
},
"root": {
"inputs": {
"beautysh": "beautysh",
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs",
"nmdSrc": "nmdSrc"
"nixpkgs": "nixpkgs"
}
},
"utils": {
"locked": {
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
}
},

View file

@ -3,10 +3,10 @@
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.nmdSrc.url = "gitlab:rycee/nmd";
inputs.nmdSrc.flake = false;
inputs.beautysh.url = "github:lovesegfault/beautysh";
inputs.beautysh.inputs.nixpkgs.follows = "nixpkgs";
outputs = { self, nixpkgs, nmdSrc, flake-utils, ... }@inputs:
outputs = { self, nixpkgs, flake-utils, ... }@inputs:
with nixpkgs.lib;
with builtins;
let
@ -22,11 +22,12 @@
pkgs = mkForce pkgs;
inherit (pkgs) lib;
helpers = import ./plugins/helpers.nix { inherit (pkgs) lib; };
inputs = inputs;
};
};
})
./plugins/default.nix
# ./plugins/default.nix
];
flakeOutput =
@ -36,18 +37,22 @@
pkgs = import nixpkgs { inherit system; };
in
{
packages.docs = import ./docs {
pkgs = import nixpkgs { inherit system; };
lib = nixpkgs.lib;
nixvimModules = nixvimModules;
inherit nmdSrc;
packages.docs = pkgs.callPackage (import ./docs.nix) {
modules = nixvimModules;
};
legacyPackages = rec {
makeNixvimWithModule = import ./wrappers/standalone.nix pkgs modules;
makeNixvim = configuration: makeNixvimWithModule {
module = {
config = configuration;
};
};
};
legacyPackages.makeNixvim = import ./wrappers/standalone.nix pkgs (modules pkgs);
});
in
flakeOutput // {
nixosModules.nixvim = import ./wrappers/nixos.nix modules;
homeManagerModules.nixvim = import ./wrappers/hm.nix modules;
nixDarwinModules.nixvim = import ./wrappers/darwin.nix modules;
};
}

33
modules/highlights.nix Normal file
View file

@ -0,0 +1,33 @@
{ config, lib, ... }:
let
helpers = import ../plugins/helpers.nix { inherit lib; };
in
with lib;
{
options = {
highlight = mkOption {
type = types.attrsOf types.anything;
default = { };
description = "Define highlight groups";
example = ''
highlight = {
Comment.fg = '#ff0000';
};
'';
};
};
config = mkIf (config.highlight != { }) {
extraConfigLuaPost = ''
-- Highlight groups {{
do
local highlights = ${helpers.toLuaObject config.highlight}
for k,v in pairs(highlights) do
vim.api.nvim_set_hl(0, k, v)
end
end
-- }}
'';
};
}

View file

@ -1,6 +1,8 @@
{ config, lib, helpers, ... }:
{ config, lib, ... }:
with lib;
let
helpers = import ../plugins/helpers.nix { inherit lib; };
mapOption = types.oneOf [
types.str
(types.submodule {
@ -115,14 +117,13 @@ in
(helpers.genMaps "c" config.maps.command);
in
{
# TODO: Use vim.keymap.set if on nvim >= 0.7
extraConfigLua = optionalString (mappings != [ ]) ''
-- Set up keybinds {{{
do
local __nixvim_binds = ${helpers.toLuaObject mappings}
for i, map in ipairs(__nixvim_binds) do
vim.api.nvim_set_keymap(map.mode, map.key, map.action, map.config)
vim.keymap.set(map.mode, map.key, map.action, map.config)
end
end
-- }}}

View file

@ -1,5 +1,8 @@
{ config, lib, helpers, ... }:
{ config, lib, ... }:
with lib;
let
helpers = import ../plugins/helpers.nix { inherit lib; };
in
{
options = {
options = mkOption {

View file

@ -22,6 +22,22 @@ let
in
{
options = {
viAlias = mkOption {
type = types.bool;
default = false;
description = ''
Symlink <command>vi</command> to <command>nvim</command> binary.
'';
};
vimAlias = mkOption {
type = types.bool;
default = false;
description = ''
Symlink <command>vim</command> to <command>nvim</command> binary.
'';
};
package = mkOption {
type = types.package;
default = pkgs.neovim-unwrapped;
@ -79,7 +95,7 @@ in
initContent = mkOption {
type = types.str;
description = "The content of the init.vim file";
description = "The content of the init.lua file";
readOnly = true;
visible = false;
};
@ -87,18 +103,6 @@ in
config =
let
customRC =
(optionalString (config.extraConfigLuaPre != "") ''
lua <<EOF
${config.extraConfigLuaPre}
EOF
'') +
config.extraConfigVim + (optionalString (config.extraConfigLua != "" || config.extraConfigLuaPost != "") ''
lua <<EOF
${config.extraConfigLua}
${config.extraConfigLuaPost}
EOF
'');
defaultPlugin = {
plugin = null;
@ -109,7 +113,8 @@ in
normalizedPlugins = map (x: defaultPlugin // (if x ? plugin then x else { plugin = x; })) config.extraPlugins;
neovimConfig = pkgs.neovimUtils.makeNeovimConfig ({
inherit customRC;
inherit (config) viAlias vimAlias;
# inherit customRC;
plugins = normalizedPlugins;
}
# Necessary to make sure the runtime path is set properly in NixOS 22.05,
@ -120,16 +125,40 @@ in
{ nixvim = { start = map (x: x.plugin) normalizedPlugins; opt = [ ]; }; };
});
extraWrapperArgs = optionalString (config.extraPackages != [ ])
''--prefix PATH : "${makeBinPath config.extraPackages}"'';
customRC =
''
vim.cmd([[
${neovimConfig.neovimRcContent}
]])
'' +
(optionalString (config.extraConfigLuaPre != "") ''
${config.extraConfigLuaPre}
'') +
(optionalString (config.extraConfigVim != "") ''
vim.cmd([[
${config.extraConfigVim}
]])
'') +
(optionalString (config.extraConfigLua != "" || config.extraConfigLuaPost != "") ''
${config.extraConfigLua}
${config.extraConfigLuaPost}
'');
extraWrapperArgs = builtins.concatStringsSep " " (
(optional (config.extraPackages != [ ])
''--prefix PATH : "${makeBinPath config.extraPackages}"'')
++
(optional (config.wrapRc)
''--add-flags -u --add-flags "${pkgs.writeText "init.lua" customRC}"'')
);
wrappedNeovim = pkgs.wrapNeovimUnstable config.package (neovimConfig // {
wrapperArgs = lib.escapeShellArgs neovimConfig.wrapperArgs + " " + extraWrapperArgs;
inherit (config) wrapRc;
wrapRc = false;
});
in
{
finalPackage = wrappedNeovim;
initContent = neovimConfig.neovimRcContent;
initContent = customRC;
};
}

View file

@ -18,6 +18,7 @@ in
colorscheme = mkOption {
type = types.enum themes;
description = "The base16 colorscheme to use";
default = head themes;
};
setUpBar = mkOption {

View file

@ -3,56 +3,93 @@ with lib;
let
cfg = config.colorschemes.tokyonight;
style = types.enum [ "storm" "night" "day" ];
helpers = import ../helpers.nix { inherit lib; };
in
{
options = {
colorschemes.tokyonight = {
enable = mkEnableOption "Enable tokyonight";
style = mkOption {
type = types.nullOr style;
default = null;
type = style;
default = "storm";
description = "Theme style";
};
terminalColors = mkEnableOption
"Configure the colors used when opening a :terminal in Neovim";
italicComments = mkEnableOption "Make comments italic";
italicKeywords = mkEnableOption "Make keywords italic";
italicFunctions = mkEnableOption "Make functions italic";
italicVariables = mkEnableOption "Make variables and identifiers italic";
terminalColors = mkOption {
type = types.bool;
default = true;
description = "Configure the colors used when opening a :terminal in Neovim";
};
transparent =
mkEnableOption "Enable this to disable setting the background color";
hideInactiveStatusline = mkEnableOption
"Enabling this option will hide inactive statuslines and replace them with a thin border";
transparentSidebar = mkEnableOption
"Sidebar like windows like NvimTree get a transparent background";
darkSidebar = mkEnableOption
"Sidebar like windows like NvimTree get a darker background";
darkFloat = mkEnableOption
"Float windows like the lsp diagnostics windows get a darker background";
lualineBold = mkEnableOption
"When true, section headers in the lualine theme will be bold";
styles =
let
mkBackgroundStyle = name: mkOption {
type = types.enum [ "dark" "transparent" "normal" ];
description = "Background style for ${name}";
default = "dark";
};
in
{
comments = mkOption {
type = types.attrsOf types.anything;
description = "Define comments highlight properties";
default = { italic = true; };
};
keywords = mkOption {
type = types.attrsOf types.anything;
description = "Define keywords highlight properties";
default = { italic = true; };
};
functions = mkOption {
type = types.attrsOf types.anything;
description = "Define functions highlight properties";
default = { };
};
variables = mkOption {
type = types.attrsOf types.anything;
description = "Define variables highlight properties";
default = { };
};
sidebars = mkBackgroundStyle "sidebars";
floats = mkBackgroundStyle "floats";
};
sidebars = mkOption {
type = types.listOf types.str;
default = [ "qf" "help" ];
description = "Set a darker background on sidebar-like windows";
example = ''["qf" "vista_kind" "terminal" "packer"]'';
};
dayBrightness = mkOption {
type = types.numbers.between 0.0 1.0;
default = 0.3;
description = "Adjusts the brightness of the colors of the **Day** style";
};
hideInactiveStatusline =
mkEnableOption
"Enabling this option will hide inactive statuslines and replace them with a thin border";
dimInactive = mkEnableOption "dims inactive windows";
lualineBold =
mkEnableOption
"When true, section headers in the lualine theme will be bold";
};
};
config = mkIf cfg.enable {
colorscheme = "tokyonight";
extraPlugins = [ pkgs.vimPlugins.tokyonight-nvim ];
options = { termguicolors = true; };
globals = {
tokyonight_style = mkIf (!isNull cfg.style) cfg.style;
tokyonight_terminal_colors = mkIf (!cfg.terminalColors) 0;
tokyonight_italic_comments = mkIf (!cfg.italicComments) 0;
tokyonight_italic_keywords = mkIf (!cfg.italicKeywords) 0;
tokyonight_italic_functions = mkIf (cfg.italicFunctions) 1;
tokyonight_italic_variables = mkIf (cfg.italicVariables) 1;
tokyonight_transparent = mkIf (cfg.transparent) 1;
tokyonight_hide_inactive_statusline =
mkIf (cfg.hideInactiveStatusline) 1;
tokyonight_transparent_sidebar = mkIf (cfg.transparentSidebar) 1;
tokyonight_dark_sidebar = mkIf (!cfg.darkSidebar) 0;
tokyonight_dark_float = mkIf (!cfg.darkFloat) 0;
tokyonight_lualine_bold = mkIf (cfg.lualineBold) 1;
};
extraConfigLuaPre =
let
setupOptions = with cfg; {
inherit (cfg) style transparent styles sidebars;
terminal_colors = terminalColors;
hide_inactive_statusline = hideInactiveStatusline;
dim_inactive = dimInactive;
lualine_bold = lualineBold;
day_brightness = dayBrightness;
};
in
''
require("tokyonight").setup(${helpers.toLuaObject setupOptions})
'';
};
}

View file

@ -7,6 +7,11 @@ in
options = {
plugins.copilot = {
enable = mkEnableOption "Enable copilot";
package = mkOption {
type = types.package;
description = "The copilot plugin package to use";
default = pkgs.vimPlugins.copilot-vim;
};
filetypes = mkOption {
type = types.attrsOf types.bool;
description = "A dictionary mapping file types to their enabled status";
@ -27,7 +32,7 @@ in
config =
mkIf cfg.enable {
extraPlugins = [ pkgs.vimPlugins.copilot-vim ];
extraPlugins = [ cfg.package ];
globals = {
copilot_node_command = "${pkgs.nodejs-16_x}/bin/node";
copilot_filetypes = cfg.filetypes;

View file

@ -0,0 +1,92 @@
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.plugins.lspkind;
helpers = import ../helpers.nix { inherit lib; };
in
{
options.plugins.lspkind = {
enable = mkEnableOption "lspkind.nvim";
mode = mkOption {
type = with types; nullOr (enum [ "text" "text_symbol" "symbol_text" "symbol" ]);
default = null;
description = "Defines how annotations are shown";
};
preset = mkOption {
type = with types; nullOr (enum [ "default" "codicons" ]);
default = null;
description = "Default symbol map";
};
symbolMap = mkOption {
type = with types; nullOr (attrsOf str);
default = null;
description = "Override preset symbols";
};
cmp = {
enable = mkOption {
type = types.bool;
default = true;
description = "Integrate with nvim-cmp";
};
maxWidth = mkOption {
type = with types; nullOr int;
default = null;
description = "Maximum number of characters to show in the popup";
};
ellipsisChar = mkOption {
type = with types; nullOr str;
default = null;
description = "Character to show when the popup exceeds maxwidth";
};
menu = mkOption {
type = with types; nullOr (attrsOf str);
default = null;
description = "Show source names in the popup";
};
after = mkOption {
type = with types; nullOr types.str;
default = null;
description = "Function to run after calculating the formatting. function(entry, vim_item, kind)";
};
};
};
config =
let
doCmp = cfg.cmp.enable && config.plugins.nvim-cmp.enable;
options = {
mode = cfg.mode;
preset = cfg.preset;
symbol_map = cfg.symbolMap;
} // (if doCmp then {
maxwidth = cfg.cmp.maxWidth;
ellipsis_char = cfg.cmp.ellipsisChar;
menu = cfg.cmp.menu;
} else { });
in
mkIf cfg.enable {
extraPlugins = [ pkgs.vimPlugins.lspkind-nvim ];
extraConfigLua = optionalString (!doCmp) ''
require('lspkind').init(${helpers.toLuaObject options})
'';
plugins.nvim-cmp.formatting.format =
if cfg.cmp.after != null then ''
function(entry, vim_item)
local kind = require('lspkind').cmp_format(${helpers.toLuaObject options})(entry, vim_item)
return (${cfg.cmp.after})(entry, vim_after, kind)
end
'' else ''
require('lspkind').cmp_format(${helpers.toLuaObject options})
'';
};
}

View file

@ -309,6 +309,8 @@ in
type = types.nullOr (types.submodule ({ ... }: {
options = {
inherit border winhighlight zindex;
col_offset = mkNullOrOption types.int "Offsets the completion window relative to the cursor";
side_padding = mkNullOrOption types.int "The amount of padding to add on the completion window's sides";
};
}));
};

View file

@ -14,14 +14,19 @@
./completion/copilot.nix
./completion/nvim-cmp
./completion/nvim-cmp/sources
./completion/lspkind.nix
./git/fugitive.nix
./git/gitgutter.nix
./git/gitsigns.nix
./git/neogit.nix
./languages/ledger.nix
./languages/nix.nix
./languages/plantuml-syntax.nix
./languages/treesitter.nix
./languages/treesitter-context.nix
./languages/treesitter-refactor.nix
./languages/zig.nix
./null-ls
@ -29,9 +34,12 @@
./nvim-lsp
./nvim-lsp/lspsaga.nix
./nvim-lsp/lsp-lines.nix
./nvim-lsp/trouble.nix
./pluginmanagers/packer.nix
./snippets/luasnip
./statuslines/airline.nix
./statuslines/lightline.nix
./statuslines/lualine.nix
@ -56,5 +64,6 @@
./utils/undotree.nix
./utils/dashboard.nix
./utils/emmet.nix
./utils/magma-nvim.nix
];
}

433
plugins/git/gitsigns.nix Normal file
View file

@ -0,0 +1,433 @@
{
config,
lib,
pkgs,
helpers,
...
}:
with lib; let
signOptions = defaults:
with types; {
hl = mkOption {
type = str;
description = "Specifies the highlight group to use for the sign";
default = defaults.hl;
};
text = mkOption {
type = str;
description = "Specifies the character to use for the sign";
default = defaults.text;
};
numhl = mkOption {
type = str;
description = "Specifies the highlight group to use for the number column";
default = defaults.numhl;
};
linehl = mkOption {
type = str;
description = "Specifies the highlight group to use for the line";
default = defaults.linehl;
};
showCount = mkEnableOption "Enable showing count of hunk, e.g. number of deleted lines";
};
signSetupOptions = values: {
inherit (values) hl text numhl linehl;
show_count = values.showCount;
};
luaFunction = types.submodule {
options.function = mkOption {
type = types.str;
description = "Lua function definition";
};
};
in {
options.plugins.gitsigns = {
enable = mkEnableOption "Enable gitsigns plugin";
signs = {
add = signOptions {
hl = "GitSignsAdd";
text = "";
numhl = "GitSignsAddNr";
linehl = "GitSignsAddLn";
};
change = signOptions {
hl = "GitSignsChange";
text = "";
numhl = "GitSignsChangeNr";
linehl = "GitSignsChangeLn";
};
delete = signOptions {
hl = "GitSignsDelete";
text = "";
numhl = "GitSignsDeleteNr";
linehl = "GitSignsDeleteLn";
};
topdelete = signOptions {
hl = "GitSignsDelete";
text = "";
numhl = "GitSignsDeleteNr";
linehl = "GitSignsDeleteLn";
};
changedelete = signOptions {
hl = "GitSignsChange";
text = "~";
numhl = "GitSignsChangeNr";
linehl = "GitSignsChangeLn";
};
untracked = signOptions {
hl = "GitSignsAdd";
text = "";
numhl = "GitSignsAddNr";
linehl = "GitSignsAddLn";
};
};
worktrees = let
worktreeModule = {
options = {
toplevel = mkOption {
type = types.str;
};
gitdir = mkOption {
type = types.str;
};
};
};
in
mkOption {
type = types.nullOr (types.listOf (types.submodule worktreeModule));
default = null;
description = ''
Detached working trees.
If normal attaching fails, then each entry in the table is attempted with the work tree
details set.
'';
};
onAttach = mkOption {
type = types.nullOr luaFunction;
default = null;
description = ''
Callback called when attaching to a buffer. Mainly used to setup keymaps
when `config.keymaps` is empty. The buffer number is passed as the first
argument.
This callback can return `false` to prevent attaching to the buffer.
'';
example = ''
\'\'
function(bufnr)
if vim.api.nvim_buf_get_name(bufnr):match(<PATTERN>) then
-- Don't attach to specific buffers whose name matches a pattern
return false
end
-- Setup keymaps
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'hs', '<cmd>lua require"gitsigns".stage_hunk()<CR>', {})
... -- More keymaps
end
\'\'
'';
};
watchGitDir = {
enable = mkOption {
type = types.bool;
default = true;
description = "Whether the watcher is enabled";
};
interval = mkOption {
type = types.int;
default = 1000;
description = "Interval the watcher waits between polls of the gitdir in milliseconds";
};
followFiles = mkOption {
type = types.bool;
default = true;
description = "If a file is moved with `git mv`, switch the buffer to the new location";
};
};
signPriority = mkOption {
type = types.int;
default = 6;
description = "Priority to use for signs";
};
signcolumn = mkOption {
type = types.bool;
default = true;
description = ''
Enable/disable symbols in the sign column.
When enabled the highlights defined in `signs.*.hl` and symbols defined
in `signs.*.text` are used.
'';
};
numhl = mkEnableOption ''
Enable/disable line number highlights.
When enabled the highlights defined in `signs.*.numhl` are used. If
the highlight group does not exist, then it is automatically defined
and linked to the corresponding highlight group in `signs.*.hl`.
'';
linehl = mkEnableOption ''
Enable/disable line highlights.
When enabled the highlights defined in `signs.*.linehl` are used. If
the highlight group does not exist, then it is automatically defined
and linked to the corresponding highlight group in `signs.*.hl`.
'';
showDeleted = mkEnableOption ''
Show the old version of hunks inline in the buffer (via virtual lines).
Note: Virtual lines currently use the highlight `GitSignsDeleteVirtLn`.
'';
diffOpts = let
diffOptModule = {
options = {
algorithm = mkOption {
type = types.enum ["myers" "minimal" "patience" "histogram"];
default = "myers";
description = "Diff algorithm to use";
};
internal = mkOption {
type = types.bool;
default = false;
description = "Use Neovim's built in xdiff library for running diffs";
};
indentHeuristic = mkOption {
type = types.bool;
default = false;
description = "Use the indent heuristic for the internal diff library.";
};
vertical = mkOption {
type = types.bool;
default = true;
description = "Start diff mode with vertical splits";
};
linematch = mkOption {
type = types.nullOr types.int;
default = null;
description = ''
Enable second-stage diff on hunks to align lines.
Requires `internal=true`.
'';
};
};
};
in
mkOption {
type = types.nullOr (types.submodule diffOptModule);
default = null;
description = "Diff options. If set to null they are derived from the vim diffopt";
};
base = mkOption {
type = types.nullOr types.str;
default = null;
description = "The object/revision to diff against. Default to 'index'";
};
countChars = mkOption {
type = types.attrsOf types.str;
default = {
"1" = "1";
"2" = "2";
"3" = "3";
"4" = "4";
"5" = "5";
"6" = "6";
"7" = "7";
"8" = "8";
"9" = "9";
"+" = ">";
};
description = ''
The count characters used when `signs.*.show_count` is enabled. The
`+` entry is used as a fallback. With the default, any count outside
of 1-9 uses the `>` character in the sign.
Possible use cases for this field:
to specify unicode characters for the counts instead of 1-9.
to define characters to be used for counts greater than 9.
'';
};
statusFormatter = mkOption {
type = luaFunction;
default = {
function = ''
function(status)
local added, changed, removed = status.added, status.changed, status.removed
local status_txt = {}
if added and added > 0 then table.insert(status_txt, '+'..added ) end
if changed and changed > 0 then table.insert(status_txt, '~'..changed) end
if removed and removed > 0 then table.insert(status_txt, '-'..removed) end
return table.concat(status_txt, ' ')
end
'';
};
description = "Function used to format `b:gitsigns_status`";
};
maxFileLength = mkOption {
type = types.int;
default = 40000;
description = "Max file length (in lines) to attach to";
};
previewConfig = mkOption {
type = types.attrsOf types.anything;
default = {
border = "single";
style = "minimal";
relative = "cursor";
row = 0;
col = 1;
};
description = ''
Option overrides for the Gitsigns preview window.
Table is passed directly to `nvim_open_win`.
'';
};
attachToUntracked = mkOption {
type = types.bool;
default = true;
description = "Attach to untracked files.";
};
updateDebounce = mkOption {
type = types.number;
default = 100;
description = "Debounce time for updates (in milliseconds).";
};
currentLineBlame = mkEnableOption ''
Adds an unobtrusive and customisable blame annotation at the end of the current line.
'';
currentLineBlameOpts = {
virtText = mkOption {
type = types.bool;
default = true;
description = "Whether to show a virtual text blame annotation";
};
virtTextPos = mkOption {
type = types.enum ["eol" "overlay" "right_align"];
default = "eol";
description = "Blame annotation position";
};
delay = mkOption {
type = types.int;
default = 1000;
description = "Sets the delay (in milliseconds) before blame virtual text is displayed";
};
ignoreWhitespace = mkEnableOption "Ignore whitespace when running blame";
virtTextPriority = mkOption {
type = types.int;
default = 100;
description = "Priority of virtual text";
};
};
currentLineBlameFormatter = {
normal = mkOption {
type = types.either types.str luaFunction;
default = " <author>, <author_time> - <summary>";
description = ''
String or function used to format the virtual text of
|gitsigns-config-current_line_blame|.
See |gitsigns-config-current_line_blame_formatter| for more details.
'';
};
nonCommitted = mkOption {
type = types.either types.str luaFunction;
default = " <author>";
description = ''
String or function used to format the virtual text of
|gitsigns-config-current_line_blame| for lines that aren't committed.
'';
};
};
trouble = mkOption {
type = types.nullOr types.bool;
default = null;
description = ''
When using setqflist() or setloclist(), open Trouble instead of the quickfix/location list
window.
'';
};
yadm.enable = mkEnableOption "Enable YADM support";
wordDiff = mkEnableOption ''
Highlight intra-line word differences in the buffer.
Requires `config.diff_opts.internal = true`.
'';
debugMode = mkEnableOption ''
Enables debug logging and makes the following functions available: `dump_cache`,
`debug_messages`, `clear_debug`.
'';
};
config = let
cfg = config.plugins.gitsigns;
in
mkIf cfg.enable {
extraPlugins = with pkgs.vimPlugins; [
gitsigns-nvim
];
extraConfigLua = let
luaFnOrStrToObj = val:
if builtins.isString val
then val
else {__raw = val.function;};
setupOptions = {
inherit (cfg) worktrees signcolumn numhl linehl trouble yadm;
signs = mapAttrs (_: signSetupOptions) cfg.signs;
on_attach =
if cfg.onAttach != null
then {__raw = cfg.onAttach.function;}
else null;
watch_gitdir = {
inherit (cfg.watchGitDir) enable interval;
follow_files = cfg.watchGitDir.followFiles;
};
sign_priority = cfg.signPriority;
show_deleted = cfg.showDeleted;
diff_opts =
if cfg.diffOpts == null
then null
else {
inherit (cfg.diffOpts) algorithm internal vertical linematch;
indent_heuristic = cfg.diffOpts.indentHeuristic;
};
count_chars = let
isStrInt = s: (builtins.match "[0-9]+" s) != null;
in {
__raw =
"{"
+ (concatStringsSep "," (
lib.mapAttrsToList (
name: value:
if isStrInt name
then "[${name}] = ${helpers.toLuaObject value}"
else "[${helpers.toLuaObject name}] = ${helpers.toLuaObject value}"
)
cfg.countChars
))
+ "}";
};
status_formatter = {__raw = cfg.statusFormatter.function;};
max_file_length = cfg.maxFileLength;
preview_config = cfg.previewConfig;
attach_to_untracked = cfg.attachToUntracked;
update_debounce = cfg.updateDebounce;
current_line_blame = cfg.currentLineBlame;
current_line_blame_opts = let
cfgCl = cfg.currentLineBlameOpts;
in {
inherit (cfgCl) delay;
virt_text = cfgCl.virtText;
virt_text_pos = cfgCl.virtTextPos;
ignore_whitespace = cfgCl.ignoreWhitespace;
virt_text_priority = cfgCl.virtTextPriority;
};
current_line_blame_formatter = luaFnOrStrToObj cfg.currentLineBlameFormatter.normal;
current_line_blame_formatter_nc = luaFnOrStrToObj cfg.currentLineBlameFormatter.nonCommitted;
word_diff = cfg.wordDiff;
debug_mode = cfg.debugMode;
};
in ''
require('gitsigns').setup(${helpers.toLuaObject setupOptions})
'';
};
}

View file

@ -22,7 +22,9 @@ rec {
"{" + concatMapStringsSep "," toLuaObject args + "}"
else if builtins.isString args then
# This should be enough!
escapeShellArg args
builtins.toJSON args
else if builtins.isPath args then
builtins.toJSON (toString args)
else if builtins.isBool args then
"${ boolToString args }"
else if builtins.isFloat args then
@ -104,6 +106,17 @@ rec {
inherit value global;
};
extraOptionsOptions = {
extraOptions = mkOption {
default = { };
type = types.attrs;
description = ''
These attributes will be added to the table parameter for the setup function.
(Can override other attributes set by nixvim)
'';
};
};
mkRaw = r: { __raw = r; };
wrapDo = string: ''

View file

@ -0,0 +1,33 @@
{
pkgs,
lib,
config,
...
}:
with lib; {
options.plugins.plantuml-syntax = {
enable = mkEnableOption "Enable plantuml syntax support";
setMakeprg = mkOption {
type = types.bool;
default = true;
description = "Set the makeprg to 'plantuml'";
};
executableScript = mkOption {
type = types.nullOr types.str;
default = null;
description = "Set the script to be called with makeprg, default to 'plantuml' in PATH";
};
};
config = let
cfg = config.plugins.plantuml-syntax;
in
mkIf cfg.enable {
extraPlugins = with pkgs.vimPlugins; [plantuml-syntax];
globals = {
plantuml_set_makeprg = cfg.setMakeprg;
plantuml_executable_script = cfg.executableScript;
};
};
}

View file

@ -0,0 +1,56 @@
{
pkgs,
lib,
config,
...
}:
with lib; {
options.plugins.treesitter-context = {
enable = mkEnableOption "Enable nvim-treesitter-context";
maxLines = mkOption {
type = types.nullOr types.ints.positive;
default = null;
description = "How many lines the window should span. Null means no limit";
};
trimScope = mkOption {
type = types.enum ["outer" "inner"];
default = "outer";
description = "Which context lines to discard if `max_lines` is exceeded";
};
maxWindowHeight = mkOption {
type = types.nullOr types.ints.positive;
default = null;
description = "Minimum editor window height to enable context";
};
patterns = mkOption {
type = types.attrsOf (types.listOf types.str);
default = {};
description = ''
Patterns to use for context delimitation. The 'default' key matches all filetypes
'';
};
exactPatterns = mkOption {
type = types.attrsOf types.bool;
default = {};
description = "Treat the coresponding entry in patterns as an exact match";
};
};
config = let
cfg = config.plugins.treesitter-context;
in
mkIf cfg.enable {
extraPlugins = with pkgs.vimPlugins; [nvim-treesitter-context];
plugins.treesitter.moduleConfig.context = {
max_lines = cfg.maxLines;
trim_scope = cfg.trimScope;
min_window_height = cfg.maxWindowHeight;
};
};
}

View file

@ -0,0 +1,128 @@
{
pkgs,
config,
lib,
...
}:
with lib; {
options.plugins.treesitter-refactor = let
disable = mkOption {
type = types.listOf types.str;
default = [];
description = "List of languages to disable the module on";
};
in {
enable =
mkEnableOption
"Enable treesitter-refactor (requires plugins.treesitter.enable to be true)";
highlightDefinitions = {
inherit disable;
enable =
mkEnableOption
"Highlights definition and usages of the current symbol under the cursor.";
clearOnCursorMove = mkOption {
type = types.bool;
default = true;
description = ''
Controls if highlights should be cleared when the cursor is moved. If your 'updatetime'
is around `100` you can set this to false to have a less laggy experience.
'';
};
};
highlightCurrentScope = {
inherit disable;
enable = mkEnableOption "Highlights the block from the current scope where the cursor is.";
};
smartRename = {
inherit disable;
enable =
mkEnableOption
"Renames the symbol under the cursor within the current scope (and current file).";
keymaps = {
smartRename = mkOption {
type = types.nullOr types.str;
default = "grr";
description = "rename symbol under the cursor";
};
};
};
navigation = {
inherit disable;
enable = mkEnableOption ''
Provides "go to definition" for the symbol under the cursor,
and lists the definitions from the current file.
'';
keymaps = {
gotoDefinition = mkOption {
type = types.nullOr types.str;
default = "gnd";
description = "go to the definition of the symbol under the cursor";
};
gotoDefinitionLspFallback = mkOption {
type = types.nullOr types.str;
default = null;
description = ''
go to the definition of the symbol under the cursor or use vim.lsp.buf.definition if
the symbol can not be resolved. You can use your own fallback function if create a
mapping fo `lua require'nvim-treesitter.refactor.navigation(nil, fallback_function)<cr>`.
'';
};
listDefinitons = mkOption {
type = types.nullOr types.str;
default = "gnD";
description = "list all definitions from the current file";
};
listDefinitonsToc = mkOption {
type = types.nullOr types.str;
default = "gO";
description = ''
list all definitions from the current file like a table of contents (similar to the one
you see when pressing |gO| in help files).
'';
};
gotoNextUsage = mkOption {
type = types.nullOr types.str;
default = "<a-*>";
description = "go to next usage of identifier under the cursor";
};
gotoPreviousUsage = mkOption {
type = types.nullOr types.str;
default = "<a-#>";
description = "go to previous usage of identifier";
};
};
};
};
config = let
cfg = config.plugins.treesitter-refactor;
in
mkIf cfg.enable {
extraPlugins = with pkgs.vimPlugins; [nvim-treesitter-refactor];
plugins.treesitter.moduleConfig.refactor = {
highlight_definitions = {
inherit (cfg.highlightDefinitions) enable disable;
clear_on_cursor_move = cfg.highlightDefinitions.clearOnCursorMove;
};
highlight_current_scope = cfg.highlightCurrentScope;
smart_rename = {
inherit (cfg.smartRename) enable disable;
keymaps = {smart_rename = cfg.smartRename.keymaps.smartRename;};
};
navigation = {
inherit (cfg.navigation) enable disable;
keymaps = let
cfgK = cfg.navigation.keymaps;
in {
goto_definition = cfgK.gotoDefinition;
goto_definition_lsp_fallback = cfgK.gotoDefinitionLspFallback;
list_definitions = cfgK.listDefinitons;
list_definitions_toc = cfgK.listDefinitonsToc;
goto_next_usage = cfgK.gotoNextUsage;
goto_previous_usage = cfgK.gotoPreviousUsage;
};
};
};
};
}

View file

@ -21,6 +21,19 @@ in
description = "Either \"all\" or a list of languages";
};
parserInstallDir = mkOption {
type = types.nullOr types.str;
default =
if cfg.nixGrammars
then null
else "$XDG_DATA_HOME/nvim/treesitter"
;
description = ''
Location of the parsers to be installed by the plugin (only needed when nixGrammars is disabled).
This default might not work on your own install, please make sure that $XDG_DATA_HOME is set if you want to use the default. Otherwise, change it to something that will work for you!
'';
};
ignoreInstall = mkOption {
type = types.listOf types.str;
default = [ ];
@ -59,6 +72,18 @@ in
indent = mkEnableOption "Enable tree-sitter based indentation";
folding = mkEnableOption "Enable tree-sitter based folding";
grammarPackages = mkOption {
type = with types; listOf package;
default = pkgs.tree-sitter.allGrammars;
description = "Grammar packages to install";
};
moduleConfig = mkOption {
type = types.attrsOf types.anything;
default = { };
description = "This is the configuration for extra modules. It should not be used directly";
};
};
};
@ -90,15 +115,18 @@ in
ensure_installed = if cfg.nixGrammars then [ ] else cfg.ensureInstalled;
ignore_install = cfg.ignoreInstall;
};
parser_install_dir = cfg.parserInstallDir;
} // cfg.moduleConfig;
in
mkIf cfg.enable {
extraConfigLua = ''
extraConfigLua = (optionalString (cfg.parserInstallDir != null) ''
vim.opt.runtimepath:append("${cfg.parserInstallDir}")
'') + ''
require('nvim-treesitter.configs').setup(${helpers.toLuaObject tsOptions})
'';
extraPlugins = with pkgs; if cfg.nixGrammars then
[ (vimPlugins.nvim-treesitter.withPlugins (_: tree-sitter.allGrammars)) ]
[ (vimPlugins.nvim-treesitter.withPlugins (_: cfg.grammarPackages)) ]
else [ vimPlugins.nvim-treesitter ];
extraPackages = [ pkgs.tree-sitter pkgs.nodejs ];

View file

@ -1,12 +1,18 @@
{ pkgs, config, lib, ... }@args:
{ pkgs, config, lib, inputs, ... }@args:
let
helpers = import ./helpers.nix args;
serverData = {
code_actions = {
};
completion = {
code_actions = {
gitsigns = { };
};
completion = { };
diagnostics = {
flake8 = {
packages = [ pkgs.python3Packages.flake8 ];
};
shellcheck = {
packages = [ pkgs.shellcheck ];
};
};
formatting = {
phpcbf = {
@ -21,8 +27,17 @@ let
prettier = {
packages = [ pkgs.nodePackages.prettier ];
};
flake8 = {
packages = [ pkgs.python3Packages.flake8 ];
black = {
packages = [ pkgs.python3Packages.black ];
};
beautysh = {
packages = [ inputs.beautysh.packages.${pkgs.system}.beautysh-python38 ];
};
fourmolu = {
packages = [ pkgs.haskellPackages.fourmolu ];
};
fnlfmt = {
packages = [ pkgs.fnlfmt ];
};
};
};
@ -32,11 +47,20 @@ let
# sourceType = "formatting";
# packages = [...];
# }]
serverDataFormatted = lib.mapAttrsToList (sourceType: sourceSet:
lib.mapAttrsToList (name: attrs: attrs // { inherit sourceType name; }) sourceSet
) serverData;
serverDataFormatted = lib.mapAttrsToList
(sourceType: sourceSet:
lib.mapAttrsToList (name: attrs: attrs // { inherit sourceType name; }) sourceSet
)
serverData;
dataFlattened = lib.flatten serverDataFormatted;
in
{
imports = lib.lists.map (helpers.mkServer) dataFlattened;
config = let
cfg = config.plugins.null-ls;
in
lib.mkIf cfg.enable {
plugins.gitsigns.enable = lib.mkIf (cfg.sources.code_actions.gitsigns.enable) true;
};
}

View file

@ -1,7 +1,13 @@
{ pkgs, config, lib, ... }@args:
with lib;
let
helpers = import ./helpers.nix args;
servers = [
{
name = "bashls";
description = "Enable bashls, for bash.";
packages = [ pkgs.nodePackages.bash-language-server ];
}
{
name = "clangd";
description = "Enable clangd LSP, for C/C++.";
@ -12,6 +18,102 @@ let
description = "Enable cssls, for CSS";
package = pkgs.nodePackages.vscode-langservers-extracted;
}
{
name = "dartls";
description = "Enable dart language-server, for dart";
packages = [ pkgs.dart ];
extraOptions = {
analysisExcludedFolders = mkOption {
type = types.nullOr (types.listOf types.str);
default = null;
description = ''
An array of paths (absolute or relative to each workspace folder) that should be
excluded from analysis.
'';
};
enableSdkFormatter = mkOption {
type = types.nullOr types.bool;
default = null;
description = ''
When set to false, prevents registration (or unregisters) the SDK formatter. When set
to true or not supplied, will register/reregister the SDK formatter
'';
};
lineLength = mkOption {
type = types.nullOr types.int;
default = null;
description = ''
The number of characters the formatter should wrap code at. If unspecified, code will
be wrapped at 80 characters.
'';
};
completeFunctionCalls = mkOption {
type = types.nullOr types.bool;
default = true;
description = ''
When set to true, completes functions/methods with their required parameters.
'';
};
showTodos = mkOption {
type = types.nullOr types.bool;
default = true;
description = ''
Whether to generate diagnostics for TODO comments. If unspecified, diagnostics will not
be generated.
'';
};
renameFilesWithClasses = mkOption {
type = types.nullOr (types.enum [ "always" "prompt" ]);
default = null;
description = ''
When set to "always", will include edits to rename files when classes are renamed if the
filename matches the class name (but in snake_form). When set to "prompt", a prompt will
be shown on each class rename asking to confirm the file rename. Otherwise, files will
not be renamed. Renames are performed using LSP's ResourceOperation edits - that means
the rename is simply included in the resulting WorkspaceEdit and must be handled by the
client.
'';
};
enableSnippets = mkOption {
type = types.nullOr types.bool;
default = null;
description = ''
Whether to include code snippets (such as class, stful, switch) in code completion. When
unspecified, snippets will be included.
'';
};
updateImportsOnRename = mkOption {
type = types.nullOr types.bool;
default = null;
description = ''
Whether to update imports and other directives when files are renamed. When unspecified,
imports will be updated if the client supports willRenameFiles requests
'';
};
documentation = mkOption {
type = types.nullOr (types.enum [ "none" "summary" "full" ]);
default = null;
description = ''
The typekind of dartdocs to include in Hovers, Code Completion, Signature Help and other
similar requests. If not set, defaults to full
'';
};
includeDependenciesInWorkspaceSymbols = mkOption {
type = types.nullOr types.bool;
default = null;
description = ''
Whether to include symbols from dependencies and Dart/Flutter SDKs in Workspace Symbol
results. If not set, defaults to true.
'';
};
};
settings = cfg: { dart = cfg; };
}
{
name = "denols";
description = "Enable denols, for Deno";
packages = [ pkgs.deno ];
}
{
name = "eslint";
description = "Enable eslint";
@ -42,6 +144,42 @@ let
description = "Enable jsonls, for JSON";
package = pkgs.nodePackages.vscode-langservers-extracted;
}
{
name = "nil_ls";
description = "Enable nil, for Nix";
packages = [ pkgs.nil ];
extraOptions = {
formatting.command = mkOption {
type = types.nullOr (types.listOf types.str);
default = null;
description = ''
External formatter command (with arguments).
It should accepts file content in stdin and print the formatted code into stdout.
'';
};
diagnostics = {
ignored = mkOption {
type = types.listOf types.str;
default = [ ];
description = ''
Ignored diagnostic kinds.
The kind identifier is a snake_cased_string usually shown together
with the diagnostic message.
'';
};
excludedFiles = mkOption {
type = types.listOf types.str;
default = [ ];
description = ''
Files to exclude from showing diagnostics. Useful for generated files.
It accepts an array of paths. Relative paths are joint to the workspace root.
Glob patterns are currently not supported.
'';
};
};
};
settings = cfg: { nil = { inherit (cfg) formatting diagnostics; }; };
}
{
name = "pyright";
description = "Enable pyright, for Python.";
@ -56,6 +194,16 @@ let
description = "Enable rust-analyzer, for Rust.";
serverName = "rust_analyzer";
}
{
name = "tailwindcss";
description = "Enable tailwindcss language server, for tailwindcss";
packages = [ pkgs.nodePackages."@tailwindcss/language-server" ];
}
{
name = "texlab";
description = "Enable texlab language server, for LaTeX";
packages = [ pkgs.texlab ];
}
{
name = "tsserver";
description = "Enable tsserver for typescript";
@ -73,6 +221,12 @@ let
name = "zls";
description = "Enable zls, for Zig.";
}
{
name = "hls";
description = "Enable haskell language server";
packages = [ pkgs.haskell-language-server ];
cmd = [ "haskell-language-server-wrapper" ];
}
];
in
{

View file

@ -36,7 +36,7 @@ in
onAttach = mkOption {
type = types.lines;
description = "A lua function to be run when a new LSP buffer is attached. The argument `client` is provided.";
description = "A lua function to be run when a new LSP buffer is attached. The argument `client` and `bufnr` is provided.";
default = "";
};
@ -69,7 +69,7 @@ in
do
${cfg.preConfig}
local __lspServers = ${helpers.toLuaObject cfg.enabledServers}
local __lspOnAttach = function(client)
local __lspOnAttach = function(client, bufnr)
${cfg.onAttach}
end

View file

@ -8,6 +8,8 @@
, package ? pkgs.${name}
, extraPackages ? { }
, cmd ? null
, settings ? null
, extraOptions ? { }
, ...
}:
# returns a module
@ -49,6 +51,7 @@
name = serverName;
extraOptions = {
inherit cmd;
settings = if settings != null then settings cfg else { };
};
}];
};

View file

@ -8,10 +8,24 @@ in
options = {
plugins.lsp-lines = {
enable = mkEnableOption "lsp_lines.nvim";
currentLine = mkOption {
type = types.bool;
default = false;
description = "Show diagnostics only on current line";
};
};
};
config =
let
diagnosticConfig = {
virtual_text = false;
virtual_lines =
if cfg.currentLine then {
only_current_line = true;
} else true;
};
in
mkIf cfg.enable {
extraPlugins = [ pkgs.vimPlugins.lsp_lines-nvim ];
@ -19,9 +33,7 @@ in
do
require("lsp_lines").setup()
vim.diagnostic.config({
virtual_text = false
})
vim.diagnostic.config(${ helpers.toLuaObject diagnosticConfig })
end
'';
};

View file

@ -0,0 +1,24 @@
{ config, pkgs, lib, ... }:
let
cfg = config.plugins.trouble;
helpers = import ../helpers.nix { inherit lib; };
in
with lib;
# with helpers;
{
options.plugins.trouble = {
enable = mkEnableOption "trouble.nvim";
position = helpers.mkNullOrOption (types.enum [ "top" "left" "right" "bottom" ]) "Position of the list";
height = helpers.mkNullOrOption types.int "Height of the trouble list when position is top or bottom";
width = helpers.mkNullOrOption types.int "Width of the trouble list when position is left or right";
icons = helpers.mkNullOrOption types.bool "Use devicons for filenames";
};
config = mkIf cfg.enable {
extraPlugins = with pkgs.vimPlugins; [
trouble-nvim
nvim-web-devicons
];
};
}

View file

@ -53,7 +53,7 @@
pname = "std2";
version = "48bb39b69ed631ef64eed6123443484133fd20fc";
doCheck = false;
doCheck = true;
src = pkgs.fetchFromGitHub {
owner = "ms-jpq";
@ -84,4 +84,42 @@
sha256 = "sha256-AtkG2XRVZgvJzH2iLr7UT/U1+LXxenvNckdapnJV+8A=";
};
};
magma-nvim = pkgs.vimUtils.buildVimPlugin rec {
pname = "magma-nvim";
version = "94370733757d550594fe4a1d65643949d7485989";
src = pkgs.fetchFromGitHub {
owner = "WhiteBlackGoose";
repo = "magma-nvim-goose";
rev = version;
sha256 = "sha256-IaslJK1F2BxTvZzKGH9OKOl2RICi4d4rSgjliAIAqK4=";
};
passthru.python3Dependencies = ps: with ps; [
pynvim
jupyter-client
ueberzug
pillow
cairosvg
plotly
ipykernel
pyperclip
(ps.buildPythonPackage rec {
pname = "pnglatex";
version = "1.1";
src = fetchPypi {
inherit pname version;
hash = "sha256-CZUGDUkmttO0BzFYbGFSNMPkWzFC/BW4NmAeOwz4Y9M=";
};
doCheck = false;
meta = with lib; {
homepage = "https://github.com/MaT1g3R/pnglatex";
description = "a small program that converts LaTeX snippets to png";
};
})
];
};
}

View file

@ -0,0 +1,98 @@
{ pkgs, config, lib, ... }:
with lib;
let
cfg = config.plugins.luasnip;
helpers = import ../../helpers.nix { lib = lib; };
in
{
options.plugins.luasnip = {
enable = mkEnableOption "Enable luasnip";
package = mkOption {
default = pkgs.vimPlugins.luasnip;
type = types.package;
};
fromVscode = mkOption {
default = [ ];
example = ''
[
{}
{
paths = ./path/to/snippets;
}
]
# generates:
#
# require("luasnip.loaders.from_vscode").lazy_load({})
# require("luasnip.loaders.from_vscode").lazy_load({['paths'] = {'/nix/store/.../path/to/snippets'}})
#
'';
type = types.listOf (types.submodule {
options = {
lazyLoad = mkOption {
type = types.bool;
default = true;
description = ''
Whether or not to lazy load the snippets
'';
};
# TODO: add option to also include the default runtimepath
paths = mkOption {
default = null;
type = with types; nullOr (oneOf
[
str
path
helpers.rawType
(listOf (oneOf
[
str
path
helpers.rawType
]))
]);
};
exclude = mkOption {
type = types.nullOr (types.listOf types.str);
default = null;
description = ''
List of languages to exclude, by default is empty.
'';
};
include = mkOption {
type = types.nullOr (types.listOf types.str);
default = null;
description = ''
List of languages to include, by default is not set.
'';
};
};
});
};
# TODO: add support for snipmate
# TODO: add support for lua
};
config =
let
fromVscodeLoaders = lists.map
(loader:
let
options = attrsets.getAttrs [ "paths" "exclude" "include" ] loader;
in
''
require("luasnip.loaders.from_vscode").${optionalString loader.lazyLoad "lazy_"}load(${helpers.toLuaObject options})
'')
cfg.fromVscode;
in
mkIf cfg.enable {
extraPlugins = [ cfg.package ];
extraConfigLua = concatStringsSep "\n" fromVscodeLoaders;
};
}

View file

@ -35,6 +35,18 @@ in
description = "Configuration for the extensions. Don't use this directly";
default = { };
};
defaults = mkOption {
type = types.nullOr types.attrs;
default = null;
description = "Telescope default configuration";
};
extraOptions = mkOption {
type = types.attrs;
default = { };
description = "An attribute set, that lets you set extra options or override options set by nixvim";
};
};
config = mkIf cfg.enable {
@ -50,13 +62,16 @@ in
let $BAT_THEME = '${cfg.highlightTheme}'
'';
extraConfigLua = ''
extraConfigLua = let
options = {
extensions = cfg.extensionConfig;
defaults = cfg.defaults;
} // cfg.extraOptions;
in ''
do
local __telescopeExtensions = ${helpers.toLuaObject cfg.enabledExtensions}
require('telescope').setup{
extensions = ${helpers.toLuaObject cfg.extensionConfig}
}
require('telescope').setup(${helpers.toLuaObject options})
for i, extension in ipairs(__telescopeExtensions) do
require('telescope').load_extension(extension)

View file

@ -0,0 +1,111 @@
{ pkgs, lib, config, ... }:
with lib;
let
cfg = config.plugins.magma-nvim;
plugins = import ../plugin-defs.nix { inherit pkgs; };
package = pkgs.fetchFromGitHub {
owner = "dccsillag";
repo = "magma-nvim";
rev = version;
sha256 = "sha256-IaslJK1F2BxTvZzKGH9OKOl2RICi4d4rSgjliAIAqK4=";
};
in {
options = {
plugins.magma-nvim = {
enable = mkEnableOption "Enable magma-nvim?";
image_provider = mkOption {
type = types.enum [ "none" "ueberzug" "kitty" ];
default = "none";
example = "ueberzug";
description =
" This configures how to display images. The following options are available:
none -- don't show imagesmagma_image_provider.
ueberzug -- use Ueberzug to display images.
kitty -- use the Kitty protocol to display images.";
};
automatically_open_output = mkOption {
type = types.bool;
default = true;
example = false;
description =
" If this is true, then whenever you have an active cell its output window will be automatically shown.
If this is false, then the output window will only be automatically shown when you've just evaluated the code. So, if you take your cursor out of the cell, and then come back, the output window won't be opened (but the cell will be highlighted). This means that there will be nothing covering your code. You can then open the output window at will using :MagmaShowOutput.";
};
wrap_output = mkOption {
type = types.bool;
default = true;
example = false;
description =
" If this is true, then text output in the output window will be wrapped (akin to set wrap).";
};
output_window_borders = mkOption {
type = types.bool;
default = true;
example = false;
description =
" If this is true, then the output window will have rounded borders. If it is false, it will have no borders.";
};
cell_highlight_group = mkOption {
type = types.str;
default = "CursorLine";
# example = "";
description =
" The highlight group to be used for highlighting cells.";
};
save_path = mkOption {
type = types.nullOr types.str;
default = null;
description =
"Where to save/load with :MagmaSave and :MagmaLoad (with no parameters).
The generated file is placed in this directory, with the filename itself being the buffer's name, with % replaced by %% and / replaced by %, and postfixed with the extension .json.";
};
show_mimetype_debug = mkOption {
type = types.bool;
default = false;
example = true;
description =
" If this is true, then before any non-iostream output chunk, Magma shows the mimetypes it received for it.
This is meant for debugging and adding new mimetypes.";
};
package = mkOption {
type = types.nullOr types.package;
default = null;
example =
"package = pkgs.fetchFromGitHub {
owner = \"WhiteBlackGoose\";
repo = \"magma-nvim-goose\";
rev = version;
sha256 = \"sha256-IaslJK1F2BxTvZzKGH9OKOl2RICi4d4rSgjliAIAqK4=\";} ";
};
};
};
config = mkIf cfg.enable {
extraPlugins = [ (
if cfg.package != null then plugins.magma-nvim.override {src = cfg.package;} else plugins.magma-nvim
)];
globals = {
magma_image_provider =
mkIf (cfg.image_provider != "none") cfg.image_provider;
magma_automatically_open_output =
mkIf (!cfg.automatically_open_output) cfg.automatically_open_output;
magma_wrap_output = mkIf (!cfg.wrap_output) cfg.wrap_output;
magma_output_window_borders =
mkIf (!cfg.output_window_borders) cfg.output_window_borders;
magma_highlight_group = mkIf (cfg.cell_highlight_group != "CursorLine")
cfg.cell_highlight_group;
magma_show_mimetype_debug =
mkIf cfg.show_mimetype_debug cfg.show_mimetype_debug;
};
};
}

View file

@ -48,11 +48,17 @@ in
description = "Hijack cursor";
};
# TODO: change this to it's new definition sync_root_with_cwd
updateCwd = mkOption {
type = types.nullOr types.bool;
default = null;
};
respectBufCwd = mkOption {
type = types.nullOr types.bool;
default = null;
};
updateToBufDir = {
enable = mkOption {
type = types.nullOr types.bool;
@ -94,6 +100,7 @@ in
default = null;
};
# TODO: change this to it's new definition update_root
updateCwd = mkOption {
type = types.nullOr types.bool;
default = null;
@ -214,12 +221,13 @@ in
open_on_tab = cfg.openOnTab;
hijack_cursor = cfg.hijackCursor;
update_cwd = cfg.updateCwd;
respect_buf_cwd = cfg.respectBufCwd;
update_to_buf_dir = {
enable = cfg.updateToBufDir.enable;
auto_open = cfg.updateToBufDir.autoOpen;
};
diagnostics = cfg.diagnostics;
updateFocusedFile = {
update_focused_file = {
enable = cfg.updateFocusedFile.enable;
update_cwd = cfg.updateFocusedFile.updateCwd;
ignore_list = cfg.updateFocusedFile.ignoreList;

View file

@ -5,7 +5,7 @@ let
helpers = import ../helpers.nix { inherit lib; };
in
{
options.plugins.project-nvim = {
options.plugins.project-nvim = helpers.extraOptionsOptions // {
enable = mkEnableOption "Enable project.nvim";
manualMode = mkOption {
@ -52,6 +52,7 @@ in
type = types.nullOr (types.either types.str helpers.rawType);
default = null;
};
};
config =
@ -66,7 +67,7 @@ in
silent_chdir = cfg.silentChdir;
scope_schdir = cfg.scopeChdir;
data_path = cfg.dataPath;
};
} // cfg.extraOptions;
in
mkIf cfg.enable {
extraPlugins = [ pkgs.vimPlugins.project-nvim ];

View file

@ -35,6 +35,11 @@ in
default = 10;
};
color = mkOption {
type = types.nullOr types.str;
default = null;
};
width = mkOption {
type = types.int;
default = 10;
@ -117,6 +122,7 @@ in
cfg.ignored_buffertypes);
popup = {
inherit (cfg) blend width;
winhl = if (!isNull cfg.color) then "SpecsPopColor" else "PMenu";
delay_ms = cfg.delay;
inc_ms = cfg.increment;
fader = helpers.mkRaw (if cfg.fader.builtin == null then
@ -133,6 +139,8 @@ in
mkIf cfg.enable {
extraPlugins = [ pkgs.vimPlugins.specs-nvim ];
highlight.SpecsPopColor.bg = mkIf (!isNull cfg.color) cfg.color;
extraConfigLua = ''
require('specs').setup(${setup})
'';

View file

@ -1,8 +0,0 @@
#!/usr/bin/env sh
# Creates a container and then runs the resulting neovim executable with the configuration
set -e
sudo nixos-container destroy nvim-test
sudo nixos-container create nvim-test --flake .
.tmp/sw/bin/nvim -u .tmp/etc/xdg/nvim/sysinit.vim $@

260
tests/flake.lock generated
View file

@ -1,12 +1,77 @@
{
"nodes": {
"beautysh": {
"inputs": {
"nixpkgs": [
"nixvim",
"nixpkgs"
],
"poetry2nix": "poetry2nix",
"utils": "utils"
},
"locked": {
"lastModified": 1667262410,
"narHash": "sha256-yqqvPvazG/Ci3WpIfPb+o+i2cNuyAYYY19lwJGCmUao=",
"owner": "lovesegfault",
"repo": "beautysh",
"rev": "a1fdaff999db2dfc5032914630f5052360f4b432",
"type": "github"
},
"original": {
"owner": "lovesegfault",
"repo": "beautysh",
"type": "github"
}
},
"beautysh_2": {
"inputs": {
"nixpkgs": [
"nixvim-stable",
"nixpkgs"
],
"poetry2nix": "poetry2nix_2",
"utils": "utils_2"
},
"locked": {
"lastModified": 1667262410,
"narHash": "sha256-yqqvPvazG/Ci3WpIfPb+o+i2cNuyAYYY19lwJGCmUao=",
"owner": "lovesegfault",
"repo": "beautysh",
"rev": "a1fdaff999db2dfc5032914630f5052360f4b432",
"type": "github"
},
"original": {
"owner": "lovesegfault",
"repo": "beautysh",
"type": "github"
}
},
"build-ts": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1669771646,
"narHash": "sha256-IfH9zCq0+QpAB8D1ClhISfWcR59mSDsi91/2NW0RWfs=",
"owner": "pta2002",
"repo": "build-ts-grammar.nix",
"rev": "bba8a5b14a4632f25411dbf0fb01de69e999ce82",
"type": "github"
},
"original": {
"owner": "pta2002",
"repo": "build-ts-grammar.nix",
"type": "github"
}
},
"flake-utils": {
"locked": {
"lastModified": 1659877975,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github"
},
"original": {
@ -17,11 +82,11 @@
},
"flake-utils_2": {
"locked": {
"lastModified": 1659877975,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github"
},
"original": {
@ -32,11 +97,11 @@
},
"flake-utils_3": {
"locked": {
"lastModified": 1659877975,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github"
},
"original": {
@ -45,6 +110,37 @@
"type": "github"
}
},
"flake-utils_4": {
"locked": {
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"gleam": {
"flake": false,
"locked": {
"lastModified": 1669665314,
"narHash": "sha256-aeho84P91cH13j7uLJwyD/zj8O/peROrpfa41HA/FGo=",
"owner": "gleam-lang",
"repo": "tree-sitter-gleam",
"rev": "97611918f79643ade377a156f3e4192cd50dc3e6",
"type": "github"
},
"original": {
"owner": "gleam-lang",
"repo": "tree-sitter-gleam",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1663491030,
@ -61,11 +157,11 @@
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1665066044,
"narHash": "sha256-mkO0LMHVunMFRWLcJhHT0fBf2v6RlH3vg7EVpfSIAFc=",
"lastModified": 1669546925,
"narHash": "sha256-Gvtk9agz88tBgqmCdHl5U7gYttTkiuEd8/Rq1Im0pTg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "ed9b904c5eba055a6d6f5c1ccb89ba8f0a056dc6",
"rev": "fecf05d4861f3985e8dee73f08bc82668ef75125",
"type": "github"
},
"original": {
@ -89,82 +185,150 @@
"type": "indirect"
}
},
"nixpkgs_3": {
"locked": {
"lastModified": 1663491030,
"narHash": "sha256-MVsfBhE9US5DvLtBAaTRjwYdv1tLO8xjahM8qLXTgTo=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "767542707d394ff15ac1981e903e005ba69528b5",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"nixvim": {
"inputs": {
"flake-utils": "flake-utils_2",
"nixpkgs": "nixpkgs_2",
"nmdSrc": "nmdSrc"
"beautysh": "beautysh",
"flake-utils": "flake-utils_3",
"nixpkgs": "nixpkgs_3"
},
"locked": {
"lastModified": 0,
"narHash": "sha256-FTGR/AeBEZQeWqSQqbnR+3oW4NJvhwshJu8/mHDWwQ8=",
"path": "/nix/store/rhjvdj0kd7drmgnaj06q3kazi496zb6f-source",
"narHash": "sha256-008LHsZ1x6jTE46J4+E2jOQTAyexpf7M9fNqSsjQOds=",
"path": "/nix/store/nj5i7q1lcsw9fzch5kha51li3c8w12h6-source",
"type": "path"
},
"original": {
"path": "/nix/store/rhjvdj0kd7drmgnaj06q3kazi496zb6f-source",
"path": "/nix/store/nj5i7q1lcsw9fzch5kha51li3c8w12h6-source",
"type": "path"
}
},
"nixvim-stable": {
"inputs": {
"flake-utils": "flake-utils_3",
"beautysh": "beautysh_2",
"flake-utils": "flake-utils_4",
"nixpkgs": [
"nixpkgs-stable"
],
"nmdSrc": "nmdSrc_2"
]
},
"locked": {
"lastModified": 0,
"narHash": "sha256-FTGR/AeBEZQeWqSQqbnR+3oW4NJvhwshJu8/mHDWwQ8=",
"path": "/nix/store/rhjvdj0kd7drmgnaj06q3kazi496zb6f-source",
"narHash": "sha256-008LHsZ1x6jTE46J4+E2jOQTAyexpf7M9fNqSsjQOds=",
"path": "/nix/store/nj5i7q1lcsw9fzch5kha51li3c8w12h6-source",
"type": "path"
},
"original": {
"path": "/nix/store/rhjvdj0kd7drmgnaj06q3kazi496zb6f-source",
"path": "/nix/store/nj5i7q1lcsw9fzch5kha51li3c8w12h6-source",
"type": "path"
}
},
"nmdSrc": {
"flake": false,
"poetry2nix": {
"inputs": {
"flake-utils": [
"nixvim",
"beautysh",
"utils"
],
"nixpkgs": [
"nixvim",
"beautysh",
"nixpkgs"
]
},
"locked": {
"lastModified": 1654807200,
"narHash": "sha256-RNLq09vfj21TyYuUCeD6BNTNC6Ew8bLhQULZytN4Xx8=",
"owner": "rycee",
"repo": "nmd",
"rev": "91dee681dd1c478d6040a00835d73c0f4a4c5c29",
"type": "gitlab"
"lastModified": 1658665240,
"narHash": "sha256-/wkx7D7enyBPRjIkK0w7QxLQhzEkb3UxNQnjyc3FTUI=",
"owner": "nix-community",
"repo": "poetry2nix",
"rev": "8b8edc85d24661d5a6d0d71d6a7011f3e699780f",
"type": "github"
},
"original": {
"owner": "rycee",
"repo": "nmd",
"type": "gitlab"
"owner": "nix-community",
"repo": "poetry2nix",
"type": "github"
}
},
"nmdSrc_2": {
"flake": false,
"poetry2nix_2": {
"inputs": {
"flake-utils": [
"nixvim-stable",
"beautysh",
"utils"
],
"nixpkgs": [
"nixvim-stable",
"beautysh",
"nixpkgs"
]
},
"locked": {
"lastModified": 1654807200,
"narHash": "sha256-RNLq09vfj21TyYuUCeD6BNTNC6Ew8bLhQULZytN4Xx8=",
"owner": "rycee",
"repo": "nmd",
"rev": "91dee681dd1c478d6040a00835d73c0f4a4c5c29",
"type": "gitlab"
"lastModified": 1658665240,
"narHash": "sha256-/wkx7D7enyBPRjIkK0w7QxLQhzEkb3UxNQnjyc3FTUI=",
"owner": "nix-community",
"repo": "poetry2nix",
"rev": "8b8edc85d24661d5a6d0d71d6a7011f3e699780f",
"type": "github"
},
"original": {
"owner": "rycee",
"repo": "nmd",
"type": "gitlab"
"owner": "nix-community",
"repo": "poetry2nix",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs",
"build-ts": "build-ts",
"flake-utils": "flake-utils_2",
"gleam": "gleam",
"nixpkgs": "nixpkgs_2",
"nixpkgs-stable": "nixpkgs-stable",
"nixvim": "nixvim",
"nixvim-stable": "nixvim-stable"
}
},
"utils": {
"locked": {
"lastModified": 1667077288,
"narHash": "sha256-bdC8sFNDpT0HK74u9fUkpbf1MEzVYJ+ka7NXCdgBoaA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "6ee9ebb6b1ee695d2cacc4faa053a7b9baa76817",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"utils_2": {
"locked": {
"lastModified": 1667077288,
"narHash": "sha256-bdC8sFNDpT0HK74u9fUkpbf1MEzVYJ+ka7NXCdgBoaA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "6ee9ebb6b1ee695d2cacc4faa053a7b9baa76817",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
}
},
"root": "root",

View file

@ -4,13 +4,17 @@
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.nixvim.url = "./..";
inputs.build-ts.url = "github:pta2002/build-ts-grammar.nix";
inputs.gleam.url = "github:gleam-lang/tree-sitter-gleam";
inputs.gleam.flake = false;
inputs.nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-22.05";
inputs.nixvim-stable = {
url = "./..";
inputs.nixpkgs.follows = "nixpkgs-stable";
};
outputs = { self, nixvim, nixvim-stable, nixpkgs, flake-utils, nixpkgs-stable, ... }:
outputs = { self, nixvim, nixvim-stable, nixpkgs, flake-utils, nixpkgs-stable, build-ts, gleam, ... }:
(flake-utils.lib.eachDefaultSystem
(system:
let
@ -61,6 +65,26 @@
plugins.lsp-lines.enable = true;
};
trouble = build {
plugins.lsp = {
enable = true;
servers.clangd.enable = true;
};
plugins.trouble.enable = true;
};
beautysh = build {
plugins.null-ls = {
enable = true;
sources.formatting.beautysh.enable = true;
};
};
keymaps = build {
maps.normal."," = "<cmd>echo \"test\"<cr>";
};
issue-40 = build-stable {
plugins = {
nix.enable = true;
@ -118,6 +142,124 @@
termguicolors = true;
};
};
issue-65 = build {
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);
};
issue-71 = build {
maps.normal."<leader>hb" = "<cmd>lua require('gitsigns').blame_line{full=true}<cr>";
};
lspkind = build {
plugins = {
lsp = {
enable = true;
servers.clangd.enable = true;
};
nvim-cmp.enable = true;
lspkind.enable = true;
};
};
highlight = build {
options.termguicolors = true;
highlight = {
Normal.fg = "#ff0000";
};
};
ts-custom = build {
plugins.treesitter = {
enable = true;
nixGrammars = true;
grammarPackages = [
(build-ts.lib.buildGrammar pkgs {
language = "gleam";
version = "0.25.0";
source = gleam;
})
];
};
};
};
})) // {
nixosConfigurations.nixvim-machine = nixpkgs.lib.nixosSystem {

30
wrappers/darwin.nix Normal file
View file

@ -0,0 +1,30 @@
modules:
{ pkgs, config, lib, ... }:
let
inherit (lib) mkEnableOption mkOption mkOptionType mkForce mkMerge mkIf types;
cfg = config.programs.nixvim;
in
{
options = {
programs.nixvim = mkOption {
type = types.submodule ((modules pkgs) ++ [{
options.enable = mkEnableOption "nixvim";
config.wrapRc = mkForce true;
}]);
};
nixvim.helpers = mkOption {
type = mkOptionType {
name = "helpers";
description = "Helpers that can be used when writing nixvim configs";
check = builtins.isAttrs;
};
description = "Use this option to access the helpers";
default = import ../plugins/helpers.nix { inherit (pkgs) lib; };
};
};
config = mkIf cfg.enable {
environment.systemPackages = [ cfg.finalPackage ];
};
}

View file

@ -2,22 +2,32 @@ modules:
{ pkgs, config, lib, ... }:
let
inherit (lib) mkEnableOption mkOption mkIf mkMerge types;
inherit (lib) mkEnableOption mkOption mkOptionType mkMerge mkIf types;
cfg = config.programs.nixvim;
in {
in
{
options = {
programs.nixvim = lib.mkOption {
programs.nixvim = mkOption {
type = types.submodule ((modules pkgs) ++ [{
options.enable = mkEnableOption "nixvim";
}]);
};
nixvim.helpers = mkOption {
type = mkOptionType {
name = "helpers";
description = "Helpers that can be used when writing nixvim configs";
check = builtins.isAttrs;
};
description = "Use this option to access the helpers";
default = import ../plugins/helpers.nix { inherit (pkgs) lib; };
};
};
config = mkIf cfg.enable
config = mkIf cfg.enable
(mkMerge [
{ home.packages = [ cfg.finalPackage ]; }
(mkIf (!cfg.wrapRc) {
xdg.configFile."nvim/init.vim".text = cfg.initContent;
xdg.configFile."nvim/init.lua".text = cfg.initContent;
})
]);
}

View file

@ -2,22 +2,32 @@ modules:
{ pkgs, config, lib, ... }:
let
inherit (lib) mkEnableOption mkOption mkMerge mkIf types;
inherit (lib) mkEnableOption mkOption mkOptionType mkMerge mkIf types;
cfg = config.programs.nixvim;
in {
in
{
options = {
programs.nixvim = lib.mkOption {
programs.nixvim = mkOption {
type = types.submodule ((modules pkgs) ++ [{
options.enable = mkEnableOption "nixvim";
}]);
};
nixvim.helpers = mkOption {
type = mkOptionType {
name = "helpers";
description = "Helpers that can be used when writing nixvim configs";
check = builtins.isAttrs;
};
description = "Use this option to access the helpers";
default = import ../plugins/helpers.nix { inherit (pkgs) lib; };
};
};
config = mkIf cfg.enable
config = mkIf cfg.enable
(mkMerge [
{ environment.systemPackages = [ cfg.finalPackage ]; }
(mkIf (!cfg.wrapRc) {
environment.etc."nvim/sysinit.vim".text = cfg.initContent;
environment.etc."nvim/sysinit.lua".text = cfg.initContent;
environment.variables."VIM" = "/etc/nvim";
})
]);

View file

@ -1,4 +1,4 @@
pkgs: modules: configuration:
default_pkgs: modules: {pkgs ? default_pkgs, module}:
let
@ -7,7 +7,7 @@ let
wrap = { wrapRc = true; };
eval = lib.evalModules {
modules = modules ++ [ { config = configuration; } wrap ];
modules = (modules pkgs) ++ [ module wrap ];
};
in eval.config.finalPackage