Compare commits

..

6 commits

64 changed files with 637 additions and 1959 deletions

View file

@ -65,15 +65,16 @@ isMaximal: {
r.enable = isMaximal; r.enable = isMaximal;
tailwind.enable = isMaximal; tailwind.enable = isMaximal;
typst.enable = isMaximal; typst.enable = isMaximal;
clang.enable = isMaximal; clang = {
enable = isMaximal;
lsp.server = "clangd";
};
scala.enable = isMaximal; scala.enable = isMaximal;
rust = { rust = {
enable = isMaximal; enable = isMaximal;
crates.enable = isMaximal; crates.enable = isMaximal;
}; };
csharp.enable = isMaximal;
julia.enable = isMaximal;
vala.enable = isMaximal;
}; };
visuals = { visuals = {

View file

@ -20,7 +20,6 @@ custom plugins that you might have added to your configuration.
```{=include=} sections ```{=include=} sections
custom-plugins/configuring.md custom-plugins/configuring.md
custom-plugins/lazy-method.md custom-plugins/new-method.md
custom-plugins/non-lazy-method.md custom-plugins/old-method.md
custom-plugins/legacy-method.md
``` ```

View file

@ -2,34 +2,12 @@
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 lua config using either be enough. In that case, you can write custom lua config using either
`config.vim.lazy.plugins.*.setupOpts` `config.vim.extraPlugins.*.setup` or `config.vim.extraPlugins` (which has the `setup` field) or
`config.vim.luaConfigRC`. `config.vim.luaConfigRC`. The first option uses an attribute set, which maps DAG
section names to a custom type, which has the fields `package`, `after`,
The first option uses an extended version of `lz.n`'s PluginSpec. `setupModule` `setup`. They allow you to set the package of the plugin, the sections its setup
and `setupOpt` can be used if the plugin uses a `require('module').setup(...)` code should be after (note that the `extraPlugins` option has its own DAG
pattern. Otherwise, the `before` and `after` hooks should do what you need. scope), and the its setup code respectively. For example:
```nix
{
config.vim.lazy.plugins = {
aerial-nvim = {
# ^^^^^^^^^ this name should match the package.pname or package.name
package = aerial-nvim;
setupModule = "aerial";
setupOpts = {option_name = false;};
after = "print('aerial loaded')";
};
};
}
```
The second option uses an attribute set, which maps DAG 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 ```nix
config.vim.extraPlugins = with pkgs.vimPlugins; { config.vim.extraPlugins = with pkgs.vimPlugins; {
@ -46,7 +24,7 @@ config.vim.extraPlugins = with pkgs.vimPlugins; {
} }
``` ```
The third option also uses an attribute set, but this one is resolved as a DAG 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. directly. The attribute names denote the section names, and the values lua code.
For example: For example:
@ -58,17 +36,13 @@ For example:
} }
``` ```
<!-- deno-fmt-ignore-start --> :::{.note}
If your configuration needs to be put in a specific place in the config, you
::: {.note} can use functions from `inputs.nvf.lib.nvim.dag` to order it. Refer to
One of the greatest strengths of nvf is the ability to order https://github.com/nix-community/home-manager/blob/master/modules/lib/dag.nix
snippets of configuration via the DAG system. It will allow specifying positions
of individual sections of configuration as needed. nvf provides helper functions
in the extended library, usually under `inputs.nvf.lib.nvim.dag` that you may
use.
Please refer to the [DAG section](/index.xhtml#ch-dag-entries) in the nvf manual
to find out more about the DAG system. to find out more about the DAG system.
::: :::
<!-- deno-fmt-ignore-end --> If you successfully made your plugin work, please feel free to create a PR to
add it to **nvf** or open an issue with your findings so that we can make it
available for everyone easily.

View file

@ -1,40 +0,0 @@
# Lazy Method {#sec-lazy-method}
As of version **0.7**, we exposed an API for configuring lazy-loaded plugins via
`lz.n` and `lzn-auto-require`.
```nix
{
config.vim.lazy.plugins = {
aerial = {
package = pkgs.vimPlugins.aerial-nvim;
setupModule = aerial;
setupOpts = {
option_name = true;
};
after = ''
-- custom lua code to run after plugin is loaded
print('aerial loaded')
'';
# Explicitly mark plugin as lazy. You don't need this if you define one of
# the trigger "events" below
lazy = true;
# load on command
cmd = ["AerialOpen"];
# load on event
event = ["BufEnter"];
# load on keymap
keys = [
{
key = "<leader>a";
action = ":AerialToggle<CR>";
}
];
};
};
}
```

View file

@ -1,4 +1,4 @@
# Non-lazy Method {#sec-non-lazy-method} # New Method {#sec-new-method}
As of version **0.5**, we have a more extensive API for configuring plugins, As of version **0.5**, we have a more extensive API for configuring plugins,
under `vim.extraPlugins`. Instead of using DAGs exposed by the library, you may under `vim.extraPlugins`. Instead of using DAGs exposed by the library, you may

View file

@ -1,6 +1,6 @@
# Legacy Method {#sec-legacy-method} # Old Method {#sec-old-method}
Prior to version v0.5, the method of adding new plugins was adding the plugin Prior to version 0.5, the method of adding new plugins was adding the plugin
package to `vim.startPlugins` and add its configuration as a DAG under one of package to `vim.startPlugins` and add its configuration as a DAG under one of
`vim.configRC` or `vim.luaConfigRC`. Users who have not yet updated to 0.5, or `vim.configRC` or `vim.luaConfigRC`. Users who have not yet updated to 0.5, or
prefer a more hands-on approach may use the old method where the load order of prefer a more hands-on approach may use the old method where the load order of
@ -8,14 +8,13 @@ the plugins is determined by DAGs.
## Adding plugins {#sec-adding-plugins} ## Adding plugins {#sec-adding-plugins}
To add a plugin not available in nvf as a module to your configuration, you may To add a plugin to **nvf**'s runtime, you may add it
add it to [](#opt-vim.startPlugins) in order to make it available to Neovim at
runtime.
```nix ```nix
{pkgs, ...}: { {pkgs, ...}: {
# Add a Neovim plugin from Nixpkgs to the runtime. # add a package from nixpkgs to startPlugins
vim.startPlugins = [pkgs.vimPlugins.aerial-nvim]; vim.startPlugins = [
pkgs.vimPlugins.aerial-nvim ];
} }
``` ```
@ -24,9 +23,7 @@ provide configuration as a DAG using the **nvf** extended library.
```nix ```nix
{inputs, ...}: let {inputs, ...}: let
# This assumes you have an input called 'nvf' in your flake inputs # assuming you have an input called nvf pointing at the nvf repository
# and 'inputs' in your specialArgs. In the case you have passed 'nvf'
# to specialArgs, the 'inputs' prefix may be omitted.
inherit (inputs.nvf.lib.nvim.dag) entryAnywhere; inherit (inputs.nvf.lib.nvim.dag) entryAnywhere;
in { in {
vim.luaConfigRC.aerial-nvim= entryAnywhere '' vim.luaConfigRC.aerial-nvim= entryAnywhere ''

View file

@ -12,14 +12,12 @@ entries in nvf:
2. `globalsScript` - used to set globals defined in `vim.globals` 2. `globalsScript` - used to set globals defined in `vim.globals`
3. `basic` - used to set basic configuration options 3. `basic` - used to set basic configuration options
4. `optionsScript` - used to set options defined in `vim.o` 4. `optionsScript` - used to set options defined in `vim.o`
5. `theme` (this is simply placed before `pluginConfigs` and `lazyConfigs`, meaning that 5. `theme` (this is simply placed before `pluginConfigs`, meaning that
surrounding entries don't depend on it) - used to set up the theme, which has to be done before surrounding entries don't depend on it) - used to set up the theme, which has
other plugins to be done before other plugins
6. `lazyConfigs` - `lz.n` and `lzn-auto-require` configs. If `vim.lazy.enable` 6. `pluginConfigs` - the result of the nested `vim.pluginRC` (internal option,
is false, this will contain each plugin's config instead.
7. `pluginConfigs` - the result of the nested `vim.pluginRC` (internal option,
see the [Custom Plugins](/index.xhtml#ch-custom-plugins) page for adding your see the [Custom Plugins](/index.xhtml#ch-custom-plugins) page for adding your
own plugins) DAG, used to set up internal plugins own plugins) DAG, used to set up internal plugins
8. `extraPluginConfigs` - the result of `vim.extraPlugins`, which is not a 7. `extraPluginConfigs` - the result of `vim.extraPlugins`, which is not a
direct DAG, but is converted to, and resolved as one internally direct DAG, but is converted to, and resolved as one internally
9. `mappings` - the result of `vim.maps` 8. `mappings` - the result of `vim.maps`

View file

@ -1,25 +1,16 @@
# Hacking nvf {#ch-hacking} # Hacking nvf {#ch-hacking}
[open issues]: https://github.com/notashelf/nvf/issues **nvf** is designed for developers as much as it is for the end user. I would like any potential contributor
[new issue]: https://github.com/notashelf/nvf/issues/new to be able to propagate their desired changes into the repository without the extra effort. As such, below are guides
(and guidelines) to streamline the contribution process and ensure that your valuable input seamlessly integrates
into **nvf**'s development without leaving question marks in your head.
nvf is designed for the developer as much as it is designed for the end-user. We This section is mainly directed towards those who wish to contribute code into **nvf**. If you wish to instead
would like for any contributor to be able to propagate their changes, or add new report a bug or discuss a potential feature implementation, first look among the
features to the project with minimum possible friction. As such, below are the already [open issues](https://github.com/notashelf/nvf/issues) and if no matching issue exists you may open
guides and guidelines written to streamline the contribution process and to a [new issue](https://github.com/notashelf/nvf/issues/new) and describe your problem/request. While creating an
ensure that your valuable input integrates into nvf's development as seamlessly issue, please try to include as much information as you can, ideally also include relevant context in which an issue
as possible without leaving any question marks in your head. occurs or a feature should be implemented.
This section is directed mainly towards those who wish to contribute code into
the project. If you instead wish to report a bug, or discuss a potential new
feature implementation (which you do not wish to implement yourself) first look
among the already [open issues] and if no matching issue exists you may open a
[new issue] and describe your problem/request.
While creating an issue, please try to include as much information as you can,
ideally also include relevant context in which an issue occurs or a feature
should be implemented. If you wish to make a contribution, but feel stuck -
please do not be afraid to submit a pull request, we will help you get it in.
```{=include=} sections ```{=include=} sections
hacking/getting-started.md hacking/getting-started.md

View file

@ -124,61 +124,3 @@ vim.your-plugin.setupOpts = {
''; '';
} }
``` ```
## Lazy plugins {#sec-lazy-plugins}
If the plugin can be lazy-loaded, `vim.lazy.plugins` should be used to add it. Lazy
plugins are managed by `lz.n`.
```nix
# in modules/.../your-plugin/config.nix
{lib, config, ...}:
let
cfg = config.vim.your-plugin;
in {
vim.lazy.plugins.your-plugin = {
# instead of vim.startPlugins, use this:
package = "your-plugin";
# if your plugin uses the `require('your-plugin').setup{...}` pattern
setupModule = "your-plugin";
inherit (cfg) setupOpts;
# events that trigger this plugin to be loaded
event = ["DirChanged"];
cmd = ["YourPluginCommand"];
# keymaps
keys = [
# we'll cover this in detail in the keymaps section
{
key = "<leader>d";
mode = "n";
action = ":YourPluginCommand";
}
];
};
;
}
```
This results in the following lua code:
```lua
require('lz.n').load({
{
"name-of-your-plugin",
after = function()
require('your-plugin').setup({--[[ your setupOpts ]]})
end,
event = {"DirChanged"},
cmd = {"YourPluginCommand"},
keys = {
{"<leader>d", ":YourPluginCommand", mode = {"n"}},
},
}
})
```
A full list of options can be found
[here](https://notashelf.github.io/nvf/options.html#opt-vim.lazy.plugins

View file

@ -1,12 +1,9 @@
# Installing nvf {#ch-installation} # Installing nvf {#ch-installation}
[module installation section]: #ch-module-installation
There are multiple ways of installing nvf on your system. You may either choose There are multiple ways of installing nvf on your system. You may either choose
the standalone installation method, which does not depend on a module system and the standalone installation method, which does not depend on a module system and may
may be done on any system that has the Nix package manager or the appropriate be done on any system that has the Nix package manager or the appropriate modules
modules for NixOS and home-manager as described in the for NixOS and home-manager as described in the [module installation section](#ch-module-installation)
[module installation section].
```{=include=} chapters ```{=include=} chapters
installation/custom-configuration.md installation/custom-configuration.md

View file

@ -17,8 +17,8 @@ configuring.md
hacking.md hacking.md
``` ```
```{=include=} appendix html:into-file=//quirks.html ```{=include=} appendix html:into-file=//plugins.html
quirks.md plugins.md
``` ```
```{=include=} appendix html:into-file=//options.html ```{=include=} appendix html:into-file=//options.html

View file

@ -1,14 +1,8 @@
# Neovim Flake Configuration Options {#ch-options} # Neovim Flake Configuration Options {#ch-options}
Below are the module options provided by nvf, in no particular order. Most Below are the options provided by nvf provided in no particular order.
options will include useful comments, warnings or setup tips on how a module They may include useful comments and warnings, or examples on how a module option
option is meant to be used as well as examples in complex cases. is meant to be used.
<!--
In the manual, individual options may be referenced in Hyperlinks as follows:
[](#opt-vim.*) If changing the prefix here, do keep in mind the #opt- suffix will have
to be changed everywhere.
-->
```{=include=} options ```{=include=} options
id-prefix: opt- id-prefix: opt-

16
docs/manual/plugins.md Normal file
View file

@ -0,0 +1,16 @@
# Plugin specific quirks {#ch-plugins}
At times, certain plugins refuse to play nicely. Be it as a result of generating
lua from Nix, or the state of packaging. This page shall list any plugins that
are known to misbehave, and potential workarounds.
```{=include=} chapters
plugins/nodejs.md
```
<!--
If adding a new section, uncomment this part and add your page to
plugins/<page>.md
```{=include=} chapters
plugins/page.md
```
-->

View file

@ -1,22 +1,16 @@
# NodeJS {#ch-quirks-nodejs} # NodeJS {#ch-plugins-nodejs}
## eslint-plugin-prettier {#sec-eslint-plugin-prettier} ## eslint-plugin-prettier {#sec-eslint-plugin-prettier}
When working with NodeJS, everything works as expected, but some projects have When working with NodeJS, everything works as expected, but some projects have settings that can fool nvf.
settings that can fool nvf.
If [this plugin](https://github.com/prettier/eslint-plugin-prettier) or similar If [this plugin](https://github.com/prettier/eslint-plugin-prettier) or similar is included, you might get a situation where your eslint configuration diagnoses your formatting according to its own config (usually `.eslintrc.js`).
is included, you might get a situation where your eslint configuration diagnoses
your formatting according to its own config (usually `.eslintrc.js`).
The issue there is your formatting is made via prettierd. The issue there is your formatting is made via prettierd.
This results in auto-formating relying on your prettier config, while your This results in auto-formating relying on your prettier config, while your eslint config diagnoses formatting [which it's not supposed to](https://prettier.io/docs/en/comparison.html))
eslint config diagnoses formatting
[which it's not supposed to](https://prettier.io/docs/en/comparison.html))
In the end, you get discrepancies between what your editor does and what it In the end, you get discrepancies between what your editor does and what it wants.
wants.
Solutions are: Solutions are:

View file

@ -1,20 +1,7 @@
# Preface {#ch-preface} # Preface {#ch-preface}
## What is nvf {#sec-what-is-it} If you noticed a bug caused by **nvf** then please consider reporting it over
[the issue tracker](https://github.com/notashelf/nvf/issues).
nvf is a highly modular, configurable, extensible and easy to use Neovim Bugfixes, feature additions and upstreamed changes from your local configurations
configuration in Nix. Designed for flexibility and ease of use, nvf allows you are always welcome in the [the pull requests tab](https://github.com/notashelf/nvf/pulls).
to easily configure your fully featured Neovim instance with a few lines of Nix.
## Bugs & Suggestions {#sec-bugs-suggestions}
[issue tracker]: https://github.com/notashelf/nvf/issues
[discussions tab]: https://github.com/notashelf/nvf/discussions
[pull requests tab]: https://github.com/notashelf/nvf/pulls
If you notice any issues with nvf, or this documentation, then please consider
reporting them over at the [issue tracker]. Issues tab, in addition to the
[discussions tab] is a good place as any to request new features.
You may also consider submitting bugfixes, feature additions and upstreamed
changes that you think are critical over at the [pull requests tab].

View file

@ -1,13 +0,0 @@
# Known Issues and Quirks {#ch-known-issues-quirks}
At times, certain plugins and modules may refuse to play nicely with your setup,
be it a result of generating Lua from Nix, or the state of packaging. This page,
in turn, will list any known modules or plugins that are known to misbehave, and
possible workarounds that you may apply.
<!-- If adding a new known quirk, please create a new page in quirks/ and include
the name of the file here.-->
```{=include=} chapters
quirks/nodejs.md
```

View file

@ -1,27 +1,25 @@
# Try it out {#ch-try-it-out} # Try it out {#ch-try-it-out}
Thanks to the portability of Nix, you can try out nvf without actually Thanks to the portability of Nix, you can try out nvf without actually installing it to your machine.
installing it to your machine. Below are the commands you may run to try out Below are the commands you may run to try out different configurations provided by this flake. As of v0.5, three
different configurations provided by this flake. As of v0.5, two specialized
configurations are provided: configurations are provided:
- **Nix** - Nix language server + simple utility plugins - Nix
- **Maximal** - Variable language servers + utility and decorative plugins - Maximal
You may try out any of the provided configurations using the `nix run` command You may try out any of the provided configurations using the `nix run` command on a system where Nix is installed.
on a system where Nix is installed.
```bash ```console
$ cachix use nvf # Optional: it'll save you CPU resources and time $ cachix use nvf # Optional: it'll save you CPU resources and time
$ nix run github:notashelf/nvf#nix # will run the default minimal configuration $ nix run github:notashelf/nvf#nix # will run the default minimal configuration
``` ```
Do keep in mind that this is **susceptible to garbage collection** meaning it Do keep in mind that this is **susceptible to garbage collection** meaning it will be removed from your Nix store
will be removed from your Nix store once you garbage collect. once you garbage collect.
## Using Prebuilt Configs {#sec-using-prebuilt-configs} ## Using Prebuilt Configs {#sec-using-prebuild-configs}
```bash ```console
$ nix run github:notashelf/nvf#nix $ nix run github:notashelf/nvf#nix
$ nix run github:notashelf/nvf#maximal $ nix run github:notashelf/nvf#maximal
``` ```
@ -30,19 +28,12 @@ $ nix run github:notashelf/nvf#maximal
#### Nix {#sec-configs-nix} #### Nix {#sec-configs-nix}
`Nix` configuration by default provides LSP/diagnostic support for Nix alongside `Nix` configuration by default provides LSP/diagnostic support for Nix alongisde a set of visual and functional plugins.
a set of visual and functional plugins. By running `nix run .#`, which is the By running `nix run .#`, which is the default package, you will build Neovim with this config.
default package, you will build Neovim with this config.
#### Maximal {#sec-configs-maximal} #### Maximal {#sec-configs-maximal}
`Maximal` is the ultimate configuration that will enable support for more `Maximal` is the ultimate configuration that will enable support for more commonly used language as well as additional
commonly used language as well as additional complementary plugins. Keep in complementary plugins. Keep in mind, however, that this will pull a lot of dependencies.
mind, however, that this will pull a lot of dependencies.
::: {.tip} You are _strongly_ recommended to use the binary cache if you would like to try the Maximal configuration.
You are _strongly_ recommended to use the binary cache if you would like to try
the Maximal configuration.
:::

View file

@ -68,19 +68,9 @@ everyone.
As part of the autocompletion rewrite, modules that used to use a `type` option As part of the autocompletion rewrite, modules that used to use a `type` option
have been replaced by per-plugin modules instead. Since both modules only had have been replaced by per-plugin modules instead. Since both modules only had
one type, you can simply change one type, you can simply change
- `vim.autocomplete.*` -> `vim.autocomplete.nvim-cmp.*` - `vim.autocomplete.*` -> `vim.autocomplete.nvim-cmp.*`
- `vim.autopairs.enable` -> `vim.autopairs.nvim-autopairs.enable` - `vim.autopairs.enable` -> `vim.autopairs.nvim-autopairs.enable`
### `nixpkgs-fmt` removed in favor of `nixfmt` {#sec-nixpkgs-fmt-deprecation}
`nixpkgs-fmt` has been archived for a while, and it's finally being removed in
favor of nixfmt (more information can be found
[here](https://github.com/nix-community/nixpkgs-fmt?tab=readme-ov-file#nixpkgs-fmt---nix-code-formatter-for-nixpkgs).
To migrate to `nixfmt`, simply change `vim.languages.nix.format.type` to
`nixfmt`.
## Changelog {#sec-release-0.7-changelog} ## Changelog {#sec-release-0.7-changelog}
[ItsSorae](https://github.com/ItsSorae): [ItsSorae](https://github.com/ItsSorae):
@ -123,10 +113,6 @@ To migrate to `nixfmt`, simply change `vim.languages.nix.format.type` to
recommended to go through rustacean.nvim's README to take a closer look at its recommended to go through rustacean.nvim's README to take a closer look at its
features and usage features and usage
- Add [lz.n] support and lazy-load some builtin plugins.
[lz.n]: https://github.com/mrcjkb/lz.n
[jacekpoz](https://jacekpoz.pl): [jacekpoz](https://jacekpoz.pl):
[ocaml-lsp]: https://github.com/ocaml/ocaml-lsp [ocaml-lsp]: https://github.com/ocaml/ocaml-lsp
@ -185,7 +171,6 @@ To migrate to `nixfmt`, simply change `vim.languages.nix.format.type` to
default. default.
- Refactor of `nvim-cmp` and completion related modules - Refactor of `nvim-cmp` and completion related modules
- Remove `autocomplete.type` in favor of per-plugin enable options such as - Remove `autocomplete.type` in favor of per-plugin enable options such as
[](#opt-vim.autocomplete.nvim-cmp.enable). [](#opt-vim.autocomplete.nvim-cmp.enable).
- Deprecate legacy Vimsnip in favor of Luasnip, and integrate - Deprecate legacy Vimsnip in favor of Luasnip, and integrate
@ -194,13 +179,6 @@ To migrate to `nixfmt`, simply change `vim.languages.nix.format.type` to
- Add sorting function options for completion sources under - Add sorting function options for completion sources under
[](#opt-vim.autocomplete.nvim-cmp.setupOpts.sorting.comparators) [](#opt-vim.autocomplete.nvim-cmp.setupOpts.sorting.comparators)
- Add C# support under `vim.languages.csharp`, with support for both
omnisharp-roslyn and csharp-language-server.
- Add Julia support under `vim.languages.julia`. Note that the entirety of Julia
is bundled with nvf, if you enable the module, since there is no way to
provide only the LSP server.
[Neovim documentation on `vim.cmd`]: https://neovim.io/doc/user/lua.html#vim.cmd() [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 - Make Neovim's configuration file entirely Lua based. This comes with a few
@ -278,13 +256,9 @@ To migrate to `nixfmt`, simply change `vim.languages.nix.format.type` to
configuration for [dashboard.nvim](https://github.com/nvimdev/dashboard-nvim) configuration for [dashboard.nvim](https://github.com/nvimdev/dashboard-nvim)
- Update `lualine.nvim` input and add missing themes: - Update `lualine.nvim` input and add missing themes:
- Adds `ayu`, `gruvbox_dark`, `iceberg`, `moonfly`, `onedark`, - Adds `ayu`, `gruvbox_dark`, `iceberg`, `moonfly`, `onedark`,
`powerline_dark` and `solarized_light` themes. `powerline_dark` and `solarized_light` themes.
- Add [](#opt-vim.spellcheck.extraSpellWords) to allow adding arbitrary
spellfiles to Neovim's runtime with ease.
[ppenguin](https://github.com/ppenguin): [ppenguin](https://github.com/ppenguin):
- Telescope: - Telescope:
@ -296,12 +270,10 @@ To migrate to `nixfmt`, simply change `vim.languages.nix.format.type` to
- Add LSP and Treesitter support for R under `vim.languages.R`. - Add LSP and Treesitter support for R under `vim.languages.R`.
- Add Otter support under `vim.lsp.otter` and an assert to prevent conflict with - Add Otter support under `vim.lsp.otter` and an assert to prevent conflict with
ccc ccc
- Fixed typo in Otter's setupOpts
- Add Neorg support under `vim.notes.neorg` - Add Neorg support under `vim.notes.neorg`
- Add LSP, diagnostics, formatter and Treesitter support for Kotlin under - Add LSP, diagnostics, formatter and Treesitter support for Kotlin under
`vim.languages.kotlin` `vim.languages.kotlin`
- changed default keybinds for leap.nvim to avoid altering expected behavior - changed default keybinds for leap.nvim to avoid altering expected behavior
- Add LSP, formatter and Treesitter support for Vala under `vim.languages.vala`
[Bloxx12](https://github.com/Bloxx12) [Bloxx12](https://github.com/Bloxx12)
@ -314,11 +286,3 @@ To migrate to `nixfmt`, simply change `vim.languages.nix.format.type` to
- Add LSP support for Scala via - Add LSP support for Scala via
[nvim-metals](https://github.com/scalameta/nvim-metals) [nvim-metals](https://github.com/scalameta/nvim-metals)
[nezia1](https://github.com/nezia1):
- Add [biome](https://github.com/biomejs/biome) support for Typescript, CSS and
Svelte. Enable them via [](#opt-vim.languages.ts.format.type),
[](#opt-vim.languages.css.format.type) and
[](#opt-vim.languages.svelte.format.type) respectively.
- Replace [nixpkgs-fmt](https://github.com/nix-community/nixpkgs-fmt) with
[nixfmt](https://github.com/NixOS/nixfmt) (nixfmt-rfc-style).

86
flake.lock generated
View file

@ -460,22 +460,6 @@
"type": "github" "type": "github"
} }
}, },
"plugin-csharpls-extended": {
"flake": false,
"locked": {
"lastModified": 1728438370,
"narHash": "sha256-sOLPV5IhOvQ0+u7CDAfG3X0ZbRCicz18QyYXQ0dxpwQ=",
"owner": "Decodetalkers",
"repo": "csharpls-extended-lsp.nvim",
"rev": "b647e1bd1f9c0410f5ef4a1517a331cbac322d9a",
"type": "github"
},
"original": {
"owner": "Decodetalkers",
"repo": "csharpls-extended-lsp.nvim",
"type": "github"
}
},
"plugin-dashboard-nvim": { "plugin-dashboard-nvim": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -892,39 +876,6 @@
"type": "github" "type": "github"
} }
}, },
"plugin-lz-n": {
"flake": false,
"locked": {
"lastModified": 1729525284,
"narHash": "sha256-fk+ejqcqqOQz3q4D3VB2Q+U/6wCpCDk1tiDMp2YrPNE=",
"owner": "nvim-neorocks",
"repo": "lz.n",
"rev": "ffd9991400ba7137f4fa8560ff50bccd7f8fb3ee",
"type": "github"
},
"original": {
"owner": "nvim-neorocks",
"repo": "lz.n",
"type": "github"
}
},
"plugin-lzn-auto-require": {
"flake": false,
"locked": {
"lastModified": 1727636949,
"narHash": "sha256-BAOzN+XOrFAJwHmsF8JtZ2EyjP9283FD/I2TbFqGSEw=",
"owner": "horriblename",
"repo": "lzn-auto-require",
"rev": "55ecd60831dac8c01d6f3dcb63a30a63a1690eb8",
"type": "github"
},
"original": {
"owner": "horriblename",
"ref": "require-rewrite",
"repo": "lzn-auto-require",
"type": "github"
}
},
"plugin-mind-nvim": { "plugin-mind-nvim": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -1502,22 +1453,6 @@
"type": "github" "type": "github"
} }
}, },
"plugin-omnisharp-extended": {
"flake": false,
"locked": {
"lastModified": 1719701797,
"narHash": "sha256-P1ZCaW8w+e3H3oBhbEjDc7vuR+XuxJmb/7IbPL3KWi4=",
"owner": "Hoffs",
"repo": "omnisharp-extended-lsp.nvim",
"rev": "aad7bf06b4ca0de816b919d475a75b30f5f62b61",
"type": "github"
},
"original": {
"owner": "Hoffs",
"repo": "omnisharp-extended-lsp.nvim",
"type": "github"
}
},
"plugin-onedark": { "plugin-onedark": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -1662,22 +1597,6 @@
"type": "github" "type": "github"
} }
}, },
"plugin-rtp-nvim": {
"flake": false,
"locked": {
"lastModified": 1724409589,
"narHash": "sha256-lmJbiD7I7MTEEpukESs67uAmLyn+p66hrUKLbEHp0Kw=",
"owner": "nvim-neorocks",
"repo": "rtp.nvim",
"rev": "494ddfc888bb466555d90ace731856de1320fe45",
"type": "github"
},
"original": {
"owner": "nvim-neorocks",
"repo": "rtp.nvim",
"type": "github"
}
},
"plugin-rustaceanvim": { "plugin-rustaceanvim": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -2013,7 +1932,6 @@
"plugin-copilot-cmp": "plugin-copilot-cmp", "plugin-copilot-cmp": "plugin-copilot-cmp",
"plugin-copilot-lua": "plugin-copilot-lua", "plugin-copilot-lua": "plugin-copilot-lua",
"plugin-crates-nvim": "plugin-crates-nvim", "plugin-crates-nvim": "plugin-crates-nvim",
"plugin-csharpls-extended": "plugin-csharpls-extended",
"plugin-dashboard-nvim": "plugin-dashboard-nvim", "plugin-dashboard-nvim": "plugin-dashboard-nvim",
"plugin-diffview-nvim": "plugin-diffview-nvim", "plugin-diffview-nvim": "plugin-diffview-nvim",
"plugin-dracula": "plugin-dracula", "plugin-dracula": "plugin-dracula",
@ -2040,8 +1958,6 @@
"plugin-lua-utils-nvim": "plugin-lua-utils-nvim", "plugin-lua-utils-nvim": "plugin-lua-utils-nvim",
"plugin-lualine": "plugin-lualine", "plugin-lualine": "plugin-lualine",
"plugin-luasnip": "plugin-luasnip", "plugin-luasnip": "plugin-luasnip",
"plugin-lz-n": "plugin-lz-n",
"plugin-lzn-auto-require": "plugin-lzn-auto-require",
"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",
@ -2078,7 +1994,6 @@
"plugin-nvim-ts-autotag": "plugin-nvim-ts-autotag", "plugin-nvim-ts-autotag": "plugin-nvim-ts-autotag",
"plugin-nvim-web-devicons": "plugin-nvim-web-devicons", "plugin-nvim-web-devicons": "plugin-nvim-web-devicons",
"plugin-obsidian-nvim": "plugin-obsidian-nvim", "plugin-obsidian-nvim": "plugin-obsidian-nvim",
"plugin-omnisharp-extended": "plugin-omnisharp-extended",
"plugin-onedark": "plugin-onedark", "plugin-onedark": "plugin-onedark",
"plugin-orgmode-nvim": "plugin-orgmode-nvim", "plugin-orgmode-nvim": "plugin-orgmode-nvim",
"plugin-otter-nvim": "plugin-otter-nvim", "plugin-otter-nvim": "plugin-otter-nvim",
@ -2088,7 +2003,6 @@
"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-rtp-nvim": "plugin-rtp-nvim",
"plugin-rustaceanvim": "plugin-rustaceanvim", "plugin-rustaceanvim": "plugin-rustaceanvim",
"plugin-scrollbar-nvim": "plugin-scrollbar-nvim", "plugin-scrollbar-nvim": "plugin-scrollbar-nvim",
"plugin-smartcolumn": "plugin-smartcolumn", "plugin-smartcolumn": "plugin-smartcolumn",

View file

@ -109,22 +109,6 @@
}; };
## Plugins ## Plugins
# Lazy loading
plugin-lz-n = {
url = "github:nvim-neorocks/lz.n";
flake = false;
};
plugin-lzn-auto-require = {
url = "github:horriblename/lzn-auto-require/require-rewrite";
flake = false;
};
plugin-rtp-nvim = {
url = "github:nvim-neorocks/rtp.nvim";
flake = false;
};
# LSP plugins # LSP plugins
plugin-nvim-lspconfig = { plugin-nvim-lspconfig = {
url = "github:neovim/nvim-lspconfig"; url = "github:neovim/nvim-lspconfig";
@ -223,16 +207,6 @@
flake = false; flake = false;
}; };
plugin-omnisharp-extended = {
url = "github:Hoffs/omnisharp-extended-lsp.nvim";
flake = false;
};
plugin-csharpls-extended = {
url = "github:Decodetalkers/csharpls-extended-lsp.nvim";
flake = false;
};
# Copying/Registers # Copying/Registers
plugin-registers = { plugin-registers = {
url = "github:tversteeg/registers.nvim"; url = "github:tversteeg/registers.nvim";

View file

@ -67,30 +67,6 @@
mkLuaBinding binding.value action binding.description; mkLuaBinding binding.value action binding.description;
pushDownDefault = attr: mapAttrs (_: mkDefault) attr; pushDownDefault = attr: mapAttrs (_: mkDefault) attr;
mkLznBinding = mode: key: action: desc: {
inherit mode desc key action;
};
mkLznExprBinding = mode: key: action: desc: {
inherit mode desc key action;
lua = true;
silent = true;
expr = true;
};
mkSetLznBinding = binding: action: {
inherit action;
key = binding.value;
desc = binding.description;
};
mkSetLuaLznBinding = binding: action: {
inherit action;
key = binding.value;
lua = true;
desc = binding.description;
};
}; };
in in
binds binds

View file

@ -84,7 +84,10 @@
# built (or "normalized") plugins that are modified # built (or "normalized") plugins that are modified
builtStartPlugins = buildConfigPlugins vimOptions.startPlugins; builtStartPlugins = buildConfigPlugins vimOptions.startPlugins;
builtOptPlugins = map (package: package // {optional = true;}) (buildConfigPlugins vimOptions.optPlugins); builtOptPlugins = map (package: {
plugin = package;
optional = true;
}) (buildConfigPlugins vimOptions.optPlugins);
# 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 mnw expects. end user should # to conform to the format mnw expects. end user should

View file

@ -50,7 +50,6 @@
"build" "build"
"rc" "rc"
"warnings" "warnings"
"lazy"
]; ];
# Extra modules, such as deprecation warnings # Extra modules, such as deprecation warnings

View file

@ -1,14 +1,11 @@
{ {
config, config,
pkgs,
lib, lib,
... ...
}: let }: let
inherit (lib.modules) mkIf mkRenamedOptionModule; inherit (lib.modules) mkIf mkRenamedOptionModule;
inherit (lib.options) mkOption mkEnableOption literalExpression; inherit (lib.options) mkOption mkEnableOption literalExpression;
inherit (lib.strings) concatLines; inherit (lib.types) listOf str;
inherit (lib.attrsets) mapAttrsToList;
inherit (lib.types) listOf str attrsOf;
inherit (lib.nvim.lua) listToLuaTable; inherit (lib.nvim.lua) listToLuaTable;
inherit (lib.nvim.dag) entryAfter; inherit (lib.nvim.dag) entryAfter;
@ -27,48 +24,10 @@ in {
description = '' description = ''
A list of languages that should be used for spellchecking. A list of languages that should be used for spellchecking.
To add your own language files, you may place your `spell` directory in either To add your own language files, you may place your `spell`
{file}`$XDG_CONFIG_HOME/nvf` or in a path that is included in the directory in either `~/.config/nvim` or the
[additionalRuntimePaths](#opt-vim.additionalRuntimePaths) list provided by nvf. [additionalRuntimePaths](#opt-vim.additionalRuntimePaths)
''; directory provided by **nvf**.
};
extraSpellWords = mkOption {
type = attrsOf (listOf str);
default = {};
example = literalExpression ''{"en.utf-8" = ["nvf" "word_you_want_to_add"];}'';
description = ''
Additional words to be used for spellchecking. The names of each key will be
used as the language code for the spell file. For example
```nix
"en.utf-8" = [ ... ];
```
will result in `en.utf-8.add.spl` being added to Neovim's runtime in the
{file}`spell` directory.
::: {.warning}
The attribute keys must be in `"<name>.<encoding>"` format for Neovim to
compile your spellfiles without mangling the resulting file names. Please
make sure that you enter the correct value, as nvf does not do any kind of
internal checking. Please see {command}`:help mkspell` for more details.
Example:
```nix
# "en" is the name, and "utf-8" is the encoding. For most use cases, utf-8
# will be enough, however, you may change it to any encoding format Neovim
# accepts, e.g., utf-16.
"en.utf-8" = ["nvf" "word_you_want_to_add"];
=> $out/spell/en-utf-8.add.spl
```
:::
Note that while adding a new language, you will still need to add the name of
the language (e.g. "en") to the {option}`vim.spellcheck.languages` list by name
in order to enable spellchecking for the language. By default only `"en"` is in
the list.
''; '';
}; };
@ -79,75 +38,38 @@ in {
description = '' description = ''
A list of filetypes for which spellchecking will be disabled. A list of filetypes for which spellchecking will be disabled.
::: {.tip} You may use `echo &filetype` in Neovim to find out the
You may use {command}`:echo &filetype` in Neovim to find out the
filetype for a specific buffer. filetype for a specific buffer.
:::
''; '';
}; };
/*
# FIXME: This needs to be revisited. It tries to install
# the spellfile to an user directory, but it cannot do so
# as we sanitize runtime paths.
programmingWordlist.enable = mkEnableOption '' programmingWordlist.enable = mkEnableOption ''
vim-dirtytalk, a wordlist for programmers containing vim-dirtytalk, a wordlist for programmers containing
common programming terms. common programming terms.
::: {.note} Setting this value as `true` has the same effect
Enabling this option will unconditionally set as setting {option}`vim.spellCheck.enable`
{option}`vim.spellcheck.enable` to true as vim-dirtytalk
depends on spellchecking having been set up.
:::
''; '';
*/
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim = { vim.luaConfigRC.spellcheck = entryAfter ["basic"] ''
additionalRuntimePaths = let vim.opt.spell = true
compileJoinedSpellfiles = vim.opt.spelllang = ${listToLuaTable cfg.languages}
pkgs.runCommandLocal "nvf-compile-spellfiles" {
# Use the same version of Neovim as the user's configuration
nativeBuildInputs = [config.vim.package];
spellfilesJoined = pkgs.symlinkJoin { -- Disable spellchecking for certain filetypes
name = "nvf-spellfiles-joined"; -- as configured by `vim.spellcheck.ignoredFiletypes`
paths = mapAttrsToList (name: value: pkgs.writeTextDir "spell/${name}.add" (concatLines value)) cfg.extraSpellWords; vim.api.nvim_create_autocmd({ "FileType" }, {
postBuild = "echo Spellfiles joined"; pattern = ${listToLuaTable cfg.ignoredFiletypes},
}; callback = function()
} '' vim.opt_local.spell = false
# Fail on unset variables and non-zero exit codes end,
# this might be the only way to trace when `nvim --headless` })
# fails in batch mode '';
set -eu
mkdir -p "$out/spell"
for spellfile in "$spellfilesJoined"/spell/*.add; do
name="$(basename "$spellfile" ".add")"
echo "Compiling spellfile: $spellfile"
nvim --headless --clean \
--cmd "mkspell $out/spell/$name.add.spl $spellfile" -Es -n
done
'';
in
mkIf (cfg.extraSpellWords != {}) [
# If .outPath is missing, additionalRuntimePaths receives the *function*
# instead of a path, causing errors.
compileJoinedSpellfiles.outPath
];
luaConfigRC.spellcheck = entryAfter ["basic"] ''
vim.opt.spell = true
vim.opt.spelllang = ${listToLuaTable cfg.languages}
-- Disable spellchecking for certain filetypes
-- as configured by `vim.spellcheck.ignoredFiletypes`
vim.api.nvim_create_augroup("nvf_autocmds", {clear = false})
vim.api.nvim_create_autocmd({ "FileType" }, {
group = "nvf_autocmds",
pattern = ${listToLuaTable cfg.ignoredFiletypes},
callback = function()
vim.opt_local.spell = false
end,
})
'';
};
}; };
} }

View file

@ -4,8 +4,11 @@
... ...
}: let }: let
inherit (builtins) toJSON; inherit (builtins) toJSON;
inherit (lib.modules) mkIf; inherit (lib.nvim.lua) toLuaObject;
inherit (lib.strings) optionalString; inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.lists) optionals;
inherit (lib.nvim.binds) mkLuaBinding;
cfg = config.vim.assistant.copilot; cfg = config.vim.assistant.copilot;
@ -20,68 +23,65 @@
end end
end end
''; '';
mkLuaKeymap = mode: key: action: desc: opts:
opts
// {
inherit mode key action desc;
lua = true;
};
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim = { vim.startPlugins =
lazy.plugins = { [
copilot-lua = { "copilot-lua"
package = "copilot-lua"; # cfg.copilotNodePackage
setupModule = "copilot"; ]
inherit (cfg) setupOpts; ++ optionals cfg.cmp.enable [
after = mkIf cfg.cmp.enable "require('copilot_cmp').setup()"; "copilot-cmp"
];
cmd = ["Copilot" "CopilotAuth" "CopilotDetach" "CopilotPanel" "CopilotStop"]; vim.autocomplete.nvim-cmp.sources = {copilot = "[Copilot]";};
keys = [
(mkLuaKeymap ["n"] cfg.mappings.panel.accept (wrapPanelBinding ''require("copilot.panel").accept'' cfg.mappings.panel.accept) "[copilot] Accept suggestion" {})
(mkLuaKeymap ["n"] cfg.mappings.panel.jumpNext (wrapPanelBinding "require(\"copilot.panel\").jump_next" cfg.mappings.panel.jumpNext) "[copilot] Accept suggestion" {})
(mkLuaKeymap ["n"] cfg.mappings.panel.jumpPrev (wrapPanelBinding "require(\"copilot.panel\").jump_prev" cfg.mappings.panel.jumpPrev) "[copilot] Accept suggestion" {})
(mkLuaKeymap ["n"] cfg.mappings.panel.refresh (wrapPanelBinding "require(\"copilot.panel\").refresh" cfg.mappings.panel.refresh) "[copilot] Accept suggestion" {})
(mkLuaKeymap ["n"] cfg.mappings.panel.open (wrapPanelBinding ''
function() require("copilot.panel").open({ position = "${cfg.setupOpts.panel.layout.position}", ratio = ${toString cfg.setupOpts.panel.layout.ratio}, }) end
''
cfg.mappings.panel.open) "[copilot] Accept suggestion" {})
(mkLuaKeymap ["i"] cfg.mappings.suggestion.accept "function() require('copilot.suggestion').accept() end" "[copilot] Accept suggestion" {}) vim.pluginRC.copilot = entryAnywhere ''
(mkLuaKeymap ["i"] cfg.mappings.suggestion.acceptLine "function() require('copilot.suggestion').accept_line() end" "[copilot] Accept suggestion (line)" {}) require("copilot").setup(${toLuaObject cfg.setupOpts})
(mkLuaKeymap ["i"] cfg.mappings.suggestion.acceptWord "function() require('copilot.suggestion').accept_word() end" "[copilot] Accept suggestion (word)" {})
(mkLuaKeymap ["i"] cfg.mappings.suggestion.dismiss "function() require('copilot.suggestion').dismiss() end" "[copilot] dismiss suggestion" {}) ${lib.optionalString cfg.cmp.enable ''
(mkLuaKeymap ["i"] cfg.mappings.suggestion.next "function() require('copilot.suggestion').next() end" "[copilot] next suggestion" {}) require("copilot_cmp").setup()
(mkLuaKeymap ["i"] cfg.mappings.suggestion.prev "function() require('copilot.suggestion').prev() end" "[copilot] previous suggestion" {}) ''}
]; '';
};
# Disable plugin handled keymaps.
# Setting it here so that it doesn't show up in user docs
vim.assistant.copilot.setupOpts = {
panel.keymap = {
jump_prev = lib.mkDefault false;
jump_next = lib.mkDefault false;
accept = lib.mkDefault false;
refresh = lib.mkDefault false;
open = lib.mkDefault false;
}; };
suggestion.keymap = {
autocomplete.nvim-cmp = { accept = lib.mkDefault false;
sources = {copilot = "[Copilot]";}; accept_word = lib.mkDefault false;
sourcePlugins = ["copilot-cmp"]; accept_line = lib.mkDefault false;
}; next = lib.mkDefault false;
prev = lib.mkDefault false;
# Disable plugin handled keymaps. dismiss = lib.mkDefault false;
# Setting it here so that it doesn't show up in user docs
assistant.copilot.setupOpts = {
panel.keymap = {
jump_prev = lib.mkDefault false;
jump_next = lib.mkDefault false;
accept = lib.mkDefault false;
refresh = lib.mkDefault false;
open = lib.mkDefault false;
};
suggestion.keymap = {
accept = lib.mkDefault false;
accept_word = lib.mkDefault false;
accept_line = lib.mkDefault false;
next = lib.mkDefault false;
prev = lib.mkDefault false;
dismiss = lib.mkDefault false;
};
}; };
}; };
vim.maps.normal = mkMerge [
(mkLuaBinding cfg.mappings.panel.jumpPrev (wrapPanelBinding "require(\"copilot.panel\").jump_prev" cfg.mappings.panel.jumpPrev) "[copilot] Accept suggestion")
(mkLuaBinding cfg.mappings.panel.jumpNext (wrapPanelBinding "require(\"copilot.panel\").jump_next" cfg.mappings.panel.jumpNext) "[copilot] Accept suggestion")
(mkLuaBinding cfg.mappings.panel.accept (wrapPanelBinding ''require("copilot.panel").accept'' cfg.mappings.panel.accept) "[copilot] Accept suggestion")
(mkLuaBinding cfg.mappings.panel.refresh (wrapPanelBinding "require(\"copilot.panel\").refresh" cfg.mappings.panel.refresh) "[copilot] Accept suggestion")
(mkLuaBinding cfg.mappings.panel.open (wrapPanelBinding ''
function() require("copilot.panel").open({ position = "${cfg.setupOpts.panel.layout.position}", ratio = ${toString cfg.setupOpts.panel.layout.ratio}, }) end
''
cfg.mappings.panel.open) "[copilot] Accept suggestion")
];
vim.maps.insert = mkMerge [
(mkLuaBinding cfg.mappings.suggestion.accept "require(\"copilot.suggestion\").accept" "[copilot] Accept suggestion")
(mkLuaBinding cfg.mappings.suggestion.acceptLine "require(\"copilot.suggestion\").accept_line" "[copilot] Accept suggestion (line)")
(mkLuaBinding cfg.mappings.suggestion.acceptWord "require(\"copilot.suggestion\").accept_word" "[copilot] Accept suggestion (word)")
(mkLuaBinding cfg.mappings.suggestion.next "require(\"copilot.suggestion\").next" "[copilot] next suggestion")
(mkLuaBinding cfg.mappings.suggestion.prev "require(\"copilot.suggestion\").prev" "[copilot] previous suggestion")
(mkLuaBinding cfg.mappings.suggestion.dismiss "require(\"copilot.suggestion\").dismiss" "[copilot] dismiss suggestion")
];
}; };
} }

View file

@ -1,7 +1,6 @@
{lib, ...}: let {lib, ...}: let
inherit (lib.options) mkEnableOption; inherit (lib.options) mkEnableOption;
inherit (lib.nvim.binds) mkMappingOption; inherit (lib.nvim.binds) mkMappingOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in { in {
options.vim.comments.comment-nvim = { options.vim.comments.comment-nvim = {
enable = mkEnableOption "smart and powerful comment plugin for neovim comment-nvim"; enable = mkEnableOption "smart and powerful comment plugin for neovim comment-nvim";
@ -16,12 +15,5 @@ in {
toggleSelectedLine = mkMappingOption "Toggle selected comment" "gc"; toggleSelectedLine = mkMappingOption "Toggle selected comment" "gc";
toggleSelectedBlock = mkMappingOption "Toggle selected block" "gb"; toggleSelectedBlock = mkMappingOption "Toggle selected block" "gb";
}; };
setupOpts = mkPluginSetupOption "Comment-nvim" {
mappings = {
basic = mkEnableOption "basic mappings";
extra = mkEnableOption "extra mappings";
};
};
}; };
} }

View file

@ -3,38 +3,46 @@
lib, lib,
... ...
}: let }: let
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.binds) mkLznExprBinding mkLznBinding; inherit (lib.nvim.binds) mkExprBinding mkBinding;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.comments.comment-nvim; cfg = config.vim.comments.comment-nvim;
self = import ./comment-nvim.nix {inherit lib;}; self = import ./comment-nvim.nix {inherit lib;};
inherit (self.options.vim.comments.comment-nvim) mappings; inherit (self.options.vim.comments.comment-nvim) mappings;
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim.lazy.plugins.comment-nvim = { vim.startPlugins = ["comment-nvim"];
package = "comment-nvim";
setupModule = "Comment"; vim.maps.normal = mkMerge [
inherit (cfg) setupOpts; (mkBinding cfg.mappings.toggleOpLeaderLine "<Plug>(comment_toggle_linewise)" mappings.toggleOpLeaderLine.description)
keys = [ (mkBinding cfg.mappings.toggleOpLeaderBlock "<Plug>(comment_toggle_blockwise)" mappings.toggleOpLeaderBlock.description)
(mkLznBinding ["n"] cfg.mappings.toggleOpLeaderLine "<Plug>(comment_toggle_linewise)" mappings.toggleOpLeaderLine.description)
(mkLznBinding ["n"] cfg.mappings.toggleOpLeaderBlock "<Plug>(comment_toggle_blockwise)" mappings.toggleOpLeaderBlock.description) (mkExprBinding cfg.mappings.toggleCurrentLine ''
(mkLznExprBinding ["n"] cfg.mappings.toggleCurrentLine '' function()
function() return vim.api.nvim_get_vvar('count') == 0 and '<Plug>(comment_toggle_linewise_current)'
return vim.api.nvim_get_vvar('count') == 0 and '<Plug>(comment_toggle_linewise_current)' or '<Plug>(comment_toggle_linewise_count)'
or '<Plug>(comment_toggle_linewise_count)' end
end ''
'' mappings.toggleCurrentLine.description)
mappings.toggleCurrentLine.description) (mkExprBinding cfg.mappings.toggleCurrentBlock ''
(mkLznExprBinding ["n"] cfg.mappings.toggleCurrentBlock '' function()
function() return vim.api.nvim_get_vvar('count') == 0 and '<Plug>(comment_toggle_blockwise_current)'
return vim.api.nvim_get_vvar('count') == 0 and '<Plug>(comment_toggle_blockwise_current)' or '<Plug>(comment_toggle_blockwise_count)'
or '<Plug>(comment_toggle_blockwise_count)' end
end ''
'' mappings.toggleCurrentBlock.description)
mappings.toggleCurrentBlock.description) ];
(mkLznBinding ["x"] cfg.mappings.toggleSelectedLine "<Plug>(comment_toggle_linewise_visual)" mappings.toggleSelectedLine.description)
(mkLznBinding ["x"] cfg.mappings.toggleSelectedBlock "<Plug>(comment_toggle_blockwise_visual)" mappings.toggleSelectedBlock.description) vim.maps.visual = mkMerge [
]; (mkBinding cfg.mappings.toggleSelectedLine "<Plug>(comment_toggle_linewise_visual)" mappings.toggleSelectedLine.description)
}; (mkBinding cfg.mappings.toggleSelectedBlock "<Plug>(comment_toggle_blockwise_visual)" mappings.toggleSelectedBlock.description)
];
vim.pluginRC.comment-nvim = entryAnywhere ''
require('Comment').setup({
mappings = { basic = false, extra = false, },
})
'';
}; };
} }

View file

@ -3,122 +3,91 @@
config, config,
... ...
}: let }: let
inherit (lib.modules) mkIf mkMerge; inherit (lib.modules) mkIf;
inherit (lib.strings) optionalString; inherit (lib.strings) optionalString;
inherit (lib.generators) mkLuaInline; inherit (lib.generators) mkLuaInline;
inherit (lib.nvim.dag) entryAfter;
inherit (lib.nvim.lua) toLuaObject; inherit (lib.nvim.lua) toLuaObject;
inherit (lib.nvim.attrsets) mapListToAttrs; inherit (builtins) attrNames;
inherit (builtins) attrNames typeOf tryEval concatStringsSep;
cfg = config.vim.autocomplete.nvim-cmp; cfg = config.vim.autocomplete.nvim-cmp;
luasnipEnable = config.vim.snippets.luasnip.enable; luasnipEnable = config.vim.snippets.luasnip.enable;
getPluginName = plugin:
if typeOf plugin == "string"
then plugin
else if (plugin ? pname && (tryEval plugin.pname).success)
then plugin.pname
else plugin.name;
inherit (cfg) mappings; inherit (cfg) mappings;
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim = { vim = {
startPlugins = ["rtp-nvim"]; startPlugins = [
lazy.plugins = mkMerge [ "nvim-cmp"
(mapListToAttrs (package: { "cmp-buffer"
name = getPluginName package; "cmp-path"
value = {
inherit package;
lazy = true;
after = ''
local path = vim.fn.globpath(vim.o.packpath, 'pack/*/opt/${getPluginName package}')
require("rtp_nvim").source_after_plugin_dir(path)
'';
};
})
cfg.sourcePlugins)
{
nvim-cmp = {
package = "nvim-cmp";
after = ''
${optionalString luasnipEnable "local luasnip = require('luasnip')"}
local cmp = require("cmp")
cmp.setup(${toLuaObject cfg.setupOpts})
${optionalString config.vim.lazy.enable
(concatStringsSep "\n" (map
(package: "require('lz.n').trigger_load(${toLuaObject (getPluginName package)})")
cfg.sourcePlugins))}
'';
event = ["InsertEnter" "CmdlineEnter"];
};
}
]; ];
autocomplete.nvim-cmp = { autocomplete.nvim-cmp.sources = {
sources = { nvim-cmp = null;
nvim-cmp = null; buffer = "[Buffer]";
buffer = "[Buffer]"; path = "[Path]";
path = "[Path]"; };
autocomplete.nvim-cmp.setupOpts = {
sources = map (s: {name = s;}) (attrNames cfg.sources);
# TODO: try to get nvim-cmp to follow global border style
window = mkIf config.vim.ui.borders.enable {
completion = mkLuaInline "cmp.config.window.bordered()";
documentation = mkLuaInline "cmp.config.window.bordered()";
}; };
sourcePlugins = ["cmp-buffer" "cmp-path"]; formatting.format = cfg.format;
};
setupOpts = { pluginRC.nvim-cmp = mkIf cfg.enable (entryAfter ["autopairs" "luasnip"] ''
sources = map (s: {name = s;}) (attrNames cfg.sources); ${optionalString luasnipEnable "local luasnip = require('luasnip')"}
local cmp = require("cmp")
cmp.setup(${toLuaObject cfg.setupOpts})
'');
# TODO: try to get nvim-cmp to follow global border style # `cmp` and `luasnip` are defined above, in the `nvim-cmp` section
window = mkIf config.vim.ui.borders.enable { autocomplete.nvim-cmp.setupOpts.mapping = {
completion = mkLuaInline "cmp.config.window.bordered()"; ${mappings.complete} = mkLuaInline "cmp.mapping.complete()";
documentation = mkLuaInline "cmp.config.window.bordered()"; ${mappings.close} = mkLuaInline "cmp.mapping.abort()";
}; ${mappings.scrollDocsUp} = mkLuaInline "cmp.mapping.scroll_docs(-4)";
${mappings.scrollDocsDown} = mkLuaInline "cmp.mapping.scroll_docs(4)";
${mappings.confirm} = mkLuaInline "cmp.mapping.confirm({ select = true })";
formatting.format = cfg.format; ${mappings.next} = mkLuaInline ''
cmp.mapping(function(fallback)
local has_words_before = function()
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end
# `cmp` and `luasnip` are defined above, in the `nvim-cmp` section if cmp.visible() then
mapping = { cmp.select_next_item()
${mappings.complete} = mkLuaInline "cmp.mapping.complete()"; ${optionalString luasnipEnable ''
${mappings.close} = mkLuaInline "cmp.mapping.abort()"; elseif luasnip.locally_jumpable(1) then
${mappings.scrollDocsUp} = mkLuaInline "cmp.mapping.scroll_docs(-4)"; luasnip.jump(1)
${mappings.scrollDocsDown} = mkLuaInline "cmp.mapping.scroll_docs(4)"; ''}
${mappings.confirm} = mkLuaInline "cmp.mapping.confirm({ select = true })"; elseif has_words_before() then
cmp.complete()
else
fallback()
end
end)
'';
${mappings.next} = mkLuaInline '' ${mappings.previous} = mkLuaInline ''
cmp.mapping(function(fallback) cmp.mapping(function(fallback)
local has_words_before = function() if cmp.visible() then
local line, col = unpack(vim.api.nvim_win_get_cursor(0)) cmp.select_prev_item()
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil ${optionalString luasnipEnable ''
end elseif luasnip.locally_jumpable(-1) then
luasnip.jump(-1)
if cmp.visible() then ''}
cmp.select_next_item() else
${optionalString luasnipEnable '' fallback()
elseif luasnip.locally_jumpable(1) then end
luasnip.jump(1) end)
''} '';
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end)
'';
${mappings.previous} = mkLuaInline ''
cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
${optionalString luasnipEnable ''
elseif luasnip.locally_jumpable(-1) then
luasnip.jump(-1)
''}
else
fallback()
end
end)
'';
};
};
}; };
}; };
}; };

