Merge branch 'NotAShelf:main' into feat-ruff

This commit is contained in:
QuiNz- 2025-03-19 16:00:22 +01:00 committed by GitHub
commit 08037dbdce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
158 changed files with 5676 additions and 4527 deletions

View file

@ -14,7 +14,7 @@ indent_style = space
indent_size = 2
trim_trailing_whitespace = false
[*.{js,nix,yml,yaml}]
[*.{js,json,nix,yml,yaml,toml}]
indent_style = space
indent_size = 2
tab_width = 2
@ -26,3 +26,6 @@ trim_trailing_whitespace = unset
[*.lock]
indent_size = unset
[npins/sources.json]
insert_final_newline = unset

View file

@ -7,14 +7,17 @@ or dependency in this section.
If your pull request aims to fix an open issue or a please bug, please also link the relevant issue
below this line. You may attach an issue to your pull request with `Fixes #<issue number>` outside
this comment, and it will be closed when your pull request is merged.
A developer package template is provided in flake/develop.nix. If working on a module, you may use
it to test your changes with minimal dependency changes.
-->
## Sanity Checking
<!--
Please check all that apply. As before, this section is not a hard requirement but checklists with more checked
items are likely to be merged faster. You may save some time in maintainer review by performing self-reviews here
before submitting your pull request.
items are likely to be merged faster. You may save some time in maintainer reviews by performing self-reviews
here before submitting your pull request.
If your pull request includes any change or unexpected behaviour not covered below, please do make sure to include
it above in your description.
@ -22,9 +25,11 @@ it above in your description.
[editorconfig]: https://editorconfig.org
[changelog]: https://github.com/NotAShelf/nvf/tree/main/docs/release-notes
[hacking nvf]: https://notashelf.github.io/nvf/index.xhtml#sec-guidelines
- [ ] I have updated the [changelog] as per my changes
- [ ] I have tested, and self-reviewed my code
- [ ] My changes fit guidelines found in [hacking nvf]
- Style and consistency
- [ ] I ran **Alejandra** to format my code (`nix fmt`)
- [ ] My code conforms to the [editorconfig] configuration of the project
@ -34,9 +39,10 @@ it above in your description.
- [ ] I have added a section in the manual
- [ ] _(For breaking changes)_ I have included a migration guide
- Package(s) built:
- [ ] `.#nix` (default package)
- [ ] `.#nix` _(default package)_
- [ ] `.#maximal`
- [ ] `.#docs-html` (manual, must build)
- [ ] `.#docs-html` _(manual, must build)_
- [ ] `.#docs-linkcheck` _(optional, please build if adding links)_
- Tested on platform(s)
- [ ] `x86_64-linux`
- [ ] `aarch64-linux`
@ -46,7 +52,8 @@ it above in your description.
<!--
If your changes touch upon a portion of the codebase that you do not understand well, please make sure to consult
the maintainers on your changes. In most cases, making an issue before creating your PR will help you avoid duplicate
efforts in the long run.
efforts in the long run. `git blame` might help you find out who is the "author" or the "maintainer" of a current
module by showing who worked on it the most.
-->
---

72
.github/README.md vendored
View file

