diff --git a/.circleci/config.yml b/.circleci/config.yml index a5ff3b18..119e012c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -56,4 +56,4 @@ workflows: - build-docs filters: branches: - only: main \ No newline at end of file + only: main diff --git a/README.md b/README.md index f1305bd8..d1781ef1 100644 --- a/README.md +++ b/README.md @@ -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 .# -- `. 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. diff --git a/docs.nix b/docs.nix new file mode 100644 index 00000000..fff79cd8 --- /dev/null +++ b/docs.nix @@ -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 < 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 + ''; +} diff --git a/docs/default.nix b/docs/default.nix deleted file mode 100644 index 5601e5f6..00000000 --- a/docs/default.nix +++ /dev/null @@ -1,48 +0,0 @@ -{ pkgs ? import { } -, lib ? import -, 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 = '' - - - - - - - ''; - }; -in -# TODO: Parse this json or something, since docbook isn't working (and it's kind of terrible anyway) -nixvimDocs.json - diff --git a/docs/man-nixvim.xml b/docs/man-nixvim.xml deleted file mode 100644 index de162807..00000000 --- a/docs/man-nixvim.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - nixvim.nix - 5 - NixVim - - - - nixvim.nix - NixVim configuration specification - - - Description - - TODO - - - - Options - - You can use the following options in your nixvim config - - - - diff --git a/docs/man-pages.xml b/docs/man-pages.xml deleted file mode 100644 index 9d4c1ce8..00000000 --- a/docs/man-pages.xml +++ /dev/null @@ -1,11 +0,0 @@ - - NixVim Reference Pages - - NixVim contributors - 2021-2022NixVim contributors - - - - diff --git a/docs/manual.xml b/docs/manual.xml deleted file mode 100644 index 090643d3..00000000 --- a/docs/manual.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - NixVim Manual - - - Preface - - This manual is meant to serve as the ultimate reference for how to use and install NixVim. - - - If you have any issues, questions, or plugin suggestions please open an issue on the - NixVim GitHub - - - - Configuration Options - - - diff --git a/docs/plugins.md b/docs/plugins.md deleted file mode 100644 index 954ca512..00000000 --- a/docs/plugins.md +++ /dev/null @@ -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"; - - # ... -}; -``` diff --git a/docs/plugins/colorschemes/base16.md b/docs/plugins/colorschemes/base16.md deleted file mode 100644 index 04ce3441..00000000 --- a/docs/plugins/colorschemes/base16.md +++ /dev/null @@ -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` diff --git a/docs/plugins/colorschemes/gruvbox.md b/docs/plugins/colorschemes/gruvbox.md deleted file mode 100644 index b7e8880e..00000000 --- a/docs/plugins/colorschemes/gruvbox.md +++ /dev/null @@ -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` - diff --git a/docs/plugins/colorschemes/one.md b/docs/plugins/colorschemes/one.md deleted file mode 100644 index 2fa8db13..00000000 --- a/docs/plugins/colorschemes/one.md +++ /dev/null @@ -1,6 +0,0 @@ -# vim-one -## Options -### `colorschemes.one.enable` -**Description**: Enable vim-one - -**Type**: `bool` diff --git a/docs/plugins/colorschemes/onedark.md b/docs/plugins/colorschemes/onedark.md deleted file mode 100644 index 92621b25..00000000 --- a/docs/plugins/colorschemes/onedark.md +++ /dev/null @@ -1,6 +0,0 @@ -# onedark -## Options -### `colorschemes.onedark.enable` -**Description**: Enable onedark - -**Type**: `bool` diff --git a/docs/plugins/colorschemes/tokyonight.md b/docs/plugins/colorschemes/tokyonight.md deleted file mode 100644 index efb53b11..00000000 --- a/docs/plugins/colorschemes/tokyonight.md +++ /dev/null @@ -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` diff --git a/docs/plugins/git/fugitive.md b/docs/plugins/git/fugitive.md deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/plugins/git/gitgutter.md b/docs/plugins/git/gitgutter.md deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/plugins/languages/ledger.md b/docs/plugins/languages/ledger.md deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/plugins/languages/nix.md b/docs/plugins/languages/nix.md deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/plugins/languages/treesitter.md b/docs/plugins/languages/treesitter.md deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/plugins/languages/zig.md b/docs/plugins/languages/zig.md deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/plugins/nvim-lsp/clangd.md b/docs/plugins/nvim-lsp/clangd.md deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/plugins/nvim-lsp/default.md b/docs/plugins/nvim-lsp/default.md deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/plugins/nvim-lsp/lspsaga.md b/docs/plugins/nvim-lsp/lspsaga.md deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/plugins/nvim-lsp/rnix-lsp.md b/docs/plugins/nvim-lsp/rnix-lsp.md deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/plugins/nvim-lsp/rust-analyzer.md b/docs/plugins/nvim-lsp/rust-analyzer.md deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/plugins/pluginmanagers/packer.md b/docs/plugins/pluginmanagers/packer.md deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/plugins/statuslines/airline.md b/docs/plugins/statuslines/airline.md deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/plugins/statuslines/lightline.md b/docs/plugins/statuslines/lightline.md deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/plugins/utils/barbar.md b/docs/plugins/utils/barbar.md deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/plugins/utils/commentary.md b/docs/plugins/utils/commentary.md deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/plugins/utils/endwise.md b/docs/plugins/utils/endwise.md deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/plugins/utils/goyo.md b/docs/plugins/utils/goyo.md deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/plugins/utils/nvim-autopairs.md b/docs/plugins/utils/nvim-autopairs.md deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/plugins/utils/startify.md b/docs/plugins/utils/startify.md deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/plugins/utils/telescope.md b/docs/plugins/utils/telescope.md deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/plugins/utils/undotree.md b/docs/plugins/utils/undotree.md deleted file mode 100644 index e69de29b..00000000 diff --git a/example.nix b/example.nix index 0fe208b1..20a89dc2 100644 --- a/example.nix +++ b/example.nix @@ -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; diff --git a/flake.lock b/flake.lock index 73627e2d..c4dfdf24 100644 --- a/flake.lock +++ b/flake.lock @@ -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" } } }, diff --git a/flake.nix b/flake.nix index 4b1aef0d..ac6957c2 100644 --- a/flake.nix +++ b/flake.nix @@ -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; }; } diff --git a/modules/highlights.nix b/modules/highlights.nix new file mode 100644 index 00000000..0f5fc1f0 --- /dev/null +++ b/modules/highlights.nix @@ -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 + -- }} + ''; + }; +} diff --git a/modules/keymaps.nix b/modules/keymaps.nix index b6426a9b..b75cf954 100644 --- a/modules/keymaps.nix +++ b/modules/keymaps.nix @@ -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 -- }}} diff --git a/modules/options.nix b/modules/options.nix index 76bceeb1..d3de54c0 100644 --- a/modules/options.nix +++ b/modules/options.nix @@ -1,5 +1,8 @@ -{ config, lib, helpers, ... }: +{ config, lib, ... }: with lib; +let + helpers = import ../plugins/helpers.nix { inherit lib; }; +in { options = { options = mkOption { diff --git a/modules/output.nix b/modules/output.nix index 40e2369e..516607b6 100644 --- a/modules/output.nix +++ b/modules/output.nix @@ -22,6 +22,22 @@ let in { options = { + viAlias = mkOption { + type = types.bool; + default = false; + description = '' + Symlink vi to nvim binary. + ''; + }; + + vimAlias = mkOption { + type = types.bool; + default = false; + description = '' + Symlink vim to nvim 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 <) 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', 'lua require"gitsigns".stage_hunk()', {}) + ... -- 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 = " , - "; + 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 = " "; + 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}) + ''; + }; +} diff --git a/plugins/helpers.nix b/plugins/helpers.nix index 35c3398b..ab6a9866 100644 --- a/plugins/helpers.nix +++ b/plugins/helpers.nix @@ -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: '' diff --git a/plugins/languages/plantuml-syntax.nix b/plugins/languages/plantuml-syntax.nix new file mode 100644 index 00000000..edfcab53 --- /dev/null +++ b/plugins/languages/plantuml-syntax.nix @@ -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; + }; + }; +} diff --git a/plugins/languages/treesitter-context.nix b/plugins/languages/treesitter-context.nix new file mode 100644 index 00000000..35e09ea9 --- /dev/null +++ b/plugins/languages/treesitter-context.nix @@ -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; + }; + }; +} diff --git a/plugins/languages/treesitter-refactor.nix b/plugins/languages/treesitter-refactor.nix new file mode 100644 index 00000000..56b768a3 --- /dev/null +++ b/plugins/languages/treesitter-refactor.nix @@ -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)`. + ''; + }; + 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 = ""; + description = "go to next usage of identifier under the cursor"; + }; + gotoPreviousUsage = mkOption { + type = types.nullOr types.str; + default = ""; + 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; + }; + }; + }; + }; +} diff --git a/plugins/languages/treesitter.nix b/plugins/languages/treesitter.nix index 73bfd223..8539af81 100644 --- a/plugins/languages/treesitter.nix +++ b/plugins/languages/treesitter.nix @@ -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 ]; diff --git a/plugins/null-ls/servers.nix b/plugins/null-ls/servers.nix index b554077f..da44c114 100644 --- a/plugins/null-ls/servers.nix +++ b/plugins/null-ls/servers.nix @@ -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; + }; } diff --git a/plugins/nvim-lsp/basic-servers.nix b/plugins/nvim-lsp/basic-servers.nix index fabcc8bd..bcb4d26e 100644 --- a/plugins/nvim-lsp/basic-servers.nix +++ b/plugins/nvim-lsp/basic-servers.nix @@ -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 { diff --git a/plugins/nvim-lsp/default.nix b/plugins/nvim-lsp/default.nix index 8949510d..f2f74593 100644 --- a/plugins/nvim-lsp/default.nix +++ b/plugins/nvim-lsp/default.nix @@ -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 diff --git a/plugins/nvim-lsp/helpers.nix b/plugins/nvim-lsp/helpers.nix index ed4e6f35..76ca74ec 100644 --- a/plugins/nvim-lsp/helpers.nix +++ b/plugins/nvim-lsp/helpers.nix @@ -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 { }; }; }]; }; diff --git a/plugins/nvim-lsp/lsp-lines.nix b/plugins/nvim-lsp/lsp-lines.nix index 54ece053..e415b469 100644 --- a/plugins/nvim-lsp/lsp-lines.nix +++ b/plugins/nvim-lsp/lsp-lines.nix @@ -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 ''; }; diff --git a/plugins/nvim-lsp/trouble.nix b/plugins/nvim-lsp/trouble.nix new file mode 100644 index 00000000..c21f41bb --- /dev/null +++ b/plugins/nvim-lsp/trouble.nix @@ -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 + ]; + }; +} diff --git a/plugins/plugin-defs.nix b/plugins/plugin-defs.nix index d6e9cda3..52064873 100644 --- a/plugins/plugin-defs.nix +++ b/plugins/plugin-defs.nix @@ -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"; + }; + }) + ]; + }; } diff --git a/plugins/snippets/luasnip/default.nix b/plugins/snippets/luasnip/default.nix new file mode 100644 index 00000000..66fcae81 --- /dev/null +++ b/plugins/snippets/luasnip/default.nix @@ -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; + }; +} diff --git a/plugins/telescope/default.nix b/plugins/telescope/default.nix index dd3397c2..46d1ba3a 100644 --- a/plugins/telescope/default.nix +++ b/plugins/telescope/default.nix @@ -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) diff --git a/plugins/utils/magma-nvim.nix b/plugins/utils/magma-nvim.nix new file mode 100644 index 00000000..67fa1358 --- /dev/null +++ b/plugins/utils/magma-nvim.nix @@ -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; + + }; + }; + +} + diff --git a/plugins/utils/nvim-tree.nix b/plugins/utils/nvim-tree.nix index 697dec06..351f49ba 100644 --- a/plugins/utils/nvim-tree.nix +++ b/plugins/utils/nvim-tree.nix @@ -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; diff --git a/plugins/utils/project-nvim.nix b/plugins/utils/project-nvim.nix index ff76926f..d81b7251 100644 --- a/plugins/utils/project-nvim.nix +++ b/plugins/utils/project-nvim.nix @@ -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 ]; diff --git a/plugins/utils/specs.nix b/plugins/utils/specs.nix index 5edd292d..9ebd3cb6 100644 --- a/plugins/utils/specs.nix +++ b/plugins/utils/specs.nix @@ -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}) ''; diff --git a/test.sh b/test.sh deleted file mode 100755 index bb66d707..00000000 --- a/test.sh +++ /dev/null @@ -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 $@ diff --git a/tests/flake.lock b/tests/flake.lock index 3b224d8c..1a49f821 100644 --- a/tests/flake.lock +++ b/tests/flake.lock @@ -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", diff --git a/tests/flake.nix b/tests/flake.nix index 1b083b37..1a23bdee 100644 --- a/tests/flake.nix +++ b/tests/flake.nix @@ -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."," = "echo \"test\""; + }; + 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."hb" = "lua require('gitsigns').blame_line{full=true}"; + }; + + 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 { diff --git a/wrappers/darwin.nix b/wrappers/darwin.nix new file mode 100644 index 00000000..75365711 --- /dev/null +++ b/wrappers/darwin.nix @@ -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 ]; + }; +} diff --git a/wrappers/hm.nix b/wrappers/hm.nix index 5a547b97..e10b63ca 100644 --- a/wrappers/hm.nix +++ b/wrappers/hm.nix @@ -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; }) ]); } diff --git a/wrappers/nixos.nix b/wrappers/nixos.nix index a82bc056..f0474eea 100644 --- a/wrappers/nixos.nix +++ b/wrappers/nixos.nix @@ -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"; }) ]); diff --git a/wrappers/standalone.nix b/wrappers/standalone.nix index a21cd33b..20fb9667 100644 --- a/wrappers/standalone.nix +++ b/wrappers/standalone.nix @@ -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