View file

@ -4,10 +4,10 @@
... ...
}: let }: let
inherit (lib.options) mkEnableOption mkOption literalExpression literalMD; inherit (lib.options) mkEnableOption mkOption literalExpression literalMD;
inherit (lib.types) str attrsOf nullOr either listOf; inherit (lib.types) str attrsOf nullOr either;
inherit (lib.generators) mkLuaInline; inherit (lib.generators) mkLuaInline;
inherit (lib.nvim.binds) mkMappingOption; inherit (lib.nvim.binds) mkMappingOption;
inherit (lib.nvim.types) mkPluginSetupOption luaInline mergelessListOf pluginType; inherit (lib.nvim.types) mkPluginSetupOption luaInline mergelessListOf;
inherit (lib.nvim.lua) toLuaObject; inherit (lib.nvim.lua) toLuaObject;
inherit (builtins) isString; inherit (builtins) isString;
@ -99,11 +99,5 @@ in {
} }
''; '';
}; };
sourcePlugins = mkOption {
type = listOf pluginType;
default = [];
description = "List of source plugins used by nvim-cmp.";
};
}; };
} }

View file

@ -6,7 +6,7 @@
inherit (lib.strings) optionalString; inherit (lib.strings) optionalString;
inherit (lib.modules) mkIf mkMerge; inherit (lib.modules) mkIf mkMerge;
inherit (lib.attrsets) mapAttrs; inherit (lib.attrsets) mapAttrs;
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetLuaBinding mkSetLuaLznBinding; inherit (lib.nvim.binds) addDescriptionsToMappings mkSetLuaBinding;
inherit (lib.nvim.dag) entryAnywhere entryAfter; inherit (lib.nvim.dag) entryAnywhere entryAfter;
cfg = config.vim.debugger.nvim-dap; cfg = config.vim.debugger.nvim-dap;
@ -52,31 +52,24 @@ in {
}) })
(mkIf (cfg.enable && cfg.ui.enable) { (mkIf (cfg.enable && cfg.ui.enable) {
vim = { vim = {
startPlugins = ["nvim-nio"]; startPlugins = ["nvim-dap-ui" "nvim-nio"];
lazy.plugins.nvim-dap-ui = { pluginRC.nvim-dap-ui = entryAfter ["nvim-dap"] (''
package = "nvim-dap-ui"; local dapui = require("dapui")
setupModule = "dapui"; dapui.setup()
inherit (cfg.ui) setupOpts; ''
+ optionalString cfg.ui.autoStart ''
keys = [
(mkSetLuaLznBinding mappings.toggleDapUI "function() require('dapui').toggle() end")
];
};
pluginRC.nvim-dap-ui = entryAfter ["nvim-dap"] (
optionalString cfg.ui.autoStart ''
dap.listeners.after.event_initialized["dapui_config"] = function() dap.listeners.after.event_initialized["dapui_config"] = function()
require("dapui").open() dapui.open()
end end
dap.listeners.before.event_terminated["dapui_config"] = function() dap.listeners.before.event_terminated["dapui_config"] = function()
require("dapui").close() dapui.close()
end end
dap.listeners.before.event_exited["dapui_config"] = function() dap.listeners.before.event_exited["dapui_config"] = function()
require("dapui").close() dapui.close()
end end
'' '');
); maps.normal = mkSetLuaBinding mappings.toggleDapUI "require('dapui').toggle";
}; };
}) })
]; ];

