Compare commits

..

No commits in common. "8997e62b3b00ece6d51685b23949e3062a19dd06" and "56a8476bc16b0aa8fba0ce5d2d8969d9ae1857db" have entirely different histories.

181 changed files with 3050 additions and 4807 deletions

View file

@ -16,7 +16,7 @@ If you have any questions regarding those files, feel free to open an issue or [
## Contributing
The contribution process is mostly documented in the [pull request template](pull_request_template.md). You will find a checklist of items to complete before submitting a pull request. Please make sure you complete it before submitting a pull request. If you are unsure about any of the items, please ask.
The contribution process is mostly documented in the [pull request template](.github/pull_request_template.md). You will find a checklist of items to complete before submitting a pull request. Please make sure you complete it before submitting a pull request. If you are unsure about any of the items, please ask.
### Guidelines

4
.github/FUNDING.yml vendored
View file

@ -1,4 +0,0 @@
github: NotAShelf
ko_fi: NotAShelf
liberapay: NotAShelf

View file

@ -0,0 +1,39 @@
# Description
A clear and concise description of the aim of your Pull Request.
**If your pull request aims to fix an open issue or a present bug, please link the relevant issue below. If not, please remove this section**
Fixes #(issue)
## Type of change
Please delete any options that are not relevant.
- Bug fix (non-breaking change which fixes an issue)
- New feature (non-breaking change which adds functionality)
- Breaking change (fix or feature that would cause existing functionality to not work as expected)
- Translation/Language update
- Docs
- Other
## Checklist
Please try to check at least a majority of the checklist before opening your pull request. Exceptions to this will be reviewed on a case by case basis.
- [ ] My code follows the style and contributing guidelines of this project.
- [ ] I ran Alejandra to format my code (`nix fmt`).
- [ ] I have performed a self-review of my own code and tested it.
- [ ] I have commented my code, particularly in hard-to-understand areas.
- [ ] My changes generate no new warnings.
- [ ] This change requires a documentation update.
- [ ] I have updated the documentation accordingly.
## Screenshots & Logs
You are kindly requested to attach screenshots of your changes in actions and preferably your build/run logs for all available packages. If you are not sure how to do this, you can refer to the [documentation](https://notashelf.github.io/neovim-flake/).
**Please do not use any external image service. Instead, just paste in or drag and drop the image here, and it will be uploaded automatically.**
```console
# Paste your logs here
```

214
.github/README.md vendored
View file

@ -1,11 +1,9 @@
<div align="center">
<img src="assets/nvf-logo-work.svg" alt="nvf Logo" width="200">
<br/>
<h1>nvf</h1>
</div>
<h1 align="center">❄️ nvf</h1>
<div align="center">
<p>
<p>
<a href="https://github.com/NotAShelf/nvf/releases/latest">
<img alt="Latest release" src="https://img.shields.io/github/v/release/NotAShelf/nvf?style=for-the-badge&logo=nixos&color=C9CBFF&logoColor=D9E0EE&labelColor=302D41" />
</a>
@ -24,8 +22,7 @@
<a href="https://github.com/NotAShelf/nvf">
<img alt="Repo Size" src="https://img.shields.io/github/repo-size/NotAShelf/nvf?color=%23DDB6F2&label=SIZE&logo=codesandbox&style=for-the-badge&logoColor=D9E0EE&labelColor=302D41" />
</a>
</p>
</div>
</p>
<p align="center">
<img src="https://stars.medv.io/NotAShelf/nvf.svg", title="stars"/>
@ -33,17 +30,34 @@
<div align="center">
<a>
nvf is a highly modular, configurable, extensible and easy to use Neovim configuration
in Nix. Designed for flexibility and ease of use, nvf allows you to easily configure
your fully featured Neovim instance with a few lines of Nix.
A highly modular, configurable, extensible and easy to use Neovim configuration
framework in Nix. Designed for flexibility and ease of use, this flake
allows you to easily configure your Neovim instance with a few lines of
Nix code.
</a>
</div>
<br/>
> [!WARNING]
> Main branch is only updated for small, non-breaking changes. For the latest version of neovim-flake, please see
> [the list of branches](https://github.com/NotAShelf/neovim-flake/branches) or
> [open pull requests](https://github.com/NotAShelf/neovim-flake/pulls?q=is%3Apr+is%3Aopen+sort%3Aupdated-desc).
> neovim-flake, at the time, is still being actively developed - and will continue to be so for the foreseeable
> future.
---
<div align="center"><p>
[Features]: #features
**[<kbd><br>Get Started<br></kbd>][Get Started]**
**[<kbd><br>Documentation<br></kbd>][Documentation]**
**[<kbd><br>Help<br></kbd>][Help]**
**[<kbd><br>Contribute<br></kbd>][Contribute]**
**[<kbd><br>FAQ<br></kbd>][Faq]**
**[<kbd><br>Credits<br></kbd>][Credits]**
</p></div>
[Get Started]: #get-started
[Documentation]: #documentation
[Help]: #help
@ -51,156 +65,100 @@
[FAQ]: #faq
[Credits]: #credits
**[<kbd><br>Features <br></kbd>][Features]**
**[<kbd><br>Get Started<br></kbd>][Get Started]**
**[<kbd><br>Documentation<br></kbd>][Documentation]**
**[<kbd><br>Help<br></kbd>][Help]**
**[<kbd><br>Contribute<br></kbd>][Contribute]**
**[<kbd><br>FAQ<br></kbd>][Faq]** **[<kbd><br>Credits<br></kbd>][Credits]**
</p></div>
---
## Features
- **Reproducible**: Your configuration will behave the same _anywhere_. No
surprises, promise!
- **Portable**: nvf depends _solely_ on your Nix store, and nothing else. No
more global binaries! Works on all platforms, without hassle.
- **Customizable**: There are _almost no defaults_ to annoy you. nvf is fully
customizable through the Nix module system.
- **Well-documented**: Documentation is priority. You will _never_ face
undocumented, obscure behaviour.
- **Idiomatic**: nvf does things ✨ _the right way_ ✨ - the codebase is, and
will, remain maintainable for myself and any contributors.
## Get Started
[nvf manual]: https://notashelf.github.io/nvf/
[issue tracker]: https://github.com/NotAShelf/nvf/issues
### Using `nix` CLI
If you are not sold on the concepts of **nvf**, and would like to try out the
default configuration before even _thinking about_ installing it, you may run
the following in order to take **nvf** out for a spin.
If you would like to try out the configuration before even thinking about
installing it, you can run the following command
```bash
# Run the default package
```console
nix run github:notashelf/nvf
```
This will get you a feel for the base configuration and UI design. Though, none
of the configuration options are final as **nvf** is designed to be modular and
configurable.
This will get you a feel for the base configuration and UI design.
The flake exposes `#nix` as the default package, providing minimal
language support and various utilities.You may also use `#nix`,
`#tidal` or `#maximal` to get try out different configurations.
> [!TIP]
> The flake exposes `#nix` as the default package, providing minimal language
> support and various utilities. You may also use the `#nix` or `#maximal`
> packages provided by the this flake to get try out different configurations.
It is as simple as changing the target output to get a different
configuration. For example, to get a configuration with `tidal` support, run:
It is as simple as changing the target output to get a different configuration.
For example, to get a configuration with large language coverage, run:
```bash
# Run the maximal package
nix run github:notashelf/nvf#maximal
```console
nix run github:notashelf/nvf#tidal
```
Similar instructions will apply for `nix profile install`. However, you are
recommended to instead use the module system as described in the manual.
> [!NOTE]
> The `maximal` configuration is quite large, and might take a while to build.
> To get a feel for the configuration, use the default `nix` configuration.
> Should you choose to try out the `maximal` configuration, using the binary
> cache as described in the manual is _strongly_ recommended.
If you are convinced, proceed to the next section to view the installation
instructions.
> The `maximal` configuration is _massive_ and will take a while to build.
> To get a feel for the configuration, use the default `nix` or `tidal`
> configurations. Should you choose to try out the `maximal` configuration,
> using the binary cache as described in the manual is _strongly_ recommended.
## Documentation
The _recommended_ way of installing **nvf** is using either the NixOS or the
Home-Manager module, though it is completely possible and no less supported to
install **nvf** as a standalone package, or a flake output.
See the [**nvf** Manual](https://notashelf.github.io/nvf/) for
detailed installation guides, configurations, available options, release notes
and more. Tips for installing userspace plugins is also contained in the
documentation.
See the rendered [nvf manual] for detailed and up-to-date installation guides,
configurations, available options, release notes and more. Tips for installing
userspace plugins is also contained in the documentation.
If you want to dive right into trying **nvf** you can get a fully
featured configuration with `nix` language support by running:
> [!TIP]
> While using NixOS or Home-Manager modules,
> `programs.nvf.enableManpages = true;` will allow you to view option
> documentation from the comfort of your terminal via `man 5 nvf`. The more you
> know.
```console
nix run github:notashelf/nvf#nix
```
Please create an issue on the [issue tracker] if you find the documentation
lacking or confusing. Any improvements to the documentation through pull
requests are also welcome, and appreciated.
Please create an issue on the [issue tracker](../../../issues) if you find
the documentation lacking or confusing. I also appreciate any contributions
to the documentation.
## Help
You can create an issue on the [issue tracker] to ask questions or report bugs.
I am not yet on spaces like matrix or IRC, so please use the issue tracker for
now.
You can create an issue on the [issue tracker](../../../issues) to ask questions
or report bugs. I am not yet on spaces like matrix or IRC, so please use the issue
tracker for now.
## Contributing
I am always looking for new ways to help improve this flake. If you would like
to contribute, please read the [contributing guide](CONTRIBUTING.md) before
submitting a pull request. You can also create an issue on the [issue tracker]
before submitting a pull request if you would like to discuss a feature or bug
fix.
submitting a pull request. You can also create an issue on the
[issue tracker](../../../issues) before submitting a pull request if you would
like to discuss a feature or bug fix.
## FAQ
[appropriate issue template]: https://github.com/NotAShelf/nvf/issues/new/choose
[list of branches]: https://github.com/NotAShelf/nvf/branches
[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
**Q**: Can you add _X_?
<br/> **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, PRs adding new features are also welcome.
<br/>
**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 [appropritate issue
template](https://github.com/NotAShelf/nvf/issues/new/choose) and I will
consider a module addition.
**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.
**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
[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.
<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.
## Credits
### Contributors
Special, heart-felt thanks to
Special thanks to
- [@fufexan](https://github.com/fufexan) - For the transition to flake-parts
- [@FlafyDev](https://github.com/FlafyDev) - For getting the home-manager to
work
- [@n3oney](https://github.com/n3oney) - For making custom keybinds finally
possible
- [@horriblename](https://github.com/horriblename) - For actively implementing
planned features and quality of life updates
- [@FlafyDev](https://github.com/FlafyDev) - For getting the home-manager to work
- [@n3oney](https://github.com/n3oney) - For making custom keybinds finally possible
- [@horriblename](https://github.com/horriblename) - For actively implementing planned features and quality of life updates
- [@Yavko](https://github.com/Yavko) - For the amazing **nvf** logo
- [@FrothyMarrow](https://github.com/FrothyMarrow) - For seeing mistakes that I
could not
- [@Diniamo](https://github.com/Diniamo) - For actively submitting PRs, pull
requests and overall assistence
- [@Gerg-l](https://github.com/gerg-l) - For the modern Neovim wrapper, mnw and
occasional code improvements
- [@FrothyMarrow](https://github.com/FrothyMarrow) - For seeing mistakes that I could not
and everyone who has submitted issues or pull requests!
@ -209,18 +167,10 @@ and everyone who has submitted issues or pull requests!
This configuration borrows from and is based on a few other configurations,
including:
- [@jordanisaacs's](https://github.com/jordanisaacs)
[neovim-flake](https://github.com/jordanisaacs/neovim-flake) that this flake
is originally based on.
- [@sioodmy's](https://github.com/sioodmy)
[dotfiles](https://github.com/sioodmy/dotfiles) that inspired the design
choices.
- [@wiltaylor's](https://github.com/wiltaylor)
[neovim-flake](https://github.com/wiltaylor/neovim-flake) for plugin and
design ideas.
- [@gvolpe's](https://github.com/gvolpe)
[neovim-flake](https://github.com/gvolpe/neovim-flake) for plugin, design and
nix concepts.
- [@jordanisaacs's](https://github.com/jordanisaacs) [neovim-flake](https://github.com/jordanisaacs/neovim-flake) that this flake is originally based on.
- [@sioodmy's](https://github.com/sioodmy) [dotfiles](https://github.com/sioodmy/dotfiles) that inspired the design choices.
- [@wiltaylor's](https://github.com/wiltaylor) [neovim-flake](https://github.com/wiltaylor/neovim-flake) for plugin and design ideas.
- [@gvolpe's](https://github.com/gvolpe) [neovim-flake](https://github.com/gvolpe/neovim-flake) for plugin, design and nix concepts.
I am grateful for their previous work and inspiration, and I wholeheartedly
recommend checking their work out.
@ -228,13 +178,9 @@ recommend checking their work out.
## License
Following the license of the
[original neovim-flake](https://github.com/jordanisaacs/neovim-flake), **nvf**
has been made available under the [**MIT License**](LICENSE). However, all
assets and documentation are published under the
[**CC BY License**](https://github.com/NotAShelf/nvf/blob/main/.github/assets/LICENSE).
<h6 align="center">Yes, this includes the logo work too. Stop taking artwork that is not yours!</h6>
Following the [original neovim-flake](https://github.com/jordanisaacs/neovim-flake)
**nvf** has been made available under the **MIT License**. However, all assets
are published under the [CC BY License].
---

View file

@ -1,57 +0,0 @@
<!--
^ Please include a clear and concise description of the aim of your Pull Request above this line ^
For plugin dependency/module additions, please make sure to link the source link of the added plugin
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.
-->
## 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.
If your pull request includes any change or unexpected behaviour not covered below, please do make sure to include
it above in your description.
-->
[editorconfig]: https://editorconfig.org
[changelog]: https://github.com/NotAShelf/nvf/tree/main/docs/release-notes
- [ ] I have updated the [changelog] as per my changes.
- [ ] I have tested, and self-reviewed my code.
- Style and consistency
- [ ] I ran **Alejandra** to format my code (`nix fmt`).
- [ ] My code conforms to the [editorconfig] configuration of the project.
- [ ] My changes are consistent with the rest of the codebase.
- If new changes are particularly complex:
- [ ] My code includes comments in particularly complex areas
- [ ] I have added a section in the manual.
- [ ] _(For breaking changes)_ I have included a migration guide.
- Package(s) built:
- [ ] `.#nix` (default package)
- [ ] `.#maximal`
- [ ] `.#docs-html`
- Tested on platform(s)
- [ ] `x86_64-linux`
- [ ] `aarch64-linux`
- [ ] `x86_64-darwin`
- [ ] `aarch64-darwin`
<!--
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.
-->
---
Add a :+1: [reaction] to [pull requests you find important].
[reaction]: https://github.blog/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/
[pull requests you find important]: https://github.com/NixOS/nixpkgs/pulls?q=is%3Aopen+sort%3Areactions-%2B1-desc

View file

@ -19,6 +19,7 @@ jobs:
package:
- default
- nix
- tidal
- maximal
steps:
- uses: easimon/maximize-build-space@v10
@ -37,7 +38,7 @@ jobs:
uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- uses: cachix/cachix-action@v15
- uses: cachix/cachix-action@v14
with:
authToken: ${{ secrets.CACHIX_TOKEN }}
extraPullNames: nix-community

View file

@ -48,4 +48,4 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: "${{ matrix.package }}"
path: result/share/doc/nvf
path: result/share/doc/neovim-flake/

View file

@ -1,22 +0,0 @@
name: Cleanup
on:
workflow_dispatch:
schedule:
- cron: "0 4 1 * *" # 4AM on 1st of every month
- cron: "0 4 15 * *" # 4AM on the 15th of every month
jobs:
branches:
name: Cleanup old branches
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: "Delete old branches"
uses: beatlabs/delete-old-branches-action@v0.0.10
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
date: "1 months ago"
dry_run: false
delete_tags: false
exclude_open_pr_branches: true

50
.github/workflows/docker.yml vendored Normal file
View file

@ -0,0 +1,50 @@
name: "Publish Docker Image"
on:
workflow_dispatch:
push:
tags: ["v*"]
jobs:
build-docker-image:
name: "Build Docker Image"
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main
- name: Magic Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@main
- name: Build Docker Image
run: nix build .#docker-nix --print-build-logs
- name: Load & Tag Built Docker Image
run: |
docker load -i result &&
docker tag neovim-flake:latest notashelf/neovim-flake:latest
- name: Log into DockerHub
uses: docker/login-action@master
with:
username: notashelf
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
- name: Push to DockerHub
run: docker push notashelf/neovim-flake:latest
- name: Log into ghcr
uses: docker/login-action@master
with:
registry: "ghcr.io"
username: "${{ github.actor }}"
password: "${{ secrets.GITHUB_TOKEN }}"
- name: Publish Docker Image (Github Packages)
run: docker push notashelf/neovim-flake:latest

View file

@ -1,5 +1,4 @@
name: "Build and deploy documentation"
on:
workflow_dispatch:
push:
@ -8,7 +7,6 @@ on:
paths:
# build the manuals only when docs directory is updated
- docs/**
- modules/**
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
@ -22,34 +20,23 @@ concurrency:
cancel-in-progress: true
jobs:
check_date:
runs-on: ubuntu-latest
name: Check latest commit
outputs:
should_run: ${{ steps.should_run.outputs.should_run }}
steps:
- uses: actions/checkout@v4.1.7
- name: print latest_commit
run: echo ${{ github.sha }}
- id: should_run
continue-on-error: true
name: check latest commit is less than a day
if: ${{ github.event_name == 'schedule' }}
run: test -z $(git rev-list --after="24 hours" ${{ github.sha }}) && echo "::set-output name=should_run::false"
publish:
needs: check_date
if: ${{ needs.check_date.outputs.should_run != 'false' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.1.7
- uses: DeterminateSystems/nix-installer-action@main
- name: Checkout
uses: actions/checkout@v4
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- run: |
nix build .#docs
cp -r result/share/doc/nvf public
- uses: peaceiris/actions-gh-pages@v4
- name: Build
run: |
nix build '.#docs'
cp -r result/share/doc/neovim-flake public
- name: Deploy
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public

View file

@ -1,4 +1,25 @@
isMaximal: {
inputs: let
modulesWithInputs = import ./modules inputs;
neovimConfiguration = {
modules ? [],
pkgs,
lib ? pkgs.lib,
check ? true,
extraSpecialArgs ? {},
extraModules ? [],
...
}:
modulesWithInputs {
inherit pkgs lib check extraSpecialArgs extraModules;
configuration.imports = modules;
};
tidalConfig = {
config.vim.languages.tidal.enable = true;
};
mainConfig = isMaximal: {
config.vim = {
viAlias = true;
vimAlias = true;
@ -17,9 +38,9 @@ isMaximal: {
lspkind.enable = false;
lightbulb.enable = true;
lspsaga.enable = false;
nvimCodeActionMenu.enable = isMaximal;
trouble.enable = true;
lspSignature.enable = true;
otter-nvim.enable = isMaximal;
lsplines.enable = isMaximal;
nvim-docs-view.enable = isMaximal;
};
@ -37,16 +58,7 @@ isMaximal: {
enableTreesitter = true;
enableExtraDiagnostics = true;
# Nim LSP is broken on Darwin and therefore
# should be disabled by default. Users may still enable
# `vim.languages.vim` to enable it, this does not restrict
# that.
# See: <https://github.com/PMunch/nimlsp/issues/178#issue-2128106096>
nim.enable = false;
nix.enable = true;
markdown.enable = isMaximal;
html.enable = isMaximal;
css.enable = isMaximal;
sql.enable = isMaximal;
@ -54,16 +66,14 @@ isMaximal: {
ts.enable = isMaximal;
svelte.enable = isMaximal;
go.enable = isMaximal;
lua.enable = isMaximal;
elixir.enable = isMaximal;
zig.enable = isMaximal;
ocaml.enable = isMaximal;
python.enable = isMaximal;
dart.enable = isMaximal;
elixir.enable = isMaximal;
bash.enable = isMaximal;
r.enable = isMaximal;
terraform.enable = isMaximal;
nim.enable = false;
tailwind.enable = isMaximal;
typst.enable = isMaximal;
clang = {
enable = isMaximal;
lsp.server = "clangd";
@ -71,20 +81,27 @@ isMaximal: {
rust = {
enable = isMaximal;
crates.enable = isMaximal;
crates.enable = true;
};
};
visuals = {
enable = true;
nvimWebDevicons.enable = true;
scrollBar.enable = isMaximal;
scrollBar.enable = true;
smoothScroll.enable = true;
cellularAutomaton.enable = false;
fidget-nvim.enable = true;
highlight-undo.enable = true;
indentBlankline.enable = true;
indentBlankline = {
enable = true;
fillChar = null;
eolChar = null;
scope = {
enabled = true;
};
};
cursorline = {
enable = true;
@ -157,15 +174,14 @@ isMaximal: {
};
utility = {
ccc.enable = false;
vim-wakatime.enable = false;
ccc.enable = isMaximal;
vim-wakatime.enable = isMaximal;
icon-picker.enable = isMaximal;
surround.enable = isMaximal;
diffview-nvim.enable = true;
motion = {
hop.enable = true;
leap.enable = true;
precognition.enable = isMaximal;
};
images = {
@ -201,13 +217,12 @@ isMaximal: {
enable = true;
setupOpts.custom_colorcolumn = {
# this is a freeform module, it's `buftype = int;` for configuring column position
nix = "110";
ruby = "120";
java = "130";
go = ["90" "130"];
nix = 110;
ruby = 120;
java = 130;
go = [90 130];
};
};
fastaction.enable = true;
};
assistant = {
@ -234,4 +249,7 @@ isMaximal: {
neocord.enable = false;
};
};
};
in {
inherit neovimConfiguration mainConfig tidalConfig;
}

View file

@ -1,25 +1,20 @@
{
inputs,
pkgs,
lib,
lib ? import ../lib/stdlib-extended.nix pkgs.lib inputs,
manpageUrls ? pkgs.path + "/doc/manpage-urls.json",
...
}: let
inherit ((lib.importJSON ../release.json)) release;
inherit (lib.modules) mkForce evalModules;
inherit (lib.strings) hasPrefix removePrefix;
inherit (lib.attrsets) isAttrs mapAttrs optionalAttrs recursiveUpdate isDerivation;
inherit (builtins) fromJSON readFile;
nvimModuleDocs = pkgs.nixosOptionsDoc {
variablelistId = "nvf-options";
warningsAreErrors = true;
# release data
release-config = fromJSON (readFile ../release.json);
revision = release-config.release;
inherit
(
(lib.evalModules {
modules =
import ../modules/modules.nix {
inherit lib pkgs;
}
++ [
(
let
# From nixpkgs:
# From home-manager:
#
# Recursively replace each derivation in the given attribute set
# with the same derivation but with the `outPath` attribute set to
@ -33,73 +28,131 @@
# Caveat: even if the package is reached by a different means, the
# path above will be shown and not e.g.
# `${config.services.foo.package}`.
scrubDerivations = namePrefix: pkgSet:
builtins.mapAttrs (
name: value: let
wholeName = "${namePrefix}.${name}";
scrubDerivations = prefixPath: attrs: let
scrubDerivation = name: value: let
pkgAttrName = prefixPath + "." + name;
in
if builtins.isAttrs value
if isAttrs value
then
scrubDerivations wholeName value
// lib.optionalAttrs (lib.isDerivation value) {
inherit (value) drvPath;
outPath = "\${${wholeName}}";
scrubDerivations pkgAttrName value
// optionalAttrs (isDerivation value) {
outPath = "\${${pkgAttrName}}";
}
else value
)
pkgSet;
in {
_module = {
check = false;
args.pkgs = lib.mkForce (scrubDerivations "pkgs" pkgs);
else value;
in
mapAttrs scrubDerivation attrs;
# Make sure the used package is scrubbed to avoid actually
# instantiating derivations.
scrubbedPkgsModule = {
imports = [
{
_module.args = {
pkgs = mkForce (scrubDerivations "pkgs" pkgs);
pkgs_i686 = mkForce {};
};
}
)
];
})
)
options
;
};
# Specify the path to the module entrypoint
nvimPath = toString ./..;
buildOptionsDocs = args @ {
modules,
includeModuleSystemOptions ? true,
warningsAreErrors ? true,
...
}: let
inherit ((evalModules {inherit modules;})) options;
# Declaration of the Github site URL.
# Takes a user, repo, and subpath, and returns a declaration site
# as a string.
githubDeclaration = user: repo: subpath: let
urlRef = "github.com";
branch = "main";
in {
url = "https://${urlRef}/${user}/${repo}/blob/${branch}/${subpath}";
name = "<${repo}/${subpath}>";
};
in
pkgs.buildPackages.nixosOptionsDoc ({
inherit warningsAreErrors;
options =
if includeModuleSystemOptions
then options
else builtins.removeAttrs options ["_module"];
transformOptions = opt:
opt
// {
declarations =
map (
decl:
if lib.hasPrefix (toString ../.) (toString decl)
recursiveUpdate opt {
# Clean up declaration sites to not refer to the nvf
# source tree.
declarations = map (decl:
if hasPrefix nvimPath (toString decl)
then
lib.pipe decl [
toString
(lib.removePrefix (toString ../.))
(lib.removePrefix "/")
(x: {
url = "https://github.com/NotAShelf/nvf/blob/main/${x}";
name = "<nvf/${x}>";
})
]
githubDeclaration "notashelf" "nvf"
(removePrefix "/" (removePrefix nvimPath (toString decl)))
else if decl == "lib/modules.nix"
then {
url = "https://github.com/NixOS/nixpkgs/blob/master/${decl}";
name = "<nixpkgs/lib/modules.nix>";
}
else decl
)
then
# TODO: handle this in a better way (may require upstream
# changes to nixpkgs)
githubDeclaration "NixOS" "nixpkgs" decl
else decl)
opt.declarations;
};
}
// builtins.removeAttrs args ["modules" "includeModuleSystemOptions"]);
nvimModuleDocs = buildOptionsDocs {
variablelistId = "nvf-options";
modules =
import ../modules/modules.nix {
inherit lib pkgs;
check = false;
}
++ [scrubbedPkgsModule];
};
# Generate the `man home-configuration.nix` package
nvf-configuration-manual =
pkgs.runCommand "nvf-reference-manpage" {
nativeBuildInputs = [pkgs.buildPackages.installShellFiles pkgs.nixos-render-docs];
allowedReferences = ["out"];
} ''
# Generate manpages.
mkdir -p $out/share/man/man5
mkdir -p $out/share/man/man1
nixos-render-docs -j $NIX_BUILD_CORES options manpage \
--revision ${revision} \
--header ${./man/header.5} \
--footer ${./man/footer.5} \
${nvimModuleDocs.optionsJSON}/share/doc/nixos/options.json \
$out/share/man/man5/nvf.5
cp ${./man/nvf.1} $out/share/man/man1/nvf.1
'';
# Generate the HTML manual pages
nvf-manual = pkgs.callPackage ./manual.nix {
inherit revision manpageUrls;
outputPath = "share/doc/nvf";
options = {
nvf = nvimModuleDocs.optionsJSON;
};
};
# Generate the HTML manual pages
html = pkgs.callPackage ./manual.nix {
inherit release;
inherit (nvimModuleDocs) optionsJSON;
};
html = nvf-manual;
htmlOpenTool = pkgs.callPackage ./html-open-tool.nix {} {inherit html;};
in {
inherit (inputs) nmd;
options = {
# TODO: Use `hmOptionsDocs.optionsJSON` directly once upstream
# `nixosOptionsDoc` is more customizable.
options.json =
json =
pkgs.runCommand "options.json" {
meta.description = "List of nvf options in JSON format";
} ''
@ -112,31 +165,8 @@ in {
'${nvimModuleDocs.optionsJSON}/share/doc/nixos' \
"$out/share/doc/nvf"
'';
# Generate the `man home-configuration.nix` package
manPages =
pkgs.runCommand "nvf-reference-manpage" {
nativeBuildInputs = [
pkgs.buildPackages.installShellFiles
pkgs.nixos-render-docs
];
allowedReferences = ["out"];
} ''
# Generate manpages.
mkdir -p $out/share/man/{man5,man1}
nixos-render-docs -j $NIX_BUILD_CORES options manpage \
--revision ${release} \
--header ${./man/header.5} \
--footer ${./man/footer.5} \
${nvimModuleDocs.optionsJSON}/share/doc/nixos/options.json \
$out/share/man/man5/nvf.5
cp ${./man/nvf.1} $out/share/man/man1/nvf.1
'';
manual = {
inherit html;
htmlOpenTool = pkgs.callPackage ./html-open-tool.nix {inherit html;};
};
manPages = nvf-configuration-manual;
manual = {inherit html htmlOpenTool;};
}

View file

@ -2,9 +2,13 @@
writeShellScriptBin,
makeDesktopItem,
symlinkJoin,
}: {
html,
pathName ? "nvf",
projectName ? pathName,
name ? "${pathName}-help",
}: let
helpScript = writeShellScriptBin "nvf-help" ''
helpScript = writeShellScriptBin name ''
set -euo pipefail
if [[ ! -v BROWSER || -z $BROWSER ]]; then
@ -20,23 +24,20 @@
echo "$0: unable to start a web browser; please set \$BROWSER"
exit 1
else
exec "$BROWSER" "${html}/share/doc/nvf/index.xhtml"
exec "$BROWSER" "${html}/share/doc/${pathName}/index.xhtml"
fi
'';
desktopItem = makeDesktopItem {
name = "nvf-manual";
desktopName = "nvf Manual";
genericName = "View nvf documentation in a web browser";
name = "${pathName}-manual";
desktopName = "${projectName} Manual";
genericName = "View ${projectName} documentation in a web browser";
icon = "nix-snowflake";
exec = "${helpScript}/bin/nvf-help";
exec = "${helpScript}/bin/${name}";
categories = ["System"];
};
in
symlinkJoin {
name = "nvf-help";
paths = [
helpScript
desktopItem
];
inherit name;
paths = [helpScript desktopItem];
}

View file

@ -4,10 +4,11 @@
# build inputs
nixos-render-docs,
documentation-highlighter,
path,
# nrd configuration
release,
optionsJSON,
manpageUrls,
revision,
options,
outputPath ? "share/doc/nvf",
}:
stdenvNoCC.mkDerivation {
name = "nvf-manual";
@ -19,11 +20,9 @@ stdenvNoCC.mkDerivation {
nativeBuildInputs = [nixos-render-docs];
buildPhase = ''
dest="$out/share/doc/nvf"
mkdir -p "$(dirname "$dest")"
mkdir -p $dest/{highlightjs,media}
mkdir -p out/{highlightjs,media}
cp -vt $dest/highlightjs \
cp -vt out/highlightjs \
${documentation-highlighter}/highlight.pack.js \
${documentation-highlighter}/LICENSE \
${documentation-highlighter}/mono-blue.css \
@ -32,30 +31,36 @@ stdenvNoCC.mkDerivation {
substituteInPlace ./options.md \
--subst-var-by \
OPTIONS_JSON \
${optionsJSON}/share/doc/nixos/options.json
${options.nvf}/share/doc/nixos/options.json
substituteInPlace ./manual.md \
--subst-var-by \
NVF_VERSION \
${release}
${revision}
# copy stylesheet
cp ${./static/style.css} "$dest/style.css"
cp ${./static/style.css} out/style.css
# copy release notes
cp -vr ${./release-notes} release-notes
# generate manual from
nixos-render-docs manual html \
--manpage-urls ${path + "/doc/manpage-urls.json"} \
--revision ${lib.trivial.revisionWithDefault release} \
--manpage-urls ${manpageUrls} \
--revision ${lib.trivial.revisionWithDefault revision} \
--stylesheet style.css \
--script highlightjs/highlight.pack.js \
--script highlightjs/loader.js \
--toc-depth 2 \
--section-toc-depth 1 \
manual.md \
"$dest/index.xhtml"
out/index.xhtml
'';
installPhase = ''
dest="$out/${outputPath}"
mkdir -p "$(dirname "$dest")"
mv out "$dest"
mkdir -p $out/nix-support/
echo "doc manual $dest index.html" >> $out/nix-support/hydra-build-products

View file

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

View file

@ -1,7 +1,7 @@
# Custom Plugins {#ch-custom-plugins}
**nvf**, by default, exposes a wide variety of plugins as module options
for your convenience and bundles necessary dependencies into **nvf**'s runtime.
for your convience and bundles necessary dependencies into **nvf**'s runtime.
In case a plugin is not available in **nvf**, you may consider making a pull
request to **nvf** to include it as a module or you may add it to your
configuration locally.

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -5,6 +5,7 @@ Below are the commands you may run to try out different configurations provided
configurations are provided:
- Nix
- Tidal
- Maximal
You may try out any of the provided configurations using the `nix run` command on a system where Nix is installed.
@ -21,6 +22,7 @@ once you garbage collect.
```console
$ nix run github:notashelf/nvf#nix
$ nix run github:notashelf/nvf#tidal
$ nix run github:notashelf/nvf#maximal
```
@ -31,6 +33,10 @@ $ nix run github:notashelf/nvf#maximal
`Nix` configuration by default provides LSP/diagnostic support for Nix alongisde a set of visual and functional plugins.
By running `nix run .#`, which is the default package, you will build Neovim with this config.
#### Tidal {#sec-configs-tidal}
Tidal is an alternative config that adds vim-tidal on top of the plugins from the Nix configuration.
#### Maximal {#sec-configs-maximal}
`Maximal` is the ultimate configuration that will enable support for more commonly used language as well as additional

View file

@ -10,5 +10,4 @@ rl-0.3.md
rl-0.4.md
rl-0.5.md
rl-0.6.md
rl-0.7.md
```

View file

@ -83,7 +83,7 @@ Release notes for release 0.5
- Updated indent-blankine.nvim to v3 - this comes with a few option changes, which will be migrated with `renamedOptionModule`
[jacekpoz](https://jacekpoz.pl):
[jacekpoz](https://github.com/jacekpoz):
- Fixed scrollOffset not being used

View file

@ -62,7 +62,7 @@ vim.api.nvim_set_keymap('n', '<leader>a', ':lua camelToSnake()<CR>', { noremap =
- Added rose-pine theme.
[jacekpoz](https://jacekpoz.pl):
[jacekpoz](https://github.com/jacekpoz):
- Added `vim.autocomplete.alwaysComplete`. Allows users to have the autocomplete window popup only when manually activated.

View file

@ -1,222 +0,0 @@
# Release 0.7 {#sec-release-0.7}
Release notes for release 0.7
## Breaking Changes and Migration Guide {#sec-breaking-changes-and-migration-guide-0-7}
### `vim.configRC` removed {#sec-vim-configrc-removed}
In v0.7 we are removing `vim.configRC` in favor of making `vim.luaConfigRC` the
top-level DAG, and thereby making the entire configuration Lua based. This
change introduces a few breaking changes:
[DAG entries in nvf manual]: /index.xhtml#ch-dag-entries
- `vim.configRC` has been removed, which means that you have to convert all of
your custom vimscript-based configuration to Lua. As for how to do that, you
will have to consult the Neovim documentation and your search engine.
- After migrating your Vimscript-based configuration to Lua, you might not be
able to use the same entry names in `vim.luaConfigRC`, because those have also
slightly changed. See the new [DAG entries in nvf manual] for more details.
**Why?**
Neovim being an aggressive refactor of Vim, is designed to be mainly Lua based;
making good use of its extensive Lua API. Additionally, Vimscript is slow and
brings unnecessary performance overhead while working with different
configuration formats.
### `vim.lsp.nvimCodeActionMenu` removed in favor of `vim.ui.fastaction` {#sec-nvim-code-action-menu-deprecation}
The nvim-code-action-menu plugin has been archived and broken for a long time,
so it's being replaced with a young, but better alternative called
fastaction.nvim. Simply remove everything set under
`vim.lsp.nvimCodeActionMenu`, and set `vim.ui.fastaction.enable` to `true`.
Note that we are looking to add more alternatives in the future like
dressing.nvim and actions-preview.nvim, in case fastaction doesn't work for
everyone.
## Changelog {#sec-release-0.7-changelog}
[ItsSorae](https://github.com/ItsSorae):
- Add support for [typst](https://typst.app/) under `vim.languages.typst` This
will enable the `typst-lsp` language server, and the `typstfmt` formatter
[frothymarrow](https://github.com/frothymarrow):
- Modified type for
[](#opt-vim.visuals.fidget-nvim.setupOpts.progress.display.overrides) from
`anything` to a `submodule` for better type checking.
- Fix null `vim.lsp.mappings` generating an error and not being filtered out.
- Add basic transparency support for `oxocarbon` theme by setting the highlight
group for `Normal`, `NormalFloat`, `LineNr`, `SignColumn` and optionally
`NvimTreeNormal` to `none`.
- Fix [](#opt-vim.ui.smartcolumn.setupOpts.custom_colorcolumn) using the wrong
type `int` instead of the expected type `string`.
[horriblename](https://github.com/horriblename):
- Fix broken treesitter-context keybinds in visual mode
- Deprecate use of `__empty` to define empty tables in Lua. Empty attrset are no
longer filtered and thus should be used instead.
- Add dap-go for better dap configurations
- Make noice.nvim customizable
- Standardize border style options and add custom borders
[rust-tools.nvim]: https://github.com/simrat39/rust-tools.nvim
[rustaceanvim]: https://github.com/mrcjkb/rustaceanvim
- Switch from [rust-tools.nvim] to the more feature-packed [rustaceanvim]. This
switch entails a whole bunch of new features and options, so you are
recommended to go through rustacean.nvim's README to take a closer look at its
features and usage
[jacekpoz](https://jacekpoz.pl):
[ocaml-lsp]: https://github.com/ocaml/ocaml-lsp
[new-file-template.nvim]: https://github.com/otavioschwanck/new-file-template.nvim
[neo-tree.nvim]: https://github.com/nvim-neo-tree/neo-tree.nvim
- Add [ocaml-lsp] support
- Fix "Emac" typo
- Add [new-file-template.nvim] to automatically fill new file contents using
templates
- Make [neo-tree.nvim] display file icons properly by enabling
`visuals.nvimWebDevicons`
[diniamo](https://github.com/diniamo):
- Move the `theme` dag entry to before `luaScript`.
- Add rustfmt as the default formatter for Rust.
- Enabled the terminal integration of catppuccin for theming Neovim's built-in
terminal (this also affects toggleterm).
- Migrate bufferline to setupOpts for more customizability
- Use `clangd` as the default language server for C languages
- Expose `lib.nvim.types.pluginType`, which for example allows the user to
create abstractions for adding plugins
- Migrate indent-blankline to setupOpts for more customizability. While the
plugin's options can now be found under `indentBlankline.setupOpts`, the
previous iteration of the module also included out of place/broken options,
which have been removed for the time being. These are:
- `listChar` - this was already unused
- `fillChar` - this had nothing to do with the plugin, please configure it
yourself by adding `vim.opt.listchars:append({ space = '<char>' })` to your
lua configuration
- `eolChar` - this also had nothing to do with the plugin, please configure it
yourself by adding `vim.opt.listchars:append({ eol = '<char>' })` to your
lua configuration
- Replace `vim.lsp.nvimCodeActionMenu` with `vim.ui.fastaction`, see the
breaking changes section above for more details
[Neovim documentation on `vim.cmd`]: https://neovim.io/doc/user/lua.html#vim.cmd()
- Make Neovim's configuration file entirely Lua based. This comes with a few
breaking changes:
- `vim.configRC` has been removed. You will need to migrate your entries to
Neovim-compliant Lua code, and add them to `vim.luaConfigRC` instead.
Existing vimscript configurations may be preserved in `vim.cmd` functions.
Please see [Neovim documentation on `vim.cmd`]
- `vim.luaScriptRC` is now the top-level DAG, and the internal `vim.pluginRC`
has been introduced for setting up internal plugins. See the "DAG entries in
nvf" manual page for more information.
[NotAShelf](https://github.com/notashelf):
[ts-error-translator.nvim]: https://github.com/dmmulroy/ts-error-translator.nvim
[credo]: https://github.com/rrrene/credo
- Add `deno fmt` as the default Markdown formatter. This will be enabled
automatically if you have autoformatting enabled, but can be disabled manually
if you choose to.
- Add `vim.extraLuaFiles` for optionally sourcing additional lua files in your
configuration.
- Refactor `programs.languages.elixir` to use lspconfig and none-ls for LSP and
formatter setups respectively. Diagnostics support is considered, and may be
added once the [credo] linter has been added to nixpkgs. A pull request is
currently open.
- Remove vim-tidal and friends.
- Clean up Lualine module to reduce theme dependency on Catppuccin, and fixed
blending issues in component separators.
- Add [ts-ereror-translator.nvim] extension of the TS language module, under
`vim.languages.ts.extensions.ts-error-translator` to aid with Typescript
development.
- Add [neo-tree.nvim] as an alternative file-tree plugin. It will be available
under `vim.filetree.neo-tree`, similar to nvimtree.
- Add `nvf-print-config` & `nvf-print-config-path` helper scripts to Neovim
closure. Both of those scripts have been automatically added to your PATH upon
using neovimConfig or `programs.nvf.enable`.
- `nvf-print-config` will display your `init.lua`, in full.
- `nvf-print-config-path` will display the path to _a clone_ of your
`init.lua`. This is not the path used by the Neovim wrapper, but an
identical clone.
- Add `vim.ui.breadcrumbs.lualine` to allow fine-tuning breadcrumbs behaviour on
Lualine. Only `vim.ui.breadcrumbs.lualine.winbar` is supported for the time
being.
- [](#opt-vim.ui.breadcrumbs.lualine.winbar.enable) has been added to allow
controlling the default behaviour of the `nvim-navic` component on Lualine,
which used to occupy `winbar.lualine_c` as long as breadcrumbs are enabled.
- `vim.ui.breadcrumbs.alwaysRender` has been renamed to
[](#opt-vim.ui.breadcrumbs.lualine.winbar.alwaysRender) to be conform to the
new format.
- Add [basedpyright](https://github.com/detachhead/basedpyright) as a Python LSP
server and make it default.
- Add [python-lsp-server](https://github.com/python-lsp/python-lsp-server) as an
additional Python LSP server.
- Add [](#opt-vim.options) to set `vim.o` values in in your nvf configuration
without using additional Lua. See option documentation for more details.
- Add [](#opt-vim.dashboard.dashboard-nvim.setupOpts) to allow user
configuration for [dashboard.nvim](https://github.com/nvimdev/dashboard-nvim)
- Update `lualine.nvim` input and add missing themes:
- Adds `ayu`, `gruvbox_dark`, `iceberg`, `moonfly`, `onedark`,
`powerline_dark` and `solarized_light` themes.
[ppenguin](https://github.com/ppenguin):
- Telescope:
- Fixed `project-nvim` command and keybinding
- Added default ikeybind/command for `Telescope resume` (`<leader>fr`)
[Soliprem](https://github.com/Soliprem):
- Add LSP and Treesitter support for R under `vim.languages.R`.
- Add Otter support under `vim.lsp.otter` and an assert to prevent conflict with
ccc
[Bloxx12](https://github.com/Bloxx12):
- Fix internal breakage in `elixir-tools` setup.
[Nowaaru](https://github.com/Nowaaru):
- Add `precognition-nvim`.

File diff suppressed because it is too large Load diff

140
flake.nix
View file

@ -1,22 +1,19 @@
{
description = "A neovim flake with a modular configuration";
outputs = {
nixpkgs,
flake-parts,
self,
...
} @ inputs: let
# call the extedended library with `inputs`
# inputs is used to get the original standard library, and to pass inputs to the plugin autodiscovery function
lib = import ./lib/stdlib-extended.nix inputs;
in
flake-parts.lib.mkFlake {
inherit inputs;
specialArgs = {inherit lib;};
} {
# Allow users to bring their own systems.
# «https://github.com/nix-systems/nix-systems»
} @ inputs:
flake-parts.lib.mkFlake {inherit inputs;} {
# provide overridable systems
# https://github.com/nix-systems/nix-systems
systems = import inputs.systems;
imports = [
# add lib to module args
{_module.args = {inherit (nixpkgs) lib;};}
./flake/apps.nix
./flake/legacyPackages.nix
./flake/overlays.nix
@ -25,32 +22,36 @@
flake = {
lib = {
inherit (lib) nvim;
inherit (lib.nvim) neovimConfiguration;
inherit (import ./lib/stdlib-extended.nix nixpkgs.lib inputs) nvim;
inherit (import ./configuration.nix inputs) neovimConfiguration;
};
homeManagerModules = {
neovim-flake =
lib.warn ''
nixpkgs.lib.warn ''
homeManagerModules.neovim-flake has been deprecated.
Plese use the homeManagerModules.nvf instead
Plese use the homeManagereModules.nvf instead
''
self.homeManagerModules.nvf;
nvf = import ./flake/modules/home-manager.nix self.packages lib;
nvf = {
imports = [(import ./flake/modules/home-manager.nix self.packages inputs)];
};
default = self.homeManagerModules.nvf;
};
nixosModules = {
neovim-flake =
lib.warn ''
nixpkgs.lib.warn ''
nixosModules.neovim-flake has been deprecated.
Please use the nixosModules.nvf instead
''
self.nixosModules.nvf;
self.nixosModules.neovim-flake;
nvf = import ./flake/modules/nixos.nix self.packages lib;
nvf = {
imports = [(import ./flake/modules/nixos.nix self.packages inputs)];
};
default = self.nixosModules.nvf;
};
@ -62,49 +63,34 @@
pkgs,
...
}: {
formatter = pkgs.alejandra;
devShells = {
default = self'.devShells.lsp;
nvim-nix = pkgs.mkShell {packages = [config.packages.nix];};
nvim-nix = pkgs.mkShell {nativeBuildInputs = [config.packages.nix];};
lsp = pkgs.mkShell {
packages = with pkgs; [nil statix deadnix alejandra];
nativeBuildInputs = with pkgs; [nil statix deadnix alejandra];
};
};
# Provide the default formatter. `nix fmt` in project root
# will format available files with the correct formatter.
# P.S: Please do not format with nixfmt! It messes with many
# syntax elements and results in unreadable code.
formatter = pkgs.alejandra;
# Check if codebase is properly formatted.
# This can be initiated with `nix build .#checks.<system>.nix-fmt`
# or with `nix flake check`
checks = {
nix-fmt = pkgs.runCommand "nix-fmt-check" {nativeBuildInputs = [pkgs.alejandra];} ''
alejandra --check ${self} < /dev/null | tee $out
'';
};
};
};
# Flake inputs
inputs = {
## Basic Inputs
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
flake-utils.url = "github:numtide/flake-utils";
systems.url = "github:nix-systems/default";
# Alternate neovim-wrapper
mnw.url = "github:Gerg-L/mnw";
# For generating documentation website
nmd = {
url = "sourcehut:~rycee/nmd";
flake = false;
};
# Language servers (use master instead of nixpkgs)
# TODO: get zig from the zig overlay instead of nixpkgs
zig.url = "github:mitchellh/zig-overlay";
# Langauge server (use master instead of nixpkgs)
rnix-lsp.url = "github:nix-community/rnix-lsp";
nil = {
url = "github:oxalica/nil";
@ -112,7 +98,13 @@
inputs.flake-utils.follows = "flake-utils";
};
## Plugins
### Plugins
# Tidal cycles
tidalcycles = {
url = "github:mitchmindtree/tidalcycles.nix";
inputs.vim-tidal-src.url = "github:tidalcycles/vim-tidal";
};
# LSP plugins
plugin-nvim-lspconfig = {
url = "github:neovim/nvim-lspconfig";
@ -144,8 +136,8 @@
flake = false;
};
plugin-fastaction-nvim = {
url = "github:Chaitanyabsprip/fastaction.nvim";
plugin-nvim-code-action-menu = {
url = "github:weilbith/nvim-code-action-menu";
flake = false;
};
@ -170,19 +162,14 @@
flake = false;
};
plugin-otter-nvim = {
url = "github:jmbuhr/otter.nvim";
flake = false;
};
# Language support
# language support
plugin-sqls-nvim = {
url = "github:nanotee/sqls.nvim";
flake = false;
};
plugin-rustaceanvim = {
url = "github:mrcjkb/rustaceanvim";
plugin-rust-tools = {
url = "github:simrat39/rust-tools.nvim";
flake = false;
};
@ -196,13 +183,23 @@
flake = false;
};
plugin-elixir-ls = {
url = "github:elixir-lsp/elixir-ls";
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";
plugin-glow-nvim = {
url = "github:ellisonleao/glow.nvim";
flake = false;
};
plugin-image-nvim = {
url = "github:3rd/image.nvim";
flake = false;
};
@ -234,22 +231,12 @@
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";
@ -515,21 +502,6 @@
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";
@ -649,15 +621,9 @@
};
plugin-nvim-nio = {
# (required by nvim-dap-ui)
# (required nvim-dap-ui)
url = "github:nvim-neotest/nvim-nio";
flake = false;
};
plugin-new-file-template-nvim = {
# (required by new-file-template.nvim)
url = "github:otavioschwanck/new-file-template.nvim";
flake = false;
};
};
}

View file

@ -1,11 +1,21 @@
{lib, ...}: let
inherit (lib.meta) getExe;
in {
perSystem = {config, ...}: {
apps = {
nix.program = getExe config.packages.nix;
maximal.program = getExe config.packages.maximal;
{lib, ...}: {
perSystem = {
system,
config,
...
}: {
apps =
{
nix.program = lib.getExe config.packages.nix;
maximal.program = lib.getExe config.packages.maximal;
default = config.apps.nix;
};
}
// (
if !(builtins.elem system ["aarch64-darwin" "x86_64-darwin"])
then {
tidal.program = lib.getExe config.packages.tidal;
}
else {}
);
};
}

View file

@ -7,6 +7,7 @@
legacyPackages = import inputs.nixpkgs {
inherit system;
overlays = [
inputs.tidalcycles.overlays.default
inputs.self.overlays.default
(_: _: {
rnix-lsp = inputs'.rnix-lsp.defaultPackage;

View file

@ -1,44 +1,40 @@
# Home Manager module
packages: lib: {
packages: inputs: {
config,
pkgs,
lib ? pkgs.lib,
...
}: let
inherit (lib) maintainers;
inherit (lib.modules) mkIf mkAliasOptionModule;
inherit (lib.modules) mkIf;
inherit (lib.lists) optional;
inherit (lib.options) mkOption mkEnableOption literalExpression;
inherit (lib.types) attrsOf anything bool;
inherit (lib.nvim) neovimConfiguration;
inherit (lib.nvim.types) anythingConcatLists;
cfg = config.programs.nvf;
cfg = config.programs.neovim-flake;
inherit (import ../../configuration.nix inputs) neovimConfiguration;
neovimConfigured = neovimConfiguration {
inherit pkgs;
modules = [cfg.settings];
};
in {
imports = [
(mkAliasOptionModule ["programs" "neovim-flake"] ["programs" "nvf"])
];
meta.maintainers = with maintainers; [NotAShelf];
options.programs.nvf = {
enable = mkEnableOption "nvf, the extensible neovim configuration wrapper";
options.programs.neovim-flake = {
enable = mkEnableOption "neovim-flake, the extensible neovim configuration wrapper";
enableManpages = mkOption {
type = bool;
default = false;
description = "Whether to enable manpages for nvf.";
description = "Whether to enable manpages for neovim-flake.";
};
defaultEditor = mkOption {
type = bool;
default = false;
description = ''
Whether to set `nvf` as the default editor.
Whether to set `neovim-flake` as the default editor.
This will set the `EDITOR` environment variable as `nvim`
if set to true.
@ -50,14 +46,14 @@ in {
visible = false;
readOnly = true;
description = ''
The built nvf package, wrapped with the user's configuration.
The built neovim-flake package, wrapped with the user's configuration.
'';
};
settings = mkOption {
type = attrsOf anythingConcatLists;
type = attrsOf anything;
default = {};
description = "Attribute set of nvf preferences.";
description = "Attribute set of neovim-flake preferences.";
example = literalExpression ''
{
vim.viAlias = false;
@ -67,6 +63,7 @@ in {
formatOnSave = true;
lightbulb.enable = true;
lspsaga.enable = false;
nvimCodeActionMenu.enable = true;
trouble.enable = true;
lspSignature.enable = true;
rust.enable = false;
@ -78,7 +75,7 @@ in {
};
config = mkIf cfg.enable {
programs.nvf.finalPackage = neovimConfigured.neovim;
programs.neovim-flake.finalPackage = neovimConfigured.neovim;
home = {
sessionVariables = mkIf cfg.defaultEditor {EDITOR = "nvim";};
@ -87,5 +84,4 @@ in {
++ optional cfg.enableManpages packages.${pkgs.stdenv.system}.docs-manpages;
};
};
_file = ./home-manager.nix;
}

View file

@ -1,44 +1,40 @@
# NixOS module
packages: lib: {
packages: inputs: {
config,
pkgs,
lib ? pkgs.lib,
...
}: let
inherit (lib) maintainers;
inherit (lib.modules) mkIf mkOverride mkAliasOptionModule;
inherit (lib.modules) mkIf mkOverride;
inherit (lib.lists) optional;
inherit (lib.options) mkOption mkEnableOption literalExpression;
inherit (lib.types) attrsOf anything bool;
inherit (lib.nvim) neovimConfiguration;
inherit (lib.nvim.types) anythingConcatLists;
cfg = config.programs.nvf;
cfg = config.programs.neovim-flake;
inherit (import ../../configuration.nix inputs) neovimConfiguration;
neovimConfigured = neovimConfiguration {
inherit pkgs;
modules = [cfg.settings];
};
in {
imports = [
(mkAliasOptionModule ["programs" "neovim-flake"] ["programs" "nvf"])
];
meta.maintainers = with maintainers; [NotAShelf];
options.programs.nvf = {
enable = mkEnableOption "nvf, the extensible neovim configuration wrapper";
options.programs.neovim-flake = {
enable = mkEnableOption "neovim-flake, the extensible neovim configuration wrapper";
enableManpages = mkOption {
type = bool;
default = false;
description = "Whether to enable manpages for nvf.";
description = "Whether to enable manpages for neovim-flake.";
};
defaultEditor = mkOption {
type = bool;
default = false;
description = ''
Whether to set `nvf` as the default editor.
Whether to set `neovim-flake` as the default editor.
This will set the `EDITOR` environment variable as `nvim`
if set to true.
@ -50,14 +46,14 @@ in {
visible = false;
readOnly = true;
description = ''
The built nvf package, wrapped with the user's configuration.
The built neovim-flake package, wrapped with the user's configuration.
'';
};
settings = mkOption {
type = attrsOf anythingConcatLists;
type = attrsOf anything;
default = {};
description = "Attribute set of nvf preferences.";
description = "Attribute set of neovim-flake preferences.";
example = literalExpression ''
{
vim.viAlias = false;
@ -67,6 +63,7 @@ in {
formatOnSave = true;
lightbulb.enable = true;
lspsaga.enable = false;
nvimCodeActionMenu.enable = true;
trouble.enable = true;
lspSignature.enable = true;
rust.enable = false;
@ -78,7 +75,7 @@ in {
};
config = mkIf cfg.enable {
programs.nvf.finalPackage = neovimConfigured.neovim;
programs.neovim-flake.finalPackage = neovimConfigured.neovim;
environment = {
variables.EDITOR = mkIf cfg.defaultEditor (mkOverride 900 "nvim");
@ -87,5 +84,4 @@ in {
++ optional cfg.enableManpages packages.${pkgs.stdenv.system}.docs-manpages;
};
};
_file = ./nixos.nix;
}

View file

@ -1,19 +1,21 @@
{
inputs,
pkgs,
lib,
...
}: let
inherit (lib.nvim) neovimConfiguration;
inherit (import ../configuration.nix inputs) neovimConfiguration mainConfig;
buildPkg = pkgs: modules: (neovimConfiguration {inherit pkgs modules;}).neovim;
nixConfig = import ../configuration.nix false;
maximalConfig = import ../configuration.nix true;
nixConfig = mainConfig false;
maximalConfig = mainConfig true;
tidalConfig = {config.vim.tidal.enable = true;};
in {
flake.overlays.default = _final: prev: {
inherit neovimConfiguration;
neovim-nix = buildPkg prev [nixConfig];
neovim-maximal = buildPkg prev [maximalConfig];
neovim-tidal = buildPkg prev [tidalConfig];
devPkg = buildPkg pkgs [nixConfig {config.vim.languages.html.enable = pkgs.lib.mkForce true;}];
};
}

View file

@ -1,14 +1,14 @@
{inputs, ...}: {
perSystem = {
system,
config,
pkgs,
lib,
...
}: let
docs = import ../docs {inherit pkgs inputs lib;};
docs = import ../docs {inherit pkgs inputs;};
in {
packages = {
inherit (docs.manual) htmlOpenTool;
packages =
{
# Documentation
docs = docs.manual.html;
docs-html = docs.manual.html;
@ -52,6 +52,11 @@
Volumes = {"/home/neovim/demo" = {};};
};
};
};
}
// (
if !(builtins.elem system ["aarch64-darwin" "x86_64-darwin"])
then {tidal = config.legacyPackages.neovim-tidal;}
else {}
);
};
}

View file

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

View file

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

View file

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

View file

@ -2,9 +2,19 @@
{lib}: let
inherit (builtins) hasAttr head throw typeOf isList isAttrs isBool isInt isString isPath isFloat toJSON;
inherit (lib.attrsets) mapAttrsToList filterAttrs;
inherit (lib.strings) concatStringsSep concatMapStringsSep stringToCharacters concatLines;
inherit (lib.trivial) boolToString warn;
inherit (lib.strings) concatStringsSep concatMapStringsSep stringToCharacters;
inherit (lib.trivial) boolToString;
in rec {
wrapLuaConfig = {
luaBefore ? "",
luaConfig,
luaAfter ? "",
}: ''
lua << EOF
${concatStringsSep "\n" [luaBefore luaConfig luaAfter]}
EOF
'';
# Convert a null value to lua's nil
nullString = value:
if value == null
@ -56,10 +66,7 @@ in rec {
if isLuaInline args
then args.expr
else if hasAttr "__empty" args
then
warn ''
Using `__empty` to define an empty lua table is deprecated. Use an empty attrset instead.
'' "{ }"
then "{ }"
else
"{"
+ (concatStringsSep ","
@ -69,7 +76,10 @@ in rec {
then toLuaObject v
else "[${toLuaObject n}] = " + (toLuaObject v))
(filterAttrs
(_: v: v != null)
(
_: v:
(v != null) && (toLuaObject v != "{}")
)
args)))
+ "}"
else if isList args

View file

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

View file

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

View file

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

View file

@ -5,7 +5,7 @@
}: let
inherit (lib.options) mkOption;
inherit (lib.attrsets) attrNames mapAttrs' filterAttrs nameValuePair;
inherit (lib.strings) hasPrefix removePrefix;
inherit (lib.strings) hasPrefix removePrefix isString;
inherit (lib.types) submodule either package enum str lines attrsOf anything listOf nullOr;
# Get the names of all flake inputs that start with the given prefix.
@ -51,12 +51,8 @@
};
};
};
borderPresets = ["none" "single" "double" "rounded" "solid" "shadow"];
in {
inherit extraPluginType fromInputs pluginType;
borderType = either (enum borderPresets) (listOf (either str (listOf str)));
inherit extraPluginType fromInputs;
pluginsOpt = {
description,
@ -97,7 +93,7 @@ in {
default = {};
type = submodule {
freeformType = anything;
freeformType = attrsOf anything;
options = opts;
};
};

26
lib/vim.nix Normal file
View file

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

View file

@ -1,134 +1,124 @@
{
inputs,
lib,
}: {
inputs: {
configuration,
pkgs,
lib ? pkgs.lib,
check ? true,
extraSpecialArgs ? {},
modules ? [],
# deprecated
extraModules ? [],
configuration ? {},
}: let
inherit (pkgs) vimPlugins;
inherit (lib.strings) isString toString;
inherit (lib.lists) filter map concatLists;
inherit (builtins) map filter isString toString getAttr;
inherit (pkgs) wrapNeovimUnstable vimPlugins;
inherit (pkgs.vimUtils) buildVimPlugin;
inherit (pkgs.neovimUtils) makeNeovimConfig;
inherit (lib.strings) makeBinPath escapeShellArgs concatStringsSep;
inherit (lib.lists) concatLists optional;
inherit (lib.attrsets) recursiveUpdate;
inherit (lib.asserts) assertMsg;
# call the extedended library with `lib` and `inputs` as arguments
# lib is used to provide the standard library functions to the extended library
# but it can be overridden while this file is being called
# inputs is used to pass inputs to the plugin autodiscovery function
extendedLib = import ../lib/stdlib-extended.nix lib inputs;
# import modules.nix with `check`, `pkgs` and `lib` as arguments
# check can be disabled while calling this file is called
# to avoid checking in all modules
nvimModules = import ./modules.nix {inherit pkgs lib;};
nvimModules = import ./modules.nix {
inherit check pkgs;
lib = extendedLib;
};
# evaluate the extended library with the modules
# optionally with any additional modules passed by the user
module = lib.evalModules {
specialArgs = extraSpecialArgs // {modulesPath = toString ./.;};
modules = concatLists [
nvimModules
modules
(lib.optional (configuration != {}) (lib.warn ''
nvf: passing 'configuration' to lib.neovimConfiguration is deprecated.
''
configuration))
(lib.optionals (extraModules != []) (lib.warn ''
nvf: passing 'extraModules' to lib.neovimConfiguration is deprecated, use 'modules' instead.
''
extraModules))
];
module = extendedLib.evalModules {
specialArgs = recursiveUpdate {modulesPath = toString ./.;} extraSpecialArgs;
modules = concatLists [[configuration] nvimModules extraModules];
};
# alias to the internal configuration
vimOptions = module.config.vim;
noBuildPlug = {pname, ...} @ attrs: let
src = inputs."plugin-${attrs.pname}";
in
{
version = src.shortRev or src.shortDirtyRev or "dirty";
outPath = src;
passthru.vimPlugin = false;
}
// attrs;
# build a vim plugin with the given name and arguments
# if the plugin is nvim-treesitter, warn the user to use buildTreesitterPlug
# instead
buildPlug = attrs: let
src = inputs."plugin-${attrs.pname}";
in
pkgs.vimUtils.buildVimPlugin (
{
version = src.shortRev or src.shortDirtyRev or "dirty";
inherit src;
}
// attrs
);
buildPlug = {pname, ...} @ args:
assert assertMsg (pname != "nvim-treesitter") "Use buildTreesitterPlug for building nvim-treesitter.";
buildVimPlugin (args
// {
version = "master";
src = getAttr ("plugin-" + pname) inputs;
});
buildTreesitterPlug = grammars: vimPlugins.nvim-treesitter.withPlugins (_: grammars);
pluginBuilders = {
nvim-treesitter = buildTreesitterPlug vimOptions.treesitter.grammars;
flutter-tools-patched = buildPlug {
buildConfigPlugins = plugins:
map
(plug: (
if (isString plug)
then
(
if (plug == "nvim-treesitter")
then (buildTreesitterPlug vimOptions.treesitter.grammars)
else if (plug == "flutter-tools-patched")
then
(buildPlug {
pname = "flutter-tools";
patches = [../patches/flutter-tools.patch];
};
};
buildConfigPlugins = plugins:
map (
plug:
if (isString plug)
then pluginBuilders.${plug} or (noBuildPlug {pname = plug;})
})
else (buildPlug {pname = plug;})
)
else plug
) (filter (f: f != null) plugins);
))
(filter
(f: f != null)
plugins);
# built (or "normalized") plugins that are modified
builtStartPlugins = buildConfigPlugins vimOptions.startPlugins;
builtOptPlugins = map (package: {
plugin = package;
optional = true;
optional = false;
}) (buildConfigPlugins vimOptions.optPlugins);
# combine built start and optional plugins
# into a single list
plugins = builtStartPlugins ++ builtOptPlugins;
# additional Lua and Python3 packages, mapped to their respective functions
# to conform to the format mnw expects. end user should
# to conform to the format makeNeovimConfig expects. end user should
# only ever need to pass a list of packages, which are modified
# here
extraLuaPackages = ps: map (x: ps.${x}) vimOptions.luaPackages;
extraPython3Packages = ps: map (x: ps.${x}) vimOptions.python3Packages;
# Wrap the user's desired (unwrapped) Neovim package with arguments that'll be used to
# generate a wrapped Neovim package.
neovim-wrapped = inputs.mnw.lib.wrap pkgs {
neovim = vimOptions.package;
plugins = builtStartPlugins ++ builtOptPlugins;
appName = "nvf";
extraBinPath = vimOptions.extraPackages;
initLua = vimOptions.builtLuaConfigRC;
luaFiles = vimOptions.extraLuaFiles;
extraWrapperArgs =
concatStringsSep " " (optional (vimOptions.extraPackages != []) ''--prefix PATH : "${makeBinPath vimOptions.extraPackages}"'');
# wrap user's desired neovim package with the desired neovim configuration
# using wrapNeovimUnstable and makeNeovimConfig from nixpkgs.
# the makeNeovimConfig function takes the following arguments:
# - withPython (bool)
# - extraPython3Packages (lambda)
# - withNodeJs (bool)
# - withRuby (bool)
# - extraLuaPackages (lambda)
# - plugins (list)
# - customRC (string)
# and returns the wrapped package
neovimConfigured = makeNeovimConfig {
inherit (vimOptions) viAlias vimAlias withRuby withNodeJs withPython3;
inherit extraLuaPackages extraPython3Packages;
inherit plugins extraLuaPackages extraPython3Packages;
customRC = vimOptions.builtConfigRC;
};
dummyInit = pkgs.writeText "nvf-init.lua" vimOptions.builtLuaConfigRC;
# Additional helper scripts for printing and displaying nvf configuration
# in your commandline.
printConfig = pkgs.writers.writeDashBin "nvf-print-config" "cat ${dummyInit}";
printConfigPath = pkgs.writers.writeDashBin "nvf-print-config-path" "echo -n ${dummyInit}";
neovim-wrapped = wrapNeovimUnstable vimOptions.package (recursiveUpdate neovimConfigured {
wrapperArgs = escapeShellArgs neovimConfigured.wrapperArgs + " " + extraWrapperArgs;
});
in {
inherit (module) options config;
inherit (module._module.args) pkgs;
# Expose wrapped neovim-package for userspace
# or module consumption.
neovim = pkgs.symlinkJoin {
name = "nvf-with-helpers";
paths = [neovim-wrapped printConfig printConfigPath];
postBuild = "echo Helpers added";
meta = {
description = "Wrapped version of Neovim with additional helper scripts";
mainProgram = "nvim";
};
};
# expose wrapped neovim-package
neovim = neovim-wrapped;
}

View file

@ -1,18 +0,0 @@
{lib, ...}: let
inherit (lib.modules) mkRemovedOptionModule;
in {
imports = [
# 2024-06-06
(mkRemovedOptionModule ["vim" "tidal"] ''
Tidalcycles language support has been removed as of 2024-06-06 as it was long unmaintained. If
you depended on this functionality, please open an issue.
'')
# 2024-07-20
(mkRemovedOptionModule ["vim" "lsp" "nvimCodeActionMenu"] ''
nvimCodeActionMenu has been deprecated and removed upstream. As of 0.7, fastaction will be
available under `vim.ui.fastaction` as a replacement. Simply remove everything under
`vim.lsp.nvimCodeActionMenu`, and set `vim.ui.fastaction.enable` to `true`.
'')
];
}

View file

@ -1,10 +1,11 @@
{
pkgs,
lib,
check ? true,
}: let
inherit (lib.modules) mkDefault;
inherit (lib.lists) concatLists;
allModules = let
# The core neovim modules.
# Contains configuration for core neovim features
# such as spellchecking, mappings, and the init script (init.vim).
@ -52,21 +53,19 @@
"warnings"
];
# Extra modules, such as deprecation warnings
# or renames in one place.
extra = map (p: ./extra + "/${p}") [
"deprecations.nix"
];
in
concatLists [neovim plugins wrapper extra];
in
allModules
++ [
{
_module.args = {
allModules = concatLists [neovim plugins wrapper];
pkgsModule = {config, ...}: {
config = {
_module = {
inherit check;
args = {
baseModules = allModules;
pkgsPath = mkDefault pkgs.path;
pkgs = mkDefault pkgs;
};
}
]
};
};
};
in
allModules ++ [pkgsModule]

View file

@ -3,21 +3,18 @@
lib,
...
}: let
inherit (lib.options) mkOption mkEnableOption literalExpression literalMD;
inherit (lib.options) mkOption literalExpression;
inherit (lib.strings) optionalString;
inherit (lib.types) enum bool str int either;
inherit (lib.generators) mkLuaInline;
inherit (lib.types) enum bool str int nullOr;
inherit (lib.nvim.dag) entryAfter;
inherit (lib.nvim.lua) toLuaObject;
inherit (lib.nvim.types) luaInline;
cfg = config.vim;
in {
options.vim = {
leaderKey = mkOption {
type = str;
default = " ";
description = "The leader key used for `<leader>` mappings";
type = nullOr str;
default = null;
description = "The leader key to be used internally";
};
colourTerm = mkOption {
@ -56,6 +53,12 @@ in {
description = "Enable syntax highlighting";
};
mapLeaderSpace = mkOption {
type = bool;
default = true;
description = "Map the space key to leader key";
};
useSystemClipboard = mkOption {
type = bool;
default = false;
@ -160,138 +163,119 @@ in {
default = "sensitive";
description = "Set the case sensitivity of search";
};
undoFile = {
enable = mkEnableOption "undofile for persistent undo behaviour";
path = mkOption {
type = either str luaInline;
default = mkLuaInline "vim.fn.stdpath('state') .. '/undo'";
defaultText = literalMD ''
```nix
mkLuaInline "vim.fn.stdpath('state') .. '/undo'"
```
'';
example = literalMD ''
```nix
mkLuaInline "os.getenv('XDG_DATA_HOME') .. '/nvf/undo'"
```
'';
description = "Path to the directory in which undo history will be stored";
};
};
};
config = {
vim.luaConfigRC.basic = entryAfter ["globalsScript"] ''
-- Settings that are set for everything
vim.o.encoding = "utf-8"
vim.o.hidden = true
vim.opt.shortmess:append("c")
vim.o.expandtab = true
vim.o.mouse = ${toLuaObject cfg.mouseSupport}
vim.o.tabstop = ${toLuaObject cfg.tabWidth}
vim.o.shiftwidth = ${toLuaObject cfg.tabWidth}
vim.o.softtabstop = ${toLuaObject cfg.tabWidth}
vim.o.cmdheight = ${toLuaObject cfg.cmdHeight}
vim.o.updatetime = ${toLuaObject cfg.updateTime}
vim.o.tm = ${toLuaObject cfg.mapTimeout}
vim.o.cursorlineopt = ${toLuaObject cfg.cursorlineOpt}
vim.o.scrolloff = ${toLuaObject cfg.scrollOffset}
vim.g.mapleader = ${toLuaObject cfg.leaderKey}
vim.g.maplocalleader = ${toLuaObject cfg.leaderKey}
${optionalString cfg.undoFile.enable ''
vim.o.undofile = true
vim.o.undodir = ${toLuaObject cfg.undoFile.path}
''}
config.vim.configRC.basic = entryAfter ["globalsScript"] ''
" Settings that are set for everything
set encoding=utf-8
set hidden
set shortmess+=c
set expandtab
set mouse=${cfg.mouseSupport}
set tabstop=${toString cfg.tabWidth}
set shiftwidth=${toString cfg.tabWidth}
set softtabstop=${toString cfg.tabWidth}
set cmdheight=${toString cfg.cmdHeight}
set updatetime=${toString cfg.updateTime}
set tm=${toString cfg.mapTimeout}
set cursorlineopt=${toString cfg.cursorlineOpt}
set scrolloff=${toString cfg.scrollOffset}
${optionalString cfg.splitBelow ''
vim.o.splitbelow = true
set splitbelow
''}
${optionalString cfg.splitRight ''
vim.o.splitright = true
set splitright
''}
${optionalString cfg.showSignColumn ''
vim.o.signcolumn = "yes"
set signcolumn=yes
''}
${optionalString cfg.autoIndent ''
vim.o.autoindent = true
set autoindent
''}
${optionalString cfg.preventJunkFiles ''
vim.o.swapfile = false
vim.o.backup = false
vim.o.writebackup = false
set noswapfile
set nobackup
set nowritebackup
''}
${optionalString (cfg.bell == "none") ''
vim.o.errorbells = false
vim.o.visualbell = false
set noerrorbells
set novisualbell
''}
${optionalString (cfg.bell == "on") ''
vim.o.visualbell = false
set novisualbell
''}
${optionalString (cfg.bell == "visual") ''
vim.o.errorbells = false
set noerrorbells
''}
${optionalString (cfg.lineNumberMode == "relative") ''
vim.o.relativenumber = true
set relativenumber
''}
${optionalString (cfg.lineNumberMode == "number") ''
vim.o.number = true
set number
''}
${optionalString (cfg.lineNumberMode == "relNumber") ''
vim.o.number = true
vim.o.relativenumber = true
set number relativenumber
''}
${optionalString cfg.useSystemClipboard ''
vim.opt.clipboard:append("unnamedplus")
set clipboard+=unnamedplus
''}
${optionalString cfg.mapLeaderSpace ''
let mapleader=" "
let maplocalleader=" "
''}
${optionalString cfg.syntaxHighlighting ''
vim.cmd("syntax on")
syntax on
''}
${optionalString (!cfg.wordWrap) ''
vim.o.wrap = false
set nowrap
''}
${optionalString cfg.hideSearchHighlight ''
vim.o.hlsearch = false
vim.o.incsearch = true
set nohlsearch
set incsearch
''}
${optionalString cfg.colourTerm ''
vim.o.termguicolors = true
set termguicolors
set t_Co=256
''}
${optionalString (!cfg.enableEditorconfig) ''
vim.g.editorconfig = false
let g:editorconfig = v:false
''}
${optionalString (cfg.leaderKey != null) ''
let mapleader = "${toString cfg.leaderKey}"
''}
${optionalString (cfg.searchCase == "ignore") ''
vim.o.smartcase = false
vim.o.ignorecase = true
set nosmartcase
set ignorecase
''}
${optionalString (cfg.searchCase == "smart") ''
vim.o.smartcase = true
vim.o.ignorecase = true
set smartcase
set ignorecase
''}
${optionalString (cfg.searchCase == "sensitive") ''
vim.o.smartcase = false
vim.o.ignorecase = false
set nosmartcase
set noignorecase
''}
'';
};
}

View file

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

View file

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

View file

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

View file

@ -4,16 +4,17 @@
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.trivial) boolToString;
inherit (lib.strings) optionalString;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.autopairs;
in {
config = mkIf cfg.enable {
vim.startPlugins = ["nvim-autopairs"];
vim.pluginRC.autopairs = entryAnywhere ''
require("nvim-autopairs").setup({ map_cr = ${boolToString (!config.vim.autocomplete.enable)} })
vim.luaConfigRC.autopairs = entryAnywhere ''
require("nvim-autopairs").setup{}
'';
};
}

View file

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

View file

@ -61,16 +61,12 @@ in {
(mkSetLuaBinding mappings.complete ''
require('cmp').complete
'')
(let
defaultKeys =
if config.vim.autopairs.enable
then "require('nvim-autopairs').autopairs_cr()"
else "vim.api.nvim_replace_termcodes(${toJSON mappings.confirm.value}, true, false, true)";
in
mkSetLuaBinding mappings.confirm ''
(mkSetLuaBinding mappings.confirm ''
function()
if not require('cmp').confirm({ select = true }) then
vim.fn.feedkeys(${defaultKeys}, 'n')
local termcode = vim.api.nvim_replace_termcodes(${toJSON mappings.confirm.value}, true, false, true)
vim.fn.feedkeys(termcode, 'n')
end
end
'')
@ -186,7 +182,7 @@ in {
# TODO: alternative snippet engines to vsnip
# https://github.com/hrsh7th/nvim-cmp/blob/main/doc/cmp.txt#L82
vim.pluginRC.completion = mkIf (cfg.type == "nvim-cmp") (dagPlacement ''
vim.luaConfigRC.completion = mkIf (cfg.type == "nvim-cmp") (dagPlacement ''
local nvim_cmp_menu_map = function(entry, vim_item)
-- name for each source
vim_item.menu = ({

View file

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

View file

@ -5,17 +5,16 @@
}: let
inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.dashboard.dashboard-nvim;
in {
config = mkIf cfg.enable {
vim = {
startPlugins = ["dashboard-nvim"];
vim.startPlugins = [
"dashboard-nvim"
];
pluginRC.dashboard-nvim = entryAnywhere ''
require("dashboard").setup(${toLuaObject cfg.setupOpts})
vim.luaConfigRC.dashboard-nvim = entryAnywhere ''
require("dashboard").setup{}
'';
};
};
}

View file

@ -1,9 +1,7 @@
{lib, ...}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in {
options.vim.dashboard.dashboard-nvim = {
enable = mkEnableOption "Fancy and Blazing Fast start screen plugin of neovim [dashboard.nvim]";
setupOpts = mkPluginSetupOption "dashboard.nvim" {};
};
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,24 +1,22 @@
{
config,
pkgs,
config,
lib,
...
}: let
inherit (builtins) attrNames;
inherit (lib.options) mkOption mkEnableOption literalExpression;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) isList;
inherit (lib.types) enum either package listOf str bool;
inherit (lib.nvim.languages) diagnosticsToLua;
inherit (lib.nvim.types) diagnostics mkGrammarOption;
inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.types) diagnostics mkGrammarOption;
cfg = config.vim.languages.bash;
defaultServer = "bash-ls";
servers = {
bash-ls = {
package = pkgs.bash-language-server;
package = pkgs.nodePackages.bash-language-server;
lspConfig = ''
lspconfig.bashls.setup{
capabilities = capabilities;
@ -57,7 +55,6 @@
ls_sources,
null_ls.builtins.diagnostics.shellcheck.with({
command = "${pkg}/bin/shellcheck",
diagnostics_format = "#{m} [#{c}]"
})
)
'';
@ -85,7 +82,7 @@ in {
description = "bash-language-server package, or the command to run as a list of strings";
example = literalExpression ''[lib.getExe pkgs.nodePackages.bash-language-server "start"]'';
type = either package (listOf str);
default = pkgs.bash-language-server;
default = pkgs.nodePackages.bash-language-server;
};
};
@ -117,30 +114,4 @@ in {
};
};
};
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.bash-lsp = servers.${cfg.lsp.server}.lspConfig;
})
(mkIf cfg.format.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources.bash-format = formats.${cfg.format.type}.nullConfig;
})
(mkIf cfg.extraDiagnostics.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources = diagnosticsToLua {
lang = "bash";
config = cfg.extraDiagnostics.types;
inherit diagnosticsProviders;
};
})
]);
}

View file

@ -0,0 +1,83 @@
{
pkgs,
config,
lib,
...
}: let
inherit (lib.lists) isList;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.languages) diagnosticsToLua;
cfg = config.vim.languages.bash;
diagnosticsProviders = {
shellcheck = {
package = pkgs.shellcheck;
nullConfig = pkg: ''
table.insert(
ls_sources,
null_ls.builtins.diagnostics.shellcheck.with({
command = "${pkg}/bin/shellcheck",
})
)
'';
};
};
formats = {
shfmt = {
package = pkgs.shfmt;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.shfmt.with({
command = "${pkgs.shfmt}/bin/shfmt",
})
)
'';
};
};
servers = {
bash-ls = {
package = pkgs.nodePackages.bash-language-server;
lspConfig = ''
lspconfig.bashls.setup{
capabilities = capabilities;
on_attach = default_on_attach;
cmd = ${
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/bash-language-server", "start"}''
};
}
'';
};
};
in {
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.bash-lsp = servers.${cfg.lsp.server}.lspConfig;
})
(mkIf cfg.format.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources.bash-format = formats.${cfg.format.type}.nullConfig;
})
(mkIf cfg.extraDiagnostics.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources = diagnosticsToLua {
lang = "bash";
config = cfg.extraDiagnostics.types;
inherit diagnosticsProviders;
};
})
]);
}

View file

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

View file

@ -12,7 +12,7 @@
inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.types) mkGrammarOption;
inherit (lib.nvim.dag) entryAfter;
inherit (lib.nvim.dag) entryAnywhere;
packageToCmd = package: defaultCmd:
if isList cfg.lsp.package
@ -21,7 +21,7 @@
cfg = config.vim.languages.clang;
defaultServer = "clangd";
defaultServer = "ccls";
servers = {
ccls = {
package = pkgs.ccls;
@ -35,7 +35,7 @@
'';
};
clangd = {
package = pkgs.clang-tools;
package = pkgs.clang-tools_16;
lspConfig = ''
local clangd_cap = capabilities
-- use same offsetEncoding as null-ls
@ -57,7 +57,7 @@
dapConfig = ''
dap.adapters.lldb = {
type = 'executable',
command = '${cfg.dap.package}/bin/lldb-dap',
command = '${cfg.dap.package}/bin/lldb-vscode',
name = 'lldb'
}
dap.configurations.cpp = {
@ -141,7 +141,7 @@ in {
config = mkIf cfg.enable (mkMerge [
(mkIf cfg.cHeader {
vim.pluginRC.c-header = entryAfter ["basic"] "vim.g.c_syntax_for_h = 1";
vim.configRC.c-header = entryAnywhere "let g:c_syntax_for_h = 1";
})
(mkIf cfg.treesitter.enable {

View file

@ -17,7 +17,7 @@
defaultServer = "vscode-langservers-extracted";
servers = {
vscode-langservers-extracted = {
package = pkgs.vscode-langservers-extracted;
package = pkgs.nodePackages.vscode-langservers-extracted;
lspConfig = ''
-- enable (broadcasting) snippet capability for completion
-- see <https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#cssls>

View file

@ -0,0 +1,76 @@
{
config,
lib,
pkgs,
...
}: let
inherit (lib.lists) isList;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.strings) optionalString;
inherit (lib.trivial) boolToString;
inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.languages.dart;
ftcfg = cfg.flutter-tools;
servers = {
dart = {
package = pkgs.dart;
lspConfig = ''
lspconfig.dartls.setup{
capabilities = capabilities;
on_attach=default_on_attach;
cmd = ${
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/dart", "language-server", "--protocol=lsp"}''
};
${optionalString (cfg.lsp.opts != null) "init_options = ${cfg.lsp.dartOpts}"}
}
'';
};
};
in {
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.dart-lsp = servers.${cfg.lsp.server}.lspConfig;
})
(mkIf ftcfg.enable {
vim.startPlugins =
if ftcfg.enableNoResolvePatch
then ["flutter-tools-patched"]
else ["flutter-tools"];
vim.luaConfigRC.flutter-tools = entryAnywhere ''
require('flutter-tools').setup {
lsp = {
color = { -- show the derived colours for dart variables
enabled = ${boolToString ftcfg.color.enable}, -- whether or not to highlight color variables at all, only supported on flutter >= 2.10
background = ${boolToString ftcfg.color.highlightBackground}, -- highlight the background
foreground = ${boolToString ftcfg.color.highlightForeground}, -- highlight the foreground
virtual_text = ${boolToString ftcfg.color.virtualText.enable}, -- show the highlight using virtual text
virtual_text_str = ${ftcfg.color.virtualText.character} -- the virtual text character to highlight
},
capabilities = capabilities,
on_attach = default_on_attach;
flags = lsp_flags,
},
${optionalString cfg.dap.enable ''
debugger = {
enabled = true,
},
''}
}
'';
})
]);
}

View file

@ -1,23 +1,18 @@
{
config,
pkgs,
lib,
pkgs,
...
}: let
inherit (builtins) attrNames;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.trivial) boolToString;
inherit (lib.lists) isList;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) enum either listOf package nullOr str bool;
inherit (lib.strings) optionalString;
inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.types) mkGrammarOption;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.languages.dart;
ftcfg = cfg.flutter-tools;
defaultServer = "dart";
servers = {
dart = {
@ -53,16 +48,15 @@ in {
default = defaultServer;
};
package = mkOption {
description = "Dart LSP server package, or the command to run as a list of strings";
example = ''[lib.getExe pkgs.jdt-language-server "-data" "~/.cache/jdtls/workspace"]'';
type = either package (listOf str);
default = servers.${cfg.lsp.server}.package;
example = ''[lib.getExe pkgs.jdt-language-server "-data" "~/.cache/jdtls/workspace"]'';
description = "Dart LSP server package, or the command to run as a list of strings";
};
opts = mkOption {
description = "Options to pass to Dart LSP server";
type = nullOr str;
default = null;
description = "Options to pass to Dart LSP server";
};
};
@ -76,26 +70,23 @@ in {
flutter-tools = {
enable = mkOption {
description = "Enable flutter-tools for flutter support";
type = bool;
default = config.vim.languages.enableLSP;
description = "Enable flutter-tools for flutter support";
};
enableNoResolvePatch = mkOption {
description = ''
Patch flutter-tools so that it doesn't resolve symlinks when detecting flutter path.
This is required if you want to use a flutter package built with nix.
If you are using a flutter SDK installed from a different source and encounter the error "`dart` missing from PATH", disable this option.
'';
type = bool;
default = true;
description = ''
Whether to patch flutter-tools so that it doesn't resolve
symlinks when detecting flutter path.
This is required if you want to use a flutter package built with nix.
If you are using a flutter SDK installed from a different source
and encounter the error "`dart` missing from PATH", disable this option.
'';
};
color = {
enable = mkEnableOption "highlighting color variables";
enable = mkEnableOption "Whether or mot to highlight color variables at all";
highlightBackground = mkOption {
type = bool;
@ -121,47 +112,4 @@ in {
};
};
};
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.dart-lsp = servers.${cfg.lsp.server}.lspConfig;
})
(mkIf ftcfg.enable {
vim.startPlugins =
if ftcfg.enableNoResolvePatch
then ["flutter-tools-patched"]
else ["flutter-tools"];
vim.pluginRC.flutter-tools = entryAnywhere ''
require('flutter-tools').setup {
lsp = {
color = { -- show the derived colours for dart variables
enabled = ${boolToString ftcfg.color.enable}, -- whether or not to highlight color variables at all, only supported on flutter >= 2.10
background = ${boolToString ftcfg.color.highlightBackground}, -- highlight the background
foreground = ${boolToString ftcfg.color.highlightForeground}, -- highlight the foreground
virtual_text = ${boolToString ftcfg.color.virtualText.enable}, -- show the highlight using virtual text
virtual_text_str = ${ftcfg.color.virtualText.character} -- the virtual text character to highlight
},
capabilities = capabilities,
on_attach = default_on_attach;
flags = lsp_flags,
},
${optionalString cfg.dap.enable ''
debugger = {
enabled = true,
},
''}
}
'';
})
]);
}

View file

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

View file

@ -2,29 +2,28 @@
inherit (lib.nvim.languages) mkEnable;
in {
imports = [
./bash.nix
./dart.nix
./bash
./dart
./elixir
./markdown
./tidal
./clang.nix
./css.nix
./elixir.nix
./go.nix
./html.nix
./java.nix
./lua.nix
./markdown.nix
./nim.nix
./nix.nix
./ocaml.nix
./php.nix
./python.nix
./r.nix
./rust.nix
./sql.nix
./svelte.nix
./tailwind.nix
./terraform.nix
./ts.nix
./typst.nix
./zig.nix
];

View file

@ -1,138 +0,0 @@
{
config,
pkgs,
lib,
...
}: let
inherit (builtins) attrNames;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) isList;
inherit (lib.types) enum either listOf package str;
inherit (lib.nvim.types) mkGrammarOption;
inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.languages.elixir;
defaultServer = "elixirls";
servers = {
elixirls = {
package = pkgs.elixir-ls;
lspConfig = ''
-- elixirls setup
lspconfig.elixirls.setup {
capabilities = capabilities,
on_attach = default_on_attach,
cmd = ${
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/elixir-ls"}''
}
}
'';
};
};
defaultFormat = "mix";
formats = {
mix = {
package = pkgs.elixir;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.mix.with({
command = "${cfg.format.package}/bin/mix",
})
)
'';
};
};
in {
options.vim.languages.elixir = {
enable = mkEnableOption "Elixir language support";
treesitter = {
enable = mkEnableOption "Elixir treesitter" // {default = config.vim.languages.enableTreesitter;};
package = mkGrammarOption pkgs "elixir";
};
lsp = {
enable = mkEnableOption "Elixir LSP support" // {default = config.vim.languages.enableLSP;};
server = mkOption {
description = "Elixir LSP server to use";
type = enum (attrNames servers);
default = defaultServer;
};
package = mkOption {
description = "Elixir LSP server package, or the command to run as a list of strings";
example = ''[lib.getExe pkgs.jdt-language-server " - data " " ~/.cache/jdtls/workspace "]'';
type = either package (listOf str);
default = servers.${cfg.lsp.server}.package;
};
};
format = {
enable = mkEnableOption "Elixir formatting" // {default = config.vim.languages.enableFormat;};
type = mkOption {
description = "Elixir formatter to use";
type = enum (attrNames formats);
default = defaultFormat;
};
package = mkOption {
description = "Elixir formatter package";
type = package;
default = formats.${cfg.format.type}.package;
};
};
elixir-tools = {
enable = mkEnableOption "Elixir tools";
};
};
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.elixir-lsp = servers.${cfg.lsp.server}.lspConfig;
})
(mkIf cfg.format.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources.elixir-format = formats.${cfg.format.type}.nullConfig;
})
(mkIf cfg.elixir-tools.enable {
vim.startPlugins = ["elixir-tools"];
vim.pluginRC.elixir-tools = entryAnywhere ''
local elixir = require("elixir")
local elixirls = require("elixir.elixirls")
-- disable imperative insstallations of various
-- elixir related tools installed by elixir-tools
elixir.setup {
nextls = {
enable = false -- defaults to false
},
credo = {
enable = false -- defaults to true
},
elixirls = {
enable = false, -- defaults to true
}
}
'';
})
]);
}

View file

@ -0,0 +1,67 @@
{
config,
lib,
pkgs,
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.meta) getExe;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.languages.elixir;
in {
config = mkIf (cfg.enable) {
vim.startPlugins = [
"elixir-tools"
];
vim.luaConfigRC.elixir-tools = entryAnywhere ''
local elixir = require("elixir")
local elixirls = require("elixir.elixirls")
elixir.setup {
elixirls = {
-- alternatively, point to an existing elixir-ls installation (optional)
-- not currently supported by elixirls, but can be a table if you wish to pass other args `{"path/to/elixirls", "--foo"}`
cmd = "${getExe pkgs.elixir-ls}",
-- default settings, use the `settings` function to override settings
settings = elixirls.settings {
dialyzerEnabled = true,
fetchDeps = false,
enableTestLenses = false,
suggestSpecs = false,
},
on_attach = function(client, bufnr)
local map_opts = { buffer = true, noremap = true}
-- run the codelens under the cursor
vim.keymap.set("n", "<space>r", vim.lsp.codelens.run, map_opts)
-- remove the pipe operator
vim.keymap.set("n", "<space>fp", ":ElixirFromPipe<cr>", map_opts)
-- add the pipe operator
vim.keymap.set("n", "<space>tp", ":ElixirToPipe<cr>", map_opts)
vim.keymap.set("v", "<space>em", ":ElixirExpandMacro<cr>", map_opts)
-- bindings for standard LSP functions.
vim.keymap.set("n", "<space>df", "<cmd>lua vim.lsp.buf.format()<cr>", map_opts)
vim.keymap.set("n", "<space>gd", "<cmd>lua vim.diagnostic.open_float()<cr>", map_opts)
vim.keymap.set("n", "<space>dt", "<cmd>lua vim.lsp.buf.definition()<cr>", map_opts)
vim.keymap.set("n", "<space>K", "<cmd>lua vim.lsp.buf.hover()<cr>", map_opts)
vim.keymap.set("n", "<space>gD","<cmd>lua vim.lsp.buf.implementation()<cr>", map_opts)
vim.keymap.set("n", "<space>1gD","<cmd>lua vim.lsp.buf.type_definition()<cr>", map_opts)
-- keybinds for fzf-lsp.nvim: https://github.com/gfanto/fzf-lsp.nvim
-- you could also use telescope.nvim: https://github.com/nvim-telescope/telescope.nvim
-- there are also core vim.lsp functions that put the same data in the loclist
vim.keymap.set("n", "<space>gr", ":References<cr>", map_opts)
vim.keymap.set("n", "<space>g0", ":DocumentSymbols<cr>", map_opts)
vim.keymap.set("n", "<space>gW", ":WorkspaceSymbols<cr>", map_opts)
vim.keymap.set("n", "<leader>d", ":Diagnostics<cr>", map_opts)
end
}
}
'';
};
}

View file

@ -1,6 +1,6 @@
{
imports = [
./precognition.nix
./config.nix
./elixir-tools.nix
];
}

View file

@ -0,0 +1,7 @@
{lib, ...}: let
inherit (lib.options) mkEnableOption;
in {
options.vim.languages.elixir = {
enable = mkEnableOption "Elixir language support";
};
}

View file

@ -12,7 +12,6 @@
inherit (lib.types) bool enum either listOf package str;
inherit (lib.nvim.types) mkGrammarOption;
inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.dag) entryAfter;
cfg = config.vim.languages.go;
@ -38,6 +37,40 @@
debuggers = {
delve = {
package = pkgs.delve;
dapConfig = ''
dap.adapters.delve = {
type = "server",
port = "''${port}",
executable = {
command = "${getExe cfg.dap.package}",
args = { "dap", "-l", "127.0.0.1:''${port}" },
},
}
dap.configurations.go = {
{
type = "delve",
name = "Debug",
request = "launch",
program = "''${file}",
},
{
type = "delve",
name = "Debug test", -- configuration for debugging test files
request = "launch",
mode = "test",
program = "''${file}",
},
-- works with go.mod packages and sub packages
{
type = "delve",
name = "Debug test (go.mod)",
request = "launch",
mode = "test",
program = "./''${relativeFileDirname}",
},
}
'';
};
};
in {
@ -69,17 +102,15 @@ in {
dap = {
enable = mkOption {
description = "Enable Go Debug Adapter via nvim-dap-go plugin";
description = "Enable Go Debug Adapter";
type = bool;
default = config.vim.languages.enableDAP;
};
debugger = mkOption {
description = "Go debugger to use";
type = enum (attrNames debuggers);
default = defaultDebugger;
};
package = mkOption {
description = "Go debugger package.";
type = package;
@ -100,17 +131,8 @@ in {
})
(mkIf cfg.dap.enable {
vim = {
startPlugins = ["nvim-dap-go"];
pluginRC.nvim-dap-go = entryAfter ["nvim-dap"] ''
require('dap-go').setup {
delve = {
path = '${getExe cfg.dap.package}',
}
}
'';
debugger.nvim-dap.enable = true;
};
vim.debugger.nvim-dap.enable = true;
vim.debugger.nvim-dap.sources.go-debugger = debuggers.${cfg.dap.debugger}.dapConfig;
})
]);
}

View file

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

View file

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

View file

@ -0,0 +1,40 @@
{
pkgs,
config,
lib,
...
}: let
inherit (lib.nvim.lua) expToLua;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) isList;
cfg = config.vim.languages.markdown;
servers = {
marksman = {
package = pkgs.marksman;
lspConfig = ''
lspconfig.marksman.setup{
capabilities = capabilities;
on_attach = default_on_attach;
cmd = ${
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/marksman", "server"}''
},
}
'';
};
};
in {
config = mkIf cfg.enable (mkMerge [
(mkIf cfg.treesitter.enable {
vim.treesitter.enable = true;
vim.treesitter.grammars = [cfg.treesitter.mdPackage cfg.treesitter.mdInlinePackage];
})
(mkIf cfg.lsp.enable {
vim.lsp.lspconfig.enable = true;
vim.lsp.lspconfig.sources.markdown-lsp = servers.${cfg.lsp.server}.lspConfig;
})
]);
}

View file

@ -1,6 +1,6 @@
{
{...}: {
imports = [
./fastaction-nvim.nix
./config.nix
./markdown.nix
];
}

View file

@ -4,8 +4,7 @@
lib,
...
}: let
inherit (builtins) attrNames concatLists;
inherit (lib.modules) mkIf mkMerge;
inherit (builtins) attrNames;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.lists) isList;
inherit (lib.types) bool enum either package listOf str;
@ -30,31 +29,15 @@
'';
};
};
defaultFormat = "denofmt";
formats = {
denofmt = {
package = pkgs.deno;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.deno_fmt.with({
filetypes = ${expToLua (concatLists [cfg.format.extraFiletypes ["markdown"]])},
command = "${cfg.format.package}/bin/deno",
})
)
'';
};
};
in {
options.vim.languages.markdown = {
enable = mkEnableOption "Markdown markup language support";
treesitter = {
enable = mkOption {
description = "Enable Markdown treesitter";
type = bool;
default = config.vim.languages.enableTreesitter;
description = "Enable Markdown treesitter";
};
mdPackage = mkGrammarOption pkgs "markdown";
mdInlinePackage = mkGrammarOption pkgs "markdown-inline";
@ -64,56 +47,17 @@ in {
enable = mkEnableOption "Enable Markdown LSP support" // {default = config.vim.languages.enableLSP;};
server = mkOption {
description = "Markdown LSP server to use";
type = enum (attrNames servers);
default = defaultServer;
description = "Markdown LSP server to use";
};
package = mkOption {
description = "Markdown LSP server package, or the command to run as a list of strings";
example = ''[lib.getExe pkgs.jdt-language-server " - data " " ~/.cache/jdtls/workspace "]'';
type = either package (listOf str);
default = servers.${cfg.lsp.server}.package;
example = ''[lib.getExe pkgs.jdt-language-server " - data " " ~/.cache/jdtls/workspace "]'';
description = "Markdown LSP server package, or the command to run as a list of strings";
};
};
format = {
enable = mkEnableOption "Markdown formatting" // {default = config.vim.languages.enableFormat;};
type = mkOption {
type = enum (attrNames formats);
default = defaultFormat;
description = "Markdown formatter to use";
};
package = mkOption {
type = package;
default = formats.${cfg.format.type}.package;
description = "Markdown formatter package";
};
extraFiletypes = mkOption {
type = listOf str;
default = [];
description = "Extra filetypes to format with the Markdown formatter";
};
};
};
config = mkIf cfg.enable (mkMerge [
(mkIf cfg.treesitter.enable {
vim.treesitter.enable = true;
vim.treesitter.grammars = [cfg.treesitter.mdPackage cfg.treesitter.mdInlinePackage];
})
(mkIf cfg.lsp.enable {
vim.lsp.lspconfig.enable = true;
vim.lsp.lspconfig.sources.markdown-lsp = servers.${cfg.lsp.server}.lspConfig;
})
(mkIf cfg.format.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources.markdown-format = formats.${cfg.format.type}.nullConfig;
})
]);
}

View file

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

View file

@ -1,105 +0,0 @@
{
config,
pkgs,
lib,
...
}: let
inherit (builtins) attrNames;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.meta) getExe;
inherit (lib.lists) isList;
inherit (lib.types) either enum listOf package str;
inherit (lib.nvim.types) mkGrammarOption;
inherit (lib.nvim.lua) expToLua;
cfg = config.vim.languages.ocaml;
defaultServer = "ocaml-lsp";
servers = {
ocaml-lsp = {
package = pkgs.ocamlPackages.ocaml-lsp;
lspConfig = ''
lspconfig.ocamllsp.setup {
capabilities = capabilities,
on_attach = default_on_attach,
cmd = ${
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''{"${getExe cfg.lsp.package}"}''
};
}
'';
};
};
defaultFormat = "ocamlformat";
formats = {
ocamlformat = {
package = pkgs.ocamlPackages.ocamlformat;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.ocamlformat.with({
command = "${cfg.format.package}/bin/ocamlformat",
})
)
'';
};
};
in {
options.vim.languages.ocaml = {
enable = mkEnableOption "OCaml language support";
treesitter = {
enable = mkEnableOption "OCaml treesitter" // {default = config.vim.languages.enableTreesitter;};
package = mkGrammarOption pkgs "ocaml";
};
lsp = {
enable = mkEnableOption "OCaml LSP support (ocaml-lsp)" // {default = config.vim.languages.enableLSP;};
server = mkOption {
description = "OCaml LSP server to user";
type = enum (attrNames servers);
default = defaultServer;
};
package = mkOption {
description = "OCaml language server package, or the command to run as a list of strings";
type = either package (listOf str);
default = servers.${cfg.lsp.server}.package;
};
};
format = {
enable = mkEnableOption "OCaml formatting support (ocamlformat)" // {default = config.vim.languages.enableFormat;};
type = mkOption {
description = "OCaml formatter to use";
type = enum (attrNames formats);
default = defaultFormat;
};
package = mkOption {
description = "OCaml formatter package";
type = package;
default = formats.${cfg.format.type}.package;
};
};
};
config = mkIf cfg.enable (mkMerge [
(mkIf cfg.lsp.enable {
vim.lsp.lspconfig.enable = true;
vim.lsp.lspconfig.sources.ocaml-lsp = servers.${cfg.lsp.server}.lspConfig;
})
(mkIf cfg.treesitter.enable {
vim.treesitter.enable = true;
vim.treesitter.grammars = [cfg.treesitter.package];
})
(mkIf cfg.format.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources.ocamlformat = formats.${cfg.format.type}.nullConfig;
vim.extraPackages = [formats.${cfg.format.type}.package];
})
]);
}

View file

@ -14,10 +14,10 @@
cfg = config.vim.languages.python;
defaultServer = "basedpyright";
defaultServer = "pyright";
servers = {
pyright = {
package = pkgs.pyright;
package = pkgs.nodePackages.pyright;
lspConfig = ''
lspconfig.pyright.setup{
capabilities = capabilities;
@ -30,36 +30,6 @@
}
'';
};
basedpyright = {
package = pkgs.basedpyright;
lspConfig = ''
lspconfig.basedpyright.setup{
capabilities = capabilities;
on_attach = default_on_attach;
cmd = ${
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/basedpyright-langserver", "--stdio"}''
}
}
'';
};
python-lsp-server = {
package = pkgs.python-lsp-server;
lspConfig = ''
lspconfig.pylsp.setup{
capabilities = capabilities;
on_attach = default_on_attach;
cmd = ${
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/pylsp"}''
}
}
'';
};
};
defaultFormat = "black";
@ -91,12 +61,11 @@
black-and-isort = {
package = pkgs.writeShellApplication {
name = "black";
runtimeInputs = [pkgs.black pkgs.isort];
text = ''
black --quiet - "$@" | isort --profile black -
'';
runtimeInputs = [pkgs.black pkgs.isort];
};
nullConfig = ''
table.insert(
ls_sources,

View file

@ -1,78 +0,0 @@
{
config,
pkgs,
lib,
...
}: let
inherit (builtins) attrNames;
inherit (lib.options) mkEnableOption mkOption literalExpression;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) isList;
inherit (lib.types) enum either listOf package str;
inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.types) mkGrammarOption;
cfg = config.vim.languages.r;
r-with-languageserver = pkgs.rWrapper.override {
packages = with pkgs.rPackages; [languageserver];
};
defaultServer = "r_language_server";
servers = {
r_language_server = {
package = pkgs.writeShellScriptBin "r_lsp" ''
${r-with-languageserver}/bin/R --slave -e "languageserver::run()"
'';
lspConfig = ''
lspconfig.r_language_server.setup{
capabilities = capabilities;
on_attach = default_on_attach;
cmd = ${
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''{"${lib.getExe cfg.lsp.package}"}''
}
}
'';
};
};
in {
options.vim.languages.r = {
enable = mkEnableOption "R language support";
treesitter = {
enable = mkEnableOption "R treesitter" // {default = config.vim.languages.enableTreesitter;};
package = mkGrammarOption pkgs "r";
};
lsp = {
enable = mkEnableOption "R LSP support" // {default = config.vim.languages.enableLSP;};
server = mkOption {
description = "R LSP server to use";
type = enum (attrNames servers);
default = defaultServer;
};
package = mkOption {
description = "R LSP server package, or the command to run as a list of strings";
example = literalExpression "[ (lib.getExe pkgs.jdt-language-server) \"-data\" \"~/.cache/jdtls/workspace\" ]";
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.r-lsp = servers.${cfg.lsp.server}.lspConfig;
})
]);
}

View file

@ -4,33 +4,17 @@
lib,
...
}: let
inherit (builtins) attrNames;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.strings) optionalString;
inherit (lib.trivial) boolToString;
inherit (lib.lists) isList optionals;
inherit (lib.types) bool package str listOf either enum;
inherit (lib.types) bool package str listOf either;
inherit (lib.nvim.types) mkGrammarOption;
inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.languages.rust;
defaultFormat = "rustfmt";
formats = {
rustfmt = {
package = pkgs.rustfmt;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.rustfmt.with({
command = "${cfg.format.package}/bin/rustfmt",
})
)
'';
};
};
in {
options.vim.languages.rust = {
enable = mkEnableOption "Rust language support";
@ -65,22 +49,6 @@ in {
};
};
format = {
enable = mkEnableOption "Rust formatting" // {default = config.vim.languages.enableFormat;};
type = mkOption {
description = "Rust formatter to use";
type = enum (attrNames formats);
default = defaultFormat;
};
package = mkOption {
description = "Rust formatter package";
type = package;
default = formats.${cfg.format.type}.package;
};
};
dap = {
enable = mkOption {
description = "Rust Debug Adapter support";
@ -102,7 +70,7 @@ in {
startPlugins = ["crates-nvim"];
lsp.null-ls.enable = mkIf cfg.crates.codeActions true;
autocomplete.sources = {"crates" = "[Crates]";};
pluginRC.rust-crates = entryAnywhere ''
luaConfigRC.rust-crates = entryAnywhere ''
require('crates').setup {
null_ls = {
enabled = ${boolToString cfg.crates.codeActions},
@ -118,46 +86,32 @@ in {
vim.treesitter.grammars = [cfg.treesitter.package];
})
(mkIf cfg.format.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources.rust-format = formats.${cfg.format.type}.nullConfig;
})
(mkIf (cfg.lsp.enable || cfg.dap.enable) {
vim = {
startPlugins = ["rustaceanvim"];
startPlugins = ["rust-tools"] ++ optionals cfg.dap.enable [cfg.dap.package];
luaConfigRC.rustaceanvim = entryAnywhere ''
vim.g.rustaceanvim = {
${optionalString cfg.lsp.enable ''
-- LSP
tools = {
hover_actions = {
replace_builtin_hover = false
},
},
server = {
cmd = ${
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/rust-analyzer"}''
},
on_attach = function(client, bufnr)
lsp.lspconfig = {
enable = true;
sources.rust-lsp = ''
local rt = require('rust-tools')
rust_on_attach = function(client, bufnr)
default_on_attach(client, bufnr)
local opts = { noremap=true, silent=true, buffer = bufnr }
vim.keymap.set("n", "<leader>rr", ":RustLsp runnables<CR>", opts)
vim.keymap.set("n", "<leader>rp", ":RustLsp parentModule<CR>", opts)
vim.keymap.set("n", "<leader>rm", ":RustLsp expandMacro<CR>", opts)
vim.keymap.set("n", "<leader>rc", ":RustLsp openCargo", opts)
vim.keymap.set("n", "<leader>rg", ":RustLsp crateGraph x11", opts)
vim.keymap.set("n", "<leader>ris", rt.inlay_hints.set, opts)
vim.keymap.set("n", "<leader>riu", rt.inlay_hints.unset, opts)
vim.keymap.set("n", "<leader>rr", rt.runnables.runnables, opts)
vim.keymap.set("n", "<leader>rp", rt.parent_module.parent_module, opts)
vim.keymap.set("n", "<leader>rm", rt.expand_macro.expand_macro, opts)
vim.keymap.set("n", "<leader>rc", rt.open_cargo_toml.open_cargo_toml, opts)
vim.keymap.set("n", "<leader>rg", function() rt.crate_graph.view_crate_graph("x11", nil) end, opts)
${optionalString cfg.dap.enable ''
vim.keymap.set("n", "<leader>rd", ":RustLsp debuggables<cr>", opts)
vim.keymap.set("n", "<leader>rd", ":RustDebuggables<cr>", opts)
vim.keymap.set(
"n", "${config.vim.debugger.nvim-dap.mappings.continue}",
function()
local dap = require("dap")
if dap.status() == "" then
vim.cmd "RustLsp debuggables"
vim.cmd "RustDebuggables"
else
dap.continue()
end
@ -166,21 +120,41 @@ in {
)
''}
end
local rustopts = {
tools = {
autoSetHints = true,
hover_with_actions = false,
inlay_hints = {
only_current_line = false,
}
},
server = {
capabilities = capabilities,
on_attach = rust_on_attach,
cmd = ${
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/rust-analyzer"}''
},
settings = {
${cfg.lsp.opts}
}
},
''}
${optionalString cfg.dap.enable ''
dap = {
adapter = {
type = "executable",
command = "${cfg.dap.package}/bin/lldb-dap",
name = "rustacean_lldb",
command = "${cfg.dap.package}/bin/lldb-vscode",
name = "rt_lldb",
},
},
''}
}
rt.setup(rustopts)
'';
};
};
})
]);
}

View file

@ -54,7 +54,7 @@
defaultDiagnosticsProvider = ["eslint_d"];
diagnosticsProviders = {
eslint_d = {
package = pkgs.eslint_d;
package = pkgs.nodePackages.eslint_d;
nullConfig = pkg: ''
table.insert(
ls_sources,

View file

@ -0,0 +1,23 @@
{
pkgs,
config,
lib,
...
}: let
inherit (lib.modules) mkIf;
cfg = config.vim.tidal;
in {
config = mkIf (cfg.enable) {
vim.startPlugins = [
# From tidalcycles flake
pkgs.vimPlugins.vim-tidal
];
vim.globals = {
"tidal_target" = "terminal";
"tidal_flash_duration" = 150;
"tidal_sc_enable" = cfg.openSC;
};
};
}

View file

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

View file

@ -0,0 +1,24 @@
{
config,
lib,
...
}: let
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) int bool;
in {
options.vim.tidal = {
enable = mkEnableOption "tidalcycles tools and plugins";
flash = mkOption {
description = ''When sending a paragraph or a single line, vim-tidal will "flash" the selection for some milliseconds'';
type = int;
default = 150;
};
openSC = mkOption {
description = "Automatically run the supercollider CLI, sclang, alongside the Tidal GHCI terminal.";
type = bool;
default = true;
};
};
}

View file

@ -9,20 +9,19 @@
inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) isList;
inherit (lib.meta) getExe;
inherit (lib.types) enum either listOf package str bool;
inherit (lib.nvim.lua) expToLua toLuaObject;
inherit (lib.nvim.types) mkGrammarOption diagnostics mkPluginSetupOption;
inherit (lib.types) enum either listOf package str;
inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.types) mkGrammarOption diagnostics;
inherit (lib.nvim.languages) diagnosticsToLua;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.languages.ts;
defaultServer = "ts_ls";
defaultServer = "tsserver";
servers = {
ts_ls = {
package = pkgs.typescript-language-server;
tsserver = {
package = pkgs.nodePackages.typescript-language-server;
lspConfig = ''
lspconfig.ts_ls.setup {
lspconfig.tsserver.setup {
capabilities = capabilities;
on_attach = attach_keymaps,
cmd = ${
@ -33,7 +32,6 @@
}
'';
};
denols = {
package = pkgs.deno;
lspConfig = ''
@ -49,24 +47,6 @@
}
'';
};
# Here for backwards compatibility. Still consider tsserver a valid
# configuration in the enum, but assert if it's set to *properly*
# redirect the user to the correct server.
tsserver = {
package = pkgs.typescript-language-server;
lspConfig = ''
lspconfig.ts_ls.setup {
capabilities = capabilities;
on_attach = attach_keymaps,
cmd = ${
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/typescript-language-server", "--stdio"}''
}
}
'';
};
};
# TODO: specify packages
@ -83,7 +63,6 @@
)
'';
};
prettierd = {
package = pkgs.prettierd;
nullConfig = ''
@ -101,7 +80,7 @@
defaultDiagnosticsProvider = ["eslint_d"];
diagnosticsProviders = {
eslint_d = {
package = pkgs.eslint_d;
package = pkgs.nodePackages.eslint_d;
nullConfig = pkg: ''
table.insert(
ls_sources,
@ -113,7 +92,6 @@
};
};
in {
_file = ./ts.nix;
options.vim.languages.ts = {
enable = mkEnableOption "Typescript/Javascript language support";
@ -165,24 +143,6 @@ in {
inherit defaultDiagnosticsProvider;
};
};
extensions = {
ts-error-translator = {
enable = mkEnableOption ''
Typescript error translation with
[ts-error-translator.nvim](github.com/dmmulroy/ts-error-translator.nvim)
'';
setupOpts = mkPluginSetupOption "ts-error-translator" {
# This is the default configuration behaviour.
auto_override_publish_diagnostics = mkOption {
description = "Automatically override the publish_diagnostics handler";
type = bool;
default = true;
};
};
};
};
};
config = mkIf cfg.enable (mkMerge [
@ -209,33 +169,5 @@ in {
inherit diagnosticsProviders;
};
})
# Extensions
(mkIf cfg.extensions."ts-error-translator".enable {
vim.startPlugins = ["ts-error-translator"];
vim.pluginRC.ts-error-translator = entryAnywhere ''
require("ts-error-translator").setup(${toLuaObject cfg.extensions.ts-error-translator.setupOpts})
'';
})
# Warn the user if they have set the default server name to tsserver to match upstream (us)
# The name "tsserver" has been deprecated in lspconfig, and now should be called ts_ls. This
# is a purely cosmetic change, but emits a warning if not accounted for.
{
assertions = [
{
assertion = cfg.lsp.enable -> cfg.lsp.server != "tsserver";
message = ''
As of a recent lspconfig update, the `tsserver` configuration has been renamed
to `ts_ls` to match upstream behaviour of `lspconfig`, and the name `tsserver`
is no longer considered valid by nvf. Please set `vim.languages.ts.lsp.server`
to `"ts_ls"` instead of to `${cfg.lsp.server}`
Please see <https://github.com/neovim/nvim-lspconfig/pull/3232> for more details
about this change.
'';
}
];
}
]);
}

View file

@ -1,100 +0,0 @@
{
config,
pkgs,
lib,
...
}: let
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) isList;
inherit (lib.types) enum either listOf package str;
inherit (lib.attrsets) attrNames;
inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.types) mkGrammarOption;
cfg = config.vim.languages.typst;
defaultFormat = "typstfmt";
formats = {
typstfmt = {
package = pkgs.typstfmt;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.typstfmt.with({
command = "${cfg.format.package}/bin/typstfmt",
})
)
'';
};
# https://github.com/Enter-tainer/typstyle
typstyle = {
package = pkgs.typstyle;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.typstfmt.with({
command = "${cfg.format.package}/bin/typstyle",
})
)
'';
};
};
in {
options.vim.languages.typst = {
enable = mkEnableOption "Typst language support";
treesitter = {
enable = mkEnableOption "Typst treesitter" // {default = config.vim.languages.enableTreesitter;};
package = mkGrammarOption pkgs "typst";
};
lsp = {
enable = mkEnableOption "Typst LSP support (typst-lsp)" // {default = config.vim.languages.enableLSP;};
package = mkOption {
description = "typst-lsp package, or the command to run as a list of strings";
example = ''[lib.getExe pkgs.jdt-language-server "-data" "~/.cache/jdtls/workspace"]'';
type = either package (listOf str);
default = pkgs.typst-lsp;
};
};
format = {
enable = mkEnableOption "Typst document formatting" // {default = config.vim.languages.enableFormat;};
type = mkOption {
description = "Typst formatter to use";
type = enum (attrNames formats);
default = defaultFormat;
};
package = mkOption {
description = "Typst formatter package";
type = package;
default = formats.${cfg.format.type}.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.typst-lsp = ''
lspconfig.typst_lsp.setup {
capabilities = capabilities,
on_attach=default_on_attach,
cmd = ${
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/typst-lsp"}''
},
}
'';
})
]);
}

View file

@ -16,10 +16,7 @@
mappingDefinitions = self.options.vim.lsp.mappings;
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
mkBinding = binding: action:
if binding.value != null
then "vim.api.nvim_buf_set_keymap(bufnr, 'n', '${binding.value}', '<cmd>lua ${action}<CR>', {noremap=true, silent=true, desc='${binding.description}'})"
else "";
mkBinding = binding: action: "vim.api.nvim_buf_set_keymap(bufnr, 'n', '${binding.value}', '<cmd>lua ${action}<CR>', {noremap=true, silent=true, desc='${binding.description}'})";
in {
config = mkIf cfg.enable {
vim = {
@ -27,7 +24,7 @@ in {
autocomplete.sources = {"nvim_lsp" = "[LSP]";};
pluginRC.lsp-setup = ''
luaConfigRC.lsp-setup = ''
vim.g.formatsave = ${boolToString cfg.formatOnSave};
local attach_keymaps = function(client, bufnr)
@ -103,11 +100,11 @@ in {
end
end
${optionalString config.vim.ui.breadcrumbs.enable ''local navic = require("nvim-navic")''}
${optionalString (config.vim.ui.breadcrumbs.enable) ''local navic = require("nvim-navic")''}
default_on_attach = function(client, bufnr)
attach_keymaps(client, bufnr)
format_callback(client, bufnr)
${optionalString config.vim.ui.breadcrumbs.enable ''
${optionalString (config.vim.ui.breadcrumbs.enable) ''
-- let navic attach to buffers
if client.server_capabilities.documentSymbolProvider then
navic.attach(client, bufnr)

View file

@ -10,10 +10,10 @@
# lsp plugins
./lspsaga
./nvim-code-action-menu
./trouble
./lsp-signature
./lightbulb
./otter
./lspkind
./lsplines
./nvim-docs-view

View file

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

View file

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

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