Compare commits

...

23 commits

Author SHA1 Message Date
raf
b96cd1a42d
Merge 7d077f43f7 into f9789432f9 2024-07-20 14:52:39 +03:00
diniamo
f9789432f9
treewide: make the entire generated config lua based (#333)
* modules: switch to gerg's neovim-wrapper

* modules: use initViml instead of writing the file

* treewide: make the entire generated config lua based

* docs: remove mentions of configRC

* plugins/treesitter: remove vim.cmd hack

* treewide: move resolveDag to lib

* modules/wrapper(rc): fix typo

* treewide: migrate to pluginRC for correct DAG order

The "new" DAG order is as follows:
- (luaConfigPre)
- globalsScript
- basic
- theme
- pluginConfigs
- extraPluginConfigs
- mappings
- (luaConfigPost)

* plugins/theme: fix theme DAG place

* plugins/theme: fix fixed theme DAG place

* modules/wrapper(rc): add removed option module for configRC

* docs: add dag-entries chapter, add release note entry

* fix: formatting CI

* languages/nix: add missing `local`

* docs: fix page link

* docs: add mention of breaking changes at the start of the release notes

* plugins/neo-tree: convert to pluginRC

* modules/wrapper(rc): add back entryAnywhere

* modules/wrapper(rc): expose pluginRC

* apply raf patch

---------

Co-authored-by: NotAShelf <raf@notashelf.dev>
2024-07-20 08:30:48 +00:00
diniamo
cbff0e4715
flake: fix neovimConfiguration in top-level lib (#345) 2024-07-20 08:22:13 +00:00
Ching Pei Yang
9c93e9a9c0
Switch to rustaceanvim (#335)
* flake: use rustaceanvim instead of rust-tools

* rust: switch to rustaceanvim

* docs: update release notes

* flake: update nixpkgs

* docs: wording

---------

Co-authored-by: raf <raf@notashelf.dev>
2024-07-18 11:48:28 +02:00
Frothy
0f17147d52
modules: fix unused src and version attrs in buildPlug (#340)
* modules: fix unused src and version attrs in buildPlug

* docs: add entry for buildPlug fix
2024-07-16 08:00:50 +00:00
raf
a4d35b4419
plugins/neo-tree: init module (#248)
* plugins/neo-tree: init module

* filetree/neo-tree: add setup options until border styles

* plugins/filetree: rename module name

* docs: update changelogs

Mention the addition of neo-tree.
2024-07-14 18:30:12 +00:00
Gerg-L
1426c83ce6
gerg: switch to new repo (#338)
* gerg: switch to new repo

* modules/default: fix buildPlug
2024-07-14 03:47:21 +00:00
Gerg-L
f6a058d1ed
flake.lock: Update (#337)
Flake lock file updates:

• Updated input 'neovim-wrapper':
    'github:Gerg-L/neovim-wrapper/be1a9ec41230708ac72cabb1c5f4492f4f01f6d1?narHash=sha256-hQ%2B%2Be9r03DPy9UByZ3aSweRn74EUx3HuoBTaUzYdE0E%3D' (2024-07-13)
  → 'github:Gerg-L/neovim-wrapper/bdcac428162888855b84fb703b29db76c1de6e73?narHash=sha256-ei4ap9Y076Livf7HNi0DeCG3FNfuKfnrmjqMkF4UbLs%3D' (2024-07-13)
2024-07-13 23:20:45 +00:00
Gerg-L
ce0b361bca
flake.lock: update neovim-wrapper (#336)
* flake.lock: update neovim-wrapper

* modules/default: half size of plugins
2024-07-13 22:04:10 +00:00
raf
5fab82ba91
modules: switch to gerg's neovim-wrapper (#325)
* modules: switch to gerg's neovim-wrapper

* Use initViml instead of writeText (#330)

---------

Co-authored-by: diniamo <55629891+diniamo@users.noreply.github.com>
2024-07-13 15:05:21 +00:00
diniamo
32d231395f
plugins/visuals(indent-blankline): move to setupOpts (#329)
* plugins/visuals(indent-blankline): move to setupOpts

* configuration: match indentblankline part with changes
2024-07-12 15:47:33 +00:00
diniamo
901363d1ac
treewide: refactor custom lib, merge lists in hm/nixos module (#323)
* treewide: refactor custom lib, merge lists in hm/nixos module

* lib/types(custom): clarify anythingConcatLists code

---------

Co-authored-by: raf <raf@notashelf.dev>
2024-07-11 22:49:44 +00:00
Ching Pei Yang
0c444830f6
lualine: use mkDefault on backwards compat configs (#318)
Co-authored-by: Pei Yang Ching <pei.ching@check24.de>
2024-07-10 21:07:04 +00:00
Ching Pei Yang
9b48c30e20
Feat noice setup opts (#297)
* noice: add setupOpts

* noice: add filter

* noice: use setupOpts

* docs: update release notes

* noice: allow null option

* noice: add descriptions for some options
2024-07-10 21:02:48 +00:00
diniamo
82d67cbc66
lib/types: expose pluginType (#322) 2024-07-10 21:58:37 +02:00
0dca62eaa2
languages/ts: use typescript-language-server from top-level 2024-07-10 12:44:54 +03:00
d33fdda463
flake: update nixpkgs input 2024-07-10 12:44:03 +03:00
Ching Pei Yang
8071bfdb72
Fix typos (#326)
* fix: typo

* docs: wrong link
2024-07-09 23:37:07 +00:00
Gerg-L
8d5f23035d
treewide: cleanup (#324)
* statix, deadnix, alejandra

* _file

* _module.args

* concatStringsSep "\n" -> concatLines
concatStringsSep "\n" map -> concatMapStringsSep "\n"

* mkShell nativeBuildInputs -> packages
2024-07-08 21:57:58 +00:00
7d077f43f7
neovim/global: begin adding vim.diagnostics.config() options 2024-05-17 19:03:05 +03:00
cb57d3d417
plugins/ui: re-organize imports 2024-05-17 19:02:37 +03:00
754c29cb7c
neovim/global: add ui/icons 2024-05-17 18:25:26 +03:00
0e84e4ebed
modules/plugins: move plugins/ui to neovim/global/ui 2024-05-17 18:25:25 +03:00
121 changed files with 1646 additions and 1088 deletions

View file

@ -1,21 +1,4 @@
inputs: let isMaximal: {
modulesWithInputs = import ./modules inputs;
neovimConfiguration = {
modules ? [],
pkgs,
lib ? pkgs.lib,
check ? true,
extraSpecialArgs ? {},
extraModules ? [],
...
}:
modulesWithInputs {
inherit pkgs lib check extraSpecialArgs extraModules;
configuration.imports = modules;
};
mainConfig = isMaximal: {
config.vim = { config.vim = {
viAlias = true; viAlias = true;
vimAlias = true; vimAlias = true;
@ -99,14 +82,7 @@ inputs: let
fidget-nvim.enable = true; fidget-nvim.enable = true;
highlight-undo.enable = true; highlight-undo.enable = true;
indentBlankline = { indentBlankline.enable = true;
enable = true;
fillChar = null;
eolChar = null;
scope = {
enabled = true;
};
};
cursorline = { cursorline = {
enable = true; enable = true;
@ -254,7 +230,4 @@ inputs: let
neocord.enable = false; neocord.enable = false;
}; };
}; };
};
in {
inherit neovimConfiguration mainConfig;
} }

View file

@ -1,7 +1,7 @@
{ {
inputs, inputs,
pkgs, pkgs,
lib ? import ../lib/stdlib-extended.nix pkgs.lib inputs, lib,
manpageUrls ? pkgs.path + "/doc/manpage-urls.json", manpageUrls ? pkgs.path + "/doc/manpage-urls.json",
... ...
}: let }: let

View file

@ -5,4 +5,5 @@ configuring/custom-package.md
configuring/custom-plugins.md configuring/custom-plugins.md
configuring/languages.md configuring/languages.md
configuring/dags.md configuring/dags.md
configuring/dag-entries.md
``` ```

View file

@ -1,16 +1,38 @@
# Configuring {#sec-configuring-plugins} # Configuring {#sec-configuring-plugins}
Just making the plugin to your Neovim configuration available might not always Just making the plugin to your Neovim configuration available might not always
be enough. In that case, you can write custom vimscript or lua config, using be enough. In that case, you can write custom lua config using either
either `config.vim.configRC` or `config.vim.luaConfigRC` respectively. Both of `config.vim.extraPlugins` (which has the `setup` field) or
these options are attribute sets, and you need to give the configuration you're `config.vim.luaConfigRC`. The first option uses an attribute set, which maps DAG
adding some name, like this: section names to a custom type, which has the fields `package`, `after`,
`setup`. They allow you to set the package of the plugin, the sections its setup
code should be after (note that the `extraPlugins` option has its own DAG
scope), and the its setup code respectively. For example:
```nix
config.vim.extraPlugins = with pkgs.vimPlugins; {
aerial = {
package = aerial-nvim;
setup = "require('aerial').setup {}";
};
harpoon = {
package = harpoon;
setup = "require('harpoon').setup {}";
after = ["aerial"]; # place harpoon configuration after aerial
};
}
```
The second option also uses an attribute set, but this one is resolved as a DAG
directly. The attribute names denote the section names, and the values lua code.
For example:
```nix ```nix
{ {
# this will create an "aquarium" section in your init.vim with the contents of your custom config # this will create an "aquarium" section in your init.lua with the contents of your custom config
# which will be *appended* to the rest of your configuration, inside your init.vim # which will be *appended* to the rest of your configuration, inside your init.vim
config.vim.configRC.aquarium = "colorscheme aquiarum"; config.vim.luaConfigRC.aquarium = "vim.cmd('colorscheme aquiarum')";
} }
``` ```

View file

@ -0,0 +1,20 @@
# DAG entries in nvf {#ch-dag-entries}
From the previous chapter, it should be clear that DAGs are useful, because you
can add code that relies on other code. However, if you don't know what the
entries are called, it's hard to do that, so here is a list of the internal
entries in nvf:
`vim.luaConfigRC` (top-level DAG):
1. (`luaConfigPre`) - not a part of the actual DAG, instead, it's simply
inserted before the rest of the DAG
2. `globalsScript` - used to set globals defined in `vim.globals`
3. `basic` - used to set basic configuration options
4. `theme` - used to set up the theme, which has to be done before other plugins
5. `pluginConfigs` - the result of the nested `vim.pluginRC` (internal option,
see the [Custom Plugins](/index.xhtml#ch-custom-plugins) page for adding your own
plugins) DAG, used to set up internal plugins
6. `extraPluginConfigs` - the result of `vim.extraPlugins`, which is not a
direct DAG, but is converted to, and resolved as one internally
7. `mappings` - the result of `vim.maps`

View file

@ -7,7 +7,7 @@ type which is borrowed from home-manager's extended library. This type is most
used for topologically sorting strings. The DAG type allows the attribute set used for topologically sorting strings. The DAG type allows the attribute set
entries to express dependency relations among themselves. This can, for entries to express dependency relations among themselves. This can, for
example, be used to control the order of configuration sections in your example, be used to control the order of configuration sections in your
`configRC` or `luaConfigRC`. `luaConfigRC`.
The below section, mostly taken from the [home-manager The below section, mostly taken from the [home-manager
manual](https://raw.githubusercontent.com/nix-community/home-manager/master/docs/manual/writing-modules/types.md) manual](https://raw.githubusercontent.com/nix-community/home-manager/master/docs/manual/writing-modules/types.md)

View file

@ -2,6 +2,28 @@
Release notes for release 0.7 Release notes for release 0.7
## Breaking Changes and Migration Guide {#sec-breaking-changes-and-migration-guide-0-7}
In v0.7 we are removing `vim.configRC` in favor of making `vim.luaConfigRC` the
top-level DAG, and thereby making the entire configuration Lua based. This
change introduces a few breaking changes:
[DAG entries in nvf manual]: /index.xhtml#ch-dag-entries
- `vim.configRC` has been removed, which means that you have to convert all of
your custom vimscript-based configuration to Lua. As for how to do that, you
will have to consult the Neovim documentation and your search engine.
- After migrating your Vimscript-based configuration to Lua, you might not be
able to use the same entry names in `vim.luaConfigRC`, because those have also
slightly changed. See the new [DAG entries in nvf manual] for more details.
**Why?**
Neovim being an aggressive refactor of Vim, is designed to be mainly Lua based;
making good use of its extensive Lua API. Additionally, Vimscript is slow and
brings unnecessary performance overhead while working with different
configuration formats.
## Changelog {#sec-release-0.7-changelog} ## Changelog {#sec-release-0.7-changelog}
[ItsSorae](https://github.com/ItsSorae): [ItsSorae](https://github.com/ItsSorae):
@ -12,8 +34,8 @@ Release notes for release 0.7
[frothymarrow](https://github.com/frothymarrow): [frothymarrow](https://github.com/frothymarrow):
- Modified type for - Modified type for
[vim.visuals.fidget-nvim.setupOpts.progress.display.overrides](#opt-vim.visuals.fidget-nvim.setupOpts.progress.display.overrides) [](#opt-vim.visuals.fidget-nvim.setupOpts.progress.display.overrides) from
from `anything` to a `submodule` for better type checking. `anything` to a `submodule` for better type checking.
- Fix null `vim.lsp.mappings` generating an error and not being filtered out. - Fix null `vim.lsp.mappings` generating an error and not being filtered out.
@ -21,21 +43,34 @@ Release notes for release 0.7
group for `Normal`, `NormalFloat`, `LineNr`, `SignColumn` and optionally group for `Normal`, `NormalFloat`, `LineNr`, `SignColumn` and optionally
`NvimTreeNormal` to `none`. `NvimTreeNormal` to `none`.
- Fix [vim.ui.smartcolumn.setupOpts.custom_colorcolumn](#opt-vim.ui.smartcolumn.setupOpts.custom_colorcolumn) - Fix [](#opt-vim.ui.smartcolumn.setupOpts.custom_colorcolumn) using the wrong
using the wrong type `int` instead of the expected type `string`. type `int` instead of the expected type `string`.
- Fix unused src and version attributes in `buildPlug`.
[horriblename](https://github.com/horriblename): [horriblename](https://github.com/horriblename):
- Fix broken treesitter-context keybinds in visual mode - Fix broken treesitter-context keybinds in visual mode
- Deprecate use of `__empty` to define empty tables in lua. Empty attrset are no - Deprecate use of `__empty` to define empty tables in Lua. Empty attrset are no
longer filtered and thus should be used instead. longer filtered and thus should be used instead.
- Add dap-go for better dap configurations - Add dap-go for better dap configurations
- Make noice.nvim customizable
[rust-tools.nvim]: https://github.com/simrat39/rust-tools.nvim
[rustaceanvim]: https://github.com/mrcjkb/rustaceanvim
- Switch from [rust-tools.nvim] to the more feature-packed [rustaceanvim]. This
switch entails a whole bunch of new features and options, so you are
recommended to go through rustacean.nvim's README to take a closer look at its
features and usage
[jacekpoz](https://github.com/jacekpoz): [jacekpoz](https://github.com/jacekpoz):
- Add [ocaml-lsp](https://github.com/ocaml/ocaml-lsp) support. [ocaml-lsp]: https://github.com/ocaml/ocaml-lsp
- Fix Emac typo - Add [ocaml-lsp] support
- Fix "Emac" typo
[diniamo](https://github.com/diniamo): [diniamo](https://github.com/diniamo):
@ -43,14 +78,46 @@ Release notes for release 0.7
- Add rustfmt as the default formatter for Rust. - Add rustfmt as the default formatter for Rust.
- Enabled the terminal integration of catppuccin for theming Neovim's built-in terminal (this also affects toggleterm). - Enabled the terminal integration of catppuccin for theming Neovim's built-in
terminal (this also affects toggleterm).
- Migrate bufferline to setupOpts for more customizability - Migrate bufferline to setupOpts for more customizability
- Use `clangd` as the default language server for C languages - Use `clangd` as the default language server for C languages
- Expose `lib.nvim.types.pluginType`, which for example allows the user to
create abstractions for adding plugins
- Migrate indent-blankline to setupOpts for more customizability. While the
plugin's options can now be found under `indentBlankline.setupOpts`, the
previous iteration of the module also included out of place/broken options,
which have been removed for the time being. These are:
- `listChar` - this was already unused
- `fillChar` - this had nothing to do with the plugin, please configure it
yourself by adding `vim.opt.listchars:append({ space = '<char>' })` to your
lua configuration
- `eolChar` - this also had nothing to do with the plugin, please configure it
yourself by adding `vim.opt.listchars:append({ eol = '<char>' })` to your
lua configuration
[Neovim documentation on `vim.cmd`]: https://neovim.io/doc/user/lua.html#vim.cmd()
- Make Neovim's configuration file entirely Lua based. This comes with a few
breaking changes:
- `vim.configRC` has been removed. You will need to migrate your entries to
Neovim-compliant Lua code, and add them to `vim.luaConfigRC` instead.
Existing vimscript configurations may be preserved in `vim.cmd` functions.
Please see [Neovim documentation on `vim.cmd`]
- `vim.luaScriptRC` is now the top-level DAG, and the internal `vim.pluginRC`
has been introduced for setting up internal plugins. See the "DAG entries in
nvf" manual page for more information.
[NotAShelf](https://github.com/notashelf): [NotAShelf](https://github.com/notashelf):
[ts-error-translator.nvim]: https://github.com/dmmulroy/ts-error-translator.nvim
[credo]: https://github.com/rrrene/credo
- Add `deno fmt` as the default Markdown formatter. This will be enabled - Add `deno fmt` as the default Markdown formatter. This will be enabled
automatically if you have autoformatting enabled, but can be disabled manually automatically if you have autoformatting enabled, but can be disabled manually
if you choose to. if you choose to.
@ -60,15 +127,17 @@ Release notes for release 0.7
- Refactor `programs.languages.elixir` to use lspconfig and none-ls for LSP and - Refactor `programs.languages.elixir` to use lspconfig and none-ls for LSP and
formatter setups respectively. Diagnostics support is considered, and may be formatter setups respectively. Diagnostics support is considered, and may be
added once the [credo](https://github.com/rrrene/credo) linter has been added added once the [credo] linter has been added to nixpkgs. A pull request is
to nixpkgs. A pull request is currently open. currently open.
- Remove vim-tidal and friends. - Remove vim-tidal and friends.
- Clean up Lualine module to reduce theme dependency on Catppuccin, and fixed - Clean up Lualine module to reduce theme dependency on Catppuccin, and fixed
blending issues in component separators. blending issues in component separators.
- Add - Add [ts-ereror-translator.nvim] extension of the TS language module, under
[ts-error-translator.nvim](https://github.com/dmmulroy/ts-error-translator.nvim) `vim.languages.ts.extensions.ts-error-translator` to aid with Typescript
extension of the TS language module, under development.
`vim.languages.ts.extensions.ts-error-translator`
- Add [neo-tree.nvim] as an alternative file-tree plugin. It will be available
under `vim.filetree.neo-tree`, similar to nvimtree.

View file

@ -67,6 +67,21 @@
"type": "github" "type": "github"
} }
}, },
"mnw": {
"locked": {
"lastModified": 1720927281,
"narHash": "sha256-4Z2FtCuL0lT+sM2gb1JMcXOUkeYrWeYZjjs1HuVTlOs=",
"owner": "Gerg-L",
"repo": "mnw",
"rev": "302b18ddb8498aa9a7e0c01f7026e49d545e6898",
"type": "github"
},
"original": {
"owner": "Gerg-L",
"repo": "mnw",
"type": "github"
}
},
"naersk": { "naersk": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@ -114,11 +129,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1719082008, "lastModified": 1721016451,
"narHash": "sha256-jHJSUH619zBQ6WdC21fFAlDxHErKVDJ5fpN0Hgx4sjs=", "narHash": "sha256-Cypl9ORr5UjtBsbjXMTJRepTe362yNVrPrntUvHiTaw=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "9693852a2070b398ee123a329e68f0dab5526681", "rev": "a14c5d651cee9ed70f9cd9e83f323f1e531002db",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -876,6 +891,22 @@
"type": "github" "type": "github"
} }
}, },
"plugin-neo-tree-nvim": {
"flake": false,
"locked": {
"lastModified": 1713050882,
"narHash": "sha256-cZwOVpdMT0NCtp6Ha592QA2RzKVS6LhXXcjfDBCQ+0k=",
"owner": "nvim-neo-tree",
"repo": "neo-tree.nvim",
"rev": "22e566aeb075c94f670f34077e05ba95190dfb4a",
"type": "github"
},
"original": {
"owner": "nvim-neo-tree",
"repo": "neo-tree.nvim",
"type": "github"
}
},
"plugin-neocord": { "plugin-neocord": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -1453,19 +1484,19 @@
"type": "github" "type": "github"
} }
}, },
"plugin-rust-tools": { "plugin-rustaceanvim": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1704259376, "lastModified": 1720595685,
"narHash": "sha256-kFane5ze7VDiOzF7jdmXkr50XQsNvdb+a9HQtybEVE0=", "narHash": "sha256-Mx8pB9ECjFpbfmZPuXfpwoE5pUZ363M53f27ht7MBmA=",
"owner": "simrat39", "owner": "mrcjkb",
"repo": "rust-tools.nvim", "repo": "rustaceanvim",
"rev": "676187908a1ce35ffcd727c654ed68d851299d3e", "rev": "047f9c9d8cd2861745eb9de6c1570ee0875aa795",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "simrat39", "owner": "mrcjkb",
"repo": "rust-tools.nvim", "repo": "rustaceanvim",
"type": "github" "type": "github"
} }
}, },
@ -1781,6 +1812,7 @@
"inputs": { "inputs": {
"flake-parts": "flake-parts", "flake-parts": "flake-parts",
"flake-utils": "flake-utils", "flake-utils": "flake-utils",
"mnw": "mnw",
"nil": "nil", "nil": "nil",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"nmd": "nmd", "nmd": "nmd",
@ -1827,6 +1859,7 @@
"plugin-mind-nvim": "plugin-mind-nvim", "plugin-mind-nvim": "plugin-mind-nvim",
"plugin-minimap-vim": "plugin-minimap-vim", "plugin-minimap-vim": "plugin-minimap-vim",
"plugin-modes-nvim": "plugin-modes-nvim", "plugin-modes-nvim": "plugin-modes-nvim",
"plugin-neo-tree-nvim": "plugin-neo-tree-nvim",
"plugin-neocord": "plugin-neocord", "plugin-neocord": "plugin-neocord",
"plugin-neodev-nvim": "plugin-neodev-nvim", "plugin-neodev-nvim": "plugin-neodev-nvim",
"plugin-noice-nvim": "plugin-noice-nvim", "plugin-noice-nvim": "plugin-noice-nvim",
@ -1863,7 +1896,7 @@
"plugin-project-nvim": "plugin-project-nvim", "plugin-project-nvim": "plugin-project-nvim",
"plugin-registers": "plugin-registers", "plugin-registers": "plugin-registers",
"plugin-rose-pine": "plugin-rose-pine", "plugin-rose-pine": "plugin-rose-pine",
"plugin-rust-tools": "plugin-rust-tools", "plugin-rustaceanvim": "plugin-rustaceanvim",
"plugin-scrollbar-nvim": "plugin-scrollbar-nvim", "plugin-scrollbar-nvim": "plugin-scrollbar-nvim",
"plugin-smartcolumn": "plugin-smartcolumn", "plugin-smartcolumn": "plugin-smartcolumn",
"plugin-sqls-nvim": "plugin-sqls-nvim", "plugin-sqls-nvim": "plugin-sqls-nvim",

View file

@ -1,19 +1,22 @@
{ {
description = "A neovim flake with a modular configuration"; description = "A neovim flake with a modular configuration";
outputs = { outputs = {
nixpkgs,
flake-parts, flake-parts,
self, self,
... ...
} @ inputs: } @ inputs: let
flake-parts.lib.mkFlake {inherit inputs;} { # call the extedended library with `inputs`
# inputs is used to get the original standard library, and to pass inputs to the plugin autodiscovery function
lib = import ./lib/stdlib-extended.nix inputs;
in
flake-parts.lib.mkFlake {
inherit inputs;
specialArgs = {inherit lib;};
} {
# provide overridable systems # provide overridable systems
# https://github.com/nix-systems/nix-systems # https://github.com/nix-systems/nix-systems
systems = import inputs.systems; systems = import inputs.systems;
imports = [ imports = [
# add lib to module args
{_module.args = {inherit (nixpkgs) lib;};}
./flake/apps.nix ./flake/apps.nix
./flake/legacyPackages.nix ./flake/legacyPackages.nix
./flake/overlays.nix ./flake/overlays.nix
@ -22,36 +25,32 @@
flake = { flake = {
lib = { lib = {
inherit (import ./lib/stdlib-extended.nix nixpkgs.lib inputs) nvim; inherit (lib) nvim;
inherit (import ./configuration.nix inputs) neovimConfiguration; inherit (lib.nvim) neovimConfiguration;
}; };
homeManagerModules = { homeManagerModules = {
neovim-flake = neovim-flake =
nixpkgs.lib.warn '' lib.warn ''
homeManagerModules.neovim-flake has been deprecated. homeManagerModules.neovim-flake has been deprecated.
Plese use the homeManagerModules.nvf instead Plese use the homeManagerModules.nvf instead
'' ''
self.homeManagerModules.nvf; self.homeManagerModules.nvf;
nvf = { nvf = import ./flake/modules/home-manager.nix self.packages lib;
imports = [(import ./flake/modules/home-manager.nix self.packages inputs)];
};
default = self.homeManagerModules.nvf; default = self.homeManagerModules.nvf;
}; };
nixosModules = { nixosModules = {
neovim-flake = neovim-flake =
nixpkgs.lib.warn '' lib.warn ''
nixosModules.neovim-flake has been deprecated. nixosModules.neovim-flake has been deprecated.
Please use the nixosModules.nvf instead Please use the nixosModules.nvf instead
'' ''
self.nixosModules.nvf; self.nixosModules.nvf;
nvf = { nvf = import ./flake/modules/nixos.nix self.packages lib;
imports = [(import ./flake/modules/nixos.nix self.packages inputs)];
};
default = self.nixosModules.nvf; default = self.nixosModules.nvf;
}; };
@ -66,9 +65,9 @@
formatter = pkgs.alejandra; formatter = pkgs.alejandra;
devShells = { devShells = {
default = self'.devShells.lsp; default = self'.devShells.lsp;
nvim-nix = pkgs.mkShell {nativeBuildInputs = [config.packages.nix];}; nvim-nix = pkgs.mkShell {packages = [config.packages.nix];};
lsp = pkgs.mkShell { lsp = pkgs.mkShell {
nativeBuildInputs = with pkgs; [nil statix deadnix alejandra]; packages = with pkgs; [nil statix deadnix alejandra];
}; };
}; };
}; };
@ -82,6 +81,9 @@
flake-utils.url = "github:numtide/flake-utils"; flake-utils.url = "github:numtide/flake-utils";
systems.url = "github:nix-systems/default"; systems.url = "github:nix-systems/default";
# Alternate neovim-wrapper
mnw.url = "github:Gerg-L/mnw";
# For generating documentation website # For generating documentation website
nmd = { nmd = {
url = "sourcehut:~rycee/nmd"; url = "sourcehut:~rycee/nmd";
@ -163,8 +165,8 @@
flake = false; flake = false;
}; };
plugin-rust-tools = { plugin-rustaceanvim = {
url = "github:simrat39/rust-tools.nvim"; url = "github:mrcjkb/rustaceanvim";
flake = false; flake = false;
}; };
@ -227,6 +229,11 @@
flake = false; flake = false;
}; };
plugin-neo-tree-nvim = {
url = "github:nvim-neo-tree/neo-tree.nvim";
flake = false;
};
# Tablines # Tablines
plugin-nvim-bufferline-lua = { plugin-nvim-bufferline-lua = {
url = "github:akinsho/nvim-bufferline.lua"; url = "github:akinsho/nvim-bufferline.lua";

View file

@ -1,8 +1,7 @@
# Home Manager module # Home Manager module
packages: inputs: { packages: lib: {
config, config,
pkgs, pkgs,
lib ? pkgs.lib,
... ...
}: let }: let
inherit (lib) maintainers; inherit (lib) maintainers;
@ -10,9 +9,10 @@ packages: inputs: {
inherit (lib.lists) optional; inherit (lib.lists) optional;
inherit (lib.options) mkOption mkEnableOption literalExpression; inherit (lib.options) mkOption mkEnableOption literalExpression;
inherit (lib.types) attrsOf anything bool; inherit (lib.types) attrsOf anything bool;
inherit (lib.nvim) neovimConfiguration;
inherit (lib.nvim.types) anythingConcatLists;
cfg = config.programs.nvf; cfg = config.programs.nvf;
inherit (import ../../configuration.nix inputs) neovimConfiguration;
neovimConfigured = neovimConfiguration { neovimConfigured = neovimConfiguration {
inherit pkgs; inherit pkgs;
@ -55,7 +55,7 @@ in {
}; };
settings = mkOption { settings = mkOption {
type = attrsOf anything; type = attrsOf anythingConcatLists;
default = {}; default = {};
description = "Attribute set of nvf preferences."; description = "Attribute set of nvf preferences.";
example = literalExpression '' example = literalExpression ''
@ -88,4 +88,5 @@ in {
++ optional cfg.enableManpages packages.${pkgs.stdenv.system}.docs-manpages; ++ optional cfg.enableManpages packages.${pkgs.stdenv.system}.docs-manpages;
}; };
}; };
_file = ./home-manager.nix;
} }

View file

@ -1,8 +1,7 @@
# NixOS module # NixOS module
packages: inputs: { packages: lib: {
config, config,
pkgs, pkgs,
lib ? pkgs.lib,
... ...
}: let }: let
inherit (lib) maintainers; inherit (lib) maintainers;
@ -10,9 +9,10 @@ packages: inputs: {
inherit (lib.lists) optional; inherit (lib.lists) optional;
inherit (lib.options) mkOption mkEnableOption literalExpression; inherit (lib.options) mkOption mkEnableOption literalExpression;
inherit (lib.types) attrsOf anything bool; inherit (lib.types) attrsOf anything bool;
inherit (lib.nvim) neovimConfiguration;
inherit (lib.nvim.types) anythingConcatLists;
cfg = config.programs.nvf; cfg = config.programs.nvf;
inherit (import ../../configuration.nix inputs) neovimConfiguration;
neovimConfigured = neovimConfiguration { neovimConfigured = neovimConfiguration {
inherit pkgs; inherit pkgs;
@ -55,7 +55,7 @@ in {
}; };
settings = mkOption { settings = mkOption {
type = attrsOf anything; type = attrsOf anythingConcatLists;
default = {}; default = {};
description = "Attribute set of nvf preferences."; description = "Attribute set of nvf preferences.";
example = literalExpression '' example = literalExpression ''
@ -88,4 +88,5 @@ in {
++ optional cfg.enableManpages packages.${pkgs.stdenv.system}.docs-manpages; ++ optional cfg.enableManpages packages.${pkgs.stdenv.system}.docs-manpages;
}; };
}; };
_file = ./nixos.nix;
} }

View file

@ -1,14 +1,14 @@
{ {
inputs,
pkgs, pkgs,
lib,
... ...
}: let }: let
inherit (import ../configuration.nix inputs) neovimConfiguration mainConfig; inherit (lib.nvim) neovimConfiguration;
buildPkg = pkgs: modules: (neovimConfiguration {inherit pkgs modules;}).neovim; buildPkg = pkgs: modules: (neovimConfiguration {inherit pkgs modules;}).neovim;
nixConfig = mainConfig false; nixConfig = import ../configuration.nix false;
maximalConfig = mainConfig true; maximalConfig = import ../configuration.nix true;
in { in {
flake.overlays.default = _final: prev: { flake.overlays.default = _final: prev: {
inherit neovimConfiguration; inherit neovimConfiguration;

View file

@ -1,11 +1,11 @@
{inputs, ...}: { {inputs, ...}: {
perSystem = { perSystem = {
system,
config, config,
pkgs, pkgs,
lib,
... ...
}: let }: let
docs = import ../docs {inherit pkgs inputs;}; docs = import ../docs {inherit pkgs inputs lib;};
in { in {
packages = { packages = {
# Documentation # Documentation

View file

@ -66,7 +66,7 @@
mkSetLuaBinding = binding: action: mkSetLuaBinding = binding: action:
mkLuaBinding binding.value action binding.description; mkLuaBinding binding.value action binding.description;
pushDownDefault = attr: mapAttrs (_: value: mkDefault value) attr; pushDownDefault = attr: mapAttrs (_: mkDefault) attr;
}; };
in in
binds binds

18
lib/configuration.nix Normal file
View file

@ -0,0 +1,18 @@
{
inputs,
lib,
}: let
modulesWithInputs = import ../modules inputs;
in
{
modules ? [],
pkgs,
check ? true,
extraSpecialArgs ? {},
extraModules ? [],
...
}:
modulesWithInputs {
inherit pkgs lib check extraSpecialArgs extraModules;
configuration.imports = modules;
}

View file

@ -8,10 +8,10 @@
# - the addition of the function `entryBefore` indicating a "wanted # - the addition of the function `entryBefore` indicating a "wanted
# by" relationship. # by" relationship.
{lib}: let {lib}: let
inherit (builtins) isAttrs attrValues attrNames elem all head tail length; inherit (builtins) isAttrs attrValues attrNames elem all head tail length toJSON isString;
inherit (lib.attrsets) filterAttrs mapAttrs; inherit (lib.attrsets) filterAttrs mapAttrs;
inherit (lib.lists) toposort; inherit (lib.lists) toposort;
inherit (lib.nvim.dag) empty isEntry entryBetween entryAfter entriesBetween; inherit (lib.nvim.dag) empty isEntry entryBetween entryAfter entriesBetween entryAnywhere topoSort;
in { in {
empty = {}; empty = {};
@ -84,7 +84,7 @@ in {
normalizedDag = normalizedDag =
mapAttrs (n: v: { mapAttrs (n: v: {
name = n; name = n;
data = v.data; inherit (v) data;
after = v.after ++ dagBefore dag n; after = v.after ++ dagBefore dag n;
}) })
dag; dag;
@ -117,7 +117,6 @@ in {
entriesBetween = tag: let entriesBetween = tag: let
go = i: before: after: entries: let go = i: before: after: entries: let
name = "${tag}-${toString i}"; name = "${tag}-${toString i}";
i' = i + 1;
in in
if entries == [] if entries == []
then empty then empty
@ -148,8 +147,22 @@ in {
${section.data} ${section.data}
''; '';
mkVimrcSection = section: '' resolveDag = {
" SECTION: ${section.name} name,
${section.data} dag,
''; mapResult,
}: let
# When the value is a string, default it to dag.entryAnywhere
finalDag = mapAttrs (_: value:
if isString value
then entryAnywhere value
else value)
dag;
sortedDag = topoSort finalDag;
result =
if sortedDag ? result
then mapResult sortedDag.result
else abort ("Dependency cycle in ${name}: " + toJSON sortedDag);
in
result;
} }

View file

@ -11,5 +11,5 @@
languages = import ./languages.nix {inherit lib;}; languages = import ./languages.nix {inherit lib;};
lists = import ./lists.nix {inherit lib;}; lists = import ./lists.nix {inherit lib;};
lua = import ./lua.nix {inherit lib;}; lua = import ./lua.nix {inherit lib;};
vim = import ./vim.nix; neovimConfiguration = import ./configuration.nix {inherit inputs lib;};
} }

View file

@ -2,19 +2,9 @@
{lib}: let {lib}: let
inherit (builtins) hasAttr head throw typeOf isList isAttrs isBool isInt isString isPath isFloat toJSON; inherit (builtins) hasAttr head throw typeOf isList isAttrs isBool isInt isString isPath isFloat toJSON;
inherit (lib.attrsets) mapAttrsToList filterAttrs; inherit (lib.attrsets) mapAttrsToList filterAttrs;
inherit (lib.strings) concatStringsSep concatMapStringsSep stringToCharacters; inherit (lib.strings) concatStringsSep concatMapStringsSep stringToCharacters concatLines;
inherit (lib.trivial) boolToString warn; inherit (lib.trivial) boolToString warn;
in rec { in rec {
wrapLuaConfig = {
luaBefore ? "",
luaConfig,
luaAfter ? "",
}: ''
lua << EOF
${concatStringsSep "\n" [luaBefore luaConfig luaAfter]}
EOF
'';
# Convert a null value to lua's nil # Convert a null value to lua's nil
nullString = value: nullString = value:
if value == null if value == null

View file

@ -1,7 +1,7 @@
# Convenience function that returns the given Nixpkgs standard library # Convenience function that returns the given Nixpkgs standard library
# extended with our functions using `lib.extend`. # extended with our functions using `lib.extend`.
nixpkgsLib: inputs: inputs:
nixpkgsLib.extend (self: super: { inputs.nixpkgs.lib.extend (self: super: {
# WARNING: New functions should not be added here, but to files # WARNING: New functions should not be added here, but to files
# imported by `./default.nix` under their own categories. If your # imported by `./default.nix` under their own categories. If your
# function does not fit to any of the existing categories, create # function does not fit to any of the existing categories, create

61
lib/types/custom.nix Normal file
View file

@ -0,0 +1,61 @@
{lib}: let
inherit (lib) isStringLike showOption showFiles getFiles mergeOneOption mergeEqualOption mkOptionType;
inherit (lib.types) anything attrsOf;
inherit (lib.nvim.types) anythingConcatLists;
inherit (builtins) typeOf isAttrs any head concatLists stringLength;
in {
# HACK: Does this break anything in our case?
# A modified version of the nixpkgs anything type that concatenates lists
# This isn't the default because the order in which the lists are concatenated depends on the order in which the modules are imported,
# which makes it non-deterministic
anythingConcatLists =
anything
// {
merge = loc: defs: let
getType = value:
if isAttrs value && isStringLike value
then "stringCoercibleSet"
else typeOf value;
# Throw an error if not all defs have the same type
checkType = getType (head defs).value;
commonType =
if any (def: getType def.value != checkType) defs
then throw "The option `${showOption loc}' has conflicting option types in ${showFiles (getFiles defs)}"
else checkType;
mergeFunctions = {
# Recursively merge attribute sets
set = (attrsOf anythingConcatLists).merge;
# Overridden behavior for lists, that concatenates lists
list = _: defs: concatLists (map (e: e.value) defs);
# This means it's a package, only accept a single definition
stringCoercibleSet = mergeOneOption;
# This works by passing the argument to the functions,
# and merging their returns values instead
lambda = loc: defs: arg:
anythingConcatLists.merge
(loc ++ ["<function body>"])
(map (def: {
inherit (def) file;
value = def.value arg;
})
defs);
};
in
# Merge the defs with the correct function from above, if available
# otherwise only allow equal values
(mergeFunctions.${commonType} or mergeEqualOption) loc defs;
};
char = mkOptionType {
name = "char";
description = "character";
descriptionClass = "noun";
check = value: stringLength value < 2;
merge = mergeEqualOption;
};
}

View file

@ -6,8 +6,10 @@
typesDag = import ./dag.nix {inherit lib;}; typesDag = import ./dag.nix {inherit lib;};
typesPlugin = import ./plugins.nix {inherit inputs lib;}; typesPlugin = import ./plugins.nix {inherit inputs lib;};
typesLanguage = import ./languages.nix {inherit lib;}; typesLanguage = import ./languages.nix {inherit lib;};
typesCustom = import ./custom.nix {inherit lib;};
in { in {
inherit (typesDag) dagOf; inherit (typesDag) dagOf;
inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption luaInline; inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption luaInline pluginType;
inherit (typesLanguage) diagnostics mkGrammarOption; inherit (typesLanguage) diagnostics mkGrammarOption;
inherit (typesCustom) anythingConcatLists char;
} }

View file

@ -5,7 +5,7 @@
}: let }: let
inherit (lib.options) mkOption; inherit (lib.options) mkOption;
inherit (lib.attrsets) attrNames mapAttrs' filterAttrs nameValuePair; inherit (lib.attrsets) attrNames mapAttrs' filterAttrs nameValuePair;
inherit (lib.strings) hasPrefix removePrefix isString; inherit (lib.strings) hasPrefix removePrefix;
inherit (lib.types) submodule either package enum str lines attrsOf anything listOf nullOr; inherit (lib.types) submodule either package enum str lines attrsOf anything listOf nullOr;
# Get the names of all flake inputs that start with the given prefix. # Get the names of all flake inputs that start with the given prefix.
@ -52,7 +52,7 @@
}; };
}; };
in { in {
inherit extraPluginType fromInputs; inherit extraPluginType fromInputs pluginType;
pluginsOpt = { pluginsOpt = {
description, description,

View file

@ -1,26 +0,0 @@
let
inherit (builtins) isInt isBool toJSON toString;
in rec {
# yes? no.
yesNo = value:
if value
then "yes"
else "no";
# convert a boolean to a vim compliant boolean string
mkVimBool = val:
if val
then "1"
else "0";
# convert a literal value to a vim compliant value
valToVim = val:
if (isInt val)
then (toString val)
else
(
if (isBool val)
then (mkVimBool val)
else (toJSON val)
);
}

View file

@ -1,37 +1,28 @@
inputs: { inputs: {
configuration, configuration,
pkgs, pkgs,
lib ? pkgs.lib, lib,
check ? true, check ? true,
extraSpecialArgs ? {}, extraSpecialArgs ? {},
extraModules ? [], extraModules ? [],
}: let }: let
inherit (builtins) map filter isString toString getAttr; inherit (pkgs) vimPlugins;
inherit (pkgs) wrapNeovimUnstable vimPlugins;
inherit (pkgs.vimUtils) buildVimPlugin; inherit (pkgs.vimUtils) buildVimPlugin;
inherit (pkgs.neovimUtils) makeNeovimConfig; inherit (lib.strings) isString toString;
inherit (lib.strings) makeBinPath escapeShellArgs concatStringsSep; inherit (lib.lists) filter map concatLists;
inherit (lib.lists) concatLists optional; inherit (lib.attrsets) recursiveUpdate getAttr;
inherit (lib.attrsets) recursiveUpdate;
inherit (lib.asserts) assertMsg; inherit (lib.asserts) assertMsg;
# call the extedended library with `lib` and `inputs` as arguments
# lib is used to provide the standard library functions to the extended library
# but it can be overridden while this file is being called
# inputs is used to pass inputs to the plugin autodiscovery function
extendedLib = import ../lib/stdlib-extended.nix lib inputs;
# import modules.nix with `check`, `pkgs` and `lib` as arguments # import modules.nix with `check`, `pkgs` and `lib` as arguments
# check can be disabled while calling this file is called # check can be disabled while calling this file is called
# to avoid checking in all modules # to avoid checking in all modules
nvimModules = import ./modules.nix { nvimModules = import ./modules.nix {
inherit pkgs check; inherit pkgs check lib;
lib = extendedLib;
}; };
# evaluate the extended library with the modules # evaluate the extended library with the modules
# optionally with any additional modules passed by the user # optionally with any additional modules passed by the user
module = extendedLib.evalModules { module = lib.evalModules {
specialArgs = recursiveUpdate {modulesPath = toString ./.;} extraSpecialArgs; specialArgs = recursiveUpdate {modulesPath = toString ./.;} extraSpecialArgs;
modules = concatLists [[configuration] nvimModules extraModules]; modules = concatLists [[configuration] nvimModules extraModules];
}; };
@ -42,13 +33,23 @@ inputs: {
# build a vim plugin with the given name and arguments # build a vim plugin with the given name and arguments
# if the plugin is nvim-treesitter, warn the user to use buildTreesitterPlug # if the plugin is nvim-treesitter, warn the user to use buildTreesitterPlug
# instead # instead
buildPlug = {pname, ...} @ args: buildPlug = {pname, ...} @ attrs: let
assert assertMsg (pname != "nvim-treesitter") "Use buildTreesitterPlug for building nvim-treesitter.";
buildVimPlugin (args
// {
version = "master";
src = getAttr ("plugin-" + pname) inputs; src = getAttr ("plugin-" + pname) inputs;
}); in
pkgs.runCommand "${pname}-${src.shortRev or src.shortDirtyRev or "dirty"}" attrs
''
mkdir -p $out
cp -r ${src}/. $out
'';
noBuildPlug = {pname, ...} @ attrs: let
input = getAttr ("plugin-" + pname) inputs;
in
{
version = input.shortRev or input.shortDirtyRev or "dirty";
outPath = getAttr ("plugin-" + pname) inputs;
}
// attrs;
buildTreesitterPlug = grammars: vimPlugins.nvim-treesitter.withPlugins (_: grammars); buildTreesitterPlug = grammars: vimPlugins.nvim-treesitter.withPlugins (_: grammars);
@ -62,11 +63,14 @@ inputs: {
then (buildTreesitterPlug vimOptions.treesitter.grammars) then (buildTreesitterPlug vimOptions.treesitter.grammars)
else if (plug == "flutter-tools-patched") else if (plug == "flutter-tools-patched")
then then
(buildPlug { (
buildPlug
{
pname = "flutter-tools"; pname = "flutter-tools";
patches = [../patches/flutter-tools.patch]; patches = [../patches/flutter-tools.patch];
}) }
else (buildPlug {pname = plug;}) )
else noBuildPlug {pname = plug;}
) )
else plug else plug
)) ))
@ -78,13 +82,9 @@ inputs: {
builtStartPlugins = buildConfigPlugins vimOptions.startPlugins; builtStartPlugins = buildConfigPlugins vimOptions.startPlugins;
builtOptPlugins = map (package: { builtOptPlugins = map (package: {
plugin = package; plugin = package;
optional = false; optional = true;
}) (buildConfigPlugins vimOptions.optPlugins); }) (buildConfigPlugins vimOptions.optPlugins);
# combine built start and optional plugins
# into a single list
plugins = builtStartPlugins ++ builtOptPlugins;
# additional Lua and Python3 packages, mapped to their respective functions # additional Lua and Python3 packages, mapped to their respective functions
# to conform to the format makeNeovimConfig expects. end user should # to conform to the format makeNeovimConfig expects. end user should
# only ever need to pass a list of packages, which are modified # only ever need to pass a list of packages, which are modified
@ -92,29 +92,19 @@ inputs: {
extraLuaPackages = ps: map (x: ps.${x}) vimOptions.luaPackages; extraLuaPackages = ps: map (x: ps.${x}) vimOptions.luaPackages;
extraPython3Packages = ps: map (x: ps.${x}) vimOptions.python3Packages; extraPython3Packages = ps: map (x: ps.${x}) vimOptions.python3Packages;
extraWrapperArgs = # Wrap the user's desired (unwrapped) Neovim package with arguments that'll be used to
concatStringsSep " " (optional (vimOptions.extraPackages != []) ''--prefix PATH : "${makeBinPath vimOptions.extraPackages}"''); # generate a wrapped Neovim package.
neovim-wrapped = inputs.mnw.lib.wrap pkgs {
neovim = vimOptions.package;
plugins = concatLists [builtStartPlugins builtOptPlugins];
appName = "nvf";
extraBinPath = vimOptions.extraPackages;
initLua = vimOptions.builtLuaConfigRC;
luaFiles = vimOptions.extraLuaFiles;
# wrap user's desired neovim package with the desired neovim configuration
# using wrapNeovimUnstable and makeNeovimConfig from nixpkgs.
# the makeNeovimConfig function takes the following arguments:
# - withPython (bool)
# - extraPython3Packages (lambda)
# - withNodeJs (bool)
# - withRuby (bool)
# - extraLuaPackages (lambda)
# - plugins (list)
# - customRC (string)
# and returns the wrapped package
neovimConfigured = makeNeovimConfig {
inherit (vimOptions) viAlias vimAlias withRuby withNodeJs withPython3; inherit (vimOptions) viAlias vimAlias withRuby withNodeJs withPython3;
inherit plugins extraLuaPackages extraPython3Packages; inherit extraLuaPackages extraPython3Packages;
customRC = vimOptions.builtConfigRC;
}; };
neovim-wrapped = wrapNeovimUnstable vimOptions.package (recursiveUpdate neovimConfigured {
wrapperArgs = escapeShellArgs neovimConfigured.wrapperArgs + " " + extraWrapperArgs;
});
in { in {
inherit (module) options config; inherit (module) options config;
inherit (module._module.args) pkgs; inherit (module._module.args) pkgs;

View file

@ -10,6 +10,7 @@
# Contains configuration for core neovim features # Contains configuration for core neovim features
# such as spellchecking, mappings, and the init script (init.vim). # such as spellchecking, mappings, and the init script (init.vim).
neovim = map (p: ./neovim + "/${p}") [ neovim = map (p: ./neovim + "/${p}") [
"global"
"init" "init"
"mappings" "mappings"
]; ];

View file

@ -0,0 +1,12 @@
{lib, ...}: let
inherit (lib.lists) concatLists;
inherit (lib.filesystem) listFilesRecursive;
in {
imports = concatLists [
# Configuration options for Neovim UI
(listFilesRecursive ./ui)
# vim.diagnostics
[./diagnostics.nix]
];
}

View file

@ -0,0 +1,115 @@
{
config,
lib,
...
}: let
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) str bool enum either;
in {
options.vim.diagnostics = {
virtual_text = mkOption {
type = bool;
default = true;
description = ''
Whether to use virtual text for diagnostics.
If multiple diagnostics are set for a namespace, one
prefix per diagnostic + the last diagnostic message
are shown.
'';
};
update_in_insert = mkOption {
type = bool;
default = false;
description = ''
Whether to update diagnostics in insert mode.
This is useful for slow diagnostics sources, but can
also cause lag in insert mode.
'';
};
underline = mkOption {
type = bool;
default = true;
description = ''
Whether to underline diagnostics.
'';
};
severity_sort = mkOption {
type = bool;
default = false;
description = ''
Whether to sort diagnostics by severity.
This affects the order in which signs and
virtual text are displayed. When true, higher
severities are displayed before lower severities (e.g.
ERROR is displayed before WARN)
'';
};
float = {
focusable = mkOption {
type = bool;
default = false;
description = ''
Whether the floating window is focusable.
When true, the floating window can be focused and
interacted with. When false, the floating window is
not focusable and will not receive input.
'';
};
border = mkOption {
type = enum ["none" "single" "double" "rounded" "solid" "shadow"];
default = config.vim.ui.border.globalStyle;
description = ''
The border style of the floating window.
Possible values:
- none
- single
- double
- rounded
- solid
- shadow
See `:h nvim_open_win` for the available border
styles and their definitions.
'';
};
source = mkOption {
type = either bool (enum ["always" "if_many"]);
default = "auto";
description = ''
The source of the floating window.
Possible values:
- auto: Use the same source as the diagnostics
window.
- window: Use the window source.
- buffer: Use the buffer source.
'';
};
prefix = mkOption {
type = str;
default = "";
description = ''
Prefix string for each diagnostic in the floating window
'';
};
suffix = mkOption {
type = str;
default = "";
description = ''
Suffix string for each diagnostic in the floating window
'';
};
};
};
}

View file

@ -0,0 +1,51 @@
{
config,
lib,
...
}: let
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.attrsets) mapAttrs;
inherit (lib.lists) optionals;
inherit (lib.types) enum;
cfg = config.vim.ui.borders;
# See `:h nvim_open_win` for the available border styles
# this list can be updated if additional styles are added.
defaultStyles = ["none" "single" "double" "rounded" "solid" "shadow"];
in {
options.vim.ui.borders = {
enable = mkEnableOption "visible borders for windows that support configurable borders";
# TODO: support configurable border elements with a lua table converted from a list of str
# e.g. [ "╔" "═" "╗" "║" "╝" "═" "╚" "║" ]
globalStyle = mkOption {
type = enum defaultStyles;
default = "single";
description = ''
The global border style to use.
'';
};
plugins = let
mkPluginStyleOption = name: {
enable = mkEnableOption "borders for the ${name} plugin" // {default = cfg.enable;};
style = mkOption {
type = enum (defaultStyles ++ optionals (name != "which-key") ["shadow"]);
default = cfg.globalStyle;
description = "The border style to use for the ${name} plugin";
};
};
in
mapAttrs (_: mkPluginStyleOption) {
# despite not having it listed in example configuration, which-key does support the rounded type
# additionally, it supports a "shadow" type that is similar to none but is of higher contrast
which-key = "which-key";
lspsaga = "lspsaga";
nvim-cmp = "nvim-cmp";
lsp-signature = "lsp-signature";
code-action-menu = "code-actions-menu";
};
};
}

View file

@ -0,0 +1,32 @@
{lib, ...}: let
inherit (lib.options) mkOption;
inherit (lib.types) str;
in {
options.vim.ui.icons = {
diagnostics = {
ERROR = mkOption {
type = str;
default = " ";
description = "The icon to use for error messages";
};
WARN = mkOption {
type = str;
default = " ";
description = "The icon to use for warning messages";
};
INFO = mkOption {
type = str;
default = " ";
description = "The icon to use for info messages";
};
HINT = mkOption {
type = str;
default = " ";
description = "The icon to use for hint messages";
};
};
};
}

View file

@ -5,16 +5,17 @@
}: let }: let
inherit (lib.options) mkOption literalExpression; inherit (lib.options) mkOption literalExpression;
inherit (lib.strings) optionalString; inherit (lib.strings) optionalString;
inherit (lib.types) enum bool str int nullOr; inherit (lib.types) enum bool str int;
inherit (lib.nvim.dag) entryAfter; inherit (lib.nvim.dag) entryAfter;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim; cfg = config.vim;
in { in {
options.vim = { options.vim = {
leaderKey = mkOption { leaderKey = mkOption {
type = nullOr str; type = str;
default = null; default = " ";
description = "The leader key to be used internally"; description = "The leader key used for `<leader>` mappings";
}; };
colourTerm = mkOption { colourTerm = mkOption {
@ -53,12 +54,6 @@ in {
description = "Enable syntax highlighting"; description = "Enable syntax highlighting";
}; };
mapLeaderSpace = mkOption {
type = bool;
default = true;
description = "Map the space key to leader key";
};
useSystemClipboard = mkOption { useSystemClipboard = mkOption {
type = bool; type = bool;
default = false; default = false;
@ -165,117 +160,110 @@ in {
}; };
}; };
config.vim.configRC.basic = entryAfter ["globalsScript"] '' config.vim.luaConfigRC.basic = entryAfter ["globalsScript"] ''
" Settings that are set for everything -- Settings that are set for everything
set encoding=utf-8 vim.o.encoding = "utf-8"
set hidden vim.o.hidden = true
set shortmess+=c vim.opt.shortmess:append("c")
set expandtab vim.o.expandtab = true
set mouse=${cfg.mouseSupport} vim.o.mouse = ${toLuaObject cfg.mouseSupport}
set tabstop=${toString cfg.tabWidth} vim.o.tabstop = ${toLuaObject cfg.tabWidth}
set shiftwidth=${toString cfg.tabWidth} vim.o.shiftwidth = ${toLuaObject cfg.tabWidth}
set softtabstop=${toString cfg.tabWidth} vim.o.softtabstop = ${toLuaObject cfg.tabWidth}
set cmdheight=${toString cfg.cmdHeight} vim.o.cmdheight = ${toLuaObject cfg.cmdHeight}
set updatetime=${toString cfg.updateTime} vim.o.updatetime = ${toLuaObject cfg.updateTime}
set tm=${toString cfg.mapTimeout} vim.o.tm = ${toLuaObject cfg.mapTimeout}
set cursorlineopt=${toString cfg.cursorlineOpt} vim.o.cursorlineopt = ${toLuaObject cfg.cursorlineOpt}
set scrolloff=${toString cfg.scrollOffset} vim.o.scrolloff = ${toLuaObject cfg.scrollOffset}
vim.g.mapleader = ${toLuaObject cfg.leaderKey}
vim.g.maplocalleader = ${toLuaObject cfg.leaderKey}
${optionalString cfg.splitBelow '' ${optionalString cfg.splitBelow ''
set splitbelow vim.o.splitbelow = true
''} ''}
${optionalString cfg.splitRight '' ${optionalString cfg.splitRight ''
set splitright vim.o.splitright = true
''} ''}
${optionalString cfg.showSignColumn '' ${optionalString cfg.showSignColumn ''
set signcolumn=yes vim.o.signcolumn = "yes"
''} ''}
${optionalString cfg.autoIndent '' ${optionalString cfg.autoIndent ''
set autoindent vim.o.autoindent = true
''} ''}
${optionalString cfg.preventJunkFiles '' ${optionalString cfg.preventJunkFiles ''
set noswapfile vim.o.swapfile = false
set nobackup vim.o.backup = false
set nowritebackup vim.o.writebackup = false
''} ''}
${optionalString (cfg.bell == "none") '' ${optionalString (cfg.bell == "none") ''
set noerrorbells vim.o.errorbells = false
set novisualbell vim.o.visualbell = false
''} ''}
${optionalString (cfg.bell == "on") '' ${optionalString (cfg.bell == "on") ''
set novisualbell vim.o.visualbell = false
''} ''}
${optionalString (cfg.bell == "visual") '' ${optionalString (cfg.bell == "visual") ''
set noerrorbells vim.o.errorbells = false
''} ''}
${optionalString (cfg.lineNumberMode == "relative") '' ${optionalString (cfg.lineNumberMode == "relative") ''
set relativenumber vim.o.relativenumber = true
''} ''}
${optionalString (cfg.lineNumberMode == "number") '' ${optionalString (cfg.lineNumberMode == "number") ''
set number vim.o.number = true
''} ''}
${optionalString (cfg.lineNumberMode == "relNumber") '' ${optionalString (cfg.lineNumberMode == "relNumber") ''
set number relativenumber vim.o.number = true
vim.o.relativenumber = true
''} ''}
${optionalString cfg.useSystemClipboard '' ${optionalString cfg.useSystemClipboard ''
set clipboard+=unnamedplus vim.opt.clipboard:append("unnamedplus")
''}
${optionalString cfg.mapLeaderSpace ''
let mapleader=" "
let maplocalleader=" "
''} ''}
${optionalString cfg.syntaxHighlighting '' ${optionalString cfg.syntaxHighlighting ''
syntax on vim.cmd("syntax on")
''} ''}
${optionalString (!cfg.wordWrap) '' ${optionalString (!cfg.wordWrap) ''
set nowrap vim.o.wrap = false
''} ''}
${optionalString cfg.hideSearchHighlight '' ${optionalString cfg.hideSearchHighlight ''
set nohlsearch vim.o.hlsearch = false
set incsearch vim.o.incsearch = true
''} ''}
${optionalString cfg.colourTerm '' ${optionalString cfg.colourTerm ''
set termguicolors vim.o.termguicolors = true
set t_Co=256
''} ''}
${optionalString (!cfg.enableEditorconfig) '' ${optionalString (!cfg.enableEditorconfig) ''
let g:editorconfig = v:false vim.g.editorconfig = false
''}
${optionalString (cfg.leaderKey != null) ''
let mapleader = "${toString cfg.leaderKey}"
''} ''}
${optionalString (cfg.searchCase == "ignore") '' ${optionalString (cfg.searchCase == "ignore") ''
set nosmartcase vim.o.smartcase = false
set ignorecase vim.o.ignorecase = true
''} ''}
${optionalString (cfg.searchCase == "smart") '' ${optionalString (cfg.searchCase == "smart") ''
set smartcase vim.o.smartcase = true
set ignorecase vim.o.ignorecase = true
''} ''}
${optionalString (cfg.searchCase == "sensitive") '' ${optionalString (cfg.searchCase == "sensitive") ''
set nosmartcase vim.o.smartcase = false
set noignorecase vim.o.ignorecase = false
''} ''}
''; '';
} }

View file

@ -9,8 +9,7 @@
in { in {
config = { config = {
vim.maps = { vim.maps = {
normal = normal = mkIf cfg.disableArrows {
mkIf cfg.disableArrows {
"<up>" = { "<up>" = {
action = "<nop>"; action = "<nop>";
@ -29,11 +28,6 @@ in {
action = "<nop>"; action = "<nop>";
noremap = false; noremap = false;
}; };
}
// mkIf cfg.mapLeaderSpace {
"<space>" = {
action = "<nop>";
};
}; };
insert = mkIf cfg.disableArrows { insert = mkIf cfg.disableArrows {

View file

@ -33,7 +33,7 @@ in {
startPlugins = [ startPlugins = [
"chatgpt" "chatgpt"
]; ];
luaConfigRC.chagpt = entryAnywhere '' pluginRC.chagpt = entryAnywhere ''
require("chatgpt").setup(${toLuaObject cfg.setupOpts}) require("chatgpt").setup(${toLuaObject cfg.setupOpts})
''; '';
maps.normal = mkMerge [ maps.normal = mkMerge [

View file

@ -30,14 +30,14 @@ in {
"copilot-lua" "copilot-lua"
# cfg.copilotNodePackage # cfg.copilotNodePackage
] ]
++ optionals (cfg.cmp.enable) [ ++ optionals cfg.cmp.enable [
"copilot-cmp" "copilot-cmp"
]; ];
vim.luaConfigRC.copilot = entryAnywhere '' vim.pluginRC.copilot = entryAnywhere ''
require("copilot").setup(${toLuaObject cfg.setupOpts}) require("copilot").setup(${toLuaObject cfg.setupOpts})
${lib.optionalString (cfg.cmp.enable) '' ${lib.optionalString cfg.cmp.enable ''
require("copilot_cmp").setup() require("copilot_cmp").setup()
''} ''}
''; '';

View file

@ -12,7 +12,7 @@ in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim.startPlugins = ["nvim-autopairs"]; vim.startPlugins = ["nvim-autopairs"];
vim.luaConfigRC.autopairs = entryAnywhere '' vim.pluginRC.autopairs = entryAnywhere ''
require("nvim-autopairs").setup({ map_cr = ${boolToString (!config.vim.autocomplete.enable)} }) require("nvim-autopairs").setup({ map_cr = ${boolToString (!config.vim.autocomplete.enable)} })
''; '';
}; };

View file

@ -41,7 +41,7 @@ in {
(mkBinding cfg.mappings.toggleSelectedBlock "<Plug>(comment_toggle_blockwise_visual)" mappings.toggleSelectedBlock.description) (mkBinding cfg.mappings.toggleSelectedBlock "<Plug>(comment_toggle_blockwise_visual)" mappings.toggleSelectedBlock.description)
]; ];
vim.luaConfigRC.comment-nvim = entryAnywhere '' vim.pluginRC.comment-nvim = entryAnywhere ''
require('Comment').setup({ require('Comment').setup({
mappings = { basic = false, extra = false, }, mappings = { basic = false, extra = false, },
}) })

View file

@ -186,7 +186,7 @@ in {
# TODO: alternative snippet engines to vsnip # TODO: alternative snippet engines to vsnip
# https://github.com/hrsh7th/nvim-cmp/blob/main/doc/cmp.txt#L82 # https://github.com/hrsh7th/nvim-cmp/blob/main/doc/cmp.txt#L82
vim.luaConfigRC.completion = mkIf (cfg.type == "nvim-cmp") (dagPlacement '' vim.pluginRC.completion = mkIf (cfg.type == "nvim-cmp") (dagPlacement ''
local nvim_cmp_menu_map = function(entry, vim_item) local nvim_cmp_menu_map = function(entry, vim_item)
-- name for each source -- name for each source
vim_item.menu = ({ vim_item.menu = ({

View file

@ -16,7 +16,7 @@ in {
# the entire credit for this dashboard configuration to https://github.com/Rishabh672003 # the entire credit for this dashboard configuration to https://github.com/Rishabh672003
# honestly, excellent work # honestly, excellent work
vim.luaConfigRC.alpha = entryAnywhere '' vim.pluginRC.alpha = entryAnywhere ''
local alpha = require("alpha") local alpha = require("alpha")
local plenary_path = require("plenary.path") local plenary_path = require("plenary.path")
local dashboard = require("alpha.themes.dashboard") local dashboard = require("alpha.themes.dashboard")

View file

@ -13,7 +13,7 @@ in {
"dashboard-nvim" "dashboard-nvim"
]; ];
vim.luaConfigRC.dashboard-nvim = entryAnywhere '' vim.pluginRC.dashboard-nvim = entryAnywhere ''
require("dashboard").setup{} require("dashboard").setup{}
''; '';
}; };

View file

@ -5,7 +5,6 @@
... ...
}: let }: let
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf;
inherit (lib.nvim.vim) mkVimBool;
cfg = config.vim.dashboard.startify; cfg = config.vim.dashboard.startify;
in { in {
@ -23,28 +22,28 @@ in {
else cfg.customFooter; else cfg.customFooter;
"startify_bookmarks" = cfg.bookmarks; "startify_bookmarks" = cfg.bookmarks;
"startify_lists" = cfg.lists; "startify_lists" = cfg.lists;
"startify_change_to_dir" = mkVimBool cfg.changeToDir; "startify_change_to_dir" = cfg.changeToDir;
"startify_change_to_vcs_root" = mkVimBool cfg.changeToVCRoot; "startify_change_to_vcs_root" = cfg.changeToVCRoot;
"startify_change_cmd" = cfg.changeDirCmd; "startify_change_cmd" = cfg.changeDirCmd;
"startify_skiplist" = cfg.skipList; "startify_skiplist" = cfg.skipList;
"startify_update_oldfiles" = mkVimBool cfg.updateOldFiles; "startify_update_oldfiles" = cfg.updateOldFiles;
"startify_session_autoload" = mkVimBool cfg.sessionAutoload; "startify_session_autoload" = cfg.sessionAutoload;
"startify_commands" = cfg.commands; "startify_commands" = cfg.commands;
"startify_files_number" = cfg.filesNumber; "startify_files_number" = cfg.filesNumber;
"startify_custom_indices" = cfg.customIndices; "startify_custom_indices" = cfg.customIndices;
"startify_disable_at_vimenter" = mkVimBool cfg.disableOnStartup; "startify_disable_at_vimenter" = cfg.disableOnStartup;
"startify_enable_unsafe" = mkVimBool cfg.unsafe; "startify_enable_unsafe" = cfg.unsafe;
"startify_padding_left" = cfg.paddingLeft; "startify_padding_left" = cfg.paddingLeft;
"startify_use_env" = mkVimBool cfg.useEnv; "startify_use_env" = cfg.useEnv;
"startify_session_before_save" = cfg.sessionBeforeSave; "startify_session_before_save" = cfg.sessionBeforeSave;
"startify_session_persistence" = mkVimBool cfg.sessionPersistence; "startify_session_persistence" = cfg.sessionPersistence;
"startify_session_delete_buffers" = mkVimBool cfg.sessionDeleteBuffers; "startify_session_delete_buffers" = cfg.sessionDeleteBuffers;
"startify_session_dir" = cfg.sessionDir; "startify_session_dir" = cfg.sessionDir;
"startify_skiplist_server" = cfg.skipListServer; "startify_skiplist_server" = cfg.skipListServer;
"startify_session_remove_lines" = cfg.sessionRemoveLines; "startify_session_remove_lines" = cfg.sessionRemoveLines;
"startify_session_savevars" = cfg.sessionSavevars; "startify_session_savevars" = cfg.sessionSavevars;
"startify_session_savecmds" = cfg.sessionSavecmds; "startify_session_savecmds" = cfg.sessionSavecmds;
"startify_session_sort" = mkVimBool cfg.sessionSort; "startify_session_sort" = cfg.sessionSort;
}; };
}; };
} }

View file

@ -1,8 +1,4 @@
{ {lib, ...}: let
config,
lib,
...
}: let
inherit (lib.options) mkEnableOption mkOption; inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) listOf attrs bool enum str oneOf int; inherit (lib.types) listOf attrs bool enum str oneOf int;
in { in {

View file

@ -18,7 +18,7 @@ in {
(mkIf cfg.enable { (mkIf cfg.enable {
vim.startPlugins = ["nvim-dap"]; vim.startPlugins = ["nvim-dap"];
vim.luaConfigRC = vim.pluginRC =
{ {
# TODO customizable keymaps # TODO customizable keymaps
nvim-dap = entryAnywhere '' nvim-dap = entryAnywhere ''
@ -51,7 +51,7 @@ in {
(mkIf (cfg.enable && cfg.ui.enable) { (mkIf (cfg.enable && cfg.ui.enable) {
vim.startPlugins = ["nvim-dap-ui" "nvim-nio"]; vim.startPlugins = ["nvim-dap-ui" "nvim-nio"];
vim.luaConfigRC.nvim-dap-ui = entryAfter ["nvim-dap"] ('' vim.pluginRC.nvim-dap-ui = entryAfter ["nvim-dap"] (''
local dapui = require("dapui") local dapui = require("dapui")
dapui.setup() dapui.setup()
'' ''

View file

@ -1,5 +1,6 @@
{ {
imports = [ imports = [
./nvimtree ./nvimtree
./neo-tree
]; ];
} }

View file

@ -0,0 +1,28 @@
{
config,
lib,
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.filetree.neo-tree;
in {
config = mkIf cfg.enable {
vim = {
startPlugins = [
# dependencies
"plenary-nvim" # commons library
"image-nvim" # optional for image previews
"nui-nvim" # ui library
# neotree
"neo-tree-nvim"
];
pluginRC.neo-tree = entryAnywhere ''
require("neo-tree").setup(${toLuaObject cfg.setupOpts})
'';
};
};
}

View file

@ -0,0 +1,6 @@
{
imports = [
./config.nix
./neo-tree.nix
];
}

View file

@ -0,0 +1,155 @@
{lib, ...}: let
inherit (lib.types) bool str int submodule enum either listOf;
inherit (lib.options) mkOption mkEnableOption literalExpression;
inherit (lib.nvim.types) mkPluginSetupOption;
in {
options.vim.filetree.neo-tree = {
enable = mkEnableOption "filetree via neo-tree.nvim";
# Permalink:
# https://github.com/nvim-neo-tree/neo-tree.nvim/blob/22e566aeb075c94f670f34077e05ba95190dfb4a/lua/neo-tree/defaults.lua
setupOpts = mkPluginSetupOption "neo-tree" {
add_blank_line_at_top = mkOption {
type = bool;
default = false;
description = ''
Whether to add a blank line at the top of the tree
'';
};
auto_clean_after_session_restore = mkOption {
type = bool;
default = false;
description = ''
Whether to automatically clean up broken neo-tree buffers
saved in sessions
'';
};
default_source = mkOption {
type = str;
default = "filesystem";
description = ''
You can choose a specific source.
`last` here which indicates the last used source
'';
};
enable_diagnostics = mkEnableOption "diagnostics" // {default = true;};
enable_git_status = mkEnableOption "git status" // {default = true;};
enable_modified_markers = mkEnableOption "markers for files with unsaved changes." // {default = true;};
enable_opened_markers =
mkEnableOption ''
tracking of opened files.
Required for `components.name.highlight_opened_files`
''
// {default = true;};
enable_refresh_on_write =
mkEnableOption ''
Refresh the tree when a file is written.
Only used if `use_libuv_file_watcher` is false.
''
// {default = true;};
enable_cursor_hijack = mkEnableOption ''
cursor hijacking.
If enabled neotree will keep the cursor on the first letter of the filename when moving in the tree
'';
git_status_async = mkEnableOption ''
async git status.
This will make the git status check async and will not block the UI.
'';
/*
git_status_async_options = mkOption {
description = "These options are for people with VERY large git repos";
type = submodule {
batch_size = mkOption {
type = int;
default = 1000;
description = "How many lines of git status results to process at a time";
};
batch_delay = mkOption {
type = int;
default = 10;
description = "Delay, in ms, between batches. Spreads out the workload to let other processes run";
};
max_lines = mkOption {
type = int;
default = 10000;
description = ''
How many lines of git status results to process.
Anything after this will be dropped. Anything before this will be used.
The last items to be processed are the untracked files.
'';
};
};
};
*/
hide_root_node = mkOption {
type = bool;
default = false;
description = ''
Whether to hide the root node of the tree
'';
};
retain_hidden_root_indent = mkOption {
type = bool;
default = false;
description = ''
Whether to retain the indent of the hidden root node
IF the root node is hidden, keep the indentation anyhow.
This is needed if you use expanders because they render in the indent.
'';
};
log_level = mkOption {
type = enum ["trace" "debug" "info" "warn" "error" "fatal"];
default = "info";
description = "Log level for the plugin.";
};
log_to_file = mkOption {
type = either bool str;
default = false;
example = literalExpression "/tmp/neo-tree.log";
description = ''
Must be either a boolean or a path to your log file.
Use :NeoTreeLogs to show the file
'';
};
open_files_in_last_window = mkOption {
type = bool;
default = true;
description = ''
Whether to open files in the last window
If disabled, neo-tree will open files in top left window
'';
};
open_files_do_not_replace_types = mkOption {
type = listOf str;
default = ["terminal" "Trouble" "qf" "edgy"];
description = ''
A list of filetypes that should not be replaced when opening a file
'';
};
};
};
}

View file

@ -29,7 +29,7 @@ in {
"<leader>t" = "+NvimTree"; "<leader>t" = "+NvimTree";
}; };
vim.luaConfigRC.nvimtreelua = entryAnywhere '' vim.pluginRC.nvimtreelua = entryAnywhere ''
${ ${
optionalString cfg.setupOpts.disable_netrw '' optionalString cfg.setupOpts.disable_netrw ''
-- disable netrew completely -- disable netrew completely

View file

@ -1,4 +1,4 @@
_: { {
imports = [ imports = [
./config.nix ./config.nix
./nvimtree.nix ./nvimtree.nix

View file

@ -69,7 +69,7 @@ in {
"<leader>g" = "+Gitsigns"; "<leader>g" = "+Gitsigns";
}; };
luaConfigRC.gitsigns = entryAnywhere '' pluginRC.gitsigns = entryAnywhere ''
require('gitsigns').setup{} require('gitsigns').setup{}
''; '';
}; };

View file

@ -12,7 +12,7 @@
inherit (lib.modules) mkIf mkMerge; inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.lua) expToLua; inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.types) mkGrammarOption; inherit (lib.nvim.types) mkGrammarOption;
inherit (lib.nvim.dag) entryAnywhere; inherit (lib.nvim.dag) entryAfter;
packageToCmd = package: defaultCmd: packageToCmd = package: defaultCmd:
if isList cfg.lsp.package if isList cfg.lsp.package
@ -141,7 +141,7 @@ in {
config = mkIf cfg.enable (mkMerge [ config = mkIf cfg.enable (mkMerge [
(mkIf cfg.cHeader { (mkIf cfg.cHeader {
vim.configRC.c-header = entryAnywhere "let g:c_syntax_for_h = 1"; vim.pluginRC.c-header = entryAfter ["basic"] "vim.g.c_syntax_for_h = 1";
}) })
(mkIf cfg.treesitter.enable { (mkIf cfg.treesitter.enable {

View file

@ -140,7 +140,7 @@ in {
then ["flutter-tools-patched"] then ["flutter-tools-patched"]
else ["flutter-tools"]; else ["flutter-tools"];
vim.luaConfigRC.flutter-tools = entryAnywhere '' vim.pluginRC.flutter-tools = entryAnywhere ''
require('flutter-tools').setup { require('flutter-tools').setup {
lsp = { lsp = {
color = { -- show the derived colours for dart variables color = { -- show the derived colours for dart variables

View file

@ -113,7 +113,7 @@ in {
(mkIf cfg.elixir-tools.enable { (mkIf cfg.elixir-tools.enable {
vim.startPlugins = ["elixir-tools"]; vim.startPlugins = ["elixir-tools"];
vim.luaConfigRC.elixir-tools = entryAnywhere '' vim.pluginRC.elixir-tools = entryAnywhere ''
local elixir-tools = require("elixir") local elixir-tools = require("elixir")
local elixirls = require("elixir-tools.elixirls") local elixirls = require("elixir-tools.elixirls")

View file

@ -102,7 +102,7 @@ in {
(mkIf cfg.dap.enable { (mkIf cfg.dap.enable {
vim = { vim = {
startPlugins = ["nvim-dap-go"]; startPlugins = ["nvim-dap-go"];
luaConfigRC.nvim-dap-go = entryAfter ["nvim-dap"] '' pluginRC.nvim-dap-go = entryAfter ["nvim-dap"] ''
require('dap-go').setup { require('dap-go').setup {
delve = { delve = {
path = '${getExe cfg.dap.package}', path = '${getExe cfg.dap.package}',

View file

@ -36,7 +36,7 @@ in {
grammars = [cfg.treesitter.package]; grammars = [cfg.treesitter.package];
}; };
luaConfigRC.html-autotag = mkIf cfg.treesitter.autotagHtml (entryAnywhere '' pluginRC.html-autotag = mkIf cfg.treesitter.autotagHtml (entryAnywhere ''
require('nvim-ts-autotag').setup() require('nvim-ts-autotag').setup()
''); '');
}; };

View file

@ -61,7 +61,7 @@ in {
(mkIf cfg.lsp.neodev.enable { (mkIf cfg.lsp.neodev.enable {
vim.startPlugins = ["neodev-nvim"]; vim.startPlugins = ["neodev-nvim"];
vim.luaConfigRC.neodev = entryBefore ["lua-lsp"] '' vim.pluginRC.neodev = entryBefore ["lua-lsp"] ''
require("neodev").setup({}) require("neodev").setup({})
''; '';
}) })

View file

@ -11,7 +11,6 @@
inherit (lib.strings) optionalString; inherit (lib.strings) optionalString;
inherit (lib.types) enum either listOf package str; inherit (lib.types) enum either listOf package str;
inherit (lib.nvim.types) mkGrammarOption diagnostics; inherit (lib.nvim.types) mkGrammarOption diagnostics;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) expToLua; inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.languages) diagnosticsToLua; inherit (lib.nvim.languages) diagnosticsToLua;
@ -176,8 +175,16 @@ in {
config = mkIf cfg.enable (mkMerge [ config = mkIf cfg.enable (mkMerge [
{ {
vim.configRC.nix = entryAnywhere '' vim.pluginRC.nix = ''
autocmd filetype nix setlocal tabstop=2 shiftwidth=2 softtabstop=2 vim.api.nvim_create_autocmd("FileType", {
pattern = "nix",
callback = function(opts)
local bo = vim.bo[opts.buf]
bo.tabstop = 2
bo.shiftwidth = 2
bo.softtabstop = 2
end
})
''; '';
} }

View file

@ -102,7 +102,7 @@ in {
startPlugins = ["crates-nvim"]; startPlugins = ["crates-nvim"];
lsp.null-ls.enable = mkIf cfg.crates.codeActions true; lsp.null-ls.enable = mkIf cfg.crates.codeActions true;
autocomplete.sources = {"crates" = "[Crates]";}; autocomplete.sources = {"crates" = "[Crates]";};
luaConfigRC.rust-crates = entryAnywhere '' pluginRC.rust-crates = entryAnywhere ''
require('crates').setup { require('crates').setup {
null_ls = { null_ls = {
enabled = ${boolToString cfg.crates.codeActions}, enabled = ${boolToString cfg.crates.codeActions},
@ -125,30 +125,39 @@ in {
(mkIf (cfg.lsp.enable || cfg.dap.enable) { (mkIf (cfg.lsp.enable || cfg.dap.enable) {
vim = { vim = {
startPlugins = ["rust-tools"] ++ optionals cfg.dap.enable [cfg.dap.package]; startPlugins = ["rustaceanvim"];
lsp.lspconfig = { luaConfigRC.rustaceanvim = entryAnywhere ''
enable = true; vim.g.rustaceanvim = {
sources.rust-lsp = '' ${optionalString cfg.lsp.enable ''
local rt = require('rust-tools') -- LSP
rust_on_attach = function(client, bufnr) tools = {
hover_actions = {
replace_builtin_hover = false
},
},
server = {
cmd = ${
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/rust-analyzer"}''
},
on_attach = function(client, bufnr)
default_on_attach(client, bufnr) default_on_attach(client, bufnr)
local opts = { noremap=true, silent=true, buffer = bufnr } local opts = { noremap=true, silent=true, buffer = bufnr }
vim.keymap.set("n", "<leader>ris", rt.inlay_hints.set, opts) vim.keymap.set("n", "<leader>rr", ":RustLsp runnables<CR>", opts)
vim.keymap.set("n", "<leader>riu", rt.inlay_hints.unset, opts) vim.keymap.set("n", "<leader>rp", ":RustLsp parentModule<CR>", opts)
vim.keymap.set("n", "<leader>rr", rt.runnables.runnables, opts) vim.keymap.set("n", "<leader>rm", ":RustLsp expandMacro<CR>", opts)
vim.keymap.set("n", "<leader>rp", rt.parent_module.parent_module, opts) vim.keymap.set("n", "<leader>rc", ":RustLsp openCargo", opts)
vim.keymap.set("n", "<leader>rm", rt.expand_macro.expand_macro, opts) vim.keymap.set("n", "<leader>rg", ":RustLsp crateGraph x11", opts)
vim.keymap.set("n", "<leader>rc", rt.open_cargo_toml.open_cargo_toml, opts)
vim.keymap.set("n", "<leader>rg", function() rt.crate_graph.view_crate_graph("x11", nil) end, opts)
${optionalString cfg.dap.enable '' ${optionalString cfg.dap.enable ''
vim.keymap.set("n", "<leader>rd", ":RustDebuggables<cr>", opts) vim.keymap.set("n", "<leader>rd", ":RustLsp debuggables<cr>", opts)
vim.keymap.set( vim.keymap.set(
"n", "${config.vim.debugger.nvim-dap.mappings.continue}", "n", "${config.vim.debugger.nvim-dap.mappings.continue}",
function() function()
local dap = require("dap") local dap = require("dap")
if dap.status() == "" then if dap.status() == "" then
vim.cmd "RustDebuggables" vim.cmd "RustLsp debuggables"
else else
dap.continue() dap.continue()
end end
@ -157,41 +166,21 @@ in {
) )
''} ''}
end end
local rustopts = {
tools = {
autoSetHints = true,
hover_with_actions = false,
inlay_hints = {
only_current_line = false,
}
},
server = {
capabilities = capabilities,
on_attach = rust_on_attach,
cmd = ${
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/rust-analyzer"}''
},
settings = {
${cfg.lsp.opts}
}
}, },
''}
${optionalString cfg.dap.enable '' ${optionalString cfg.dap.enable ''
dap = { dap = {
adapter = { adapter = {
type = "executable", type = "executable",
command = "${cfg.dap.package}/bin/lldb-vscode", command = "${cfg.dap.package}/bin/lldb-vscode",
name = "rt_lldb", name = "rustacean_lldb",
}, },
}, },
''} ''}
} }
rt.setup(rustopts)
''; '';
}; };
};
}) })
]); ]);
} }

View file

@ -20,7 +20,7 @@
defaultServer = "tsserver"; defaultServer = "tsserver";
servers = { servers = {
tsserver = { tsserver = {
package = pkgs.nodePackages.typescript-language-server; package = pkgs.typescript-language-server;
lspConfig = '' lspConfig = ''
lspconfig.tsserver.setup { lspconfig.tsserver.setup {
capabilities = capabilities; capabilities = capabilities;
@ -192,7 +192,7 @@ in {
(mkIf cfg.extensions."ts-error-translator".enable { (mkIf cfg.extensions."ts-error-translator".enable {
vim.startPlugins = ["ts-error-translator"]; vim.startPlugins = ["ts-error-translator"];
vim.luaConfigRC.ts-error-translator = entryAnywhere '' vim.pluginRC.ts-error-translator = entryAnywhere ''
require("ts-error-translator").setup(${toLuaObject cfg.extensions.ts-error-translator.setupOpts}) require("ts-error-translator").setup(${toLuaObject cfg.extensions.ts-error-translator.setupOpts})
''; '';
}) })

View file

@ -27,7 +27,7 @@ in {
autocomplete.sources = {"nvim_lsp" = "[LSP]";}; autocomplete.sources = {"nvim_lsp" = "[LSP]";};
luaConfigRC.lsp-setup = '' pluginRC.lsp-setup = ''
vim.g.formatsave = ${boolToString cfg.formatOnSave}; vim.g.formatsave = ${boolToString cfg.formatOnSave};
local attach_keymaps = function(client, bufnr) local attach_keymaps = function(client, bufnr)
@ -103,11 +103,11 @@ in {
end end
end end
${optionalString (config.vim.ui.breadcrumbs.enable) ''local navic = require("nvim-navic")''} ${optionalString config.vim.ui.breadcrumbs.enable ''local navic = require("nvim-navic")''}
default_on_attach = function(client, bufnr) default_on_attach = function(client, bufnr)
attach_keymaps(client, bufnr) attach_keymaps(client, bufnr)
format_callback(client, bufnr) format_callback(client, bufnr)
${optionalString (config.vim.ui.breadcrumbs.enable) '' ${optionalString config.vim.ui.breadcrumbs.enable ''
-- let navic attach to buffers -- let navic attach to buffers
if client.server_capabilities.documentSymbolProvider then if client.server_capabilities.documentSymbolProvider then
navic.attach(client, bufnr) navic.attach(client, bufnr)

View file

@ -12,7 +12,7 @@ in {
vim = { vim = {
startPlugins = ["nvim-lightbulb"]; startPlugins = ["nvim-lightbulb"];
luaConfigRC.lightbulb = entryAnywhere '' pluginRC.lightbulb = entryAnywhere ''
vim.api.nvim_command('autocmd CursorHold,CursorHoldI * lua require\'nvim-lightbulb\'.update_lightbulb()') vim.api.nvim_command('autocmd CursorHold,CursorHoldI * lua require\'nvim-lightbulb\'.update_lightbulb()')
-- Enable trouble diagnostics viewer -- Enable trouble diagnostics viewer

View file

@ -20,7 +20,7 @@ in {
handler_opts.border = config.vim.ui.borders.plugins.lsp-signature.style; handler_opts.border = config.vim.ui.borders.plugins.lsp-signature.style;
}; };
luaConfigRC.lsp-signature = entryAnywhere '' pluginRC.lsp-signature = entryAnywhere ''
-- Enable lsp signature viewer -- Enable lsp signature viewer
require("lsp_signature").setup(${toLuaObject cfg.lspSignature.setupOpts}) require("lsp_signature").setup(${toLuaObject cfg.lspSignature.setupOpts})
''; '';

View file

@ -17,7 +17,7 @@ in {
startPlugins = ["nvim-lspconfig"]; startPlugins = ["nvim-lspconfig"];
luaConfigRC.lspconfig = entryAfter ["lsp-setup"] '' pluginRC.lspconfig = entryAfter ["lsp-setup"] ''
local lspconfig = require('lspconfig') local lspconfig = require('lspconfig')
${ ${
@ -29,7 +29,7 @@ in {
}; };
} }
{ {
vim.luaConfigRC = mapAttrs (_: v: (entryAfter ["lspconfig"] v)) cfg.lspconfig.sources; vim.pluginRC = mapAttrs (_: v: (entryAfter ["lspconfig"] v)) cfg.lspconfig.sources;
} }
]); ]);
} }

View file

@ -10,7 +10,7 @@
in { in {
config = mkIf (cfg.enable && cfg.lspkind.enable) { config = mkIf (cfg.enable && cfg.lspkind.enable) {
vim.startPlugins = ["lspkind"]; vim.startPlugins = ["lspkind"];
vim.luaConfigRC.lspkind = entryAnywhere '' vim.pluginRC.lspkind = entryAnywhere ''
local lspkind = require'lspkind' local lspkind = require'lspkind'
local lspkind_opts = { local lspkind_opts = {
mode = '${cfg.lspkind.mode}' mode = '${cfg.lspkind.mode}'

View file

@ -10,7 +10,7 @@
in { in {
config = mkIf (cfg.enable && cfg.lsplines.enable) { config = mkIf (cfg.enable && cfg.lsplines.enable) {
vim.startPlugins = ["lsp-lines"]; vim.startPlugins = ["lsp-lines"];
vim.luaConfigRC.lsplines = entryAfter ["lspconfig"] '' vim.pluginRC.lsplines = entryAfter ["lspconfig"] ''
require("lsp_lines").setup() require("lsp_lines").setup()
vim.diagnostic.config({ vim.diagnostic.config({

View file

@ -41,7 +41,7 @@ in {
]; ];
}; };
luaConfigRC.lspsaga = entryAnywhere '' pluginRC.lspsaga = entryAnywhere ''
require('lspsaga').init_lsp_saga({ require('lspsaga').init_lsp_saga({
${optionalString config.vim.ui.borders.plugins.lspsaga.enable '' ${optionalString config.vim.ui.borders.plugins.lspsaga.enable ''
border_style = '${config.vim.ui.borders.plugins.lspsaga.style}', border_style = '${config.vim.ui.borders.plugins.lspsaga.style}',

View file

@ -22,7 +22,7 @@ in {
# since it will hook into LSPs to receive information # since it will hook into LSPs to receive information
lsp.enable = true; lsp.enable = true;
luaConfigRC = { pluginRC = {
# early setup for null-ls # early setup for null-ls
null_ls-setup = entryAnywhere '' null_ls-setup = entryAnywhere ''
local null_ls = require("null-ls") local null_ls = require("null-ls")
@ -46,7 +46,7 @@ in {
}; };
} }
{ {
vim.luaConfigRC = mapAttrs (_: v: (entryBetween ["null_ls"] ["null_ls-setup"] v)) cfg.null-ls.sources; vim.pluginRC = mapAttrs (_: v: (entryBetween ["null_ls"] ["null_ls-setup"] v)) cfg.null-ls.sources;
} }
]); ]);
} }

View file

@ -23,7 +23,7 @@ in {
"<leader>c" = "+CodeAction"; "<leader>c" = "+CodeAction";
}; };
luaConfigRC.code-action-menu = entryAnywhere '' pluginRC.code-action-menu = entryAnywhere ''
-- border configuration -- border configuration
vim.g.code_action_menu_window_border = '${config.vim.ui.borders.plugins.code-action-menu.style}' vim.g.code_action_menu_window_border = '${config.vim.ui.borders.plugins.code-action-menu.style}'

View file

@ -19,7 +19,7 @@ in {
lsp.enable = true; lsp.enable = true;
startPlugins = ["nvim-docs-view"]; startPlugins = ["nvim-docs-view"];
luaConfigRC.nvim-docs-view = entryAnywhere '' pluginRC.nvim-docs-view = entryAnywhere ''
require("docs-view").setup ${toLuaObject cfg.setupOpts} require("docs-view").setup ${toLuaObject cfg.setupOpts}
''; '';

View file

@ -32,7 +32,7 @@ in {
"<leader>lw" = "Workspace"; "<leader>lw" = "Workspace";
}; };
luaConfigRC.trouble = entryAnywhere '' pluginRC.trouble = entryAnywhere ''
-- Enable trouble diagnostics viewer -- Enable trouble diagnostics viewer
require("trouble").setup {} require("trouble").setup {}
''; '';

View file

@ -31,7 +31,7 @@ in {
"<leader>m" = "+Minimap"; "<leader>m" = "+Minimap";
}; };
luaConfigRC.codewindow = entryAnywhere '' pluginRC.codewindow = entryAnywhere ''
local codewindow = require('codewindow') local codewindow = require('codewindow')
codewindow.setup({ codewindow.setup({
exclude_filetypes = { 'NvimTree', 'orgagenda', 'Alpha'}, exclude_filetypes = { 'NvimTree', 'orgagenda', 'Alpha'},

View file

@ -25,7 +25,7 @@ in {
"<leader>o" = "+Notes"; "<leader>o" = "+Notes";
}; };
luaConfigRC.mind-nvim = entryAnywhere '' pluginRC.mind-nvim = entryAnywhere ''
require'mind'.setup() require'mind'.setup()
''; '';
}; };

View file

@ -22,7 +22,7 @@ in {
"<leader>o" = "+Notes"; "<leader>o" = "+Notes";
}; };
luaConfigRC.obsidian = entryAnywhere '' pluginRC.obsidian = entryAnywhere ''
require("obsidian").setup(${toLuaObject cfg.setupOpts}) require("obsidian").setup(${toLuaObject cfg.setupOpts})
''; '';
}; };

View file

@ -21,7 +21,7 @@ in {
"<leader>o" = "+Notes"; "<leader>o" = "+Notes";
}; };
luaConfigRC.orgmode = entryAnywhere '' pluginRC.orgmode = entryAnywhere ''
-- Treesitter configuration -- Treesitter configuration
require('nvim-treesitter.configs').setup { require('nvim-treesitter.configs').setup {

View file

@ -24,7 +24,7 @@ in {
(mkIf config.vim.lsp.trouble.enable (mkBinding cfg.mappings.trouble ":TodoTrouble<CR>" mappings.trouble.description)) (mkIf config.vim.lsp.trouble.enable (mkBinding cfg.mappings.trouble ":TodoTrouble<CR>" mappings.trouble.description))
]; ];
luaConfigRC.todo-comments = '' pluginRC.todo-comments = ''
require('todo-comments').setup(${toLuaObject cfg.setupOpts}) require('todo-comments').setup(${toLuaObject cfg.setupOpts})
''; '';
}; };

View file

@ -14,7 +14,7 @@ in {
"project-nvim" "project-nvim"
]; ];
vim.luaConfigRC.project-nvim = entryAnywhere '' vim.pluginRC.project-nvim = entryAnywhere ''
require('project_nvim').setup(${toLuaObject cfg.setupOpts}) require('project_nvim').setup(${toLuaObject cfg.setupOpts})
''; '';
}; };

View file

@ -1,8 +1,4 @@
{ {lib, ...}: let
config,
lib,
...
}: let
inherit (lib.options) mkEnableOption mkOption; inherit (lib.options) mkEnableOption mkOption;
inherit (lib.modules) mkRenamedOptionModule; inherit (lib.modules) mkRenamedOptionModule;
inherit (lib.types) bool listOf str enum; inherit (lib.types) bool listOf str enum;

View file

@ -12,7 +12,7 @@ in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim.startPlugins = ["neocord"]; vim.startPlugins = ["neocord"];
vim.luaConfigRC.neocord = entryAnywhere '' vim.pluginRC.neocord = entryAnywhere ''
-- Description of each option can be found in https://github.com/IogaMaster/neocord#lua -- Description of each option can be found in https://github.com/IogaMaster/neocord#lua
require("neocord").setup(${toLuaObject cfg.setupOpts}) require("neocord").setup(${toLuaObject cfg.setupOpts})
''; '';

View file

@ -28,7 +28,7 @@ in {
# TODO: load_current_dir_session # TODO: load_current_dir_session
]; ];
luaConfigRC.nvim-session-manager = entryAnywhere '' pluginRC.nvim-session-manager = entryAnywhere ''
local Path = require('plenary.path') local Path = require('plenary.path')
local sm = require('session_manager.config') local sm = require('session_manager.config')
require('session_manager').setup(${toLuaObject cfg.setupOpts}) require('session_manager').setup(${toLuaObject cfg.setupOpts})

View file

@ -14,7 +14,7 @@ in {
# vim-dirtytalk doesn't have any setup # vim-dirtytalk doesn't have any setup
# but we would like to append programming to spelllang # but we would like to append programming to spelllang
# as soon as possible while the plugin is enabled # as soon as possible while the plugin is enabled
luaConfigRC.vim-dirtytalk = entryAfter ["basic"] '' pluginRC.vim-dirtytalk = entryAfter ["basic"] ''
-- append programming to spelllang -- append programming to spelllang
vim.opt.spelllang:append("programming") vim.opt.spelllang:append("programming")
''; '';

View file

@ -4,7 +4,7 @@
... ...
}: let }: let
inherit (builtins) map; inherit (builtins) map;
inherit (lib.modules) mkIf mkMerge; inherit (lib.modules) mkIf mkMerge mkDefault;
inherit (lib.trivial) boolToString; inherit (lib.trivial) boolToString;
inherit (lib.nvim.dag) entryAnywhere; inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject; inherit (lib.nvim.lua) toLuaObject;
@ -15,7 +15,7 @@
in { in {
config = mkMerge [ config = mkMerge [
# TODO: move into nvim-tree file # TODO: move into nvim-tree file
(mkIf (config.vim.filetree.nvimTree.enable) { (mkIf config.vim.filetree.nvimTree.enable {
vim.statusline.lualine.setupOpts = { vim.statusline.lualine.setupOpts = {
extensions = ["nvim-tree"]; extensions = ["nvim-tree"];
}; };
@ -23,7 +23,7 @@ in {
(mkIf (breadcrumbsCfg.enable && breadcrumbsCfg.source == "nvim-navic") { (mkIf (breadcrumbsCfg.enable && breadcrumbsCfg.source == "nvim-navic") {
vim.statusline.lualine.setupOpts = { vim.statusline.lualine.setupOpts = {
# TODO: rewrite in new syntax # TODO: rewrite in new syntax
winbar.lualine_c = [ winbar.lualine_c = mkDefault [
[ [
"navic" "navic"
(mkLuaInline "draw_empty = ${boolToString config.vim.ui.breadcrumbs.alwaysRender}") (mkLuaInline "draw_empty = ${boolToString config.vim.ui.breadcrumbs.alwaysRender}")
@ -35,42 +35,42 @@ in {
vim = { vim = {
startPlugins = ["lualine"]; startPlugins = ["lualine"];
luaConfigRC.lualine = entryAnywhere '' pluginRC.lualine = entryAnywhere ''
local lualine = require('lualine') local lualine = require('lualine')
lualine.setup ${toLuaObject cfg.setupOpts} lualine.setup ${toLuaObject cfg.setupOpts}
''; '';
# this is for backwards-compatibility # this is for backwards-compatibility
# NOTE: since lualine relies heavily on mixed list + key-value table syntax in lua e.g. {1, 2, three = 3}
# and we don't have a good syntax for that we're keeping the old options for now
statusline.lualine.setupOpts = { statusline.lualine.setupOpts = {
options = { options = {
icons_enabled = cfg.icons.enable; icons_enabled = mkDefault cfg.icons.enable;
theme = cfg.theme; theme = mkDefault cfg.theme;
component_separators = [cfg.componentSeparator.left cfg.componentSeparator.right]; component_separators = mkDefault [cfg.componentSeparator.left cfg.componentSeparator.right];
section_separators = [cfg.sectionSeparator.left cfg.sectionSeparator.right]; section_separators = mkDefault [cfg.sectionSeparator.left cfg.sectionSeparator.right];
globalstatus = cfg.globalStatus; globalstatus = mkDefault cfg.globalStatus;
refresh = cfg.refresh; refresh = mkDefault cfg.refresh;
always_divide_middle = mkDefault cfg.alwaysDivideMiddle;
}; };
sections = { sections = {
lualine_a = map mkLuaInline (cfg.activeSection.a ++ cfg.extraActiveSection.a); lualine_a = mkDefault (map mkLuaInline (cfg.activeSection.a ++ cfg.extraActiveSection.a));
lualine_b = map mkLuaInline (cfg.activeSection.b ++ cfg.extraActiveSection.b); lualine_b = mkDefault (map mkLuaInline (cfg.activeSection.b ++ cfg.extraActiveSection.b));
lualine_c = map mkLuaInline (cfg.activeSection.c ++ cfg.extraActiveSection.c); lualine_c = mkDefault (map mkLuaInline (cfg.activeSection.c ++ cfg.extraActiveSection.c));
lualine_x = map mkLuaInline (cfg.activeSection.x ++ cfg.extraActiveSection.x); lualine_x = mkDefault (map mkLuaInline (cfg.activeSection.x ++ cfg.extraActiveSection.x));
lualine_y = map mkLuaInline (cfg.activeSection.y ++ cfg.extraActiveSection.y); lualine_y = mkDefault (map mkLuaInline (cfg.activeSection.y ++ cfg.extraActiveSection.y));
lualine_z = map mkLuaInline (cfg.activeSection.z ++ cfg.extraActiveSection.z); lualine_z = mkDefault (map mkLuaInline (cfg.activeSection.z ++ cfg.extraActiveSection.z));
}; };
inactive_sections = { inactive_sections = {
lualine_a = map mkLuaInline (cfg.inactiveSection.a ++ cfg.extraInactiveSection.a); lualine_a = mkDefault (map mkLuaInline (cfg.inactiveSection.a ++ cfg.extraInactiveSection.a));
lualine_b = map mkLuaInline (cfg.inactiveSection.b ++ cfg.extraInactiveSection.b); lualine_b = mkDefault (map mkLuaInline (cfg.inactiveSection.b ++ cfg.extraInactiveSection.b));
lualine_c = map mkLuaInline (cfg.inactiveSection.c ++ cfg.extraInactiveSection.c); lualine_c = mkDefault (map mkLuaInline (cfg.inactiveSection.c ++ cfg.extraInactiveSection.c));
lualine_x = map mkLuaInline (cfg.inactiveSection.x ++ cfg.extraInactiveSection.x); lualine_x = mkDefault (map mkLuaInline (cfg.inactiveSection.x ++ cfg.extraInactiveSection.x));
lualine_y = map mkLuaInline (cfg.inactiveSection.y ++ cfg.extraInactiveSection.y); lualine_y = mkDefault (map mkLuaInline (cfg.inactiveSection.y ++ cfg.extraInactiveSection.y));
lualine_z = map mkLuaInline (cfg.inactiveSection.z ++ cfg.extraInactiveSection.z); lualine_z = mkDefault (map mkLuaInline (cfg.inactiveSection.z ++ cfg.extraInactiveSection.z));
}; };
# probably don't need this?
tabline = [];
}; };
}; };
}) })

View file

@ -39,7 +39,7 @@ in {
"<leader>bsi" = "BufferLineSortById"; "<leader>bsi" = "BufferLineSortById";
}; };
luaConfigRC.nvimBufferline = entryAnywhere '' pluginRC.nvimBufferline = entryAnywhere ''
require("bufferline").setup(${toLuaObject cfg.setupOpts}) require("bufferline").setup(${toLuaObject cfg.setupOpts})
''; '';
}; };

View file

@ -23,7 +23,7 @@ in {
maps.normal = mkBinding cfg.mappings.open "<Cmd>execute v:count . \"ToggleTerm\"<CR>" "Toggle terminal"; maps.normal = mkBinding cfg.mappings.open "<Cmd>execute v:count . \"ToggleTerm\"<CR>" "Toggle terminal";
luaConfigRC.toggleterm = entryAnywhere '' pluginRC.toggleterm = entryAnywhere ''
require("toggleterm").setup(${toLuaObject cfg.setupOpts}) require("toggleterm").setup(${toLuaObject cfg.setupOpts})
''; '';
}; };
@ -35,7 +35,7 @@ in {
vim.startPlugins = optionals (cfg.lazygit.package != null) [ vim.startPlugins = optionals (cfg.lazygit.package != null) [
cfg.lazygit.package cfg.lazygit.package
]; ];
vim.luaConfigRC.toggleterm-lazygit = entryAfter ["toggleterm"] '' vim.pluginRC.toggleterm-lazygit = entryAfter ["toggleterm"] ''
local terminal = require 'toggleterm.terminal' local terminal = require 'toggleterm.terminal'
local lazygit = terminal.Terminal:new({ local lazygit = terminal.Terminal:new({
cmd = '${ cmd = '${

View file

@ -6,10 +6,7 @@
inherit (lib.trivial) boolToString warnIf; inherit (lib.trivial) boolToString warnIf;
in { in {
onedark = { onedark = {
setup = { setup = {style ? "dark"}: ''
style ? "dark",
transparent,
}: ''
-- OneDark theme -- OneDark theme
require('onedark').setup { require('onedark').setup {
style = "${style}" style = "${style}"
@ -33,10 +30,7 @@ in {
}; };
dracula = { dracula = {
setup = { setup = {transparent}: ''
style ? null,
transparent,
}: ''
require('dracula').setup({ require('dracula').setup({
transparent_bg = ${boolToString transparent}, transparent_bg = ${boolToString transparent},
}); });

View file

@ -7,10 +7,10 @@
inherit (lib.attrsets) attrNames; inherit (lib.attrsets) attrNames;
inherit (lib.types) bool lines enum; inherit (lib.types) bool lines enum;
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryBefore; inherit (lib.nvim.dag) entryAfter;
cfg = config.vim.theme; cfg = config.vim.theme;
supported_themes = import ./supported_themes.nix { supportedThemes = import ./supported-themes.nix {
inherit lib config; inherit lib config;
}; };
in { in {
@ -21,12 +21,12 @@ in {
}; };
name = mkOption { name = mkOption {
type = enum (attrNames supported_themes); type = enum (attrNames supportedThemes);
description = "Supported themes can be found in `supported_themes.nix`"; description = "Supported themes can be found in `supportedThemes.nix`";
}; };
style = mkOption { style = mkOption {
type = enum supported_themes.${cfg.name}.styles; type = enum supportedThemes.${cfg.name}.styles;
description = "Specific style for theme if it supports it"; description = "Specific style for theme if it supports it";
}; };
@ -45,11 +45,9 @@ in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim = { vim = {
startPlugins = [cfg.name]; startPlugins = [cfg.name];
configRC.theme = entryBefore ["luaScript"] '' luaConfigRC.theme = entryAfter ["basic"] ''
lua << EOF
${cfg.extraConfig} ${cfg.extraConfig}
${supported_themes.${cfg.name}.setup (with cfg; {inherit style transparent;})} ${supportedThemes.${cfg.name}.setup {inherit (cfg) style transparent;}}
EOF
''; '';
}; };
}; };

View file

@ -37,18 +37,18 @@ in {
}; };
# For some reason treesitter highlighting does not work on start if this is set before syntax on # For some reason treesitter highlighting does not work on start if this is set before syntax on
configRC.treesitter-fold = mkIf cfg.fold (entryBefore ["basic"] '' pluginRC.treesitter-fold = mkIf cfg.fold (entryBefore ["basic"] ''
" This is required by treesitter-context to handle folds -- This is required by treesitter-context to handle folds
set foldmethod=expr vim.o.foldmethod = "expr"
set foldexpr=nvim_treesitter#foldexpr() vim.o.foldexpr = "nvim_treesitter#foldexpr()"
" This is optional, but is set rather as a sane default. -- This is optional, but is set rather as a sane default.
" If unset, opened files will be folded by automatically as -- If unset, opened files will be folded by automatically as
" the files are opened -- the files are opened
set nofoldenable vim.o.foldenable = false
''); '');
luaConfigRC.treesitter = entryAfter ["basic"] '' pluginRC.treesitter = entryAfter ["basic"] ''
require('nvim-treesitter.configs').setup { require('nvim-treesitter.configs').setup {
-- Disable imperative treesitter options that would attempt to fetch -- Disable imperative treesitter options that would attempt to fetch
-- grammars into the read-only Nix store. To add additional grammars here -- grammars into the read-only Nix store. To add additional grammars here

View file

@ -16,7 +16,7 @@ in {
# set up treesitter-context after Treesitter. The ordering # set up treesitter-context after Treesitter. The ordering
# should not matter, but there is no harm in doing this # should not matter, but there is no harm in doing this
luaConfigRC.treesitter-context = entryAfter ["treesitter"] '' pluginRC.treesitter-context = entryAfter ["treesitter"] ''
require("treesitter-context").setup(${toLuaObject cfg.setupOpts}) require("treesitter-context").setup(${toLuaObject cfg.setupOpts})
''; '';
}; };

View file

@ -1,46 +0,0 @@
{
config,
lib,
...
}: let
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.lists) optionals;
inherit (lib.types) enum;
cfg = config.vim.ui.borders;
defaultStyles = ["none" "single" "double" "rounded"];
in {
options.vim.ui.borders = {
enable = mkEnableOption "visible borders for most windows";
globalStyle = mkOption {
type = enum defaultStyles;
default = "rounded";
description = ''
The global border style to use.
'';
};
# TODO: make per-plugin borders configurable
plugins = let
mkPluginStyleOption = name: {
enable = mkEnableOption "borders for the ${name} plugin" // {default = cfg.enable;};
style = mkOption {
type = enum (defaultStyles ++ optionals (name != "which-key") ["shadow"]);
default = cfg.globalStyle;
description = "The border style to use for the ${name} plugin";
};
};
in {
# despite not having it listed in example configuration, which-key does support the rounded type
# additionally, it supports a "shadow" type that is similar to none but is of higher contrast
which-key = mkPluginStyleOption "which-key";
lspsaga = mkPluginStyleOption "lspsaga";
nvim-cmp = mkPluginStyleOption "nvim-cmp";
lsp-signature = mkPluginStyleOption "lsp-signature";
code-action-menu = mkPluginStyleOption "code-actions-menu";
};
};
}

View file

@ -1,5 +0,0 @@
{
imports = [
./borders.nix
];
}

View file

@ -78,7 +78,7 @@ in {
}; };
}; };
vim.luaConfigRC.breadcrumbs = entryAfter ["lspconfig"] '' vim.pluginRC.breadcrumbs = entryAfter ["lspconfig"] ''
${optionalString (cfg.source == "nvim-navic") '' ${optionalString (cfg.source == "nvim-navic") ''
local navic = require("nvim-navic") local navic = require("nvim-navic")

View file

@ -1,8 +1,4 @@
{ {lib, ...}: let
config,
lib,
...
}: let
inherit (lib.options) mkOption mkEnableOption; inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) attrsOf enum nullOr submodule bool str; inherit (lib.types) attrsOf enum nullOr submodule bool str;
inherit (lib.modules) mkRenamedOptionModule; inherit (lib.modules) mkRenamedOptionModule;

View file

@ -14,7 +14,7 @@ in {
"nvim-colorizer-lua" "nvim-colorizer-lua"
]; ];
vim.luaConfigRC.colorizer = entryAnywhere '' vim.pluginRC.colorizer = entryAnywhere ''
require('colorizer').setup(${toLuaObject cfg.setupOpts}) require('colorizer').setup(${toLuaObject cfg.setupOpts})
''; '';
}; };

View file

@ -1,12 +1,11 @@
{ {
imports = [ imports = [
./noice ./breadcrumbs
./modes
./notifications
./smartcolumn
./colorizer ./colorizer
./illuminate ./illuminate
./breadcrumbs ./modes
./borders ./noice
./notifications
./smartcolumn
]; ];
} }

View file

@ -11,7 +11,7 @@ in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim.startPlugins = ["vim-illuminate"]; vim.startPlugins = ["vim-illuminate"];
vim.luaConfigRC.vim-illuminate = entryAnywhere '' vim.pluginRC.vim-illuminate = entryAnywhere ''
require('illuminate').configure({ require('illuminate').configure({
filetypes_denylist = { filetypes_denylist = {
'dirvish', 'dirvish',

View file

@ -14,7 +14,7 @@ in {
"modes-nvim" "modes-nvim"
]; ];
vim.luaConfigRC.modes-nvim = entryAnywhere '' vim.pluginRC.modes-nvim = entryAnywhere ''
require('modes').setup(${toLuaObject cfg.setupOpts}) require('modes').setup(${toLuaObject cfg.setupOpts})
''; '';
}; };

View file

@ -6,13 +6,11 @@
}: let }: let
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf;
inherit (lib.lists) optionals; inherit (lib.lists) optionals;
inherit (lib.strings) optionalString; inherit (lib.nvim.lua) toLuaObject;
inherit (lib.trivial) boolToString;
inherit (lib.nvim.dag) entryAnywhere; inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.ui.noice; cfg = config.vim.ui.noice;
tscfg = config.vim.treesitter; tscfg = config.vim.treesitter;
cmptype = config.vim.autocomplete.type;
defaultGrammars = with pkgs.vimPlugins.nvim-treesitter.builtGrammars; [vim regex lua bash markdown]; defaultGrammars = with pkgs.vimPlugins.nvim-treesitter.builtGrammars; [vim regex lua bash markdown];
in { in {
@ -25,68 +23,8 @@ in {
treesitter.grammars = optionals tscfg.addDefaultGrammars defaultGrammars; treesitter.grammars = optionals tscfg.addDefaultGrammars defaultGrammars;
luaConfigRC.noice-nvim = entryAnywhere '' pluginRC.noice-nvim = entryAnywhere ''
require("noice").setup({ require("noice").setup(${toLuaObject cfg.setupOpts})
lsp = {
override = {
["vim.lsp.util.convert_input_to_markdown_lines"] = true,
["vim.lsp.util.stylize_markdown"] = true,
${optionalString (cmptype == "nvim-cmp") "[\"cmp.entry.get_documentation\"] = true,"}
},
signature = {
enabled = false, -- FIXME: enabling this file throws an error which I couldn't figure out
},
},
hover = {
enabled = true,
silent = false, -- set to true to not show a message if hover is not available
view = nil, -- when nil, use defaults from documentation
opts = {}, -- merged with defaults from documentation
},
presets = {
bottom_search = true, -- use a classic bottom cmdline for search
command_palette = true, -- position the cmdline and popupmenu together
long_message_to_split = true, -- long messages will be sent to a split
inc_rename = false, -- enables an input dialog for inc-rename.nvim
lsp_doc_border = ${boolToString config.vim.ui.borders.enable}, -- add a border to hover docs and signature help
},
format = {
cmdline = { pattern = "^:", icon = "", lang = "vim" },
search_down = { kind = "search", pattern = "^/", icon = " ", lang = "regex" },
search_up = { kind = "search", pattern = "^%?", icon = " ", lang = "regex" },
filter = { pattern = "^:%s*!", icon = "", lang = "bash" },
lua = { pattern = "^:%s*lua%s+", icon = "", lang = "lua" },
help = { pattern = "^:%s*he?l?p?%s+", icon = "󰋖" },
input = {},
},
messages = {
-- NOTE: If you enable messages, then the cmdline is enabled automatically.
-- This is a current Neovim limitation.
enabled = true, -- enables the Noice messages UI
view = "notify", -- default view for messages
view_error = "notify", -- view for errors
view_warn = "notify", -- view for warnings
view_history = "messages", -- view for :messages
view_search = "virtualtext", -- view for search count messages. Set to `false` to disable
},
-- Hide written messages
routes = {
{
filter = {
event = "msg_show",
kind = "",
find = "written",
},
opts = { skip = true },
},
},
})
''; '';
}; };
}; };

View file

@ -1,7 +1,142 @@
{lib, ...}: let {
inherit (lib.options) mkEnableOption; lib,
config,
...
}: let
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) anything nullOr listOf submodule str;
inherit (lib.nvim.types) mkPluginSetupOption;
inherit (lib.nvim.config) mkBool;
in { in {
options.vim.ui.noice = { options.vim.ui.noice = {
enable = mkEnableOption "noice.nvim UI modification library"; enable = mkEnableOption "noice.nvim UI modification library";
setupOpts = mkPluginSetupOption "noice.nvim" {
lsp = {
override = {
"vim.lsp.util.convert_input_to_markdown_lines" =
mkBool true "override the default lsp markdown formatter with Noice";
"vim.lsp.util.stylize_markdown" =
mkBool true "override the lsp markdown formatter with Noice";
"cmp.entry.get_documentation" =
mkBool (config.vim.autocomplete.type == "nvim-cmp") "override cmp documentation with Noice";
};
signature = {
enabled = mkEnableOption "signature help";
};
};
presets = {
bottom_search = mkBool true "use a classic bottom cmdline for search";
command_palette = mkBool true "position the cmdline and popupmenu together";
long_message_to_split = mkBool true "long messages will be sent to a split";
inc_rename = mkBool false "enables an input dialog for inc-rename.nvim";
lsp_doc_border =
mkBool config.vim.ui.borders.enable "add a border to hover docs and signature help";
};
# TODO: is it possible to write a submodule for this?
format = {
cmdline = mkOption {
description = "formatting options for the cmdline";
type = nullOr anything;
default = {
pattern = "^:";
icon = "";
lang = "vim";
};
};
search_down = mkOption {
description = "formatting options for search_down";
type = nullOr anything;
default = {
kind = "search";
pattern = "^/";
icon = " ";
lang = "regex";
};
};
search_up = mkOption {
description = "formatting options for search_up";
type = nullOr anything;
default = {
kind = "search";
pattern = "^%?";
icon = " ";
lang = "regex";
};
};
filter = mkOption {
description = "formatting options for filter";
type = nullOr anything;
default = {
pattern = "^:%s*!";
icon = "";
lang = "bash";
};
};
lua = mkOption {
description = "formatting options for lua";
type = nullOr anything;
default = {
pattern = "^:%s*lua%s+";
icon = "";
lang = "lua";
};
};
help = mkOption {
description = "formatting options for help";
type = nullOr anything;
default = {
pattern = "^:%s*he?l?p?%s+";
icon = "󰋖";
};
};
};
routes = mkOption {
description = "How to route messages";
type = listOf (submodule {
options = {
view = mkOption {
description = "how this route is viewed";
type = nullOr str;
default = null;
};
filter = mkOption {
description = "a filter for messages matching this route";
type = anything;
};
opts = mkOption {
description = "options for the view and the route";
type = nullOr anything;
default = null;
};
};
});
default = [
{
filter = {
event = "msg_show";
kind = "";
find = "written";
};
opts = {skip = true;};
}
];
defaultText = "Hide written messages";
};
};
}; };
} }

View file

@ -13,7 +13,7 @@ in {
vim = { vim = {
startPlugins = ["nvim-notify"]; startPlugins = ["nvim-notify"];
luaConfigRC.nvim-notify = entryAnywhere '' pluginRC.nvim-notify = entryAnywhere ''
require('notify').setup(${toLuaObject cfg.setupOpts}) require('notify').setup(${toLuaObject cfg.setupOpts})
-- required to fix offset_encoding errors -- required to fix offset_encoding errors

View file

@ -13,7 +13,7 @@ in {
vim = { vim = {
startPlugins = ["smartcolumn"]; startPlugins = ["smartcolumn"];
luaConfigRC.smartcolumn = entryAnywhere '' pluginRC.smartcolumn = entryAnywhere ''
require("smartcolumn").setup(${toLuaObject cfg.setupOpts}) require("smartcolumn").setup(${toLuaObject cfg.setupOpts})
''; '';
}; };

View file

@ -1,6 +1,6 @@
{lib, ...}: let {lib, ...}: let
inherit (lib.options) mkOption mkEnableOption literalExpression; inherit (lib.options) mkOption mkEnableOption literalExpression;
inherit (lib.types) nullOr int str attrsOf either listOf; inherit (lib.types) nullOr str attrsOf either listOf;
inherit (lib.modules) mkRenamedOptionModule; inherit (lib.modules) mkRenamedOptionModule;
inherit (lib.nvim.types) mkPluginSetupOption; inherit (lib.nvim.types) mkPluginSetupOption;
in { in {

View file

@ -1,8 +1,4 @@
{ {lib, ...}: let
config,
lib,
...
}: let
inherit (lib.options) mkEnableOption; inherit (lib.options) mkEnableOption;
in { in {
options.vim.binds.cheatsheet = { options.vim.binds.cheatsheet = {

View file

@ -8,10 +8,10 @@
cfg = config.vim.binds.cheatsheet; cfg = config.vim.binds.cheatsheet;
in { in {
config = mkIf (cfg.enable) { config = mkIf cfg.enable {
vim.startPlugins = ["cheatsheet-nvim"]; vim.startPlugins = ["cheatsheet-nvim"];
vim.luaConfigRC.cheaetsheet-nvim = entryAnywhere '' vim.pluginRC.cheaetsheet-nvim = entryAnywhere ''
require('cheatsheet').setup({}) require('cheatsheet').setup({})
''; '';
}; };

Some files were not shown because too many files have changed in this diff Show more