View file

@ -2,16 +2,12 @@
inherit (lib.options) mkEnableOption mkOption; inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) bool attrsOf str; inherit (lib.types) bool attrsOf str;
inherit (lib.nvim.binds) mkMappingOption; inherit (lib.nvim.binds) mkMappingOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in { in {
options.vim.debugger.nvim-dap = { options.vim.debugger.nvim-dap = {
enable = mkEnableOption "debugging via nvim-dap"; enable = mkEnableOption "debugging via nvim-dap";
ui = { ui = {
enable = mkEnableOption "UI extension for nvim-dap"; enable = mkEnableOption "UI extension for nvim-dap";
setupOpts = mkPluginSetupOption "nvim-dap-ui" {};
autoStart = mkOption { autoStart = mkOption {
type = bool; type = bool;
default = true; default = true;

View file

@ -4,6 +4,8 @@
... ...
}: let }: let
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.filetree.neo-tree; cfg = config.vim.filetree.neo-tree;
in { in {
@ -14,17 +16,15 @@ in {
"plenary-nvim" # commons library "plenary-nvim" # commons library
"image-nvim" # optional for image previews "image-nvim" # optional for image previews
"nui-nvim" # ui library "nui-nvim" # ui library
# neotree
"neo-tree-nvim"
]; ];
lazy.plugins.neo-tree-nvim = {
package = "neo-tree-nvim";
setupModule = "neo-tree";
inherit (cfg) setupOpts;
cmd = ["Neotree"];
};
visuals.nvimWebDevicons.enable = true; visuals.nvimWebDevicons.enable = true;
pluginRC.neo-tree = entryAnywhere ''
require("neo-tree").setup(${toLuaObject cfg.setupOpts})
'';
}; };
}; };
} }

View file

@ -5,9 +5,10 @@
... ...
}: let }: let
inherit (lib.strings) optionalString; inherit (lib.strings) optionalString;
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.binds) mkLznBinding; inherit (lib.nvim.binds) mkBinding;
inherit (lib.nvim.dag) entryAnywhere; inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
inherit (lib.nvim.binds) pushDownDefault; inherit (lib.nvim.binds) pushDownDefault;
cfg = config.vim.filetree.nvimTree; cfg = config.vim.filetree.nvimTree;
@ -15,74 +16,69 @@
inherit (self.options.vim.filetree.nvimTree) mappings; inherit (self.options.vim.filetree.nvimTree) mappings;
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim = { vim.startPlugins = ["nvim-tree-lua"];
binds.whichKey.register = pushDownDefault {
"<leader>t" = "+NvimTree";
};
lazy.plugins.nvim-tree-lua = { vim.maps.normal = mkMerge [
package = "nvim-tree-lua"; (mkBinding cfg.mappings.toggle ":NvimTreeToggle<cr>" mappings.toggle.description)
setupModule = "nvim-tree"; (mkBinding cfg.mappings.refresh ":NvimTreeRefresh<cr>" mappings.refresh.description)
inherit (cfg) setupOpts; (mkBinding cfg.mappings.findFile ":NvimTreeFindFile<cr>" mappings.findFile.description)
cmd = ["NvimTreeClipboard" "NvimTreeClose" "NvimTreeCollapse" "NvimTreeCollapseKeepBuffers" "NvimTreeFindFile" "NvimTreeFindFileToggle" "NvimTreeFocus" "NvimTreeHiTest" "NvimTreeOpen" "NvimTreeRefresh" "NvimTreeResize" "NvimTreeToggle"]; (mkBinding cfg.mappings.focus ":NvimTreeFocus<cr>" mappings.focus.description)
keys = [ ];
(mkLznBinding ["n"] cfg.mappings.toggle ":NvimTreeToggle<cr>" mappings.toggle.description)
(mkLznBinding ["n"] cfg.mappings.refresh ":NvimTreeRefresh<cr>" mappings.refresh.description)
(mkLznBinding ["n"] cfg.mappings.findFile ":NvimTreeFindFile<cr>" mappings.findFile.description)
(mkLznBinding ["n"] cfg.mappings.focus ":NvimTreeFocus<cr>" mappings.focus.description)
];
};
pluginRC.nvimtreelua = entryAnywhere '' vim.binds.whichKey.register = pushDownDefault {
${ "<leader>t" = "+NvimTree";
optionalString cfg.setupOpts.disable_netrw '' };
-- disable netrew completely
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
''
}
${ vim.pluginRC.nvimtreelua = entryAnywhere ''
optionalString cfg.openOnSetup '' ${
${optionalString config.vim.lazy.enable ''require('lz.n').trigger_load("nvim-tree-lua")''} optionalString cfg.setupOpts.disable_netrw ''
-- autostart behaviour -- disable netrew completely
-- Open on startup has been deprecated vim.g.loaded_netrw = 1
-- see https://github.com/nvim-tree/nvim-tree.lua/wiki/Open-At-Startup vim.g.loaded_netrwPlugin = 1
''
}
-- use a nix eval to dynamically insert the open on startup function require'nvim-tree'.setup(${toLuaObject cfg.setupOpts})
local function open_nvim_tree(data)
local IGNORED_FT = {
"markdown",
}
-- buffer is a real file on the disk ${
local real_file = vim.fn.filereadable(data.file) == 1 optionalString cfg.openOnSetup ''
-- autostart behaviour
-- Open on startup has been deprecated
-- see https://github.com/nvim-tree/nvim-tree.lua/wiki/Open-At-Startup
-- buffer is a [No Name] -- use a nix eval to dynamically insert the open on startup function
local no_name = data.file == "" and vim.bo[data.buf].buftype == "" local function open_nvim_tree(data)
local IGNORED_FT = {
"markdown",
}
-- &ft -- buffer is a real file on the disk
local filetype = vim.bo[data.buf].ft local real_file = vim.fn.filereadable(data.file) == 1
-- only files please -- buffer is a [No Name]
if not real_file and not no_name then local no_name = data.file == "" and vim.bo[data.buf].buftype == ""
return
end
-- skip ignored filetypes -- &ft
if vim.tbl_contains(IGNORED_FT, filetype) then local filetype = vim.bo[data.buf].ft
return
end
-- open the tree but don't focus it -- only files please
require("nvim-tree.api").tree.toggle({ focus = false }) if not real_file and not no_name then
return
end end
-- function to automatically open the tree on VimEnter -- skip ignored filetypes
vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree }) if vim.tbl_contains(IGNORED_FT, filetype) then
'' return
} end
'';
}; -- open the tree but don't focus it
require("nvim-tree.api").tree.toggle({ focus = false })
end
-- function to automatically open the tree on VimEnter
vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree })
''
}
'';
}; };
} }