@ -50,6 +50,7 @@
[Contribute]: #contributing
[FAQ]: #frequently-asked-questions
[Credits]: #credits
[License]: #license
**[<kbd><br>Features <br></kbd>][Features]**
**[<kbd><br>Get Started<br></kbd>][Get Started]**
@ -67,6 +68,10 @@
[standalone]: https://notashelf.github.io/nvf/index.xhtml#ch-standalone-installation
[NixOS module]: https://notashelf.github.io/nvf/index.xhtml#ch-standalone-nixos
[Home-Manager module]: https://notashelf.github.io/nvf/index.xhtml#ch-standalone-hm
[release notes]: https://notashelf.github.io/nvf/release-notes.html
[discussions tab]: https://github.com/notashelf/nvf/discussions
[FAQ section]: #frequently-asked-questions
[DAG]: https://en.wikipedia.org/wiki/Directed_acyclic_graph
- **Simple**: One language to rule them all! Use Nix to configure everything,
with optional Lua support for robust configurability!
@ -79,11 +84,31 @@
customizable through the Nix module system.
- Not comfortable with a full-nix config or want to bring your Lua config? You
can do just that, no unnecessary restrictions.
- Lazyloading? We got it! Lazyload both internal and external plugins at will.
- Lazyloading 💤? We got it! Lazyload both internal and external plugins at
will.
- nvf allows _ordering configuration bits_ using [DAG] (_Directed acyclic
graph_)s. It has never been easier to construct an editor configuration
deterministically!
- nvf exposes everything you need to avoid a vendor lock-in. Which means you
can add new modules, plugins and so on without relying on us adding a module
for them! Though, of course, feel free to request them.
- Use plugins from anywhere. Inputs, npins, nixpkgs... You name it.
- Add your own modules, with ease. It's all built-in!
- **Well-documented**: Documentation is priority. You will _never_ face
undocumented, obscure behaviour.
- Changes, breaking or otherwise, will be communicated in the [release notes]
- Refer to the [FAQ section] for answers to common questions.
- Your question not there? Head to the to the [discussions tab]!
- **Idiomatic**: nvf does things ✨ _the right way_ ✨ - the codebase is, and
will, remain maintainable for myself and any contributors.
- **Community-Led**: we would like nvf to be fully capable of accomplishing what
you really want it to do. If you have a use case that is not made possible by
nvf, please open an issue (or a pull request!)
- Your feedback is more than welcome! Feedback is what _drives_ nvf forward.
If you have anything to say, or ask, please let us know.
- Pull requests are _always_ welcome. If you think the project can benefit
from something you did locally, but are not quite sure how to upstream,
please feel free to contact us! We'll help you get it done.
## Get Started
@ -173,36 +198,49 @@ fix.
[list of open pull requests]: https://github.com/NotAShelf/nvf/pulls
**Q**: What platforms are supported?
<br/> **A**: nvf actively supports **Linux and Darwin** platforms using
standalone Nix, NixOS or Home-Manager. Please take a look at the [nvf manual]
for available installation instructions.
**A**: nvf actively supports **Linux and Darwin** platforms using standalone
Nix, NixOS or Home-Manager. Please take a look at the [nvf manual] for available
installation instructions.
**Q**: Can you add _X_?
<br/> **A**: Maybe! It is not one of our goals to support each and every Neovim
**A**: Maybe! It is not one of our goals to support each and every Neovim
plugin, however, I am always open to new modules and plugin setup additions to
**nvf**. Use the appropriate [issue template] and I will consider a module
addition. As mentioned before, pull requests to add new features are also
welcome.
**Q**: A plugin I need is not available in **nvf**. What to do?
<br/> **A**: **nvf** exposes several APIs for you to be able to add your own
plugin configurations! Please see the documentation on how you may do this.
**A**: **nvf** exposes several APIs for you to be able to add your own plugin
configurations! Please see the documentation on how you may do this.
**Q**: Main branch is awfully silent, is the project dead?
<br/> **A**: No! Sometimes we branch out (e.g. `v0.6`) to avoid breaking
userspace and work in a separate branch until we make sure the new additions are
implemented in the most comfortable way possible for the end user. If you have
not noticed any activity on the main branch, consider taking a look at the
**A**: No! Sometimes we branch out (e.g. `v0.6`) to avoid breaking userspace and
work in a separate branch until we make sure the new additions are implemented
in the most comfortable way possible for the end user. If you have not noticed
any activity on the main branch, consider taking a look at the
[list of branches] or the [list of open pull requests]. You may also consider
_testing_ those release branches to get access to new features ahead of time and
better prepare to breaking changes.
**Q**: Will you support non-flake installations?
<br/> **A**: Quite possibly. **nvf** started as "neovim-flake", which does mean
it is and will remain flakes-first but we might consider non-flakes
compatibility. Though keep in mind that **nvf** under non-flake environments
would lose customizability of plugin inputs, which is one of our primary
features.
**A**: Quite possibly. **nvf** started as "neovim-flake", which does mean it is
and will remain flakes-first but we might consider non-flakes compatibility.
Though keep in mind that **nvf** under non-flake environments would lose
customizability of plugin inputs, which is one of our primary features.
**Q**: I prefer working with Lua, can I use nvf as a plugin manager while I use
an imperative path (e.g., `~/.config/nvim`) for my Neovim configuration instead
of a configuration generated from Nix?
**A**: Yes! Add `"~/.config/nvim"` to `vim.additionalRuntimePaths = [ ... ]` and
any plugins you want to load to `vim.startPlugins`. This will load your
configuration from `~/.config/nvim`. You may still use `vim.*` to modify
Neovim's behaviour with Nix.
## Credits
@ -245,7 +283,7 @@ and everyone who has submitted issues or pull requests!
### Inspiration
This configuration borrows from and is based on a few other configurations,
This configuration borrows from, and is based on a few other configurations,
including:
- [@jordanisaacs's](https://github.com/jordanisaacs)

10
.github/typos.toml vendored
View file

@ -1,2 +1,10 @@
default.extend-ignore-words-re = ["(?i)(noice)", "befores", "annote", "viw"]
files.extend-exclude = ["npins/sources.json"]
default.extend-ignore-words-re = [
"(?i)(noice)",
"befores",
"annote",
"viw",
"BA", # somehow "BANanaD3V" is valid, but BA is not...
]

View file

@ -35,9 +35,8 @@ jobs:
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- uses: cachix/cachix-action@v15
- uses: cachix/cachix-action@v16
with:
authToken: ${{ secrets.CACHIX_TOKEN }}
extraPullNames: nix-community

View file

@ -21,7 +21,6 @@ jobs:
steps:
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- name: Checkout
uses: actions/checkout@v4
@ -42,13 +41,13 @@ jobs:
with:
name: "${{ matrix.package }}"
path: result/share/doc/nvf
flake-docs-linkcheck:
name: Validate hyperlinks in documentation sources
runs-on: ubuntu-latest
steps:
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- name: Checkout
uses: actions/checkout@v4

View file

@ -19,7 +19,6 @@ jobs:
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- name: Check Flake
run: nix flake check
@ -33,6 +32,5 @@ jobs:
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- run: nix run nixpkgs#alejandra -- -c .

View file

@ -26,7 +26,6 @@ jobs:
steps:
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- name: Checkout
uses: actions/checkout@v4

View file

@ -30,7 +30,6 @@ jobs:
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- name: Checking EditorConfig
shell: bash

View file

@ -45,7 +45,6 @@ jobs:
steps:
- uses: actions/checkout@v4.1.7
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- run: |
nix build .#docs -Lv
cp -r result/share/doc/nvf public

View file

@ -1,6 +1,7 @@
# This is the sample configuration for nvf, aiming to give you a feel of the default options
# while certain plugins are enabled. While it may act as one, this is not an overview of nvf's
# module options. To find a complete overview of nvf's options and examples, visit the manual.
# while certain plugins are enabled. While it may partially act as one, this is *not* quite
# an overview of nvf's module options. To find a complete and curated list of nvf module
# options, examples, instruction tutorials and more; please visit the online manual.
# https://notashelf.github.io/nvf/options.html
isMaximal: {
config.vim = {
@ -172,15 +173,18 @@ isMaximal: {
utility = {
ccc.enable = false;
vim-wakatime.enable = false;
diffview-nvim.enable = true;
yanky-nvim.enable = false;
icon-picker.enable = isMaximal;
surround.enable = isMaximal;
diffview-nvim.enable = true;
leetcode-nvim.enable = isMaximal;
multicursors.enable = isMaximal;
motion = {
hop.enable = true;
leap.enable = true;
precognition.enable = isMaximal;
};
images = {
image-nvim.enable = false;
};
@ -230,6 +234,7 @@ isMaximal: {
enable = false;
cmp.enable = isMaximal;
};
codecompanion-nvim.enable = false;
};
session = {

View file

@ -102,7 +102,7 @@ in
--script script/anchor-use.js \
--script script/anchor-min.js \
--script script/search.js \
--toc-depth 2 \
--toc-depth 1 \
--section-toc-depth 1 \
manual.md \
"$dest/index.xhtml"

View file

@ -3,7 +3,7 @@
```{=include=} chapters
configuring/custom-package.md
configuring/custom-plugins.md
configuring/custom-inputs.md
configuring/overriding-plugins.md
configuring/languages.md
configuring/dags.md
configuring/dag-entries.md

View file

@ -1,53 +0,0 @@
# Custom Inputs {#ch-custom-inputs}
One of the greatest strengths of **nvf** is its ability to get plugins from
flake inputs and build them locally from any given source. For plugins that do
not require any kind of additional building step, this is a powerful method of
adding plugins to your configuration that are not packaged in nixpkgs, or those
you want to track from source without relying on nixpkgs.
The [additional plugins section](#sec-additional-plugins) details the addition
of new plugins to nvf under regular circumstances, i.e. while making a pull
request to the project. You may _override_ those plugin inputs in your own
`flake.nix` to change source versions, e.g., to use newer versions of plugins
that are not yet updated in **nvf**.
```nix
{
inputs = {
# ...
# The name here is arbitrary, you can name it whatever.
# This will add a plugin input called "your-neodev-input"
# that you can reference in a `follows` line.
your-neodev-input = {
url = "github:folke/neodev.nvim";
flake = false;
};
nvf = {
url = "github:notashelf/nvf";
# The name of the input must match for the follows line
# plugin-neodev-nvim is what the input is called inside nvf
# so you must match the exact name here.
inputs.plugin-neodev-nvim.follows = "your-neodev-input";
};
# ...
};
}
```
This will override the source for the `neodev.nvim` plugin that is used in nvf
with your own input. You can update your new input via `nix flake update` or
more specifically `nix flake update <name of your input>` to keep it up to date.
::: {.warning}
While updating plugin inputs, make sure that any configuration that has been
deprecated in newer versions is changed in the plugin's `setupOpts`. If you
depend on a new version, requesting a version bump in the issues section is a
more reliable option.
:::

View file

@ -67,7 +67,7 @@ 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
Please refer to the [DAG section](#ch-dag-entries) in the nvf manual
to find out more about the DAG system.
:::

View file

@ -0,0 +1,35 @@
# Overriding plugins {#ch-overriding-plugins}
The [additional plugins section](#sec-additional-plugins) details the addition
of new plugins to nvf under regular circumstances, i.e. while making a pull
request to the project. You may _override_ those plugins in your config
to change source versions, e.g., to use newer versions of plugins
that are not yet updated in **nvf**.
```nix
vim.pluginOverrides = {
lazydev-nvim = pkgs.fetchFromGitHub {
owner = "folke";
repo = "lazydev.nvim";
rev = "";
hash = "";
};
# It's also possible to use a flake input
lazydev-nvim = inputs.lazydev-nvim;
# Or a local path
lazydev-nvim = ./lazydev;
# Or a npins pin... etc
};
```
This will override the source for the `neodev.nvim` plugin that is used in nvf
with your own plugin.
::: {.warning}
While updating plugin inputs, make sure that any configuration that has been
deprecated in newer versions is changed in the plugin's `setupOpts`. If you
depend on a new version, requesting a version bump in the issues section is a
more reliable option.
:::

View file

@ -1,36 +1,25 @@
# Adding Plugins {#sec-additional-plugins}
To add a new Neovim plugin, first add the source url in the inputs section of
`flake.nix` with the prefix `plugin-`
To add a new Neovim plugin, use `npins`
Use:
`nix-shell -p npins` or `nix shell nixpkgs#npins`
Then run:
`npins add --name <plugin name> github <owner> <repo> -b <branch>`
Be sure to replace any non-alphanumeric characters with `-` for `--name`
For example
`npins add --name lazydev-nvim github folke lazydev.nvim -b main`
You can now reference this plugin as a **string**.
```nix
{
inputs = {
# ...
plugin-neodev-nvim = {
url = "github:folke/neodev.nvim";
flake = false;
};
# ...
};
}
```
Prepending `plugin-` to the name of the input will allow nvf to automatically
discover inputs that are marked as plugins, and make them available in
`vim.startPlugins` or other areas that require a very specific plugin type as it
is defined in `@NVF_REPO@/lib/types/plugins.nix`
The addition of the `plugin-` prefix will allow **nvf** to autodiscover the
input from the flake inputs automatically, allowing you to refer to it in areas
that require a very specific plugin type as defined in `lib/types/plugins.nix`
You can now reference this plugin using its string name, the plugin will be
built with the name and source URL from the flake input, allowing you to refer
to it as a **string**.
```nix
config.vim.startPlugins = ["neodev-nvim"];
config.vim.startPlugins = ["lazydev-nvim"];
```
## Modular setup options {#sec-modular-setup-options}

View file

@ -23,15 +23,17 @@ An example flake that exposes your custom Neovim configuration might look like
nvf.url = "github:notashelf/nvf";
};
outputs = {
self,
nixpkgs,
...
} @ inputs: {
packages."x86_64-linux" = let
neovimConfigured = (inputs.nvf.lib.neovimConfiguration {
inherit (nixpkgs.legacyPackages."x86_64-linux") pkgs;
modules = [{
outputs = {nixpkgs, ...} @ inputs: {
packages.x86_64-linux = {
# Set the default package to the wrapped instance of Neovim.
# This will allow running your Neovim configuration with
# `nix run` and in addition, sharing your configuration with
# other users in case your repository is public.
default =
(inputs.nvf.lib.neovimConfiguration {
pkgs = nixpkgs.legacyPackages.x86_64-linux;
modules = [
{
config.vim = {
# Enable custom theming options
theme.enable = true;
@ -43,14 +45,10 @@ An example flake that exposes your custom Neovim configuration might look like
# reference in Appendix B of the nvf manual.
# ...
};
}];
});
in {
# Set the default package to the wrapped instance of Neovim.
# This will allow running your Neovim configuration with
# `nix run` and in addition, sharing your configuration with
# other users in case your repository is public.
default = neovimConfigured.neovim;
}
];
})
.neovim;
};
};
}

View file

@ -49,13 +49,10 @@ Followed by importing the home-manager module somewhere in your configuration.
nvf.url = "github:notashelf/nvf";
};
outputs = { nixpkgs, home-manager, nvf, ... }: let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
in {
outputs = { nixpkgs, home-manager, nvf, ... }: {
# ↓ this is your home output in the flake schema, expected by home-manager
"your-username@your-hostname" = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
pkgs = nixpkgs.legacyPackages.x86_64-linux;
modules = [
nvf.homeManagerModules.default # <- this imports the home-manager module that provides the options
./home.nix # <- your home entrypoint, `programs.nvf.*` may be defined here

View file

@ -16,26 +16,32 @@ the default theme enabled. You may use other options inside `config.vim` in
nvf.url = "github:notashelf/nvf";
};
outputs = {nixpkgs, nvf, ...}: let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
configModule = {
# Add any custom options (and do feel free to upstream them!)
# options = { ... };
config.vim = {
theme.enable = true;
# and more options as you see fit...
};
};
customNeovim = nvf.lib.neovimConfiguration {
inherit pkgs;
modules = [configModule];
};
in {
outputs = {
nixpkgs,
nvf,
self,
...
}: {
# This will make the package available as a flake output under 'packages'
packages.${system}.my-neovim = customNeovim.neovim;
packages.x86_64-linux.my-neovim =
(nvf.lib.neovimConfiguration {
pkgs = nixpkgs.legacyPackages.x86_64-linux;
modules = [
# Or move this to a separate file and add it's path here instead
# IE: ./nvf_module.nix
(
{pkgs, ...}: {
# Add any custom options (and do feel free to upstream them!)
# options = { ... };
config.vim = {
theme.enable = true;
# and more options as you see fit...
};
}
)
];
})
.neovim;
# Example nixosConfiguration using the configured Neovim package
nixosConfigurations = {
@ -43,11 +49,13 @@ the default theme enabled. You may use other options inside `config.vim` in
# ...
modules = [
# This will make wrapped neovim available in your system packages
{environment.systemPackages = [customNeovim.neovim];}
# Can also move this to another config file if you pass inputs/self around with specialArgs
({pkgs, ...}: {
environment.systemPackages = [self.packages.${pkgs.stdenv.system}.neovim];
})
];
# ...
};
};
};
}
```
}```

View file

@ -1,9 +1,13 @@
# Neovim Flake Configuration Options {#ch-options}
# nvf Configuration Options {#ch-options}
Below are the module options provided by nvf, in no particular order. Most
options will include useful comments, warnings or setup tips on how a module
option is meant to be used as well as examples in complex cases.
An offline version of this page is bundled with nvf as a part of the manpages
which you can access with `man 5 nvf`. Please us know if you believe any of the
options below are missing useful examples.
<!--
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

View file

@ -1,6 +1,7 @@
# Helpful Tips {#ch-helpful-tips}
```{=include=} chapters
tips/pure-lua-config.md
tips/debugging-nvf.md
tips/offline-docs.md
```

View file

@ -17,3 +17,9 @@ nvf-print-config | bat --language=lua
```
Alternatively, `cat` or `less` may also be used.
## Accessing `neovimConfig` {#sec-accessing-config}
It is also possible to access the configuration for the wrapped package. The
_built_ Neovim package will contain a `neovimConfig` attribute in its
`passthru`.

View file

@ -0,0 +1,117 @@
# Pure Lua Configuration {#sec-pure-lua-config}
We recognize that you might not always want to configure your setup purely in
Nix, sometimes doing things in Lua is simply the "superior" option. In such a
case you might want to configure your Neovim instance using Lua, and nothing but
Lua. It is also possible to mix Lua and Nix configurations.
Pure Lua or hybrid Lua/Nix configurations can be achieved in two different ways.
_Purely_, by modifying Neovim's runtime directory or _impurely_ by placing Lua
configuration in a directory found in `$HOME`. For your convenience, this
section will document both methods as they can be used.
## Pure Runtime Directory {#sec-pure-nvf-runtime}
As of 0.6, nvf allows you to modify Neovim's runtime path to suit your needs.
One of the ways the new runtime option is to add a configuration **located
relative to your `flake.nix`**, which must be version controlled in pure flakes
manner.
```nix
{
# Let us assume we are in the repository root, i.e., the same directory as the
# flake.nix. For the sake of the argument, we will assume that the Neovim lua
# configuration is in a nvim/ directory relative to flake.nix.
vim = {
additionalRuntimeDirectories = [
# This will be added to Neovim's runtime paths. Conceptually, this behaves
# very similarly to ~/.config/nvim but you may not place a top-level
# init.lua to be able to require it directly.
./nvim
];
};
}
```
This will add the `nvim` directory, or rather, the _store path_ that will be
realised after your flake gets copied to the Nix store, to Neovim's runtime
directory. You may now create a `lua/myconfig` directory within this nvim
directory, and call it with [](#opt-vim.luaConfigRC).
```nix
{pkgs, ...}: {
vim = {
additionalRuntimeDirectories = [
# You can list more than one file here.
./nvim-custom-1
# To make sure list items are ordered, use lib.mkBefore or lib.mkAfter
# Simply placing list items in a given order will **not** ensure that
# this list will be deterministic.
./nvim-custom-2
];
startPlugins = [pkgs.vimPlugins.gitsigns];
# Neovim supports in-line syntax highlighting for multi-line strings.
# Simply place the filetype in a /* comment */ before the line.
luaConfigRC.myconfig = /* lua */ ''
-- Call the Lua module from ./nvim/lua/myconfig
require("myconfig")
-- Any additional Lua configuration that you might want *after* your own
-- configuration. For example, a plugin setup call.
require('gitsigns').setup({})
'';
};
}
```
## Impure Absolute Directory {#sec-impure-absolute-dir}
[Neovim 0.9]: https://github.com/neovim/neovim/pull/22128
As of [Neovim 0.9], {var}`$NVIM_APPNAME` is a variable expected by Neovim to
decide on the configuration directory. nvf sets this variable as `"nvf"`,
meaning `~/.config/nvf` will be regarded as _the_ configuration directory by
Neovim, similar to how `~/.config/nvim` behaves in regular installations. This
allows some degree of Lua configuration, backed by our low-level wrapper
[mnw](https://github.com/Gerg-L/mnw). Creating a `lua/` directory located in
`$NVIM_APPNAME` ("nvf" by default) and placing your configuration in, e.g.,
`~/.config/nvf/lua/myconfig` will allow you to `require` it as a part of the Lua
module system through nvf's module system.
Let's assume your `~/.config/nvf/lua/myconfig/init.lua` consists of the
following:
```lua
-- init.lua
vim.keymap.set("n", " ", "<Nop>", { silent = true, remap = false })
vim.g.mapleader = " "
```
The following Nix configuration via [](#opt-vim.luaConfigRC) will allow loading
this
```nix
{
# The attribute name "myconfig-dir" here is arbitrary. It is required to be
# a *named* attribute by the DAG system, but the name is entirely up to you.
vim.luaConfigRC.myconfig-dir = ''
require("myconfig")
-- Any additional Lua
'';
}
```
[DAG system]: https://notashelf.github.io/nvf/index.xhtml#ch-using-dags
After you load your custom configuration, you may use an `init.lua` located in
your custom configuration directory to configure Neovim exactly as you would
without a wrapper like nvf. If you want to place your `require` call in a
specific position (i.e., before or after options you set in nvf) the
[DAG system] will let you place your configuration in a location of your
choosing.
[top-level DAG system]: https://notashelf.github.io/nvf/index.xhtml#ch-vim-luaconfigrc

View file

@ -1,9 +1,26 @@
# Release 0.8 {#sec-release-0.8}
## Breaking changes
[Lspsaga documentation]: https://nvimdev.github.io/lspsaga/
- `git-conflict` keybinds are now prefixed with `<leader>` to avoid conflicting
with builtins.
- `alpha` is now configured with nix, default config removed.
- Lspsaga module no longer ships default keybindings. The keybind format has
been changed by upstream, and old keybindings do not have equivalents under
the new API they provide. Please manually set your keybinds according to
[Lspsaga documentation] following the new API.
[NotAShelf](https://github.com/notashelf):
[typst-preview.nvim]: https://github.com/chomosuke/typst-preview.nvim
[render-markdown.nvim]: https://github.com/MeanderingProgrammer/render-markdown.nvim
[yanky.nvim]: https://github.com/gbprod/yanky.nvim
[yazi.nvim]: https://github.com/mikavilpas/yazi.nvim
[snacks.nvim]: https://github.com/folke/snacks.nvim
- Add [typst-preview.nvim] under
`languages.typst.extensions.typst-preview-nvim`.
@ -11,7 +28,7 @@
- Add a search widget to the options page in the nvf manual.
- Add [render-markdown.nvim] under
`languages.markdown.extensions.render-markdown-nvim`
`languages.markdown.extensions.render-markdown-nvim`.
- Implement [](#opt-vim.git.gitsigns.setupOpts) for user-specified setup table
in gitsigns configuration.
@ -33,16 +50,46 @@
- Add [](#opt-vim.lsp.lightbulb.autocmd.enable) for manually managing the
previously managed lightbulb autocommand.
- A warning will occur if [](#opt-vim.lsp.lightbulb.autocmd.enable) and
`vim.lsp.lightbulb.setupOpts.autocmd.enabled` are both set at the same time.
Pick only one.
- Add [yanky.nvim] to available plugins, under `vim.utility.yanky-nvim`.
- Fix plugin `setupOpts` for yanky.nvim and assert if shada is configured as a
backend while shada is disabled in Neovim options.
- Add [yazi.nvim] as a companion plugin for Yazi, the terminal file manager.
- Add [](#opt-vim.autocmds) and [](#opt-vim.augroups) to allow declaring
autocommands via Nix.
- Fix plugin `setupOpts` for yanky.nvim and assert if shada is configured as a
backend while shada is disabled in Neovim options.
- Add [yazi.nvim] as a companion plugin for Yazi, the terminal file manager.
- Add [snacks.nvim] under `vim.utility.snacks-nvim` as a general-purpose utility
plugin.
- Move LSPSaga to `setupOpts` format, allowing freeform configuration in
`vim.lsp.lspsaga.setupOpts`.
- Lazyload Lspsaga and remove default keybindings for it.
[amadaluzia](https://github.com/amadaluzia):
[haskell-tools.nvim]: https://github.com/MrcJkb/haskell-tools.nvim
- Add Haskell support under `vim.languages.haskell` using [haskell-tools.nvim].
[horriblename](https://github.com/horriblename):
[blink.cmp]: https://github.com/saghen/blink.cmp
- Add [blink.cmp] support.
[diniamo](https://github.com/diniamo):
- Add Odin support under `vim.languages.odin`.
@ -55,8 +102,8 @@
[aerial.nvim]: (https://github.com/stevearc/aerial.nvim)
[nvim-ufo]: (https://github.com/kevinhwang91/nvim-ufo)
- Add [aerial.nvim]
- Add [nvim-ufo]
- Add [aerial.nvim].
- Add [nvim-ufo].
[LilleAila](https://github.com/LilleAila):
@ -128,8 +175,10 @@
[thamenato](https://github.com/thamenato):
[ruff]: (https://github.com/astral-sh/ruff)
[cue]: (https://cuelang.org/)
- Add [ruff] as a formatter option in `vim.languages.python.format.type`.
- Add [cue] support under `vim.languages.cue`.
[QuiNzX](https://github.com/QuiNzX):
@ -138,5 +187,92 @@
[ARCIII](https://github.com/ArmandoCIII):
[leetcode.nvim]: https://github.com/kawre/leetcode.nvim
[codecompanion-nvim]: https://github.com/olimorris/codecompanion.nvim
- Add `vim.languages.zig.dap` support through pkgs.lldb dap adapter. Code
Inspiration from `vim.languages.clang.dap` implementation.
- Add [leetcode.nvim] plugin under `vim.utility.leetcode-nvim`.
- Add [codecompanion.nvim] plugin under `vim.assistant.codecompanion-nvim`.
[nezia1](https://github.com/nezia1):
- Add support for [nixd](https://github.com/nix-community/nixd) language server.
[jahanson](https://github.com/jahanson):
- Add [multicursors.nvim](https://github.com/smoka7/multicursors.nvim) to
available plugins, under `vim.utility.multicursors`.
- Add [hydra.nvim](https://github.com/nvimtools/hydra.nvim) as dependency for
`multicursors.nvim` and lazy loads by default.
[folospior](https://github.com/folospior):
- Fix plugin name for lsp/lspkind.
- Move `vim-illuminate` to `setupOpts format`
[iynaix](https://github.com/iynaix):
- Add lsp options support for [nixd](https://github.com/nix-community/nixd)
language server.
[Mr-Helpful](https://github.com/Mr-Helpful):
- Corrects pin names used for nvim themes.
[Libadoxon](https://github.com/Libadoxon):
- Add [git-conflict](https://github.com/akinsho/git-conflict.nvim) plugin for
resolving git conflicts.
- Add formatters for go: [gofmt](https://go.dev/blog/gofmt),
[golines](https://github.com/segmentio/golines) and
[gofumpt](https://github.com/mvdan/gofumpt).
[UltraGhostie](https://github.com/UltraGhostie)
- Add [harpoon](https://github.com/ThePrimeagen/harpoon) plugin for navigation
[MaxMur](https://github.com/TheMaxMur):
- Add YAML support under `vim.languages.yaml`.
[alfarel](https://github.com/alfarelcynthesis):
- Add missing `yazi.nvim` dependency (`snacks.nvim`).
- Add [mkdir.nvim](https://github.com/jghauser/mkdir.nvim) plugin for automatic
creation of parent directories when editing a nested file.
- Add [nix-develop.nvim](https://github.com/figsoda/nix-develop.nvim) plugin for
in-neovim `nix develop`, `nix shell` and more.
- Add [direnv.vim](https://github.com/direnv/direnv.vim) plugin for automatic
syncing of nvim shell environment with direnv's.
- Add [blink.cmp] source options and some default-disabled sources.
- Add [blink.cmp] option to add
[friendly-snippets](https://github.com/rafamadriz/friendly-snippets)
so blink.cmp can source snippets from it.
- Fix [blink.cmp] breaking when built-in sources were modified.
[TheColorman](https://github.com/TheColorman):
- Fix plugin `setupOpts` for `neovim-session-manager` having an invalid value
for `autoload_mode`.
[esdevries](https://github.com/esdevries):
[projekt0n/github-nvim-theme]: https://github.com/projekt0n/github-nvim-theme
- Add `github-nvim-theme` theme from [projekt0n/github-nvim-theme].
[BANanaD3V](https://github.com/BANanaD3V):
- `alpha` is now configured with nix.
[viicslen](https://github.com/viicslen):
- Add `intelephense` language server support under
`vim.languages.php.lsp.server`
[Butzist](https://github.com/butzist):
- Add Helm chart support under `vim.languages.helm`.

2852
flake.lock generated

File diff suppressed because it is too large Load diff

876
flake.nix
View file

@ -7,7 +7,7 @@
} @ inputs: let
# call the extended library with `inputs`
# inputs is used to get the original standard library, and to pass inputs to the plugin autodiscovery function
lib = import ./lib/stdlib-extended.nix inputs;
lib = import ./lib/stdlib-extended.nix {inherit inputs self;};
in
flake-parts.lib.mkFlake {
inherit inputs;
@ -17,6 +17,8 @@
# «https://github.com/nix-systems/nix-systems»
systems = import inputs.systems;
imports = [
./flake/templates
./flake/apps.nix
./flake/legacyPackages.nix
./flake/overlays.nix
@ -31,7 +33,7 @@
};
homeManagerModules = {
nvf = import ./flake/modules/home-manager.nix {inherit lib self;};
nvf = import ./flake/modules/home-manager.nix {inherit lib inputs;};
default = self.homeManagerModules.nvf;
neovim-flake =
lib.warn ''
@ -42,7 +44,7 @@
};
nixosModules = {
nvf = import ./flake/modules/nixos.nix {inherit lib self;};
nvf = import ./flake/modules/nixos.nix {inherit lib inputs;};
default = self.nixosModules.nvf;
neovim-flake =
lib.warn ''
@ -51,6 +53,8 @@
''
self.nixosModules.nvf;
};
inherit (lib.importJSON ./npins/sources.json) pins;
};
perSystem = {pkgs, ...}: {
@ -94,871 +98,5 @@
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
## 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
plugin-nvim-lspconfig = {
url = "github:neovim/nvim-lspconfig";
flake = false;
};
plugin-lspsaga = {
url = "github:tami5/lspsaga.nvim";
flake = false;
};
plugin-lspkind = {
url = "github:onsails/lspkind-nvim";
flake = false;
};
plugin-trouble = {
url = "github:folke/trouble.nvim";
flake = false;
};
plugin-nvim-treesitter-context = {
url = "github:nvim-treesitter/nvim-treesitter-context";
flake = false;
};
plugin-nvim-lightbulb = {
url = "github:kosayoda/nvim-lightbulb";
flake = false;
};
plugin-fastaction-nvim = {
url = "github:Chaitanyabsprip/fastaction.nvim";
flake = false;
};
plugin-lsp-signature = {
url = "github:ray-x/lsp_signature.nvim";
flake = false;
};
plugin-lsp-lines = {
url = "sourcehut:~whynothugo/lsp_lines.nvim";
flake = false;
};
plugin-none-ls = {
# https://github.com/nvimtools/none-ls.nvim/issues/58
url = "github:nvimtools/none-ls.nvim/bb680d752cec37949faca7a1f509e2fe67ab418a";
flake = false;
};
plugin-nvim-docs-view = {
url = "github:amrbashir/nvim-docs-view";
flake = false;
};
plugin-otter-nvim = {
url = "github:jmbuhr/otter.nvim";
flake = false;
};
# Language support
plugin-sqls-nvim = {
url = "github:nanotee/sqls.nvim";
flake = false;
};
plugin-rustaceanvim = {
url = "github:mrcjkb/rustaceanvim";
flake = false;
};
plugin-flutter-tools = {
url = "github:akinsho/flutter-tools.nvim";
flake = false;
};
plugin-neodev-nvim = {
url = "github:folke/neodev.nvim";
flake = false;
};
plugin-elixir-tools = {
url = "github:elixir-tools/elixir-tools.nvim";
flake = false;
};
plugin-ts-error-translator = {
url = "github:dmmulroy/ts-error-translator.nvim";
flake = false;
};
plugin-typst-preview-nvim = {
url = "github:chomosuke/typst-preview.nvim";
flake = false;
};
plugin-nvim-metals = {
url = "github:scalameta/nvim-metals";
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
plugin-registers = {
url = "github:tversteeg/registers.nvim";
flake = false;
};
plugin-nvim-neoclip = {
url = "github:AckslD/nvim-neoclip.lua";
flake = false;
};
# Pickers
plugin-telescope = {
url = "github:nvim-telescope/telescope.nvim";
flake = false;
};
plugin-fzf-lua = {
url = "github:ibhagwan/fzf-lua";
flake = false;
};
# Runners
plugin-run-nvim = {
url = "github:diniamo/run.nvim";
flake = false;
};
# Debuggers
plugin-nvim-dap = {
url = "github:mfussenegger/nvim-dap";
flake = false;
};
plugin-nvim-dap-ui = {
url = "github:rcarriga/nvim-dap-ui";
flake = false;
};
plugin-nvim-dap-go = {
url = "github:leoluz/nvim-dap-go";
flake = false;
};
# Filetrees
plugin-nvim-tree-lua = {
url = "github:nvim-tree/nvim-tree.lua";
flake = false;
};
plugin-neo-tree-nvim = {
url = "github:nvim-neo-tree/neo-tree.nvim";
flake = false;
};
# Tablines
plugin-nvim-bufferline-lua = {
url = "github:akinsho/nvim-bufferline.lua";
flake = false;
};
# Statuslines
plugin-lualine = {
url = "github:hoob3rt/lualine.nvim";
flake = false;
};
plugin-nvim-cmp = {
url = "github:hrsh7th/nvim-cmp";
flake = false;
};
plugin-cmp-buffer = {
url = "github:hrsh7th/cmp-buffer";
flake = false;
};
plugin-cmp-nvim-lsp = {
url = "github:hrsh7th/cmp-nvim-lsp";
flake = false;
};
plugin-cmp-path = {
url = "github:hrsh7th/cmp-path";
flake = false;
};
plugin-cmp-treesitter = {
url = "github:ray-x/cmp-treesitter";
flake = false;
};
plugin-cmp-luasnip = {
url = "github:saadparwaiz1/cmp_luasnip";
flake = false;
};
# snippets
plugin-luasnip = {
url = "github:L3MON4D3/LuaSnip";
flake = false;
};
plugin-friendly-snippets = {
url = "github:rafamadriz/friendly-snippets";
flake = false;
};
# Presence
plugin-neocord = {
url = "github:IogaMaster/neocord";
flake = false; # uses flake-utils, avoid the flake
};
# Autopairs
plugin-nvim-autopairs = {
url = "github:windwp/nvim-autopairs";
flake = false;
};
plugin-nvim-ts-autotag = {
url = "github:windwp/nvim-ts-autotag";
flake = false;
};
# Commenting
plugin-comment-nvim = {
url = "github:numToStr/Comment.nvim";
flake = false;
};
plugin-todo-comments = {
url = "github:folke/todo-comments.nvim";
flake = false;
};
# Buffer tools
plugin-bufdelete-nvim = {
url = "github:famiu/bufdelete.nvim";
flake = false;
};
# Dashboard Utilities
plugin-dashboard-nvim = {
url = "github:glepnir/dashboard-nvim";
flake = false;
};
plugin-alpha-nvim = {
url = "github:goolord/alpha-nvim";
flake = false;
};
plugin-vim-startify = {
url = "github:mhinz/vim-startify";
flake = false;
};
# Themes
plugin-base16 = {
url = "github:rrethy/base16-nvim";
flake = false;
};
plugin-tokyonight = {
url = "github:folke/tokyonight.nvim";
flake = false;
};
plugin-onedark = {
url = "github:navarasu/onedark.nvim";
flake = false;
};
plugin-catppuccin = {
url = "github:catppuccin/nvim";
flake = false;
};
plugin-dracula = {
url = "github:Mofiqul/dracula.nvim";
flake = false;
};
plugin-oxocarbon = {
url = "github:nyoom-engineering/oxocarbon.nvim";
flake = false;
};
plugin-gruvbox = {
url = "github:ellisonleao/gruvbox.nvim";
flake = false;
};
plugin-rose-pine = {
url = "github:rose-pine/neovim";
flake = false;
};
plugin-nord = {
url = "github:gbprod/nord.nvim";
flake = false;
};
# Rust crates
plugin-crates-nvim = {
url = "github:Saecki/crates.nvim";
flake = false;
};
# Project Management
plugin-project-nvim = {
url = "github:ahmedkhalf/project.nvim";
flake = false;
};
# Visuals
plugin-nvim-cursorline = {
url = "github:yamatsum/nvim-cursorline";
flake = false;
};
plugin-nvim-scrollbar = {
url = "github:petertriho/nvim-scrollbar";
flake = false;
};
plugin-cinnamon-nvim = {
url = "github:declancm/cinnamon.nvim";
flake = false;
};
plugin-cellular-automaton = {
url = "github:Eandrju/cellular-automaton.nvim";
flake = false;
};
plugin-indent-blankline = {
url = "github:lukas-reineke/indent-blankline.nvim";
flake = false;
};
plugin-nvim-web-devicons = {
url = "github:nvim-tree/nvim-web-devicons";
flake = false;
};
plugin-tiny-devicons-auto-colors = {
url = "github:rachartier/tiny-devicons-auto-colors.nvim";
flake = false;
};
plugin-gitsigns-nvim = {
url = "github:lewis6991/gitsigns.nvim";
flake = false;
};
plugin-vim-fugitive = {
url = "github:tpope/vim-fugitive";
flake = false;
};
plugin-fidget-nvim = {
url = "github:j-hui/fidget.nvim";
flake = false;
};
plugin-highlight-undo = {
url = "github:tzachar/highlight-undo.nvim";
flake = false;
};
plugin-render-markdown-nvim = {
url = "github:MeanderingProgrammer/render-markdown.nvim";
flake = false;
};
plugin-rainbow-delimiters = {
url = "github:HiPhish/rainbow-delimiters.nvim";
flake = false;
};
# Minimap
plugin-minimap-vim = {
url = "github:wfxr/minimap.vim";
flake = false;
};
plugin-codewindow-nvim = {
url = "github:gorbit99/codewindow.nvim";
flake = false;
};
# Notifications
plugin-nvim-notify = {
url = "github:rcarriga/nvim-notify";
flake = false;
};
# Utilities
plugin-ccc = {
url = "github:uga-rosa/ccc.nvim";
flake = false;
};
plugin-diffview-nvim = {
url = "github:sindrets/diffview.nvim";
flake = false;
};
plugin-icon-picker-nvim = {
url = "github:ziontee113/icon-picker.nvim";
flake = false;
};
plugin-which-key = {
url = "github:folke/which-key.nvim";
flake = false;
};
plugin-cheatsheet-nvim = {
url = "github:sudormrfbin/cheatsheet.nvim";
flake = false;
};
plugin-gesture-nvim = {
url = "github:notomo/gesture.nvim";
flake = false;
};
plugin-hop-nvim = {
url = "github:phaazon/hop.nvim";
flake = false;
};
plugin-leap-nvim = {
url = "github:ggandor/leap.nvim";
flake = false;
};
plugin-smartcolumn = {
url = "github:m4xshen/smartcolumn.nvim";
flake = false;
};
plugin-nvim-surround = {
url = "github:kylechui/nvim-surround";
flake = false;
};
plugin-glow-nvim = {
url = "github:ellisonleao/glow.nvim";
flake = false;
};
plugin-image-nvim = {
url = "github:3rd/image.nvim";
flake = false;
};
plugin-precognition-nvim = {
url = "github:tris203/precognition.nvim";
flake = false;
};
# Note-taking
plugin-obsidian-nvim = {
url = "github:epwalsh/obsidian.nvim";
flake = false;
};
plugin-orgmode-nvim = {
url = "github:nvim-orgmode/orgmode";
flake = false;
};
plugin-mind-nvim = {
url = "github:phaazon/mind.nvim";
flake = false;
};
# Spellchecking
plugin-vim-dirtytalk = {
url = "github:psliwka/vim-dirtytalk";
flake = false;
};
# Terminal
plugin-toggleterm-nvim = {
url = "github:akinsho/toggleterm.nvim";
flake = false;
};
# UI
plugin-nvim-navbuddy = {
url = "github:SmiteshP/nvim-navbuddy";
flake = false;
};
plugin-nvim-navic = {
url = "github:SmiteshP/nvim-navic";
flake = false;
};
plugin-noice-nvim = {
url = "github:folke/noice.nvim";
flake = false;
};
plugin-modes-nvim = {
url = "github:mvllow/modes.nvim";
flake = false;
};
plugin-nvim-colorizer-lua = {
url = "github:NvChad/nvim-colorizer.lua";
flake = false;
};
plugin-vim-illuminate = {
url = "github:RRethy/vim-illuminate";
flake = false;
};
# Assistant
plugin-chatgpt = {
url = "github:jackMort/ChatGPT.nvim";
flake = false;
};
plugin-copilot-lua = {
url = "github:zbirenbaum/copilot.lua";
flake = false;
};
plugin-copilot-cmp = {
url = "github:zbirenbaum/copilot-cmp";
flake = false;
};
# Session management
plugin-nvim-session-manager = {
url = "github:Shatur/neovim-session-manager";
flake = false;
};
# Dependencies
plugin-plenary-nvim = {
# (required by crates-nvim)
url = "github:nvim-lua/plenary.nvim";
flake = false;
};
plugin-dressing-nvim = {
# (required by icon-picker-nvim)
url = "github:stevearc/dressing.nvim";
flake = false;
};
plugin-vim-markdown = {
# (required by obsidian-nvim)
url = "github:preservim/vim-markdown";
flake = false;
};
plugin-tabular = {
# (required by vim-markdown)
url = "github:godlygeek/tabular";
flake = false;
};
plugin-lua-utils-nvim = {
url = "github:nvim-neorg/lua-utils.nvim";
flake = false;
};
plugin-pathlib-nvim = {
url = "github:pysan3/pathlib.nvim";
flake = false;
};
plugin-neorg = {
url = "github:nvim-neorg/neorg";
flake = false;
};
plugin-neorg-telescope = {
url = "github:nvim-neorg/neorg-telescope";
flake = false;
};
plugin-nui-nvim = {
# (required by noice.nvim)
url = "github:MunifTanjim/nui.nvim";
flake = false;
};
plugin-vim-repeat = {
# (required by leap.nvim)
url = "github:tpope/vim-repeat";
flake = false;
};
plugin-nvim-nio = {
# (required by nvim-dap-ui)
url = "github:nvim-neotest/nvim-nio";
flake = false;
};
plugin-promise-async = {
url = "github:kevinhwang91/promise-async";
flake = false;
};
plugin-nvim-ufo = {
url = "github:kevinhwang91/nvim-ufo";
flake = false;
};
plugin-new-file-template-nvim = {
# (required by new-file-template.nvim)
url = "github:otavioschwanck/new-file-template.nvim";
flake = false;
};
plugin-haskell-tools-nvim = {
url = "github:mrcjkb/haskell-tools.nvim";
flake = false;
};
plugin-aerial-nvim = {
url = "github:stevearc/aerial.nvim";
flake = false;
};
# Mini.nvim
plugin-mini-ai = {
url = "github:echasnovski/mini.ai";
flake = false;
};
plugin-mini-align = {
url = "github:echasnovski/mini.align";
flake = false;
};
plugin-mini-animate = {
url = "github:echasnovski/mini.animate";
flake = false;
};
plugin-mini-base16 = {
url = "github:echasnovski/mini.base16";
flake = false;
};
plugin-mini-basics = {
url = "github:echasnovski/mini.basics";
flake = false;
};
plugin-mini-bracketed = {
url = "github:echasnovski/mini.bracketed";
flake = false;
};
plugin-mini-bufremove = {
url = "github:echasnovski/mini.bufremove";
flake = false;
};
plugin-mini-clue = {
url = "github:echasnovski/mini.clue";
flake = false;
};
plugin-mini-colors = {
url = "github:echasnovski/mini.colors";
flake = false;
};
plugin-mini-comment = {
url = "github:echasnovski/mini.comment";
flake = false;
};
plugin-mini-completion = {
url = "github:echasnovski/mini.completion";
flake = false;
};
plugin-mini-diff = {
url = "github:echasnovski/mini.diff";
flake = false;
};
plugin-mini-doc = {
url = "github:echasnovski/mini.doc";
flake = false;
};
plugin-mini-extra = {
url = "github:echasnovski/mini.extra";
flake = false;
};
plugin-mini-files = {
url = "github:echasnovski/mini.files";
flake = false;
};
plugin-mini-fuzzy = {
url = "github:echasnovski/mini.fuzzy";
flake = false;
};
plugin-mini-git = {
url = "github:echasnovski/mini-git";
flake = false;
};
plugin-mini-hipatterns = {
url = "github:echasnovski/mini.hipatterns";
flake = false;
};
plugin-mini-hues = {
url = "github:echasnovski/mini.hues";
flake = false;
};
plugin-mini-icons = {
url = "github:echasnovski/mini.icons";
flake = false;
};
plugin-mini-indentscope = {
url = "github:echasnovski/mini.indentscope";
flake = false;
};
plugin-mini-jump = {
url = "github:echasnovski/mini.jump";
flake = false;
};
plugin-mini-jump2d = {
url = "github:echasnovski/mini.jump2d";
flake = false;
};
plugin-mini-map = {
url = "github:echasnovski/mini.map";
flake = false;
};
plugin-mini-misc = {
url = "github:echasnovski/mini.misc";
flake = false;
};
plugin-mini-move = {
url = "github:echasnovski/mini.move";
flake = false;
};
plugin-mini-notify = {
url = "github:echasnovski/mini.notify";
flake = false;
};
plugin-mini-operators = {
url = "github:echasnovski/mini.operators";
flake = false;
};
plugin-mini-pairs = {
url = "github:echasnovski/mini.pairs";
flake = false;
};
plugin-mini-pick = {
url = "github:echasnovski/mini.pick";
flake = false;
};
plugin-mini-sessions = {
url = "github:echasnovski/mini.sessions";
flake = false;
};
plugin-mini-snippets = {
url = "github:echasnovski/mini.snippets";
flake = false;
};
plugin-mini-splitjoin = {
url = "github:echasnovski/mini.splitjoin";
flake = false;
};
plugin-mini-starter = {
url = "github:echasnovski/mini.starter";
flake = false;
};
plugin-mini-statusline = {
url = "github:echasnovski/mini.statusline";
flake = false;
};
plugin-mini-surround = {
url = "github:echasnovski/mini.surround";
flake = false;
};
plugin-mini-tabline = {
url = "github:echasnovski/mini.tabline";
flake = false;
};
plugin-mini-test = {
url = "github:echasnovski/mini.test";
flake = false;
};
plugin-mini-trailspace = {
url = "github:echasnovski/mini.trailspace";
flake = false;
};
plugin-mini-visits = {
url = "github:echasnovski/mini.visits";
flake = false;
};
};
}

View file

@ -9,7 +9,7 @@
default = self'.devShells.lsp;
nvim-nix = pkgs.mkShellNoCC {packages = [config.packages.nix];};
lsp = pkgs.mkShellNoCC {
packages = with pkgs; [nil statix deadnix alejandra];
packages = with pkgs; [nil statix deadnix alejandra npins];
};
};

View file

@ -1,4 +1,8 @@
{inputs, ...}: {
{
inputs,
self,
...
}: {
perSystem = {
system,
inputs',
@ -9,10 +13,21 @@
overlays = [
inputs.self.overlays.default
(_: _: {
(final: prev: {
# Build nil from source to get most recent
# features as they are added.
nil = inputs'.nil.packages.default;
blink-cmp = let
pin = self.pins.blink-cmp;
in
final.callPackage ./legacyPackages/blink-cmp.nix {
inherit (pin) version;
src = prev.fetchFromGitHub {
inherit (pin.repository) owner repo;
rev = pin.revision;
sha256 = pin.hash;
};
};
})
];
};

View file

@ -0,0 +1,52 @@
{
rustPlatform,
hostPlatform,
vimUtils,
git,
src,
version,
fetchpatch,
}: let
blink-fuzzy-lib = rustPlatform.buildRustPackage {
pname = "blink-fuzzy-lib";
inherit version src;
# TODO: remove this if plugin stops using nightly rust
env.RUSTC_BOOTSTRAP = true;
useFetchCargoVendor = true;
cargoHash = "sha256-F1wh/TjYoiIbDY3J/prVF367MKk3vwM7LqOpRobOs7I=";
nativeBuildInputs = [git];
};
libExt =
if hostPlatform.isDarwin
then "dylib"
else "so";
in
vimUtils.buildVimPlugin {
pname = "blink-cmp";
inherit version src;
# blink references a repro.lua which is placed outside the lua/ directory
doCheck = false;
preInstall = ''
mkdir -p target/release
ln -s ${blink-fuzzy-lib}/lib/libblink_cmp_fuzzy.${libExt} target/release/libblink_cmp_fuzzy.${libExt}
echo -n "nix" > target/release/version
'';
# Borrowed from nixpkgs
# TODO: Remove this patch when updating to next version
patches = [
(fetchpatch {
name = "blink-add-bypass-for-nix.patch";
url = "https://github.com/Saghen/blink.cmp/commit/6c83ef1ae34abd7ef9a32bfcd9595ac77b61037c.diff?full_index=1";
hash = "sha256-304F1gDDKVI1nXRvvQ0T1xBN+kHr3jdmwMMp8CNl+GU=";
})
];
# Module for reproducing issues
nvimSkipModule = ["repro"];
}

View file

@ -1,13 +1,13 @@
# Home Manager module
{
self,
inputs,
lib,
}: {
config,
pkgs,
...
}: let
inherit (self) packages inputs;
inherit (inputs.self) packages;
inherit (lib) maintainers;
inherit (lib.modules) mkIf mkAliasOptionModule;
inherit (lib.lists) optional;

View file

@ -1,13 +1,13 @@
# NixOS module
{
self,
inputs,
lib,
}: {
config,
pkgs,
...
}: let
inherit (self) inputs packages;
inherit (inputs.self) packages;
inherit (lib) maintainers;
inherit (lib.modules) mkIf mkOverride mkAliasOptionModule;
inherit (lib.lists) optional;

View file

@ -10,10 +10,10 @@
nixConfig = import ../configuration.nix false;
maximalConfig = import ../configuration.nix true;
in {
flake.overlays.default = _final: prev: {
flake.overlays.default = final: _prev: {
inherit neovimConfiguration;
neovim-nix = buildPkg prev [nixConfig];
neovim-maximal = buildPkg prev [maximalConfig];
neovim-nix = buildPkg final [nixConfig];
neovim-maximal = buildPkg final [maximalConfig];
devPkg = buildPkg pkgs [nixConfig {config.vim.languages.html.enable = pkgs.lib.mkForce true;}];
};
}

View file

@ -19,9 +19,11 @@
in
pkgs.testers.lycheeLinkCheck {
inherit site;
remap = {
"https://notashelf.github.io/nvf/" = site;
};
extraConfig = {
exclude = [];
include_mail = true;
@ -29,43 +31,39 @@
};
};
# Build and open the built manual in your system browser
docs-html-wrapped = pkgs.writeScriptBin "docs-html-wrapped" ''
#!${pkgs.stdenv.shell}
# use xdg-open to open the docs in the browser
${pkgs.xdg-utils}/bin/xdg-open ${docs.manual.html}
'';
# Helper utility for building the HTML manual and opening it in the
# browser with $BROWSER or using xdg-open as a fallback tool.
# Adapted from Home-Manager, available under the MIT license.
docs-html-wrapped = let
xdg-open = lib.getExe' pkgs.xdg-utils "xdg-open";
docs-html = docs.manual.html + /share/doc/nvf;
in
pkgs.writeShellScriptBin "docs-html-wrapped" ''
set -euo pipefail
if [[ ! -v BROWSER || -z $BROWSER ]]; then
for candidate in xdg-open open w3m; do
BROWSER="$(type -P $candidate || true)"
if [[ -x $BROWSER ]]; then
break;
fi
done
fi
if [[ ! -v BROWSER || -z $BROWSER ]]; then
echo "$0: unable to start a web browser; please set \$BROWSER"
echo "$0: Trying xdg-open as a fallback"
${xdg-open} ${docs-html}/index.xhtml
else
echo "\$BROWSER is set. Attempting to open manual"
exec "$BROWSER" "${docs-html}/index.xhtml"
fi
'';
# Exposed neovim configurations
nix = config.legacyPackages.neovim-nix;
maximal = config.legacyPackages.neovim-maximal;
default = config.legacyPackages.neovim-nix;
# Published docker images
docker-nix = let
inherit (pkgs) bash gitFull buildEnv;
inherit (config.legacyPackages) neovim-nix;
in
pkgs.dockerTools.buildImage {
name = "nvf";
tag = "latest";
copyToRoot = buildEnv {
name = "neovim-root";
pathsToLink = ["/bin"];
paths = [
neovim-nix
gitFull
bash
];
};
config = {
Cmd = ["${neovim-nix}/bin/nvim"];
WorkingDir = "/home/neovim/demo";
Volumes = {"/home/neovim/demo" = {};};
};
};
};
};
}

View file

@ -0,0 +1,17 @@
{
flake.templates = {
standalone = {
path = ./standalone;
description = "Standalone flake template for nvf";
welcomeText = ''
Template flake.nix has been created in flake.nix!
Note that this is a very basic example to bootstrap nvf for you. Please edit your
configuration as described in the nvf manual before using this template. The
configured packages will be ran with 'nix run .' or 'nix run .#neovimConfigured'
Happy editing!
'';
};
};
}

View file

@ -0,0 +1,64 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nvf.url = "github:notashelf/nvf";
};
outputs = {
self,
nixpkgs,
...
} @ inputs: let
# An abstraction over systems to easily provide the same package
# for multiple systems. This is preferable to abstraction libraries.
forEachSystem = nixpkgs.lib.genAttrs ["x86_64-linux"];
in {
packages = forEachSystem (system: let
pkgs = inputs.nixpkgs.legacyPackages.${system};
# A module to be evaluated via lib.evalModules inside nvf's module system.
# All options supported by nvf will go under config.vim to create the final
# wrapped package. You may also add some new *options* under options.* to
# expand the module system.
configModule = {
# You may browse available options for nvf on the online manual. Please see
# <https://notashelf.github.io/nvf/options.html>
config.vim = {
theme.enable = true;
# Language support and automatic configuration of companion plugins.
# Note that enabling, e.g., languages.<lang>.diagnostics will automatically
# enable top-level options such as enableLSP or enableExtraDiagnostics as
# they are needed.
languages = {
enableLSP = true;
enableFormat = true;
enableTreesitter = true;
enableExtraDiagnostics = true;
# Nix language and diagnostics.
nix.enable = true;
};
};
};
# Evaluate any and all modules to create the wrapped Neovim package.
neovimConfigured = inputs.nvf.lib.neovimConfiguration {
inherit pkgs;
modules = [
# Configuration module to be imported. You may define multiple modules
# or even import them from other files (e.g., ./modules/lsp.nix) to
# better modularize your configuration.
configModule
];
};
in {
# Packages to be exposed under packages.<system>. Those can accessed
# directly from package outputs in other flakes if this flake is added
# as an input. You may run those packages with 'nix run .#<package>'
default = self.packages.${system}.neovim;
neovimConfigured = neovimConfigured.neovim;
});
};
}

View file

@ -24,7 +24,7 @@ in {
entryAfter, and entryBefore to a topologically sorted list of
entries.
Internally this function uses the `toposort` function in
Internally this function uses the `topoSort` function in
`<nixpkgs/lib/lists.nix>` and its value is accordingly.
Specifically, the result on success is
@ -136,16 +136,26 @@ in {
entriesAfter = tag: entriesBetween tag [];
entriesBefore = tag: before: entriesBetween tag before [];
# mkLuarcSection and mkVimrcSection take a section DAG
# and return a string containing a comment to identify
# mkLuarcSection takes a section DAG, containing 'name' and 'data' fields
# then returns a string containing a comment to identify the section, and
# the data contained within the section.
# the section, and the data contained within the section
#
# all operations are done without any modifications
# to the inputted section data
mkLuarcSection = section: ''
-- SECTION: ${section.name}
${section.data}
'';
# All operations are done without any modifications to the inputted section
# data, but if a non-string is passed to name or data, then it will try to
# coerce it into a string, which may fail. Setting data to "" or null will
# return an empty string.
#
# section.data should never be null, though taking 'null' as a value that
# can "clear" the DAG might come in handy for filtering sections more easily.
# Or perhaps simply unsetting them from an user perspective.
mkLuarcSection = section:
if section.data == "" || section.data == null
then ""
else ''
-- SECTION: ${section.name}
${section.data}
'';
resolveDag = {
name,

View file

@ -1,10 +1,10 @@
{
self,
inputs,
lib,
...
}: {
types = import ./types {inherit inputs lib;};
types = import ./types {inherit lib;};
config = import ./config.nix {inherit lib;};
binds = import ./binds.nix {inherit lib;};
dag = import ./dag.nix {inherit lib;};
@ -12,5 +12,5 @@
lists = import ./lists.nix {inherit lib;};
attrsets = import ./attrsets.nix {inherit lib;};
lua = import ./lua.nix {inherit lib;};
neovimConfiguration = import ../modules {inherit inputs lib;};
neovimConfiguration = import ../modules {inherit self inputs lib;};
}

View file

@ -1,6 +1,10 @@
# Convenience function that returns the given Nixpkgs standard library
# extended with our functions using `lib.extend`.
inputs:
{
inputs,
self,
...
} @ args:
inputs.nixpkgs.lib.extend (self: super: {
# WARNING: New functions should not be added here, but to files
# imported by `./default.nix` under their own categories. If your
@ -12,7 +16,7 @@ inputs.nixpkgs.lib.extend (self: super: {
# E.g. for an input called `nvf`, `inputs.nvf.lib.nvim` will return the set
# below.
nvim = import ./. {
inherit inputs;
inherit (args) inputs self;
lib = self;
};

View file

@ -1,10 +1,6 @@
{
inputs,
lib,
...
}: let
{lib}: let
typesDag = import ./dag.nix {inherit lib;};
typesPlugin = import ./plugins.nix {inherit inputs lib;};
typesPlugin = import ./plugins.nix {inherit lib;};
typesLanguage = import ./languages.nix {inherit lib;};
customTypes = import ./custom.nix {inherit lib;};
in {

View file

@ -1,12 +1,8 @@
{
inputs,
lib,
...
}: let
{lib}: let
inherit (lib.options) mkOption;
inherit (lib.attrsets) attrNames mapAttrs' filterAttrs nameValuePair;
inherit (lib.strings) hasPrefix removePrefix;
inherit (lib.types) submodule either package enum str lines attrsOf anything listOf nullOr;
inherit (lib.types) submodule either package enum str lines anything listOf nullOr;
# Get the names of all flake inputs that start with the given prefix.
fromInputs = {
@ -15,11 +11,8 @@
}:
mapAttrs' (n: v: nameValuePair (removePrefix prefix n) {src = v;}) (filterAttrs (n: _: hasPrefix prefix n) inputs);
# Get the names of all flake inputs that start with the given prefix.
pluginInputNames = attrNames (fromInputs {
inherit inputs;
prefix = "plugin-";
});
# Get the names of all npins
pluginInputNames = attrNames (lib.importJSON ../../npins/sources.json).pins;
# You can either use the name of the plugin or a package.
pluginType = nullOr (

View file

@ -1,4 +1,5 @@
{
self,
inputs,
lib,
}: {
@ -23,7 +24,7 @@
specialArgs =
extraSpecialArgs
// {
inherit inputs;
inherit self inputs;
modulesPath = toString ./.;
};
modules = concatLists [

View file

@ -4,6 +4,7 @@
inherit (lib.nvim.config) batchRenameOptions;
renamedVimOpts = batchRenameOptions ["vim"] ["vim" "options"] {
# 2024-12-01
colourTerm = "termguicolors";
mouseSupport = "mouse";
cmdHeight = "cmdheight";
@ -15,6 +16,9 @@
autoIndent = "autoindent";
wordWrap = "wrap";
showSignColumn = "signcolumn";
# 2025-02-07
scrollOff = "scrolloff";
};
in {
imports = concatLists [
@ -93,9 +97,15 @@ in {
# 2024-12-02
(mkRenamedOptionModule ["vim" "enableEditorconfig"] ["vim" "globals" "editorconfig"])
# 2025-02-06
(mkRemovedOptionModule ["vim" "disableArrows"] ''
Top-level convenience options are now in the process of being removed from nvf as
their behaviour was abstract, and confusing. Please use 'vim.options' or 'vim.luaConfigRC'
to replicate previous behaviour.
'')
]
# 2024-12-01
# Migrated via batchRenameOptions. Further batch renames must be below this line.
renamedVimOpts
];

View file

@ -23,7 +23,9 @@
"completion"
"dashboard"
"debugger"
"diagnostics"
"filetree"
"formatter"
"git"
"languages"
"lsp"

View file

@ -0,0 +1,185 @@
{
config,
lib,
...
}: let
inherit (lib.options) mkOption mkEnableOption literalExpression;
inherit (lib.lists) filter;
inherit (lib.strings) optionalString;
inherit (lib.types) nullOr submodule listOf str bool;
inherit (lib.nvim.types) luaInline;
inherit (lib.nvim.lua) toLuaObject;
inherit (lib.nvim.dag) entryAfter;
autocommandType = submodule {
options = {
enable =
mkEnableOption ""
// {
default = true;
description = "Whether to enable this autocommand";
};
event = mkOption {
type = nullOr (listOf str);
default = null;
example = ["BufRead" "BufWritePre"];
description = "The event(s) that trigger the autocommand.";
};
pattern = mkOption {
type = nullOr (listOf str);
default = null;
example = ["*.lua" "*.vim"];
description = "The file pattern(s) that determine when the autocommand applies).";
};
callback = mkOption {
type = nullOr luaInline;
default = null;
example = literalExpression ''
mkLuaInline '''
function()
print("Saving a Lua file...")
end
''''
'';
description = "The file pattern(s) that determine when the autocommand applies.";
};
command = mkOption {
type = nullOr str;
default = null;
description = "Vim command string instead of a Lua function.";
};
group = mkOption {
type = nullOr str;
default = null;
example = "MyAutoCmdGroup";
description = "An optional autocommand group to manage related autocommands.";
};
desc = mkOption {
type = nullOr str;
default = null;
example = "Notify when saving a Lua file";
description = "A description for the autocommand.";
};
once = mkOption {
type = bool;
default = false;
description = "Whether autocommand run only once.";
};
nested = mkOption {
type = bool;
default = false;
description = "Whether to allow nested autocommands to trigger.";
};
};
};
autogroupType = submodule {
options = {
enable =
mkEnableOption ""
// {
default = true;
description = "Whether to enable this autogroup";
};
name = mkOption {
type = str;
example = "MyAutoCmdGroup";
description = "The name of the autocommand group.";
};
clear = mkOption {
type = bool;
default = true;
description = ''
Whether to clear existing autocommands in this group before defining new ones.
This helps avoid duplicate autocommands.
'';
};
};
};
cfg = config.vim;
in {
options.vim = {
augroups = mkOption {
type = listOf autogroupType;
default = [];
description = ''
A list of Neovim autogroups, which are used to organize and manage related
autocommands together. Groups allow multiple autocommands to be cleared
or redefined collectively, preventing duplicate definitions.
Each autogroup consists of a name, a boolean indicating whether to clear
existing autocommands, and a list of associated autocommands.
'';
};
autocmds = mkOption {
type = listOf autocommandType;
default = [];
description = ''
A list of Neovim autocommands to be registered.
Each entry defines an autocommand, specifying events, patterns, optional
callbacks, commands, groups, and execution settings.
'';
};
};
config = {
vim = let
enabledAutocommands = filter (cmd: cmd.enable) cfg.autocmds;
enabledAutogroups = filter (au: au.enable) cfg.augroups;
in {
luaConfigRC = {
augroups = entryAfter ["pluginConfigs"] (optionalString (enabledAutogroups != []) ''
local nvf_autogroups = {}
for _, group in ipairs(${toLuaObject enabledAutogroups}) do
if group.name then
nvf_autogroups[group.name] = { clear = group.clear }
end
end
for group_name, options in pairs(nvf_autogroups) do
vim.api.nvim_create_augroup(group_name, options)
end
'');
autocmds = entryAfter ["pluginConfigs"] (optionalString (enabledAutocommands != []) ''
local nvf_autocommands = ${toLuaObject enabledAutocommands}
for _, autocmd in ipairs(nvf_autocommands) do
vim.api.nvim_create_autocmd(
autocmd.event,
{
group = autocmd.group,
pattern = autocmd.pattern,
buffer = autocmd.buffer,
desc = autocmd.desc,
callback = autocmd.callback,
command = autocmd.command,
once = autocmd.once,
nested = autocmd.nested
}
)
end
'');
};
};
assertions = [
{
assertion = builtins.all (cmd: (cmd.command == null || cmd.callback == null)) cfg.autocmds;
message = "An autocommand cannot have both 'command' and 'callback' defined at the same time.";
}
];
};
}

View file

@ -16,12 +16,6 @@
cfg = config.vim;
in {
options.vim = {
disableArrows = mkOption {
type = bool;
default = false;
description = "Set to prevent arrow keys from moving cursor";
};
hideSearchHighlight = mkOption {
type = bool;
default = false;

View file

@ -1,5 +1,6 @@
{
imports = [
./autocmds.nix
./basic.nix
./debug.nix
./highlight.nix

View file

@ -26,34 +26,6 @@
in {
config = {
vim.keymaps = mkMerge [
(
mkIf cfg.disableArrows [
{
key = "<up>";
mode = ["n" "i"];
action = "<nop>";
noremap = false;
}
{
key = "<down>";
mode = ["n" "i"];
action = "<nop>";
noremap = false;
}
{
key = "<left>";
mode = ["n" "i"];
action = "<nop>";
noremap = false;
}
{
key = "<right>";
mode = ["n" "i"];
action = "<nop>";
noremap = false;
}
]
)
(
pipe cfg.maps
[

View file

@ -30,17 +30,19 @@
in {
config = mkIf cfg.enable {
vim = {
startPlugins = [
"chatgpt"
];
startPlugins = ["chatgpt-nvim"];
pluginRC.chagpt = entryAnywhere ''
require("chatgpt").setup(${toLuaObject cfg.setupOpts})
'';
maps.normal = mkMerge [
(mkSetBinding mappings.chatGpt "<cmd>ChatGPT<CR>")
maps
];
maps.visual = maps;
maps = {
visual = maps;
normal = mkMerge [
(mkSetBinding mappings.chatGpt "<cmd>ChatGPT<CR>")
maps
];
};
};
};
}

View file

@ -0,0 +1,278 @@
{lib, ...}: let
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) int str enum nullOr attrs;
inherit (lib.nvim.types) mkPluginSetupOption luaInline;
in {
options.vim.assistant = {
codecompanion-nvim = {
enable = mkEnableOption "complementary neovim plugin for codecompanion.nvim";
setupOpts = mkPluginSetupOption "codecompanion-nvim" {
opts = {
send_code = mkEnableOption "code from being sent to the LLM.";
log_level = mkOption {
type = enum ["DEBUG" "INFO" "ERROR" "TRACE"];
default = "ERROR";
description = "Change the level of logging.";
};
language = mkOption {
type = str;
default = "English";
description = "Specify which language an LLM should respond in.";
};
};
display = {
diff = {
enabled =
mkEnableOption ""
// {
default = true;
description = "a diff view to see the changes made by the LLM.";
};
close_chat_at = mkOption {
type = int;
default = 240;
description = ''
Close an open chat buffer if the
total columns of your display are less than...
'';
};
layout = mkOption {
type = enum ["vertical" "horizontal"];
default = "vertical";
description = "Type of split for default provider.";
};
provider = mkOption {
type = enum ["default" "mini_diff"];
default = "default";
description = "The preferred kind of provider.";
};
};
inline = {
layout = mkOption {
type = enum ["vertical" "horizontal" "buffer"];
default = "vertical";
description = "Customize how output is created in new buffer.";
};
};
chat = {
auto_scroll = mkEnableOption "automatic page scrolling.";
show_settings = mkEnableOption ''
LLM settings to appear at the top of the chat buffer.
'';
start_in_insert_mode = mkEnableOption ''
opening the chat buffer in insert mode.
'';
show_header_separator = mkEnableOption ''
header separators in the chat buffer.
Set this to false if you're using an
external markdown formatting plugin.
'';
show_references =
mkEnableOption ""
// {
default = true;
description = "references in the chat buffer.";
};
show_token_count =
mkEnableOption ""
// {
default = true;
description = "the token count for each response.";
};
intro_message = mkOption {
type = str;
default = "Welcome to CodeCompanion ! Press ? for options.";
description = "Message to appear in chat buffer.";
};
separator = mkOption {
type = str;
default = "";
description = ''
The separator between the
different messages in the chat buffer.
'';
};
icons = {
pinned_buffer = mkOption {
type = str;
default = " ";
description = "The icon to represent a pinned buffer.";
};
watched_buffer = mkOption {
type = str;
default = "👀 ";
description = "The icon to represent a watched buffer.";
};
};
};
action_palette = {
width = mkOption {
type = int;
default = 95;
description = "Width of the action palette.";
};
height = mkOption {
type = int;
default = 10;
description = "Height of the action palette.";
};
prompt = mkOption {
type = str;
default = "Prompt ";
description = "Prompt used for interactive LLM calls.";
};
provider = mkOption {
type = enum ["default" "telescope" "mini_pick"];
default = "default";
description = "Provider used for the action palette.";
};
opts = {
show_default_actions =
mkEnableOption ""
// {
default = true;
description = "showing default actions in the action palette.";
};
show_default_prompt_library =
mkEnableOption ""
// {
default = true;
description = ''
showing default prompt library in the action palette.
'';
};
};
};
};
adapters = mkOption {
type = nullOr luaInline;
default = null;
description = "An adapter is what connects Neovim to an LLM.";
};
strategies = {
chat = {
adapter = mkOption {
type = nullOr str;
default = null;
description = "Adapter used for the chat strategy.";
};
keymaps = mkOption {
type = nullOr attrs;
default = null;
description = "Define or override the default keymaps.";
};
variables = mkOption {
type = nullOr luaInline;
default = null;
description = ''
Define your own variables
to share specific content.
'';
};
slash_commands = mkOption {
type = nullOr luaInline;
default = null;
description = ''
Slash Commands (invoked with /) let you dynamically
insert context into the chat buffer,
such as file contents or date/time.
'';
};
tools = mkOption {
type = nullOr attrs;
default = null;
description = ''
Configure tools to perform specific
tasks when invoked by an LLM.
'';
};
roles = mkOption {
type = nullOr luaInline;
default = null;
description = ''
The chat buffer places user and LLM responses under a H2 header.
These can be customized in the configuration.
'';
};
};
inline = {
adapter = mkOption {
type = nullOr str;
default = null;
description = "Adapter used for the inline strategy.";
};
variables = mkOption {
type = nullOr luaInline;
default = null;
description = ''
Define your own variables
to share specific content.
'';
};
keymaps = {
accept_change = {
n = mkOption {
type = str;
default = "ga";
description = "Accept the suggested change.";
};
};
reject_change = {
n = mkOption {
type = str;
default = "gr";
description = "Reject the suggested change.";
};
};
};
};
};
prompt_library = mkOption {
type = nullOr attrs;
default = null;
description = ''
A prompt library is a collection of prompts
that can be used in the action palette.
'';
};
};
};
};
}

View file

@ -0,0 +1,27 @@
{
config,
lib,
...
}: let
inherit (lib.modules) mkIf;
cfg = config.vim.assistant.codecompanion-nvim;
in {
config = mkIf cfg.enable {
vim = {
startPlugins = [
"plenary-nvim"
];
lazy.plugins = {
codecompanion-nvim = {
package = "codecompanion-nvim";
setupModule = "codecompanion";
inherit (cfg) setupOpts;
};
};
treesitter.enable = true;
};
};
}

View file

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

View file

@ -2,5 +2,6 @@
imports = [
./chatgpt
./copilot
./codecompanion
];
}

View file

@ -0,0 +1,219 @@
{lib, ...}: let
inherit (lib.options) mkEnableOption mkOption literalMD;
inherit (lib.types) bool listOf str either attrsOf submodule enum anything int nullOr;
inherit (lib.generators) mkLuaInline;
inherit (lib.nvim.types) mkPluginSetupOption luaInline pluginType;
inherit (lib.nvim.binds) mkMappingOption;
inherit (lib.nvim.config) mkBool;
keymapType = submodule {
freeformType = attrsOf (listOf (either str luaInline));
options = {
preset = mkOption {
type = enum ["default" "none" "super-tab" "enter"];
default = "none";
description = "keymap presets";
};
};
};
providerType = submodule {
freeformType = anything;
options = {
module = mkOption {
type = nullOr str;
default = null;
description = "Provider module.";
};
};
};
in {
options.vim.autocomplete.blink-cmp = {
enable = mkEnableOption "blink.cmp";
setupOpts = mkPluginSetupOption "blink.cmp" {
sources = {
default = mkOption {
type = listOf str;
default = ["lsp" "path" "snippets" "buffer"];
description = "Default list of sources to enable for completion.";
};
providers = mkOption {
type = attrsOf providerType;
default = {};
description = "Settings for completion providers.";
};
transform_items = mkOption {
type = nullOr luaInline;
default = mkLuaInline "function(_, items) return items end";
defaultText = ''
Our default does nothing. If you want blink.cmp's default, which
lowers the score for snippets, set this option to null.
'';
description = ''
Function to use when transforming the items before they're returned
for all providers.
'';
};
};
cmdline = {
sources = mkOption {
type = nullOr (listOf str);
default = [];
description = "List of sources to enable for cmdline. Null means use default source list.";
};
keymap = mkOption {
type = keymapType;
default = {};
description = "blink.cmp cmdline keymap";
};
};
completion = {
documentation = {
auto_show = mkBool true "Show documentation whenever an item is selected";
auto_show_delay_ms = mkOption {
type = int;
default = 200;
description = "Delay before auto show triggers";
};
};
menu.auto_show = mkOption {
type = bool;
default = true;
description = ''
Manages the appearance of the completion menu. You may prevent the menu
from automatically showing by this option to `false` and manually showing
it with the show keymap command.
'';
};
};
keymap = mkOption {
type = keymapType;
default = {};
description = "blink.cmp keymap";
example = literalMD ''
```nix
vim.autocomplete.blink-cmp.setupOpts.keymap = {
preset = "none";
"<Up>" = ["select_prev" "fallback"];
"<C-n>" = [
(lib.generators.mkLuaInline ''''
function(cmp)
if some_condition then return end -- runs the next command
return true -- doesn't run the next command
end,
'''')
"select_next"
];
};
```
'';
};
fuzzy = {
prebuilt_binaries = {
download = mkBool false ''
Auto-downloads prebuilt binaries.
::: .{warning}
Do not enable this option, as it does **not work** on Nix!
:::
'';
};
implementation = mkOption {
type = enum ["lua" "prefer_rust" "rust" "prefer_rust_with_warning"];
default = "prefer_rust";
description = ''
fuzzy matcher implementation for Blink.
* `"lua"`: slower, Lua native fuzzy matcher implementation
* `"rust": use the SIMD fuzzy matcher, 'frizbee'
* `"prefer_rust"`: use the rust implementation, but fall back to lua
* `"prefer_rust_with_warning"`: use the rust implementation, and fall back to lua
if it is not available after emitting a warning.
'';
};
};
};
mappings = {
complete = mkMappingOption "Complete [blink.cmp]" "<C-Space>";
confirm = mkMappingOption "Confirm [blink.cmp]" "<CR>";
next = mkMappingOption "Next item [blink.cmp]" "<Tab>";
previous = mkMappingOption "Previous item [blink.cmp]" "<S-Tab>";
close = mkMappingOption "Close [blink.cmp]" "<C-e>";
scrollDocsUp = mkMappingOption "Scroll docs up [blink.cmp]" "<C-d>";
scrollDocsDown = mkMappingOption "Scroll docs down [blink.cmp]" "<C-f>";
};
sourcePlugins = let
sourcePluginType = submodule {
options = {
enable = mkEnableOption "this source";
package = mkOption {
type = pluginType;
description = ''
`blink-cmp` source plugin package.
'';
};
module = mkOption {
type = str;
description = ''
Value of {option}`vim.autocomplete.blink-cmp.setupOpts.sources.providers.<name>.module`.
Should be present in the source's documentation.
'';
};
};
};
in
mkOption {
type = submodule {
freeformType = attrsOf sourcePluginType;
options = let
defaultSourcePluginOption = name: package: module: {
package = mkOption {
type = pluginType;
default = package;
description = ''
`blink-cmp` ${name} source plugin package.
'';
};
module = mkOption {
type = str;
default = module;
description = ''
Value of {option}`vim.autocomplete.blink-cmp.setupOpts.sources.providers.${name}.module`.
'';
};
enable = mkEnableOption "${name} source";
};
in {
# emoji completion after :
emoji = defaultSourcePluginOption "emoji" "blink-emoji-nvim" "blink-emoji";
# spelling suggestions as completions
spell = defaultSourcePluginOption "spell" "blink-cmp-spell" "blink-cmp-spell";
# words from nearby files
ripgrep = defaultSourcePluginOption "ripgrep" "blink-ripgrep-nvim" "blink-ripgrep";
};
};
default = {};
description = ''
`blink.cmp` sources.
Attribute names must be source names used in {option}`vim.autocomplete.blink-cmp.setupOpts.sources.default`.
'';
};
friendly-snippets.enable = mkEnableOption "friendly-snippets for blink to source from automatically";
};
}

View file

@ -0,0 +1,128 @@
{
lib,
config,
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.strings) optionalString;
inherit (lib.generators) mkLuaInline;
inherit (lib.attrsets) attrValues filterAttrs mapAttrsToList;
inherit (lib.lists) map optional elem;
inherit (lib.nvim.lua) toLuaObject;
inherit (builtins) concatStringsSep typeOf tryEval attrNames mapAttrs;
cfg = config.vim.autocomplete.blink-cmp;
cmpCfg = config.vim.autocomplete.nvim-cmp;
inherit (cfg) mappings;
getPluginName = plugin:
if typeOf plugin == "string"
then plugin
else if (plugin ? pname && (tryEval plugin.pname).success)
then plugin.pname
else plugin.name;
enabledBlinkSources = filterAttrs (_source: definition: definition.enable) cfg.sourcePlugins;
blinkSourcePlugins = map (definition: definition.package) (attrValues enabledBlinkSources);
blinkBuiltins = [
"path"
"lsp"
"snippets"
"buffer"
"omni"
];
in {
assertions =
mapAttrsToList (provider: definition: {
assertion = elem provider blinkBuiltins || definition.module != null;
message = "`config.vim.autocomplete.blink-cmp.setupOpts.sources.providers.${provider}.module` is `null`: non-builtin providers must set `module`.";
})
cfg.setupOpts.sources.providers;
vim = mkIf cfg.enable {
startPlugins = ["blink-compat"] ++ blinkSourcePlugins ++ (optional cfg.friendly-snippets.enable "friendly-snippets");
lazy.plugins = {
blink-cmp = {
package = "blink-cmp";
setupModule = "blink.cmp";
inherit (cfg) setupOpts;
# TODO: lazy disabled until lspconfig is lazy loaded
#
# event = ["InsertEnter" "CmdlineEnter"];
after =
# lua
''
${optionalString config.vim.lazy.enable
(concatStringsSep "\n" (map
(package: "require('lz.n').trigger_load(${toLuaObject (getPluginName package)})")
cmpCfg.sourcePlugins))}
'';
};
};
autocomplete = {
enableSharedCmpSources = true;
blink-cmp.setupOpts = {
sources = {
default =
[
"lsp"
"path"
"snippets"
"buffer"
]
++ (attrNames cmpCfg.sources)
++ (attrNames enabledBlinkSources);
providers =
mapAttrs (name: _: {
inherit name;
module = "blink.compat.source";
})
cmpCfg.sources
// (mapAttrs (name: definition: {
inherit name;
inherit (definition) module;
})
enabledBlinkSources);
};
snippets = mkIf config.vim.snippets.luasnip.enable {
preset = "luasnip";
};
keymap = {
${mappings.complete} = ["show" "fallback"];
${mappings.close} = ["hide" "fallback"];
${mappings.scrollDocsUp} = ["scroll_documentation_up" "fallback"];
${mappings.scrollDocsDown} = ["scroll_documentation_down" "fallback"];
${mappings.confirm} = ["accept" "fallback"];
${mappings.next} = [
"select_next"
"snippet_forward"
(mkLuaInline
# lua
''
function(cmp)
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
has_words_before = col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
if has_words_before then
return cmp.show()
end
end
'')
"fallback"
];
${mappings.previous} = [
"select_prev"
"snippet_backward"
"fallback"
];
};
};
};
};
}