View file

@ -1,122 +0,0 @@
{
lib,
pkgs,
config,
options,
...
}: let
inherit (builtins) attrNames;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) either listOf package str enum;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) isList;
inherit (lib.strings) optionalString;
inherit (lib.nvim.types) mkGrammarOption;
inherit (lib.nvim.lua) expToLua;
lspKeyConfig = config.vim.lsp.mappings;
lspKeyOptions = options.vim.lsp.mappings;
mkLspBinding = optionName: action: let
key = lspKeyConfig.${optionName};
desc = lspKeyOptions.${optionName}.description;
in
optionalString (key != null) "vim.keymap.set('n', '${key}', ${action}, {buffer=bufnr, noremap=true, silent=true, desc='${desc}'})";
# Omnisharp doesn't have colors in popup docs for some reason, and I've also
# seen mentions of it being way slower, so until someone finds missing
# functionality, this will be the default.
defaultServer = "csharp_ls";
servers = {
omnisharp = {
package = pkgs.omnisharp-roslyn;
internalFormatter = true;
lspConfig = ''
lspconfig.omnisharp.setup {
capabilities = capabilities,
on_attach = function(client, bufnr)
default_on_attach(client, bufnr)
local oe = require("omnisharp_extended")
${mkLspBinding "goToDefinition" "oe.lsp_definition"}
${mkLspBinding "goToType" "oe.lsp_type_definition"}
${mkLspBinding "listReferences" "oe.lsp_references"}
${mkLspBinding "listImplementations" "oe.lsp_implementation"}
end,
cmd = ${
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else "{'${cfg.lsp.package}/bin/OmniSharp'}"
}
}
'';
};
csharp_ls = {
package = pkgs.csharp-ls;
internalFormatter = true;
lspConfig = ''
local extended_handler = require("csharpls_extended").handler
lspconfig.csharp_ls.setup {
capabilities = capabilities,
on_attach = default_on_attach,
handlers = {
["textDocument/definition"] = extended_handler,
["textDocument/typeDefinition"] = extended_handler
},
cmd = ${
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else "{'${cfg.lsp.package}/bin/csharp-ls'}"
}
}
'';
};
};
extraServerPlugins = {
omnisharp = ["omnisharp-extended"];
csharp_ls = ["csharpls-extended"];
};
cfg = config.vim.languages.csharp;
in {
options = {
vim.languages.csharp = {
enable = mkEnableOption "C# language support";
treesitter = {
enable = mkEnableOption "C# treesitter" // {default = config.vim.languages.enableTreesitter;};
package = mkGrammarOption pkgs "c-sharp";
};
lsp = {
enable = mkEnableOption "C# LSP support" // {default = config.vim.languages.enableLSP;};
server = mkOption {
description = "C# LSP server to use";
type = enum (attrNames servers);
default = defaultServer;
};
package = mkOption {
description = "C# LSP server package, or the command to run as a list of strings";
type = either package (listOf str);
default = servers.${cfg.lsp.server}.package;
};
};
};
};
config = mkIf cfg.enable (mkMerge [
(mkIf cfg.treesitter.enable {
vim.treesitter.enable = true;
vim.treesitter.grammars = [cfg.treesitter.package];
})
(mkIf cfg.lsp.enable {
vim.startPlugins = extraServerPlugins.${cfg.lsp.server} or [];
vim.lsp.lspconfig.enable = true;
vim.lsp.lspconfig.sources.csharp-lsp = servers.${cfg.lsp.server}.lspConfig;
})
]);
}

View file

@ -63,18 +63,6 @@
) )
''; '';
}; };
biome = {
package = pkgs.biome;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.biome.with({
command = "${cfg.format.package}/bin/biome",
})
)
'';
};
}; };
in { in {
options.vim.languages.css = { options.vim.languages.css = {

View file

@ -14,7 +14,6 @@ in {
./lua.nix ./lua.nix
./markdown.nix ./markdown.nix
./nim.nix ./nim.nix
./vala.nix
./nix.nix ./nix.nix
./ocaml.nix ./ocaml.nix
./php.nix ./php.nix
@ -29,8 +28,6 @@ in {
./ts.nix ./ts.nix
./typst.nix ./typst.nix
./zig.nix ./zig.nix
./csharp.nix
./julia.nix
]; ];
options.vim.languages = { options.vim.languages = {

View file

@ -1,126 +0,0 @@
{
lib,
pkgs,
config,
...
}: let
inherit (builtins) attrNames isList;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) either listOf package str enum bool nullOr;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.strings) optionalString;
inherit (lib.nvim.types) mkGrammarOption;
inherit (lib.nvim.lua) expToLua;
defaultServer = "julials";
servers = {
julials = {
package = pkgs.julia.withPackages ["LanguageServer"];
internalFormatter = true;
lspConfig = ''
lspconfig.julials.setup {
capabilities = capabilities,
on_attach = default_on_attach,
cmd = ${
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''
{
"${optionalString (cfg.lsp.package != null) "${cfg.lsp.package}/bin/"}julia",
"--startup-file=no",
"--history-file=no",
"--eval",
[[
using LanguageServer
depot_path = get(ENV, "JULIA_DEPOT_PATH", "")
project_path = let
dirname(something(
## 1. Finds an explicitly set project (JULIA_PROJECT)
Base.load_path_expand((
p = get(ENV, "JULIA_PROJECT", nothing);
p === nothing ? nothing : isempty(p) ? nothing : p
)),
## 2. Look for a Project.toml file in the current working directory,
## or parent directories, with $HOME as an upper boundary
Base.current_project(),
## 3. First entry in the load path
get(Base.load_path(), 1, nothing),
## 4. Fallback to default global environment,
## this is more or less unreachable
Base.load_path_expand("@v#.#"),
))
end
@info "Running language server" VERSION pwd() project_path depot_path
server = LanguageServer.LanguageServerInstance(stdin, stdout, project_path, depot_path)
server.runlinter = true
run(server)
]]
}
''
}
}
'';
};
};
cfg = config.vim.languages.julia;
in {
options = {
vim.languages.julia = {
enable = mkEnableOption "Julia language support";
treesitter = {
enable = mkEnableOption "Julia treesitter" // {default = config.vim.languages.enableTreesitter;};
package = mkGrammarOption pkgs "julia";
};
lsp = {
enable = mkOption {
type = bool;
default = config.vim.languages.enableLSP;
description = ''
Whether to enable Julia LSP support.
::: {.note}
The entirety of Julia is bundled with nvf, if you enable this
option, since there is no way to provide only the LSP server.
If you want to avoid that, you have to change
[](#opt-vim.languages.julia.lsp.package) to use the Julia binary
in {env}`PATH` (set it to `null`), and add the `LanguageServer` package to
Julia in your devshells.
:::
'';
};
server = mkOption {
type = enum (attrNames servers);
default = defaultServer;
description = "Julia LSP server to use";
};
package = mkOption {
description = ''
Julia LSP server package, `null` to use the Julia binary in {env}`PATH`, or
the command to run as a list of strings.
'';
type = nullOr (either package (listOf str));
default = servers.${cfg.lsp.server}.package;
};
};
};
};
config = mkIf cfg.enable (mkMerge [
(mkIf cfg.treesitter.enable {
vim.treesitter.enable = true;
vim.treesitter.grammars = [cfg.treesitter.package];
})
(mkIf cfg.lsp.enable {
vim.lsp.lspconfig.enable = true;
vim.lsp.lspconfig.sources.julia-lsp = servers.${cfg.lsp.server}.lspConfig;
})
]);
}

View file

@ -8,7 +8,7 @@
inherit (lib.modules) mkIf mkMerge; inherit (lib.modules) mkIf mkMerge;
inherit (lib.meta) getExe; inherit (lib.meta) getExe;
inherit (lib.nvim.languages) diagnosticsToLua; inherit (lib.nvim.languages) diagnosticsToLua;
inherit (lib.types) either package listOf str; inherit (lib.types) package;
inherit (lib.nvim.types) mkGrammarOption diagnostics; inherit (lib.nvim.types) mkGrammarOption diagnostics;
inherit (lib.lists) isList; inherit (lib.lists) isList;
inherit (lib.nvim.lua) expToLua; inherit (lib.nvim.lua) expToLua;
@ -43,17 +43,17 @@ in {
package = mkOption { package = mkOption {
description = "kotlin_language_server package with Kotlin runtime"; description = "kotlin_language_server package with Kotlin runtime";
type = either package (listOf str); type = package;
example = literalExpression '' example = literalExpression ''
pkgs.symlinkJoin { pkgs.symlinkJoin {
name = "kotlin-language-server-wrapped"; name = "kotlin-language-server-wrapped";
paths = [pkgs.kotlin-language-server]; paths = [pkgs.kotlin-language-server];
nativeBuildInputs = [pkgs.makeBinaryWrapper]; nativeBuildInputs = [pkgs.makeWrapper];
postBuild = ''' postBuild = '''
wrapProgram $out/bin/kotlin-language-server \ wrapProgram $out/bin/kotlin-language-server \
--prefix PATH : ''${pkgs.kotlin}/bin --prefix PATH : ''${pkgs.kotlin}/bin
'''; ''';
}; };
''; '';
default = pkgs.kotlin-language-server; default = pkgs.kotlin-language-server;
}; };

View file

@ -5,7 +5,6 @@
... ...
}: let }: let
inherit (builtins) attrNames; inherit (builtins) attrNames;
inherit (lib) concatStringsSep;
inherit (lib.options) mkEnableOption mkOption; inherit (lib.options) mkEnableOption mkOption;
inherit (lib.modules) mkIf mkMerge; inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) isList; inherit (lib.lists) isList;
@ -63,10 +62,10 @@
command = {"${cfg.format.package}/bin/alejandra", "--quiet"}, command = {"${cfg.format.package}/bin/alejandra", "--quiet"},
}, },
''} ''}
${optionalString (cfg.format.type == "nixfmt") ${optionalString (cfg.format.type == "nixpkgs-fmt")
'' ''
formatting = { formatting = {
command = {"${cfg.format.package}/bin/nixfmt"}, command = {"${cfg.format.package}/bin/nixpkgs-fmt"},
}, },
''} ''}
}, },
@ -91,19 +90,10 @@
''; '';
}; };
nixfmt = { nixpkgs-fmt = {
package = pkgs.nixfmt-rfc-style; package = pkgs.nixpkgs-fmt;
nullConfig = '' # Never need to use null-ls for nixpkgs-fmt
table.insert(
ls_sources,
null_ls.builtins.formatting.nixfmt.with({
command = "${cfg.format.package}/bin/nixfmt"
})
)
'';
}; };
nixpkgs-fmt = null; # removed
}; };
defaultDiagnosticsProvider = ["statix" "deadnix"]; defaultDiagnosticsProvider = ["statix" "deadnix"];
@ -145,7 +135,7 @@ in {
enable = mkEnableOption "Nix LSP support" // {default = config.vim.languages.enableLSP;}; enable = mkEnableOption "Nix LSP support" // {default = config.vim.languages.enableLSP;};
server = mkOption { server = mkOption {
description = "Nix LSP server to use"; description = "Nix LSP server to use";
type = enum (attrNames servers); type = str;
default = defaultServer; default = defaultServer;
}; };
@ -185,12 +175,6 @@ in {
config = mkIf cfg.enable (mkMerge [ config = mkIf cfg.enable (mkMerge [
{ {
assertions = [
{
assertion = cfg.format.type != "nixpkgs-fmt";
message = "nixpkgs-fmt has been archived upstream. Please use one of the following instead: ${concatStringsSep ", " (attrNames formats)}";
}
];
vim.pluginRC.nix = '' vim.pluginRC.nix = ''
vim.api.nvim_create_autocmd("FileType", { vim.api.nvim_create_autocmd("FileType", {
pattern = "nix", pattern = "nix",

View file

@ -48,18 +48,6 @@
) )
''; '';
}; };
biome = {
package = pkgs.biome;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.biome.with({
command = "${cfg.format.package}/bin/biome",
})
)
'';
};
}; };
# TODO: specify packages # TODO: specify packages

View file

@ -95,18 +95,6 @@
) )
''; '';
}; };
biome = {
package = pkgs.biome;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.biome.with({
command = "${cfg.format.package}/bin/biome",
})
)
'';
};
}; };
# TODO: specify packages # TODO: specify packages

View file