View file

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

View file

@ -0,0 +1,34 @@
{
lib,
config,
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.nvim.attrsets) mapListToAttrs;
inherit (builtins) typeOf tryEval;
cfg = config.vim.autocomplete;
getPluginName = plugin:
if typeOf plugin == "string"
then plugin
else if (plugin ? pname && (tryEval plugin.pname).success)
then plugin.pname
else plugin.name;
in {
config.vim = mkIf cfg.enableSharedCmpSources {
startPlugins = ["rtp-nvim"];
lazy.plugins =
mapListToAttrs (package: {
name = getPluginName package;
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.nvim-cmp.sourcePlugins;
};
}

View file

@ -1,5 +1,9 @@
{
imports = [
./module.nix
./config.nix
./nvim-cmp
./blink-cmp
];
}

View file

@ -0,0 +1,7 @@
{lib, ...}: let
inherit (lib.options) mkEnableOption;
in {
options.vim.autocomplete = {
enableSharedCmpSources = mkEnableOption "sources shared by blink.cmp and nvim-cmp";
};
}

View file

@ -24,114 +24,97 @@
in {
config = mkIf cfg.enable {
vim = {
startPlugins = ["rtp-nvim"];
lazy.plugins = mkMerge [
(mapListToAttrs (package: {
name = getPluginName package;
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)
lazy.plugins = {
nvim-cmp = {
package = "nvim-cmp";
after = ''
${optionalString luasnipEnable "local luasnip = require('luasnip')"}
local cmp = require("cmp")
local kinds = require("cmp.types").lsp.CompletionItemKind
local deprio = function(kind)
return function(e1, e2)
if e1:get_kind() == kind then
return false
end
if e2:get_kind() == kind then
return true
end
return nil
end
end
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 = {
enableSharedCmpSources = true;
nvim-cmp = {
sourcePlugins = ["cmp-buffer" "cmp-path"];
setupOpts = {
sources = map (s: {name = s;}) (attrNames cfg.sources);
window = mkIf borders.enable {
completion.border = borders.style;
documentation.border = borders.style;
};
formatting.format = cfg.format;
# `cmp` and `luasnip` are defined above, in the `nvim-cmp` section
mapping = {
${mappings.complete} = mkLuaInline "cmp.mapping.complete()";
${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 })";
${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
if cmp.visible() then
cmp.select_next_item()
${optionalString luasnipEnable ''
elseif luasnip.locally_jumpable(1) then
luasnip.jump(1)
''}
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)
'';
};
})
cfg.sourcePlugins)
{
nvim-cmp = {
package = "nvim-cmp";
after = ''
${optionalString luasnipEnable "local luasnip = require('luasnip')"}
local cmp = require("cmp")
local kinds = require("cmp.types").lsp.CompletionItemKind
local deprio = function(kind)
return function(e1, e2)
if e1:get_kind() == kind then
return false
end
if e2:get_kind() == kind then
return true
end
return nil
end
end
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 = {
sources = {
nvim-cmp = null;
buffer = "[Buffer]";
path = "[Path]";
};
sourcePlugins = ["cmp-buffer" "cmp-path"];
setupOpts = {
sources = map (s: {name = s;}) (attrNames cfg.sources);
window = mkIf borders.enable {
completion.border = borders.style;
documentation.border = borders.style;
};
formatting.format = cfg.format;
# `cmp` and `luasnip` are defined above, in the `nvim-cmp` section
mapping = {
${mappings.complete} = mkLuaInline "cmp.mapping.complete()";
${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 })";
${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
if cmp.visible() then
cmp.select_next_item()
${optionalString luasnipEnable ''
elseif luasnip.locally_jumpable(1) then
luasnip.jump(1)
''}
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

@ -98,14 +98,16 @@ in {
sources = mkOption {
type = attrsOf (nullOr str);
default = {};
default = {
nvim-cmp = null;
buffer = "[Buffer]";
path = "[Path]";
};
example = {
nvim-cmp = null;
buffer = "[Buffer]";
};
description = "The list of sources used by nvim-cmp";
example = literalExpression ''
{
nvim-cmp = null;
buffer = "[Buffer]";
}
'';
};
sourcePlugins = mkOption {

View file

@ -1,7 +1,23 @@
{lib, ...}: let
inherit (lib.options) mkEnableOption;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) listOf attrsOf anything nullOr enum;
in {
options.vim.dashboard.alpha = {
enable = mkEnableOption "fast and fully programmable greeter for neovim [alpha.mvim]";
enable = mkEnableOption "fast and fully programmable greeter for neovim [alpha.nvim]";
theme = mkOption {
type = nullOr (enum ["dashboard" "startify" "theta"]);
default = "dashboard";
description = "Alpha default theme to use";
};
layout = mkOption {
type = listOf (attrsOf anything);
default = [];
description = "Alpha dashboard layout";
};
opts = mkOption {
type = attrsOf anything;
default = {};
description = "Optional global options";
};
};
}

View file

@ -5,8 +5,11 @@
}: let
inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.dashboard.alpha;
themeDefined = cfg.theme != null;
layoutDefined = cfg.layout != [];
in {
config = mkIf cfg.enable {
vim.startPlugins = [
@ -14,207 +17,30 @@ in {
"nvim-web-devicons"
];
# the entire credit for this dashboard configuration to https://github.com/Rishabh672003
# honestly, excellent work
vim.pluginRC.alpha = entryAnywhere ''
local alpha = require("alpha")
local plenary_path = require("plenary.path")
local dashboard = require("alpha.themes.dashboard")
local cdir = vim.fn.getcwd()
local if_nil = vim.F.if_nil
local nvim_web_devicons = {
enabled = true,
highlight = true,
}
local function get_extension(fn)
local match = fn:match("^.+(%..+)$")
local ext = ""
if match ~= nil then
ext = match:sub(2)
end
return ext
end
local function icon(fn)
local nwd = require("nvim-web-devicons")
local ext = get_extension(fn)
return nwd.get_icon(fn, ext, { default = true })
end
local function file_button(fn, sc, short_fn)
short_fn = short_fn or fn
local ico_txt
local fb_hl = {}
if nvim_web_devicons.enabled then
local ico, hl = icon(fn)
local hl_option_type = type(nvim_web_devicons.highlight)
if hl_option_type == "boolean" then
if hl and nvim_web_devicons.highlight then
table.insert(fb_hl, { hl, 0, 3 })
end
end
if hl_option_type == "string" then
table.insert(fb_hl, { nvim_web_devicons.highlight, 0, 3 })
end
ico_txt = ico .. " "
else
ico_txt = ""
end
local file_button_el = dashboard.button(sc, ico_txt .. short_fn, "<cmd>e " .. fn .. " <CR>")
local fn_start = short_fn:match(".*[/\\]")
if fn_start ~= nil then
table.insert(fb_hl, { "Comment", #ico_txt - 2, #fn_start + #ico_txt })
end
file_button_el.opts.hl = fb_hl
return file_button_el
end
local default_mru_ignore = { "gitcommit" }
local mru_opts = {
ignore = function(path, ext)
return (string.find(path, "COMMIT_EDITMSG")) or (vim.tbl_contains(default_mru_ignore, ext))
end,
}
--- @param start number
--- @param cwd string optional
--- @param items_number number optional number of items to generate, default = 10
local function mru(start, cwd, items_number, opts)
opts = opts or mru_opts
items_number = if_nil(items_number, 15)
local oldfiles = {}
for _, v in pairs(vim.v.oldfiles) do
if #oldfiles == items_number then
break
end
local cwd_cond
if not cwd then
cwd_cond = true
else
cwd_cond = vim.startswith(v, cwd)
end
local ignore = (opts.ignore and opts.ignore(v, get_extension(v))) or false
if (vim.fn.filereadable(v) == 1) and cwd_cond and not ignore then
oldfiles[#oldfiles + 1] = v
end
end
local target_width = 35
local tbl = {}
for i, fn in ipairs(oldfiles) do
local short_fn
if cwd then
short_fn = vim.fn.fnamemodify(fn, ":.")
else
short_fn = vim.fn.fnamemodify(fn, ":~")
end
if #short_fn > target_width then
short_fn = plenary_path.new(short_fn):shorten(1, { -2, -1 })
if #short_fn > target_width then
short_fn = plenary_path.new(short_fn):shorten(1, { -1 })
end
end
local shortcut = tostring(i + start - 1)
local file_button_el = file_button(fn, shortcut, short_fn)
tbl[i] = file_button_el
end
return {
type = "group",
val = tbl,
opts = {},
}
end
local default_header = {
type = "text",
val = {
[[ ]],
[[ ]],
[[ ]],
[[ ]],
[[ ]],
-- [[ __ ]],
-- [[ ___ ___ ___ __ __ /\_\ ___ ___ ]],
-- [[ / _ `\ / __`\ / __`\/\ \/\ \\/\ \ / __` __`\ ]],
-- [[/\ \/\ \/\ __//\ \_\ \ \ \_/ |\ \ \/\ \/\ \/\ \ ]],
-- [[\ \_\ \_\ \____\ \____/\ \___/ \ \_\ \_\ \_\ \_\]],
-- [[ \/_/\/_/\/____/\/___/ \/__/ \/_/\/_/\/_/\/_/]],
},
opts = {
position = "center",
hl = "Type",
-- wrap = "overflow";
},
}
local section_mru = {
type = "group",
val = {
{
type = "text",
val = "Recent files",
opts = {
hl = "SpecialComment",
shrink_margin = false,
position = "center",
},
},
{ type = "padding", val = 1 },
{
type = "group",
val = function()
return { mru(0, cdir) }
end,
opts = { shrink_margin = false },
},
},
}
local buttons = {
type = "group",
val = {
{ type = "text", val = "Quick links", opts = { hl = "SpecialComment", position = "center" } },
{ type = "padding", val = 1 },
-- TODO: buttons should be added based on whether or not the relevant plugin is available
dashboard.button("e", " New file", "<cmd>ene<CR>"), -- available all the time
dashboard.button("SPC F", "󰈞 Find file"), -- telescope
dashboard.button("SPC ff", "󰊄 Live grep"), -- telescope
dashboard.button("SPC p", " Projects"), -- any project
dashboard.button("q", "󰅚 Quit", "<cmd>qa<CR>"), -- available all the time
},
position = "center",
}
local config = {
layout = {
{ type = "padding", val = 2 },
default_header,
{ type = "padding", val = 2 },
section_mru,
{ type = "padding", val = 2 },
buttons,
},
opts = {
margin = 5,
setup = function()
vim.cmd([[
autocmd alpha_temp DirChanged * lua require('alpha').redraw()
]])
end,
},
}
alpha.setup(config)
vim.pluginRC.alpha = let
setupOpts =
if themeDefined
then lib.generators.mkLuaInline "require'alpha.themes.${cfg.theme}'.config"
else {
inherit (cfg) layout opts;
};
in ''
require('alpha').setup(${toLuaObject setupOpts})
'';
assertions = [
{
assertion = themeDefined || layoutDefined;
message = ''
One of 'theme' or 'layout' should be defined in Alpha configuration.
'';
}
{
assertion = !(themeDefined && layoutDefined);
message = ''
'theme' and 'layout' cannot be defined at the same time.
'';
}
];
};
}

View file

@ -0,0 +1,3 @@
{
imports = [./nvim-lint];
}

View file

@ -0,0 +1,20 @@
{
config,
lib,
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.diagnostics.nvim-lint;
in {
config = mkIf cfg.enable {
vim = {
startPlugins = ["nvim-lint"];
pluginRC.nvim-lint = entryAnywhere ''
require("lint").linters_by_ft(${toLuaObject cfg.linters_by_ft})
'';
};
};
}

View file

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

View file

@ -0,0 +1,25 @@
{lib, ...}: let
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) attrsOf listOf str;
in {
options.vim.diagnostics.nvim-lint = {
enable = mkEnableOption "asynchronous linter plugin for Neovim [nvim-lint]";
# nvim-lint does not have a setup table.
linters_by_ft = mkOption {
type = attrsOf (listOf str);
default = {};
example = {
text = ["vale"];
markdown = ["vale"];
};
description = ''
Map of filetype to formatters. This option takes a set of `key = value`
format where the `value` will be converted to its Lua equivalent
through `toLuaObject. You are responsible for passing the correct Nix
data types to generate a correct Lua value that conform is able to
accept.
'';
};
};
}

View file

@ -0,0 +1,20 @@
{
config,
lib,
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.formatter.conform-nvim;
in {
config = mkIf cfg.enable {
vim = {
startPlugins = ["conform-nvim"];
pluginRC.conform-nvim = entryAnywhere ''
require("conform").setup(${toLuaObject cfg.setupOpts})
'';
};
};
}

View file

@ -0,0 +1,56 @@
{
pkgs,
lib,
...
}: let
inherit (lib.options) mkOption mkEnableOption literalExpression;
inherit (lib.types) attrs enum;
inherit (lib.nvim.types) mkPluginSetupOption;
inherit (lib.nvim.lua) mkLuaInline;
in {
options.vim.formatter.conform-nvim = {
enable = mkEnableOption "lightweight yet powerful formatter plugin for Neovim [conform-nvim]";
setupOpts = mkPluginSetupOption "conform.nvim" {
formatters_by_ft = mkOption {
type = attrs;
default = {};
example = {lua = ["stylua"];};
description = ''
Map of filetype to formatters. This option takes a set of
`key = value` format where the `value will` be converted
to its Lua equivalent. You are responsible for passing the
correct Nix data types to generate a correct Lua value that
conform is able to accept.
'';
};
default_format_opts = mkOption {
type = attrs;
default = {lsp_format = "fallback";};
description = "Default values when calling `conform.format()`";
};
format_on_save = mkOption {
type = attrs;
default = {
lsp_format = "fallback";
timeout_ms = 500;
};
description = ''
Table that will be passed to `conform.format()`. If this
is set, Conform will run the formatter on save.
'';
};
format_after_save = mkOption {
type = attrs;
default = {lsp_format = "fallback";};
description = ''
Table that will be passed to `conform.format()`. If this
is set, Conform will run the formatter asynchronously after
save.
'';
};
};
};
}

View file

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

View file

@ -0,0 +1,3 @@
{
imports = [./conform-nvim];
}

View file

@ -4,6 +4,7 @@ in {
imports = [
./gitsigns
./vim-fugitive
./git-conflict
];
options.vim.git = {
@ -13,6 +14,7 @@ in {
Enabling this option will enable the following plugins:
* gitsigns
* vim-fugitive
* git-conflict
'';
};
}

View file

@ -0,0 +1,40 @@
{
config,
lib,
...
}: let
inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetBinding;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.git.git-conflict;
self = import ./git-conflict.nix {inherit lib config;};
gcMappingDefinitions = self.options.vim.git.git-conflict.mappings;
gcMappings = addDescriptionsToMappings cfg.mappings gcMappingDefinitions;
in {
config = mkIf cfg.enable (mkMerge [
{
vim = {
startPlugins = ["git-conflict-nvim"];
maps = {
normal = mkMerge [
(mkSetBinding gcMappings.ours "<Plug>(git-conflict-ours)")
(mkSetBinding gcMappings.theirs "<Plug>(git-conflict-theirs)")
(mkSetBinding gcMappings.both "<Plug>(git-conflict-both)")
(mkSetBinding gcMappings.none "<Plug>(git-conflict-none)")
(mkSetBinding gcMappings.prevConflict "<Plug>(git-conflict-prev-conflict)")
(mkSetBinding gcMappings.nextConflict "<Plug>(git-conflict-next-conflict)")
];
};
pluginRC.git-conflict = entryAnywhere ''
require('git-conflict').setup(${toLuaObject ({default_mappings = false;} // cfg.setupOpts)})
'';
};
}
]);
}

View file

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

View file

@ -0,0 +1,23 @@
{
config,
lib,
...
}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.binds) mkMappingOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in {
options.vim.git.git-conflict = {
enable = mkEnableOption "git-conflict" // {default = config.vim.git.enable;};
setupOpts = mkPluginSetupOption "git-conflict" {};
mappings = {
ours = mkMappingOption "Choose Ours [Git-Conflict]" "<leader>co";
theirs = mkMappingOption "Choose Theirs [Git-Conflict]" "<leader>ct";
both = mkMappingOption "Choose Both [Git-Conflict]" "<leader>cb";
none = mkMappingOption "Choose None [Git-Conflict]" "<leader>c0";
prevConflict = mkMappingOption "Go to the previous Conflict [Git-Conflict]" "]x";
nextConflict = mkMappingOption "Go to the next Conflict [Git-Conflict]" "[x";
};
};
}

View file

@ -0,0 +1,22 @@
{
config,
lib,
...
}: let
inherit (lib.modules) mkIf;
cfg = config.vim.hydra;
in {
config = mkIf cfg.enable {
vim = {
startPlugins = [];
lazy.plugins.hydra = {
package = "hydra.nvim";
setupModule = "hydra";
inherit (cfg) setupOpts;
event = ["DeferredUIEnter"];
cmd = ["MCstart" "MCvisual" "MCclear" "MCpattern" "MCvisualPattern" "MCunderCursor"];
};
};
};
}

View file

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

View file

@ -0,0 +1,7 @@
{lib, ...}: let
inherit (lib.options) mkEnableOption;
in {
options.vim.utility.hydra = {
enable = mkEnableOption "utility for creating custom submodes and menus [nvimtools/hydra.nvim]";
};
}

View file

@ -75,8 +75,8 @@
};
extraServerPlugins = {
omnisharp = ["omnisharp-extended"];
csharp_ls = ["csharpls-extended"];
omnisharp = ["omnisharp-extended-lsp-nvim"];
csharp_ls = ["csharpls-extended-lsp-nvim"];
};
cfg = config.vim.languages.csharp;

View file

@ -0,0 +1,51 @@
{
pkgs,
config,
lib,
...
}: let
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.types) package;
inherit (lib.nvim.types) mkGrammarOption;
cfg = config.vim.languages.cue;
in {
options.vim.languages.cue = {
enable = mkEnableOption "CUE language support";
treesitter = {
enable = mkEnableOption "CUE treesitter" // {default = config.vim.languages.enableTreesitter;};
package = mkGrammarOption pkgs "cue";
};
lsp = {
enable = mkEnableOption "CUE LSP support" // {default = config.vim.languages.enableLSP;};
package = mkOption {
type = package;
default = pkgs.cue;
description = "cue lsp implementation";
};
};
};
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.cue-lsp = ''
lspconfig.cue.setup {
capabilities = capabilities,
on_attach = default_on_attach,
cmd = {"${cfg.lsp.package}/bin/cue", "lsp"},
}
'';
})
]);
}

View file

@ -137,7 +137,7 @@ in {
vim.startPlugins =
if ftcfg.enableNoResolvePatch
then ["flutter-tools-patched"]
else ["flutter-tools"];
else ["flutter-tools-nvim"];
vim.pluginRC.flutter-tools = entryAnywhere ''
require('flutter-tools').setup {

View file

@ -5,6 +5,7 @@ in {
./asm.nix
./astro.nix
./bash.nix
./cue.nix
./dart.nix
./clang.nix
./css.nix
@ -12,6 +13,7 @@ in {
./gleam.nix
./go.nix
./hcl.nix
./helm.nix
./kotlin.nix
./html.nix
./haskell.nix
@ -39,6 +41,7 @@ in {
./nu.nix
./odin.nix
./wgsl.nix
./yaml.nix
./ruby.nix
];

View file

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

View file

@ -34,6 +34,43 @@
};
};
defaultFormat = "gofmt";
formats = {
gofmt = {
package = pkgs.go;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.gofmt.with({
command = "${cfg.format.package}/bin/gofmt",
})
)
'';
};
gofumpt = {
package = pkgs.gofumpt;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.gofumpt.with({
command = "${cfg.format.package}/bin/gofumpt",
})
)
'';
};
golines = {
package = pkgs.golines;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.golines.with({
command = "${cfg.format.package}/bin/golines",
})
)
'';
};
};
defaultDebugger = "delve";
debuggers = {
delve = {
@ -67,6 +104,22 @@ in {
};
};
format = {
enable = mkEnableOption "Go formatting" // {default = config.vim.languages.enableFormat;};
type = mkOption {
description = "Go formatter to use";
type = enum (attrNames formats);
default = defaultFormat;
};
package = mkOption {
description = "Go formatter package";
type = package;
default = formats.${cfg.format.type}.package;
};
};
dap = {
enable = mkOption {
description = "Enable Go Debug Adapter via nvim-dap-go plugin";
@ -99,6 +152,11 @@ in {
vim.lsp.lspconfig.sources.go-lsp = servers.${cfg.lsp.server}.lspConfig;
})
(mkIf cfg.format.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources.go-format = formats.${cfg.format.type}.nullConfig;
})
(mkIf cfg.dap.enable {
vim = {
startPlugins = ["nvim-dap-go"];

View file

@ -0,0 +1,89 @@
{
pkgs,
config,
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.helm;
yamlCfg = config.vim.languages.yaml;
helmCmd =
if isList cfg.lsp.package
then cfg.lsp.package
else ["${cfg.lsp.package}/bin/helm_ls" "serve"];
yamlCmd =
if isList yamlCfg.lsp.package
then builtins.elemAt yamlCfg.lsp.package 0
else "${yamlCfg.lsp.package}/bin/yaml-language-server";
defaultServer = "helm-ls";
servers = {
helm-ls = {
package = pkgs.helm-ls;
lspConfig = ''
lspconfig.helm_ls.setup {
capabilities = capabilities,
on_attach = default_on_attach,
cmd = ${expToLua helmCmd},
settings = {
['helm-ls'] = {
yamlls = {
path = "${yamlCmd}"
}
}
}
}
'';
};
};
in {
options.vim.languages.helm = {
enable = mkEnableOption "Helm language support";
treesitter = {
enable = mkEnableOption "Helm treesitter" // {default = config.vim.languages.enableTreesitter;};
package = mkGrammarOption pkgs "helm";
};
lsp = {
enable = mkEnableOption "Helm LSP support" // {default = config.vim.languages.enableLSP;};
server = mkOption {
description = "Helm LSP server to use";
type = enum (attrNames servers);
default = defaultServer;
};
package = mkOption {
description = "Helm LSP server package";
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.helm-lsp = servers.${cfg.lsp.server}.lspConfig;
})
{
# Enables filetype detection
vim.startPlugins = [pkgs.vimPlugins.vim-helm];
}
]);
}

View file

@ -8,7 +8,6 @@
inherit (lib.modules) mkIf mkMerge;
inherit (lib.meta) getExe;
inherit (lib.lists) isList;
inherit (lib.strings) optionalString;
inherit (lib.types) either listOf package str;
inherit (lib.nvim.types) mkGrammarOption;
inherit (lib.nvim.lua) expToLua;
@ -16,6 +15,12 @@
cfg = config.vim.languages.lua;
in {
imports = [
(lib.mkRemovedOptionModule ["vim" "languages" "lua" "lsp" "neodev"] ''
neodev has been replaced by lazydev
'')
];
options.vim.languages.lua = {
enable = mkEnableOption "Lua language support";
treesitter = {
@ -32,7 +37,7 @@ in {
default = pkgs.lua-language-server;
};
neodev.enable = mkEnableOption "neodev.nvim integration, useful for neovim plugin developers";
lazydev.enable = mkEnableOption "lazydev.nvim integration, useful for neovim plugin developers";
};
};
@ -49,7 +54,6 @@ in {
lspconfig.lua_ls.setup {
capabilities = capabilities;
on_attach = default_on_attach;
${optionalString cfg.lsp.neodev.enable "before_init = require('neodev.lsp').before_init;"}
cmd = ${
if isList cfg.lsp.package
then expToLua cfg.lsp.package
@ -59,10 +63,15 @@ in {
'';
})
(mkIf cfg.lsp.neodev.enable {
vim.startPlugins = ["neodev-nvim"];
vim.pluginRC.neodev = entryBefore ["lua-lsp"] ''
require("neodev").setup({})
(mkIf cfg.lsp.lazydev.enable {
vim.startPlugins = ["lazydev-nvim"];
vim.pluginRC.lazydev = entryBefore ["lua-lsp"] ''
require("lazydev").setup({
enabled = function(root_dir)
return not vim.uv.fs_stat(root_dir .. "/.luarc.json")
end,
library = { { path = "''${3rd}/luv/library", words = { "vim%.uv" } } },
})
'';
})
]))

View file

@ -10,9 +10,9 @@
inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) isList;
inherit (lib.strings) optionalString;
inherit (lib.types) enum either listOf package str;
inherit (lib.types) anything attrsOf enum either listOf nullOr package str;
inherit (lib.nvim.types) mkGrammarOption diagnostics;
inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.lua) expToLua toLuaObject;
inherit (lib.nvim.languages) diagnosticsToLua;
cfg = config.vim.languages.nix;
@ -59,6 +59,41 @@
}
'';
};
nixd = {
package = pkgs.nixd;
internalFormatter = true;
lspConfig = ''
lspconfig.nixd.setup{
capabilities = capabilities,
${
if cfg.format.enable
then useFormat
else noFormat
},
cmd = ${packageToCmd cfg.lsp.package "nixd"},
${optionalString cfg.format.enable ''
settings = {
nixd = {
${optionalString (cfg.format.type == "alejandra")
''
formatting = {
command = {"${cfg.format.package}/bin/alejandra", "--quiet"},
},
''}
${optionalString (cfg.format.type == "nixfmt")
''
formatting = {
command = {"${cfg.format.package}/bin/nixfmt"},
},
''}
options = ${toLuaObject cfg.lsp.options},
},
},
''}
}
'';
};
};
defaultFormat = "alejandra";
@ -86,8 +121,6 @@
)
'';
};
nixpkgs-fmt = null; # removed
};
defaultDiagnosticsProvider = ["statix" "deadnix"];
@ -139,6 +172,12 @@ in {
type = either package (listOf str);
default = servers.${cfg.lsp.server}.package;
};
options = mkOption {
type = nullOr (attrsOf anything);
default = null;
description = "Options to pass to nixd LSP server";
};
};
format = {
@ -178,7 +217,6 @@ in {
${concatStringsSep ", " (attrNames formats)}
'';
}
{
assertion = cfg.lsp.server != "rnix";
message = ''

View file

@ -64,6 +64,26 @@
}
'';
};
intelephense = {
package = pkgs.intelephense;
lspConfig = ''
lspconfig.intelephense.setup{
capabilities = capabilities,
on_attach = default_on_attach,
cmd = ${
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''
{
"${getExe cfg.lsp.package}",
"--stdio"
},
''
}
}
'';
};
};
in {
options.vim.languages.php = {

View file

@ -62,6 +62,15 @@ in {
description = "Options to pass to rust analyzer";
type = str;
default = "";
example = ''
['rust-analyzer'] = {
cargo = {allFeature = true},
checkOnSave = true,
procMacro = {
enable = true,
},
},
'';
};
};
@ -142,6 +151,9 @@ in {
then expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/rust-analyzer"}''
},
default_settings = {
${cfg.lsp.opts}
},
on_attach = function(client, bufnr)
default_on_attach(client, bufnr)
local opts = { noremap=true, silent=true, buffer = bufnr }

View file

@ -82,7 +82,7 @@
ls_sources,
null_ls.builtins.formatting.prettier.with({
command = "${cfg.format.package}/bin/prettier",
filetypes = { "typescript" },
filetypes = { "typescript", "javascript" },
})
)
'';
@ -230,7 +230,7 @@ in {
# Extensions
(mkIf cfg.extensions."ts-error-translator".enable {
vim.startPlugins = ["ts-error-translator"];
vim.startPlugins = ["ts-error-translator-nvim"];
vim.pluginRC.ts-error-translator = entryAnywhere ''
require("ts-error-translator").setup(${toLuaObject cfg.extensions.ts-error-translator.setupOpts})
'';

View file

@ -0,0 +1,85 @@
{
pkgs,
config,
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.yaml;
onAttach =
if config.vim.languages.helm.lsp.enable
then ''
on_attach = function(client, bufnr)
local filetype = vim.bo[bufnr].filetype
if filetype == "helm" then
client.stop()
end
end''
else "on_attach = default_on_attach";
defaultServer = "yaml-language-server";
servers = {
yaml-language-server = {
package = pkgs.nodePackages.yaml-language-server;
lspConfig = ''
lspconfig.yamlls.setup {
capabilities = capabilities,
${onAttach},
cmd = ${
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/yaml-language-server", "--stdio"}''
},
}
'';
};
};
in {
options.vim.languages.yaml = {
enable = mkEnableOption "YAML language support";
treesitter = {
enable = mkEnableOption "YAML treesitter" // {default = config.vim.languages.enableTreesitter;};
package = mkGrammarOption pkgs "yaml";
};
lsp = {
enable = mkEnableOption "YAML LSP support" // {default = config.vim.languages.enableLSP;};
server = mkOption {
type = enum (attrNames servers);
default = defaultServer;
description = "YAML LSP server to use";
};
package = mkOption {
type = either package (listOf str);
default = servers.${cfg.lsp.server}.package;
description = "YAML 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.yaml-lsp = servers.${cfg.lsp.server}.lspConfig;
})
]);
}

View file

@ -11,6 +11,7 @@
cfg = config.vim.lsp;
usingNvimCmp = config.vim.autocomplete.nvim-cmp.enable;
usingBlinkCmp = config.vim.autocomplete.blink-cmp.enable;
self = import ./module.nix {inherit config lib pkgs;};
mappingDefinitions = self.options.vim.lsp.mappings;
@ -22,7 +23,7 @@
in {
config = mkIf cfg.enable {
vim = {
autocomplete.nvim-cmp = {
autocomplete.nvim-cmp = mkIf usingNvimCmp {
sources = {nvim_lsp = "[LSP]";};
sourcePlugins = ["cmp-nvim-lsp"];
};
@ -170,6 +171,10 @@ in {
},
}
''}
${optionalString usingBlinkCmp ''
capabilities = require('blink.cmp').get_lsp_capabilities()
''}
'';
};
};

View file

@ -10,9 +10,19 @@
cfg = config.vim.lsp;
in {
config = mkIf (cfg.enable && cfg.lspSignature.enable) {
assertions = [
{
assertion = !config.vim.autocomplete.blink-cmp.enable;
message = ''
lsp-signature does not work with blink.cmp. Please use blink.cmp's builtin signature feature:
vim.autocomplete.blink-cmp.setupOpts.signature.enabled = true;
'';
}
];
vim = {
startPlugins = [
"lsp-signature"
"lsp-signature-nvim"
];
lsp.lspSignature.setupOpts = {

View file

@ -8,27 +8,39 @@
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.lsp.lspkind;
usingCmp = config.vim.autocomplete.nvim-cmp.enable;
usingBlink = config.vim.autocomplete.blink-cmp.enable;
in {
config = mkIf cfg.enable {
assertions = [
{
assertion = config.vim.autocomplete.nvim-cmp.enable;
assertion = usingCmp || usingBlink;
message = ''
While lspkind supports Neovim's native lsp upstream, using that over
nvim-cmp isn't recommended, nor supported by nvf.
nvim-cmp/blink.cmp isn't recommended, nor supported by nvf.
Please migrate to nvim-cmp if you want to use lspkind.
Please migrate to nvim-cmp/blink.cmp if you want to use lspkind.
'';
}
];
vim = {
startPlugins = ["lspkind"];
startPlugins = ["lspkind-nvim"];
lsp.lspkind.setupOpts.before = config.vim.autocomplete.nvim-cmp.format;
autocomplete.nvim-cmp.setupOpts.formatting.format = mkForce (mkLuaInline ''
require("lspkind").cmp_format(${toLuaObject cfg.setupOpts})
'');
autocomplete = {
nvim-cmp = mkIf usingCmp {
setupOpts.formatting.format = mkForce (mkLuaInline ''
require("lspkind").cmp_format(${toLuaObject cfg.setupOpts})
'');
};
blink-cmp = mkIf usingBlink {
setupOpts.appearance.kind_icons = mkLuaInline ''
require("lspkind").symbol_map
'';
};
};
};
};
}

View file

@ -3,51 +3,24 @@
lib,
...
}: let
inherit (lib.modules) mkIf mkMerge;
inherit (lib.strings) optionalString;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetLuaBinding;
inherit (lib.modules) mkIf mkDefault;
cfg = config.vim.lsp;
self = import ./lspsaga.nix {inherit lib;};
mappingDefinitions = self.options.vim.lsp.lspsaga.mappings;
mappings = addDescriptionsToMappings cfg.lspsaga.mappings mappingDefinitions;
in {
config = mkIf (cfg.enable && cfg.lspsaga.enable) {
vim = {
startPlugins = ["lspsaga"];
lazy.plugins.lspsaga-nvim = {
package = "lspsaga-nvim";
setupModule = "lspsaga";
inherit (cfg.lspsaga) setupOpts;
maps = {
visual = mkSetLuaBinding mappings.codeAction "require('lspsaga.codeaction').range_code_action";
normal = mkMerge [
(mkSetLuaBinding mappings.lspFinder "require('lspsaga.provider').lsp_finder")
(mkSetLuaBinding mappings.renderHoveredDoc "require('lspsaga.hover').render_hover_doc")
(mkSetLuaBinding mappings.smartScrollUp "function() require('lspsaga.action').smart_scroll_with_saga(-1) end")
(mkSetLuaBinding mappings.smartScrollDown "function() require('lspsaga.action').smart_scroll_with_saga(1) end")
(mkSetLuaBinding mappings.rename "require('lspsaga.rename').rename")
(mkSetLuaBinding mappings.previewDefinition "require('lspsaga.provider').preview_definition")
(mkSetLuaBinding mappings.showLineDiagnostics "require('lspsaga.diagnostic').show_line_diagnostics")
(mkSetLuaBinding mappings.showCursorDiagnostics "require('lspsaga.diagnostic').show_cursor_diagnostics")
(mkSetLuaBinding mappings.nextDiagnostic "require('lspsaga.diagnostic').navigate('next')")
(mkSetLuaBinding mappings.previousDiagnostic "require('lspsaga.diagnostic').navigate('prev')")
(mkSetLuaBinding mappings.codeAction "require('lspsaga.codeaction').code_action")
(mkIf (!cfg.lspSignature.enable) (mkSetLuaBinding mappings.signatureHelp "require('lspsaga.signaturehelp').signature_help"))
];
event = ["LspAttach"];
};
pluginRC.lspsaga = entryAnywhere ''
require('lspsaga').init_lsp_saga({
${optionalString config.vim.ui.borders.plugins.lspsaga.enable ''
border_style = '${config.vim.ui.borders.plugins.lspsaga.style}',
''}
})
'';
# Optional dependencies, pretty useful to enhance default functionality of
# Lspsaga.
treesitter.enable = mkDefault true;
visuals.nvim-web-devicons.enable = mkDefault true;
};
};
}

View file

@ -1,29 +1,32 @@
{lib, ...}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.binds) mkMappingOption;
{
config,
lib,
...
}: let
inherit (lib.modules) mkRemovedOptionModule;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.nvim.types) borderType mkPluginSetupOption;
in {
imports = [
(mkRemovedOptionModule ["vim" "lsp" "lspsaga" "mappings"] ''
Lspsaga mappings have been removed from nvf, as the original author has made
very drastic changes to the API after taking back ownership, and the fork we
used is now archived. Please refer to Lspsaga documentation to add keybinds
for functionality you have used.
<https://nvimdev.github.io/lspsaga>
'')
];
options.vim.lsp.lspsaga = {
enable = mkEnableOption "LSP Saga";
mappings = {
lspFinder = mkMappingOption "LSP Finder [LSPSaga]" "<leader>lf";
renderHoveredDoc = mkMappingOption "Rendered hovered docs [LSPSaga]" "<leader>lh";
smartScrollUp = mkMappingOption "Smart scroll up [LSPSaga]" "<C-f>";
smartScrollDown = mkMappingOption "Smart scroll up [LSPSaga]" "<C-b>";
rename = mkMappingOption "Rename [LSPSaga]" "<leader>lr";
previewDefinition = mkMappingOption "Preview definition [LSPSaga]" "<leader>ld";
showLineDiagnostics = mkMappingOption "Show line diagnostics [LSPSaga]" "<leader>ll";
showCursorDiagnostics = mkMappingOption "Show cursor diagnostics [LSPSaga]" "<leader>lc";
nextDiagnostic = mkMappingOption "Next diagnostic [LSPSaga]" "<leader>ln";
previousDiagnostic = mkMappingOption "Previous diagnostic [LSPSaga]" "<leader>lp";
codeAction = mkMappingOption "Code action [LSPSaga]" "<leader>ca";
signatureHelp = mkMappingOption "Signature help [LSPSaga]" "<leader>ls";
setupOpts = mkPluginSetupOption "lspsaga" {
border_style = mkOption {
type = borderType;
default = config.vim.ui.borders.globalStyle;
description = "Border type, see {command}`:help nvim_open_win`";
};
};
};
}

View file

@ -14,7 +14,7 @@ in {
{
vim = {
startPlugins = [
"none-ls"
"none-ls-nvim"
"plenary-nvim"
];

View file

@ -57,8 +57,8 @@ in {
};
mappings = {
viewToggle = mkMappingOption "Open or close the docs view panel" "lvt";
viewUpdate = mkMappingOption "Manually update the docs view panel" "lvu";
viewToggle = mkMappingOption "Open or close the docs view panel" "<leader>lvt";
viewUpdate = mkMappingOption "Manually update the docs view panel" "<leader>lvu";
};
};
}

View file

@ -15,13 +15,12 @@
mappings = addDescriptionsToMappings cfg.otter-nvim.mappings mappingDefinitions;
in {
config = mkIf (cfg.enable && cfg.otter-nvim.enable) {
assertions = [
{
assertion = !config.vim.utility.ccc.enable;
message = ''
ccc and otter have a breaking conflict. It's been reported upstream. Until it's fixed, disable one of them
'';
}
warnings = [
# TODO: remove warning when we update to nvim 0.11
(mkIf config.vim.utility.ccc.enable ''
ccc and otter occasionally have small conflicts that will disappear with nvim 0.11.
In the meantime, otter handles it by throwing a warning, but both plugins will work.
'')
];
vim = {
startPlugins = ["otter-nvim"];

View file

@ -10,13 +10,13 @@
cfg = config.vim.minimap.minimap-vim;
in {
config = mkIf cfg.enable {
vim.startPlugins = [
pkgs.code-minimap
"minimap-vim"
];
vim = {
startPlugins = ["minimap-vim"];
extraPackages = [pkgs.code-minimap];
vim.binds.whichKey.register = pushDownDefault {
"<leader>m" = "+Minimap";
binds.whichKey.register = pushDownDefault {
"<leader>m" = "+Minimap";
};
};
};
}

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