@ -1,79 +0,0 @@
{
config,
pkgs,
lib,
...
}: let
inherit (builtins) attrNames;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) isList;
inherit (lib.types) enum either listOf package str;
inherit (lib.nvim.types) mkGrammarOption;
inherit (lib.nvim.lua) expToLua;
cfg = config.vim.languages.vala;
defaultServer = "vala_ls";
servers = {
vala_ls = {
package = pkgs.symlinkJoin {
name = "vala-language-server-wrapper";
paths = [pkgs.vala-language-server];
buildInputs = [pkgs.makeBinaryWrapper];
postBuild = ''
wrapProgram $out/bin/vala-language-server \
--prefix PATH : ${pkgs.uncrustify}/bin
'';
};
internalFormatter = true;
lspConfig = ''
lspconfig.vala_ls.setup {
capabilities = capabilities;
on_attach = default_on_attach;
cmd = ${
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/vala-language-server"}''
},
}
'';
};
};
in {
options.vim.languages.vala = {
enable = mkEnableOption "Vala language support";
treesitter = {
enable = mkEnableOption "Vala treesitter" // {default = config.vim.languages.enableTreesitter;};
package = mkGrammarOption pkgs "vala";
};
lsp = {
enable = mkEnableOption "Vala LSP support" // {default = config.vim.languages.enableLSP;};
server = mkOption {
description = "Vala LSP server to use";
type = enum (attrNames servers);
default = defaultServer;
};
package = mkOption {
description = "Vala LSP server package, or the command to run as a list of strings";
type = either package (listOf str);
default = servers.${cfg.lsp.server}.package;
};
};
};
config = mkIf cfg.enable (mkMerge [
(mkIf cfg.treesitter.enable {
vim.treesitter.enable = true;
vim.treesitter.grammars = [cfg.treesitter.package];
})
(mkIf cfg.lsp.enable {
vim.lsp.lspconfig.enable = true;
vim.lsp.lspconfig.sources.vala_ls = servers.${cfg.lsp.server}.lspConfig;
})
]);
}

View file

@ -5,6 +5,7 @@
... ...
}: let }: let
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf;
inherit (lib.lists) optional;
inherit (lib.strings) optionalString; inherit (lib.strings) optionalString;
inherit (lib.trivial) boolToString; inherit (lib.trivial) boolToString;
inherit (lib.nvim.binds) addDescriptionsToMappings; inherit (lib.nvim.binds) addDescriptionsToMappings;
@ -17,40 +18,39 @@
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions; mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
mkBinding = binding: action: mkBinding = binding: action:
if binding.value != null if binding.value != null
then "vim.keymap.set('n', '${binding.value}', ${action}, {buffer=bufnr, noremap=true, silent=true, desc='${binding.description}'})" then "vim.api.nvim_buf_set_keymap(bufnr, 'n', '${binding.value}', '<cmd>lua ${action}<CR>', {noremap=true, silent=true, desc='${binding.description}'})"
else ""; else "";
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim = { vim = {
autocomplete.nvim-cmp = { startPlugins = optional usingNvimCmp "cmp-nvim-lsp";
sources = {nvim_lsp = "[LSP]";};
sourcePlugins = ["cmp-nvim-lsp"]; autocomplete.nvim-cmp.sources = {nvim_lsp = "[LSP]";};
};
pluginRC.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)
${mkBinding mappings.goToDeclaration "vim.lsp.buf.declaration"} ${mkBinding mappings.goToDeclaration "vim.lsp.buf.declaration()"}
${mkBinding mappings.goToDefinition "vim.lsp.buf.definition"} ${mkBinding mappings.goToDefinition "vim.lsp.buf.definition()"}
${mkBinding mappings.goToType "vim.lsp.buf.type_definition"} ${mkBinding mappings.goToType "vim.lsp.buf.type_definition()"}
${mkBinding mappings.listImplementations "vim.lsp.buf.implementation"} ${mkBinding mappings.listImplementations "vim.lsp.buf.implementation()"}
${mkBinding mappings.listReferences "vim.lsp.buf.references"} ${mkBinding mappings.listReferences "vim.lsp.buf.references()"}
${mkBinding mappings.nextDiagnostic "vim.diagnostic.goto_next"} ${mkBinding mappings.nextDiagnostic "vim.diagnostic.goto_next()"}
${mkBinding mappings.previousDiagnostic "vim.diagnostic.goto_prev"} ${mkBinding mappings.previousDiagnostic "vim.diagnostic.goto_prev()"}
${mkBinding mappings.openDiagnosticFloat "vim.diagnostic.open_float"} ${mkBinding mappings.openDiagnosticFloat "vim.diagnostic.open_float()"}
${mkBinding mappings.documentHighlight "vim.lsp.buf.document_highlight"} ${mkBinding mappings.documentHighlight "vim.lsp.buf.document_highlight()"}
${mkBinding mappings.listDocumentSymbols "vim.lsp.buf.document_symbol"} ${mkBinding mappings.listDocumentSymbols "vim.lsp.buf.document_symbol()"}
${mkBinding mappings.addWorkspaceFolder "vim.lsp.buf.add_workspace_folder"} ${mkBinding mappings.addWorkspaceFolder "vim.lsp.buf.add_workspace_folder()"}
${mkBinding mappings.removeWorkspaceFolder "vim.lsp.buf.remove_workspace_folder"} ${mkBinding mappings.removeWorkspaceFolder "vim.lsp.buf.remove_workspace_folder()"}
${mkBinding mappings.listWorkspaceFolders "function() vim.notify(vim.inspect(vim.lsp.buf.list_workspace_folders())) end"} ${mkBinding mappings.listWorkspaceFolders "print(vim.inspect(vim.lsp.buf.list_workspace_folders()))"}
${mkBinding mappings.listWorkspaceSymbols "vim.lsp.buf.workspace_symbol"} ${mkBinding mappings.listWorkspaceSymbols "vim.lsp.buf.workspace_symbol()"}
${mkBinding mappings.hover "vim.lsp.buf.hover"} ${mkBinding mappings.hover "vim.lsp.buf.hover()"}
${mkBinding mappings.signatureHelp "vim.lsp.buf.signature_help"} ${mkBinding mappings.signatureHelp "vim.lsp.buf.signature_help()"}
${mkBinding mappings.renameSymbol "vim.lsp.buf.rename"} ${mkBinding mappings.renameSymbol "vim.lsp.buf.rename()"}
${mkBinding mappings.codeAction "vim.lsp.buf.code_action"} ${mkBinding mappings.codeAction "vim.lsp.buf.code_action()"}
${mkBinding mappings.format "vim.lsp.buf.format"} ${mkBinding mappings.format "vim.lsp.buf.format()"}
${mkBinding mappings.toggleFormatOnSave "function() vim.b.disableFormatSave = not vim.b.disableFormatSave end"} ${mkBinding mappings.toggleFormatOnSave "vim.b.disableFormatSave = not vim.b.disableFormatSave"}
end end
-- Enable formatting -- Enable formatting
@ -116,60 +116,7 @@ in {
end end
local capabilities = vim.lsp.protocol.make_client_capabilities() local capabilities = vim.lsp.protocol.make_client_capabilities()
${optionalString usingNvimCmp '' ${optionalString usingNvimCmp "capabilities = require('cmp_nvim_lsp').default_capabilities()"}
-- HACK: copied from cmp-nvim-lsp. If we ever lazy load lspconfig we
-- should re-evaluate whether we can just use `default_capabilities`
capabilities = {
textDocument = {
completion = {
dynamicRegistration = false,
completionItem = {
snippetSupport = true,
commitCharactersSupport = true,
deprecatedSupport = true,
preselectSupport = true,
tagSupport = {
valueSet = {
1, -- Deprecated
}
},
insertReplaceSupport = true,
resolveSupport = {
properties = {
"documentation",
"detail",
"additionalTextEdits",
"sortText",
"filterText",
"insertText",
"textEdit",
"insertTextFormat",
"insertTextMode",
},
},
insertTextModeSupport = {
valueSet = {
1, -- asIs
2, -- adjustIndentation
}
},
labelDetailsSupport = true,
},
contextSupport = true,
insertTextMode = 1,
completionList = {
itemDefaults = {
'commitCharacters',
'editRange',
'insertTextFormat',
'insertTextMode',
'data',
}
}
},
},
}
''}
''; '';
}; };
}; };

View file

@ -32,7 +32,7 @@ in {
pluginRC.otter-nvim = entryAnywhere '' pluginRC.otter-nvim = entryAnywhere ''
-- Enable otter diagnostics viewer -- Enable otter diagnostics viewer
require("otter").setup(${toLuaObject cfg.otter-nvim.setupOpts}) require("otter").setup({${toLuaObject cfg.otter-nvim.setupOpts}})
''; '';
}; };
}; };

View file

@ -1,40 +1,41 @@
{ {
config, config,
lib, lib,
options,
... ...
}: let }: let
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetLznBinding pushDownDefault; inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetBinding pushDownDefault;
cfg = config.vim.lsp; cfg = config.vim.lsp;
mappingDefinitions = options.vim.lsp.trouble.mappings; self = import ./trouble.nix {inherit lib;};
mappingDefinitions = self.options.vim.lsp.trouble.mappings;
mappings = addDescriptionsToMappings cfg.trouble.mappings mappingDefinitions; mappings = addDescriptionsToMappings cfg.trouble.mappings mappingDefinitions;
in { in {
config = mkIf (cfg.enable && cfg.trouble.enable) { config = mkIf (cfg.enable && cfg.trouble.enable) {
vim = { vim = {
lazy.plugins.trouble = { startPlugins = ["trouble"];
package = "trouble";
setupModule = "trouble";
inherit (cfg.trouble) setupOpts;
cmd = "Trouble"; maps.normal = mkMerge [
keys = [ (mkSetBinding mappings.toggle "<cmd>TroubleToggle<CR>")
(mkSetLznBinding mappings.toggle "<cmd>TroubleToggle<CR>") (mkSetBinding mappings.workspaceDiagnostics "<cmd>TroubleToggle workspace_diagnostics<CR>")
(mkSetLznBinding mappings.workspaceDiagnostics "<cmd>TroubleToggle workspace_diagnostics<CR>") (mkSetBinding mappings.documentDiagnostics "<cmd>TroubleToggle document_diagnostics<CR>")
(mkSetLznBinding mappings.documentDiagnostics "<cmd>TroubleToggle document_diagnostics<CR>") (mkSetBinding mappings.lspReferences "<cmd>TroubleToggle lsp_references<CR>")
(mkSetLznBinding mappings.lspReferences "<cmd>TroubleToggle lsp_references<CR>") (mkSetBinding mappings.quickfix "<cmd>TroubleToggle quickfix<CR>")
(mkSetLznBinding mappings.quickfix "<cmd>TroubleToggle quickfix<CR>") (mkSetBinding mappings.locList "<cmd>TroubleToggle loclist<CR>")
(mkSetLznBinding mappings.locList "<cmd>TroubleToggle loclist<CR>") ];
];
};
binds.whichKey.register = pushDownDefault { binds.whichKey.register = pushDownDefault {
"<leader>l" = "Trouble"; "<leader>l" = "Trouble";
"<leader>x" = "+Trouble"; "<leader>x" = "+Trouble";
"<leader>lw" = "Workspace"; "<leader>lw" = "Workspace";
}; };
pluginRC.trouble = entryAnywhere ''
-- Enable trouble diagnostics viewer
require("trouble").setup {}
'';
}; };
}; };
} }

View file

@ -1,14 +1,11 @@
{lib, ...}: let {lib, ...}: let
inherit (lib.options) mkEnableOption; inherit (lib.options) mkEnableOption;
inherit (lib.nvim.binds) mkMappingOption; inherit (lib.nvim.binds) mkMappingOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in { in {
options.vim.lsp = { options.vim.lsp = {
trouble = { trouble = {
enable = mkEnableOption "trouble diagnostics viewer"; enable = mkEnableOption "trouble diagnostics viewer";
setupOpts = mkPluginSetupOption "Trouble" {};
mappings = { mappings = {
toggle = mkMappingOption "Toggle trouble [trouble]" "<leader>xx"; toggle = mkMappingOption "Toggle trouble [trouble]" "<leader>xx";
workspaceDiagnostics = mkMappingOption "Workspace diagnostics [trouble]" "<leader>lwd"; workspaceDiagnostics = mkMappingOption "Workspace diagnostics [trouble]" "<leader>lwd";

View file

@ -9,18 +9,9 @@
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim = { vim = {
lazy.plugins = { startPlugins = ["luasnip" "cmp-luasnip"] ++ cfg.providers;
luasnip = { autocomplete.nvim-cmp.sources = {luasnip = "[LuaSnip]";};
package = "luasnip"; pluginRC.luasnip = cfg.loaders;
lazy = true;
after = cfg.loaders;
};
};
startPlugins = cfg.providers;
autocomplete.nvim-cmp = {
sources = {luasnip = "[LuaSnip]";};
sourcePlugins = ["cmp-luasnip"];
};
}; };
}; };
} }

View file

@ -7,26 +7,16 @@
inherit (lib.nvim.dag) entryAfter; inherit (lib.nvim.dag) entryAfter;
cfg = config.vim.spellcheck; cfg = config.vim.spellcheck;
in { in {
config = mkIf cfg.programmingWordlist.enable { config = mkIf (cfg.enable && cfg.programmingWordlist.enable) {
vim = { vim = {
startPlugins = ["vim-dirtytalk"]; startPlugins = ["vim-dirtytalk"];
spellcheck.enable = true; # vim-dirtytalk doesn't have any setup
# but we would like to append programming to spelllang
# vim-dirtytalk doesn't have any setup but we would # as soon as possible while the plugin is enabled
# like to append programming to spelllangs as soon as pluginRC.vim-dirtytalk = entryAfter ["basic"] ''
# possible while the plugin is enabled and the state -- append programming to spelllang
# directory can be found. vim.opt.spelllang:append("programming")
pluginRC.vim-dirtytalk = entryAfter ["spellcheck"] ''
-- If Neovim can find (or access) the state directory
-- then append "programming" wordlist from vim-dirtytalk
-- to spelllang table. If path cannot be found, display
-- an error and avoid appending the programming words
if vim.fn.isdirectory(vim.fn.stdpath('state')) == 1 then
vim.opt.spelllang:append("programming")
else
vim.notify("State path does not exist: " .. state_path, vim.log.levels.ERROR)
end
''; '';
}; };
}; };

View file

@ -3,31 +3,39 @@
lib, lib,
... ...
}: let }: let
inherit (lib.strings) optionalString; inherit (builtins) toJSON;
inherit (lib.lists) optional; inherit (lib.lists) optionals;
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf mkMerge;
inherit (lib.meta) getExe; inherit (lib.meta) getExe;
inherit (lib.nvim.binds) mkLznBinding; inherit (lib.nvim.binds) mkBinding;
inherit (lib.nvim.dag) entryAnywhere entryAfter;
inherit (lib.nvim.lua) toLuaObject; inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.terminal.toggleterm; cfg = config.vim.terminal.toggleterm;
lazygitMapDesc = "Open lazygit [toggleterm]";
in { in {
config = mkIf cfg.enable { config = mkMerge [
vim = { (
lazy.plugins.toggleterm-nvim = { mkIf cfg.enable {
package = "toggleterm-nvim"; vim = {
cmd = ["ToggleTerm" "ToggleTermSendCurrentLine" "ToggleTermSendVisualLines" "ToggleTermSendVisualSelection" "ToggleTermSetName" "ToggleTermToggleAll"]; startPlugins = [
keys = "toggleterm-nvim"
[(mkLznBinding ["n"] cfg.mappings.open "<Cmd>execute v:count . \"ToggleTerm\"<CR>" "Toggle terminal")] ];
++ optional cfg.lazygit.enable {
key = cfg.lazygit.mappings.open;
desc = lazygitMapDesc;
};
setupModule = "toggleterm"; maps.normal = mkBinding cfg.mappings.open "<Cmd>execute v:count . \"ToggleTerm\"<CR>" "Toggle terminal";
inherit (cfg) setupOpts;
after = optionalString cfg.lazygit.enable '' pluginRC.toggleterm = entryAnywhere ''
require("toggleterm").setup(${toLuaObject cfg.setupOpts})
'';
};
}
)
(
mkIf (cfg.enable && cfg.lazygit.enable)
{
vim.startPlugins = optionals (cfg.lazygit.package != null) [
cfg.lazygit.package
];
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 = '${
@ -42,9 +50,9 @@ in {
end end
}) })
vim.keymap.set('n', ${toLuaObject cfg.lazygit.mappings.open}, function() lazygit:toggle() end, {silent = true, noremap = true, desc = '${lazygitMapDesc}'}) vim.keymap.set('n', ${toJSON cfg.lazygit.mappings.open}, function() lazygit:toggle() end, {silent = true, noremap = true, desc = 'Open lazygit [toggleterm]'})
''; '';
}; }
}; )
}; ];
} }

View file

@ -66,7 +66,7 @@ in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim = { vim = {
startPlugins = [cfg.name]; startPlugins = [cfg.name];
luaConfigRC.theme = entryBefore ["pluginConfigs" "lazyConfigs"] '' luaConfigRC.theme = entryBefore ["pluginConfigs"] ''
${cfg.extraConfig} ${cfg.extraConfig}
${supportedThemes.${cfg.name}.setup {inherit (cfg) style transparent base16-colors;}} ${supportedThemes.${cfg.name}.setup {inherit (cfg) style transparent base16-colors;}}
''; '';

View file

@ -5,12 +5,13 @@
... ...
}: let }: let
inherit (lib.modules) mkIf mkMerge; inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) optionals; inherit (lib.lists) optional optionals;
inherit (lib.nvim.binds) mkSetBinding addDescriptionsToMappings; inherit (lib.nvim.binds) mkSetBinding addDescriptionsToMappings;
inherit (lib.nvim.lua) toLuaObject; inherit (lib.nvim.lua) toLuaObject;
inherit (lib.nvim.dag) entryBefore entryAfter; inherit (lib.nvim.dag) entryBefore entryAfter;
cfg = config.vim.treesitter; cfg = config.vim.treesitter;
usingNvimCmp = config.vim.autocomplete.nvim-cmp.enable;
self = import ./treesitter.nix {inherit pkgs lib;}; self = import ./treesitter.nix {inherit pkgs lib;};
mappingDefinitions = self.options.vim.treesitter.mappings; mappingDefinitions = self.options.vim.treesitter.mappings;
@ -18,13 +19,9 @@
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim = { vim = {
startPlugins = ["nvim-treesitter"]; startPlugins = ["nvim-treesitter"] ++ optional usingNvimCmp "cmp-treesitter";
autocomplete.nvim-cmp = {
sources = {treesitter = "[Treesitter]";};
sourcePlugins = ["cmp-treesitter"];
};
autocomplete.nvim-cmp.sources = {treesitter = "[Treesitter]";};
treesitter.grammars = optionals cfg.addDefaultGrammars cfg.defaultGrammars; treesitter.grammars = optionals cfg.addDefaultGrammars cfg.defaultGrammars;
maps = { maps = {

View file

@ -4,18 +4,15 @@
... ...
}: let }: let
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf;
inherit (lib.strings) optionalString; inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.binds.cheatsheet; cfg = config.vim.binds.cheatsheet;
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim.lazy.plugins.cheatsheet-nvim = { vim.startPlugins = ["cheatsheet-nvim"];
package = "cheatsheet-nvim";
setupModule = "cheatsheet";
setupOpts = {};
cmd = ["Cheatsheet" "CheatsheetEdit"];
before = optionalString config.vim.lazy.enable "require('lz.n').trigger_load('telescope')"; vim.pluginRC.cheaetsheet-nvim = entryAnywhere ''
}; require('cheatsheet').setup({})
'';
}; };
} }

View file

@ -8,14 +8,9 @@
cfg = config.vim.utility.diffview-nvim; cfg = config.vim.utility.diffview-nvim;
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim = { vim.startPlugins = [
startPlugins = ["plenary-nvim"]; "diffview-nvim"
lazy.plugins.diffview-nvim = { "plenary-nvim"
package = "diffview-nvim"; ];
cmd = ["DiffviewClose" "DiffviewFileHistory" "DiffviewFocusFiles" "DiffviewLog" "DiffviewOpen" "DiffviewRefresh" "DiffviewToggleFiles"];
setupModule = "diffview";
inherit (cfg) setupOpts;
};
};
}; };
} }

View file

@ -1,9 +1,7 @@
{lib, ...}: let {lib, ...}: let
inherit (lib.options) mkEnableOption; inherit (lib.options) mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in { in {
options.vim.utility.diffview-nvim = { options.vim.utility.diffview-nvim = {
enable = mkEnableOption "diffview-nvim: cycle through diffs for all modified files for any git rev"; enable = mkEnableOption "diffview-nvim: cycle through diffs for all modified files for any git rev";
setupOpts = mkPluginSetupOption "Fidget" {};
}; };
} }

View file

@ -4,20 +4,20 @@
... ...
}: let }: let
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.utility.icon-picker; cfg = config.vim.utility.icon-picker;
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim.startPlugins = ["dressing-nvim"]; vim.startPlugins = [
"icon-picker-nvim"
"dressing-nvim"
];
vim.lazy.plugins.icon-picker-nvim = { vim.pluginRC.icon-picker = entryAnywhere ''
package = "icon-picker-nvim"; require("icon-picker").setup({
setupModule = "icon-picker"; disable_legacy_commands = true
setupOpts = { })
disable_legacy_commands = true; '';
};
cmd = ["IconPickerInsert" "IconPickerNormal" "IconPickerYank"];
};
}; };
} }

View file

@ -3,59 +3,73 @@
lib, lib,
... ...
}: let }: let
inherit (lib.modules) mkIf mkDefault; inherit (lib.modules) mkIf mkMerge mkDefault;
inherit (lib.nvim.binds) mkLznBinding; inherit (lib.nvim.binds) mkBinding;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.utility.motion.leap; cfg = config.vim.utility.motion.leap;
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim = { vim.startPlugins = [
startPlugins = ["vim-repeat"]; "leap-nvim"
lazy.plugins.leap-nvim = { "vim-repeat"
package = "leap-nvim"; ];
keys = [
(mkLznBinding ["n" "o" "x"] cfg.mappings.leapForwardTo "<Plug>(leap-forward-to)" "Leap forward to")
(mkLznBinding ["n" "o" "x"] cfg.mappings.leapBackwardTo "<Plug>(leap-backward-to)" "Leap backward to")
(mkLznBinding ["n" "o" "x"] cfg.mappings.leapForwardTill "<Plug>(leap-forward-till)" "Leap forward till")
(mkLznBinding ["n" "o" "x"] cfg.mappings.leapBackwardTill "<Plug>(leap-backward-till)" "Leap backward till")
(mkLznBinding ["n" "o" "x"] cfg.mappings.leapFromWindow "<Plug>(leap-from-window)" "Leap from window")
];
after = '' vim.maps.normal = mkMerge [
require('leap').opts = { (mkBinding cfg.mappings.leapForwardTo "<Plug>(leap-forward-to)" "Leap forward to")
max_phase_one_targets = nil, (mkBinding cfg.mappings.leapBackwardTo "<Plug>(leap-backward-to)" "Leap backward to")
highlight_unlabeled_phase_one_targets = false, (mkBinding cfg.mappings.leapFromWindow "<Plug>(leap-from-window)" "Leap from window")
max_highlighted_traversal_targets = 10, ];
case_sensitive = false,
equivalence_classes = { ' \t\r\n', },
substitute_chars = {},
safe_labels = {
"s", "f", "n", "u", "t", "/",
"S", "F", "N", "L", "H", "M", "U", "G", "T", "?", "Z"
},
labels = {
"s", "f", "n",
"j", "k", "l", "h", "o", "d", "w", "e", "m", "b",
"u", "y", "v", "r", "g", "t", "c", "x", "/", "z",
"S", "F", "N",
"J", "K", "L", "H", "O", "D", "W", "E", "M", "B",
"U", "Y", "V", "R", "G", "T", "C", "X", "?", "Z"
},
special_keys = {
repeat_search = '<enter>',
next_phase_one_target = '<enter>',
next_target = {'<enter>', ';'},
prev_target = {'<tab>', ','},
next_group = '<space>',
prev_group = '<tab>',
multi_accept = '<enter>',
multi_revert = '<backspace>',
},
}
'';
};
binds.whichKey.register."<leader>s" = mkDefault "+Leap"; vim.maps.operator = mkMerge [
}; (mkBinding cfg.mappings.leapForwardTo "<Plug>(leap-forward-to)" "Leap forward to")
(mkBinding cfg.mappings.leapBackwardTo "<Plug>(leap-backward-to)" "Leap backward to")
(mkBinding cfg.mappings.leapForwardTill "<Plug>(leap-forward-till)" "Leap forward till")
(mkBinding cfg.mappings.leapBackwardTill "<Plug>(leap-backward-till)" "Leap backward till")
(mkBinding cfg.mappings.leapFromWindow "<Plug>(leap-from-window)" "Leap from window")
];
vim.maps.visualOnly = mkMerge [
(mkBinding cfg.mappings.leapForwardTo "<Plug>(leap-forward-to)" "Leap forward to")
(mkBinding cfg.mappings.leapBackwardTo "<Plug>(leap-backward-to)" "Leap backward to")
(mkBinding cfg.mappings.leapForwardTill "<Plug>(leap-forward-till)" "Leap forward till")
(mkBinding cfg.mappings.leapBackwardTill "<Plug>(leap-backward-till)" "Leap backward till")
(mkBinding cfg.mappings.leapFromWindow "<Plug>(leap-from-window)" "Leap from window")
];
vim.binds.whichKey.register."<leader>s" = mkDefault "+Leap";
vim.pluginRC.leap-nvim = entryAnywhere ''
require('leap').opts = {
max_phase_one_targets = nil,
highlight_unlabeled_phase_one_targets = false,
max_highlighted_traversal_targets = 10,
case_sensitive = false,
equivalence_classes = { ' \t\r\n', },
substitute_chars = {},
safe_labels = {
"s", "f", "n", "u", "t", "/",
"S", "F", "N", "L", "H", "M", "U", "G", "T", "?", "Z"
},
labels = {
"s", "f", "n",
"j", "k", "l", "h", "o", "d", "w", "e", "m", "b",
"u", "y", "v", "r", "g", "t", "c", "x", "/", "z",
"S", "F", "N",
"J", "K", "L", "H", "O", "D", "W", "E", "M", "B",
"U", "Y", "V", "R", "G", "T", "C", "X", "?", "Z"
},
special_keys = {
repeat_search = '<enter>',
next_phase_one_target = '<enter>',
next_target = {'<enter>', ';'},
prev_target = {'<tab>', ','},
next_group = '<space>',
prev_group = '<tab>',
multi_accept = '<enter>',
multi_revert = '<backspace>',
},
}
'';
}; };
} }

View file

@ -8,47 +8,24 @@
inherit (lib.nvim.lua) toLuaObject; inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.utility.surround; cfg = config.vim.utility.surround;
mkLznKey = mode: key: {
inherit key mode;
};
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim = { vim = {
startPlugins = ["nvim-surround"]; startPlugins = ["nvim-surround"];
pluginRC.surround = entryAnywhere "require('nvim-surround').setup(${toLuaObject cfg.setupOpts})"; pluginRC.surround = entryAnywhere "require('nvim-surround').setup(${toLuaObject cfg.setupOpts})";
lazy.plugins.nvim-surround = { utility.surround.setupOpts.keymaps = mkIf cfg.useVendoredKeybindings {
package = "nvim-surround"; insert = "<C-g>z";
setupModule = "nvim-surround"; insert_line = "<C-g>Z";
inherit (cfg) setupOpts; normal = "gz";
normal_cur = "gZ";
keys = normal_line = "gzz";
[ normal_cur_line = "gZZ";
(mkLznKey ["i"] cfg.setupOpts.keymaps.insert) visual = "gz";
(mkLznKey ["i"] cfg.setupOpts.keymaps.insert_line) visual_line = "gZ";
(mkLznKey ["x"] cfg.setupOpts.keymaps.visual) delete = "gzd";
(mkLznKey ["x"] cfg.setupOpts.keymaps.visual_line) change = "gzr";
(mkLznKey ["n"] cfg.setupOpts.keymaps.normal) change_line = "gZR";
(mkLznKey ["n"] cfg.setupOpts.keymaps.normal_cur)
(mkLznKey ["n"] cfg.setupOpts.keymaps.normal_line)
(mkLznKey ["n"] cfg.setupOpts.keymaps.normal_cur_line)
(mkLznKey ["n"] cfg.setupOpts.keymaps.delete)
(mkLznKey ["n"] cfg.setupOpts.keymaps.change)
(mkLznKey ["n"] cfg.setupOpts.keymaps.change_line)
]
++ map (mkLznKey ["n" "i" "v"]) [
"<Plug>(nvim-surround-insert)"
"<Plug>(nvim-surround-insert-line)"
"<Plug>(nvim-surround-normal)"
"<Plug>(nvim-surround-normal-cur)"
"<Plug>(nvim-surround-normal-line)"
"<Plug>(nvim-surround-normal-cur-line)"
"<Plug>(nvim-surround-visual)"
"<Plug>(nvim-surround-visual-line)"
"<Plug>(nvim-surround-delete)"
"<Plug>(nvim-surround-change)"
"<Plug>(nvim-surround-change-line)"
];
}; };
}; };
}; };

View file

@ -1,36 +1,7 @@
{ {lib, ...}: let
lib,
config,
...
}: let
inherit (lib.options) mkOption; inherit (lib.options) mkOption;
inherit (lib.types) bool str; inherit (lib.types) bool;
inherit (lib.nvim.types) mkPluginSetupOption; inherit (lib.nvim.types) mkPluginSetupOption;
cfg = config.vim.utility.surround;
vendoredKeybinds = {
insert = "<C-g>z";
insert_line = "<C-g>Z";
normal = "gz";
normal_cur = "gZ";
normal_line = "gzz";
normal_cur_line = "gZZ";
visual = "gz";
visual_line = "gZ";
delete = "gzd";
change = "gzr";
change_line = "gZR";
};
mkKeymapOption = name: default:
mkOption {
description = "keymap for ${name}";
type = str;
default =
if cfg.useVendoredKeybindings
then vendoredKeybinds.${name}
else default;
};
in { in {
options.vim.utility.surround = { options.vim.utility.surround = {
enable = mkOption { enable = mkOption {
@ -42,21 +13,7 @@ in {
with nvim-leap. with nvim-leap.
''; '';
}; };
setupOpts = mkPluginSetupOption "nvim-surround" { setupOpts = mkPluginSetupOption "nvim-surround" {};
keymaps = {
insert = mkKeymapOption "insert" "<C-g>s";
insert_line = mkKeymapOption "insert_line" "<C-g>S";
normal = mkKeymapOption "normal" "ys";
normal_cur = mkKeymapOption "normal_cur" "yss";
normal_line = mkKeymapOption "normal_line" "yS";
normal_cur_line = mkKeymapOption "normal_cur_line" "ySS";
visual = mkKeymapOption "visual" "S";
visual_line = mkKeymapOption "visual_line" "gS";
delete = mkKeymapOption "delete" "ds";
change = mkKeymapOption "change" "cs";
change_line = mkKeymapOption "change_line" "cS";
};
};
useVendoredKeybindings = mkOption { useVendoredKeybindings = mkOption {
type = bool; type = bool;

View file

@ -1,72 +1,63 @@
{ {
options,
config, config,
pkgs,
lib, lib,
... ...
}: let }: let
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.binds) addDescriptionsToMappings; inherit (lib.nvim.binds) addDescriptionsToMappings mkSetBinding;
inherit (lib.strings) optionalString; inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.lists) optionals; inherit (lib.nvim.binds) pushDownDefault;
inherit (lib.nvim.binds) pushDownDefault mkSetLznBinding; inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.telescope; cfg = config.vim.telescope;
mappingDefinitions = options.vim.telescope.mappings; self = import ./telescope.nix {inherit pkgs lib;};
mappingDefinitions = self.options.vim.telescope.mappings;
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions; mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim = { vim = {
startPlugins = ["plenary-nvim"]; startPlugins = [
"telescope"
"plenary-nvim"
];
lazy.plugins.telescope = { maps.normal = mkMerge [
package = "telescope"; (mkSetBinding mappings.findFiles "<cmd> Telescope find_files<CR>")
setupModule = "telescope"; (mkSetBinding mappings.liveGrep "<cmd> Telescope live_grep<CR>")
inherit (cfg) setupOpts; (mkSetBinding mappings.buffers "<cmd> Telescope buffers<CR>")
after = '' (mkSetBinding mappings.helpTags "<cmd> Telescope help_tags<CR>")
local telescope = require("telescope") (mkSetBinding mappings.open "<cmd> Telescope<CR>")
${optionalString config.vim.ui.noice.enable "telescope.load_extension('noice')"} (mkSetBinding mappings.resume "<cmd> Telescope resume<CR>")
${optionalString config.vim.notify.nvim-notify.enable "telescope.load_extension('notify')"}
${optionalString config.vim.projects.project-nvim.enable "telescope.load_extension('projects')"}
'';
cmd = ["Telescope"]; (mkSetBinding mappings.gitCommits "<cmd> Telescope git_commits<CR>")
(mkSetBinding mappings.gitBufferCommits "<cmd> Telescope git_bcommits<CR>")
(mkSetBinding mappings.gitBranches "<cmd> Telescope git_branches<CR>")
(mkSetBinding mappings.gitStatus "<cmd> Telescope git_status<CR>")
(mkSetBinding mappings.gitStash "<cmd> Telescope git_stash<CR>")
keys = (mkIf config.vim.lsp.enable (mkMerge [
[ (mkSetBinding mappings.lspDocumentSymbols "<cmd> Telescope lsp_document_symbols<CR>")
(mkSetLznBinding mappings.findFiles "<cmd> Telescope find_files<CR>") (mkSetBinding mappings.lspWorkspaceSymbols "<cmd> Telescope lsp_workspace_symbols<CR>")
(mkSetLznBinding mappings.liveGrep "<cmd> Telescope live_grep<CR>")
(mkSetLznBinding mappings.buffers "<cmd> Telescope buffers<CR>")
(mkSetLznBinding mappings.helpTags "<cmd> Telescope help_tags<CR>")
(mkSetLznBinding mappings.open "<cmd> Telescope<CR>")
(mkSetLznBinding mappings.gitCommits "<cmd> Telescope git_commits<CR>") (mkSetBinding mappings.lspReferences "<cmd> Telescope lsp_references<CR>")
(mkSetLznBinding mappings.gitBufferCommits "<cmd> Telescope git_bcommits<CR>") (mkSetBinding mappings.lspImplementations "<cmd> Telescope lsp_implementations<CR>")
(mkSetLznBinding mappings.gitBranches "<cmd> Telescope git_branches<CR>") (mkSetBinding mappings.lspDefinitions "<cmd> Telescope lsp_definitions<CR>")
(mkSetLznBinding mappings.gitStatus "<cmd> Telescope git_status<CR>") (mkSetBinding mappings.lspTypeDefinitions "<cmd> Telescope lsp_type_definitions<CR>")
(mkSetLznBinding mappings.gitStash "<cmd> Telescope git_stash<CR>") (mkSetBinding mappings.diagnostics "<cmd> Telescope diagnostics<CR>")
] ]))
++ (optionals config.vim.lsp.enable [
(mkSetLznBinding mappings.lspDocumentSymbols "<cmd> Telescope lsp_document_symbols<CR>")
(mkSetLznBinding mappings.lspWorkspaceSymbols "<cmd> Telescope lsp_workspace_symbols<CR>")
(mkSetLznBinding mappings.lspReferences "<cmd> Telescope lsp_references<CR>") (
(mkSetLznBinding mappings.lspImplementations "<cmd> Telescope lsp_implementations<CR>") mkIf config.vim.treesitter.enable
(mkSetLznBinding mappings.lspDefinitions "<cmd> Telescope lsp_definitions<CR>") (mkSetBinding mappings.treesitter "<cmd> Telescope treesitter<CR>")
(mkSetLznBinding mappings.lspTypeDefinitions "<cmd> Telescope lsp_type_definitions<CR>") )
(mkSetLznBinding mappings.diagnostics "<cmd> Telescope diagnostics<CR>")
]) (
++ ( mkIf config.vim.projects.project-nvim.enable
optionals config.vim.treesitter.enable [ (mkSetBinding mappings.findProjects "<cmd> Telescope projects<CR>")
(mkSetLznBinding mappings.treesitter "<cmd> Telescope treesitter<CR>") )
] ];
)
++ (
optionals config.vim.projects.project-nvim.enable [
(mkSetLznBinding mappings.findProjects "<cmd Telescope projects<CR>")
]
);
};
binds.whichKey.register = pushDownDefault { binds.whichKey.register = pushDownDefault {
"<leader>f" = "+Telescope"; "<leader>f" = "+Telescope";
@ -75,6 +66,29 @@ in {
"<leader>fv" = "Telescope Git"; "<leader>fv" = "Telescope Git";
"<leader>fvc" = "Commits"; "<leader>fvc" = "Commits";
}; };
pluginRC.telescope = entryAnywhere ''
local telescope = require('telescope')
telescope.setup(${toLuaObject cfg.setupOpts})
${
if config.vim.ui.noice.enable
then "telescope.load_extension('noice')"
else ""
}
${
if config.vim.notify.nvim-notify.enable
then "telescope.load_extension('notify')"
else ""
}
${
if config.vim.projects.project-nvim.enable
then "telescope.load_extension('projects')"
else ""
}
'';
}; };
}; };
} }

View file

@ -4,15 +4,16 @@
... ...
}: let }: let
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf;
inherit (lib.nvim.lua) toLuaObject;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.visuals.fidget-nvim; cfg = config.vim.visuals.fidget-nvim;
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim.lazy.plugins.fidget-nvim = { vim.startPlugins = ["fidget-nvim"];
package = "fidget-nvim";
setupModule = "fidget"; vim.pluginRC.fidget-nvim = entryAnywhere ''
event = "LspAttach"; require'fidget'.setup(${toLuaObject cfg.setupOpts})
inherit (cfg) setupOpts; '';
};
}; };
} }

View file

@ -1,108 +0,0 @@
{
lib,
config,
...
}: let
inherit (builtins) toJSON typeOf head length filter concatLists concatStringsSep;
inherit (lib.attrsets) mapAttrsToList;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.generators) mkLuaInline;
inherit (lib.strings) optionalString;
inherit (lib.nvim.lua) toLuaObject;
inherit (lib.nvim.dag) entryBefore entryAfter;
cfg = config.vim.lazy;
toLuaLznKeySpec = keySpec:
(removeAttrs keySpec ["key" "lua" "action"])
// {
"@1" = keySpec.key;
"@2" =
if keySpec.lua
then mkLuaInline keySpec.action
else keySpec.action;
};
toLuaLznSpec = name: spec:
(removeAttrs spec ["package" "setupModule" "setupOpts" "keys"])
// {
"@1" = name;
before =
if spec.before != null
then
mkLuaInline ''
function()
${spec.before}
end
''
else null;
after =
if spec.setupModule == null && spec.after == null
then null
else
mkLuaInline ''
function()
${
optionalString (spec.setupModule != null)
"require(${toJSON spec.setupModule}).setup(${toLuaObject spec.setupOpts})"
}
${optionalString (spec.after != null) spec.after}
end
'';
keys =
if typeOf spec.keys == "list" && length spec.keys > 0 && typeOf (head spec.keys) == "set"
then map toLuaLznKeySpec (filter (keySpec: keySpec.key != null) spec.keys)
# empty list or str or (listOf str)
else spec.keys;
};
lznSpecs = mapAttrsToList toLuaLznSpec cfg.plugins;
pluginPackages = mapAttrsToList (_: plugin: plugin.package) cfg.plugins;
specToNotLazyConfig = _: spec: ''
do
${optionalString (spec.before != null) spec.before}
${optionalString (spec.setupModule != null)
"require(${toJSON spec.setupModule}).setup(${toLuaObject spec.setupOpts})"}
${optionalString (spec.after != null) spec.after}
end
'';
specToKeymaps = _: spec:
if typeOf spec.keys == "list"
then map (x: removeAttrs x ["ft"]) (filter (lznKey: lznKey.action != null && lznKey.ft == null) spec.keys)
else if spec.keys == null || typeOf spec.keys == "string"
then []
else [spec.keys];
notLazyConfig =
concatStringsSep "\n"
(mapAttrsToList specToNotLazyConfig cfg.plugins);
beforeAllJoined =
concatStringsSep "\n"
(filter (x: x != null) (mapAttrsToList (_: spec: spec.beforeAll) cfg.plugins));
in {
config.vim = mkMerge [
(mkIf cfg.enable {
startPlugins = ["lz-n" "lzn-auto-require"];
optPlugins = pluginPackages;
lazy.builtLazyConfig = ''
require('lz.n').load(${toLuaObject lznSpecs})
${optionalString cfg.enableLznAutoRequire "require('lzn-auto-require').enable()"}
'';
})
(mkIf (!cfg.enable) {
startPlugins = pluginPackages;
lazy.builtLazyConfig = ''
${beforeAllJoined}
${notLazyConfig}
'';
keymaps = concatLists (mapAttrsToList specToKeymaps cfg.plugins);
})
];
}

View file

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

View file

@ -1,237 +0,0 @@
{lib, ...}: let
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) enum listOf submodule nullOr str bool int attrsOf anything either oneOf lines;
inherit (lib.nvim.types) pluginType;
inherit (lib.nvim.config) mkBool;
lznKeysSpec = submodule {
options = {
key = mkOption {
type = nullOr str;
description = "Key to bind to. If key is null this entry is ignored.";
};
action = mkOption {
type = nullOr str;
default = null;
description = "Action to trigger.";
};
lua = mkBool false ''
If true, `action` is considered to be lua code.
Thus, it will not be wrapped in `""`.
'';
desc = mkOption {
description = "Description of the key map";
type = nullOr str;
default = null;
};
ft = mkOption {
description = "TBD";
type = nullOr (listOf str);
default = null;
};
mode = mkOption {
description = "Modes to bind in";
type = either str (listOf str);
default = ["n" "x" "s" "o"];
};
silent = mkBool true "Whether this mapping should be silent. Equivalent to adding <silent> to a map.";
nowait = mkBool false "Whether to wait for extra input on ambiguous mappings. Equivalent to adding <nowait> to a map.";
script = mkBool false "Equivalent to adding <script> to a map.";
expr = mkBool false "Means that the action is actually an expression. Equivalent to adding <expr> to a map.";
unique = mkBool false "Whether to fail if the map is already defined. Equivalent to adding <unique> to a map.";
noremap = mkBool true "Whether to use the 'noremap' variant of the command, ignoring any custom mappings on the defined action. It is highly advised to keep this on, which is the default.";
};
};
lznPluginType = submodule {
options = {
package = mkOption {
type = pluginType;
description = "Plugin package";
};
setupModule = mkOption {
type = nullOr str;
description = "Lua module to run setup function on.";
default = null;
};
setupOpts = mkOption {
type = submodule {freeformType = attrsOf anything;};
description = "Options to pass to the setup function";
default = {};
};
# lz.n options
enabled = mkOption {
type = nullOr (either bool str);
description = "When false, or if the lua function returns false, this plugin will not be included in the spec";
default = null;
};
beforeAll = mkOption {
type = nullOr lines;
description = "Lua code to run before any plugins are loaded. This will be wrapped in a function.";
default = null;
};
before = mkOption {
type = nullOr lines;
description = "Lua code to run before plugin is loaded. This will be wrapped in a function.";
default = null;
};
after = mkOption {
type = nullOr lines;
description = ''
Lua code to run after plugin is loaded. This will be wrapped in a function.
If [](#opt-vim.lazy.plugins._name_.setupModule) is provided, the setup will be ran before `after`.
'';
default = null;
};
event = mkOption {
description = "Lazy-load on event";
default = null;
type = let
event = submodule {
options = {
event = mkOption {
type = nullOr (either str (listOf str));
description = "Exact event name";
example = "BufEnter";
};
pattern = mkOption {
type = nullOr (either str (listOf str));
description = "Event pattern";
example = "BufEnter *.lua";
};
};
};
in
nullOr (oneOf [str (listOf str) event]);
};
cmd = mkOption {
description = "Lazy-load on command";
default = null;
type = nullOr (either str (listOf str));
};
ft = mkOption {
description = "Lazy-load on filetype";
default = null;
type = nullOr (either str (listOf str));
};
keys = mkOption {
description = "Lazy-load on key mapping";
default = null;
type = nullOr (oneOf [str (listOf lznKeysSpec) (listOf str)]);
example = ''
keys = [
{
mode = "n";
key = "<leader>s";
action = ":DapStepOver<cr>";
desc = "DAP Step Over";
}
{
mode = ["n", "x"];
key = "<leader>dc";
action = "function() require('dap').continue() end";
lua = true;
desc = "DAP Continue";
}
]
'';
};
colorscheme = mkOption {
description = "Lazy-load on colorscheme.";
type = nullOr (either str (listOf str));
default = null;
};
lazy = mkBool false "Lazy-load manually, e.g. using `trigger_load`.";
priority = mkOption {
type = nullOr int;
description = "Only useful for stat plugins (not lazy-loaded) to force loading certain plugins first.";
default = null;
};
load = mkOption {
type = nullOr lines;
default = null;
description = ''
Lua code to override the `vim.g.lz_n.load()` function for a single plugin.
This will be wrapped in a function.
'';
};
};
};
in {
options.vim.lazy = {
enable = mkEnableOption "plugin lazy-loading via lz.n and lzn-auto-require" // {default = true;};
loader = mkOption {
description = "Lazy loader to use";
type = enum ["lz.n"];
default = "lz.n";
};
plugins = mkOption {
default = [];
type = attrsOf lznPluginType;
description = ''
Plugins to lazy load.
The attribute key is used as the plugin name: for the default `vim.g.lz_n.load`
function this should be either the `package.pname` or `package.name`.
'';
example = ''
{
toggleterm-nvim = {
package = "toggleterm-nvim";
setupModule = "toggleterm";
setupOpts = cfg.setupOpts;
after = "require('toggleterm').do_something()";
cmd = ["ToggleTerm"];
};
$${pkgs.vimPlugins.vim-bbye.pname} = {
package = pkgs.vimPlugins.vim-bbye;
cmd = ["Bdelete" "Bwipeout"];
};
}
'';
};
enableLznAutoRequire = mkOption {
description = ''
Enable lzn-auto-require. Since builtin plugins rely on this, only turn
off for debugging.
'';
type = bool;
default = true;
};
builtLazyConfig = mkOption {
internal = true;
type = lines;
description = ''
The built config for lz.n, or if `vim.lazy.enable` is false, the
individual plugin configs.
'';
};
};
}

View file

@ -5,7 +5,7 @@
}: let }: let
inherit (builtins) map mapAttrs filter; inherit (builtins) map mapAttrs filter;
inherit (lib.attrsets) mapAttrsToList; inherit (lib.attrsets) mapAttrsToList;
inherit (lib.strings) concatLines concatMapStringsSep optionalString; inherit (lib.strings) concatLines concatMapStringsSep;
inherit (lib.trivial) showWarnings; inherit (lib.trivial) showWarnings;
inherit (lib.generators) mkLuaInline; inherit (lib.generators) mkLuaInline;
inherit (lib.nvim.dag) entryAfter mkLuarcSection resolveDag entryAnywhere; inherit (lib.nvim.dag) entryAfter mkLuarcSection resolveDag entryAnywhere;
@ -52,8 +52,7 @@ in {
optionsScript = entryAfter ["basic"] (concatLines optionsScript); optionsScript = entryAfter ["basic"] (concatLines optionsScript);
# Basic # Basic
lazyConfigs = entryAfter ["optionsScript"] cfg.lazy.builtLazyConfig; pluginConfigs = entryAfter ["optionsScript"] pluginConfigs;
pluginConfigs = entryAfter ["lazyConfigs"] pluginConfigs;
extraPluginConfigs = entryAfter ["pluginConfigs"] extraPluginConfigs; extraPluginConfigs = entryAfter ["pluginConfigs"] extraPluginConfigs;
mappings = entryAfter ["extraPluginConfigs"] keymaps; mappings = entryAfter ["extraPluginConfigs"] keymaps;
}; };