Compare commits

..

No commits in common. "b248b5af59ffdfaf9f6fdd400a114f60718f0b31" and "2a89fd409374ee14ca08d5d710bb05f3bedc77b8" have entirely different histories.

284 changed files with 3722 additions and 7253 deletions

View file

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

3
.github/FUNDING.yml vendored
View file

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

View file

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

132
.github/README.md vendored
View file

@ -50,7 +50,6 @@
[Contribute]: #contributing [Contribute]: #contributing
[FAQ]: #frequently-asked-questions [FAQ]: #frequently-asked-questions
[Credits]: #credits [Credits]: #credits
[License]: #license
**[<kbd><br>Features <br></kbd>][Features]** **[<kbd><br>Features <br></kbd>][Features]**
**[<kbd><br>Get Started<br></kbd>][Get Started]** **[<kbd><br>Get Started<br></kbd>][Get Started]**
@ -68,10 +67,6 @@
[standalone]: https://notashelf.github.io/nvf/index.xhtml#ch-standalone-installation [standalone]: https://notashelf.github.io/nvf/index.xhtml#ch-standalone-installation
[NixOS module]: https://notashelf.github.io/nvf/index.xhtml#ch-standalone-nixos [NixOS module]: https://notashelf.github.io/nvf/index.xhtml#ch-standalone-nixos
[Home-Manager module]: https://notashelf.github.io/nvf/index.xhtml#ch-standalone-hm [Home-Manager module]: https://notashelf.github.io/nvf/index.xhtml#ch-standalone-hm
[release notes]: https://notashelf.github.io/nvf/release-notes.html
[discussions tab]: https://github.com/notashelf/nvf/discussions
[FAQ section]: #frequently-asked-questions
[DAG]: https://en.wikipedia.org/wiki/Directed_acyclic_graph
- **Simple**: One language to rule them all! Use Nix to configure everything, - **Simple**: One language to rule them all! Use Nix to configure everything,
with optional Lua support for robust configurability! with optional Lua support for robust configurability!
@ -84,31 +79,11 @@
customizable through the Nix module system. customizable through the Nix module system.
- Not comfortable with a full-nix config or want to bring your Lua config? You - Not comfortable with a full-nix config or want to bring your Lua config? You
can do just that, no unnecessary restrictions. can do just that, no unnecessary restrictions.
- Lazyloading 💤? We got it! Lazyload both internal and external plugins at - Lazyloading? We got it! Lazyload both internal and external plugins at will.
will.
- nvf allows _ordering configuration bits_ using [DAG] (_Directed acyclic
graph_)s. It has never been easier to construct an editor configuration
deterministically!
- nvf exposes everything you need to avoid a vendor lock-in. Which means you
can add new modules, plugins and so on without relying on us adding a module
for them! Though, of course, feel free to request them.
- Use plugins from anywhere. Inputs, npins, nixpkgs... You name it.
- Add your own modules, with ease. It's all built-in!
- **Well-documented**: Documentation is priority. You will _never_ face - **Well-documented**: Documentation is priority. You will _never_ face
undocumented, obscure behaviour. undocumented, obscure behaviour.
- Changes, breaking or otherwise, will be communicated in the [release notes]
- Refer to the [FAQ section] for answers to common questions.
- Your question not there? Head to the to the [discussions tab]!
- **Idiomatic**: nvf does things ✨ _the right way_ ✨ - the codebase is, and - **Idiomatic**: nvf does things ✨ _the right way_ ✨ - the codebase is, and
will, remain maintainable for myself and any contributors. will, remain maintainable for myself and any contributors.
- **Community-Led**: we would like nvf to be fully capable of accomplishing what
you really want it to do. If you have a use case that is not made possible by
nvf, please open an issue (or a pull request!)
- Your feedback is more than welcome! Feedback is what _drives_ nvf forward.
If you have anything to say, or ask, please let us know.
- Pull requests are _always_ welcome. If you think the project can benefit
from something you did locally, but are not quite sure how to upstream,
please feel free to contact us! We'll help you get it done.
## Get Started ## Get Started
@ -198,66 +173,39 @@ fix.
[list of open pull requests]: https://github.com/NotAShelf/nvf/pulls [list of open pull requests]: https://github.com/NotAShelf/nvf/pulls
**Q**: What platforms are supported? **Q**: What platforms are supported?
<br/> **A**: nvf actively supports **Linux and Darwin** platforms using
**A**: nvf actively supports **Linux and Darwin** platforms using standalone standalone Nix, NixOS or Home-Manager. Please take a look at the [nvf manual]
Nix, NixOS or Home-Manager. Please take a look at the [nvf manual] for available for available installation instructions.
installation instructions.
**Q**: Can you add _X_? **Q**: Can you add _X_?
<br/> **A**: Maybe! It is not one of our goals to support each and every Neovim
**A**: Maybe! It is not one of our goals to support each and every Neovim
plugin, however, I am always open to new modules and plugin setup additions to 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 **nvf**. Use the appropriate [issue template] and I will consider a module
addition. As mentioned before, pull requests to add new features are also addition. As mentioned before, pull requests to add new features are also
welcome. welcome.
**Q**: A plugin I need is not available in **nvf**. What to do? **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
**A**: **nvf** exposes several APIs for you to be able to add your own plugin plugin configurations! Please see the documentation on how you may do this.
configurations! Please see the documentation on how you may do this.
**Q**: Main branch is awfully silent, is the project dead? **Q**: Main branch is awfully silent, is the project dead?
<br/> **A**: No! Sometimes we branch out (e.g. `v0.6`) to avoid breaking
**A**: No! Sometimes we branch out (e.g. `v0.6`) to avoid breaking userspace and userspace and work in a separate branch until we make sure the new additions are
work in a separate branch until we make sure the new additions are implemented implemented in the most comfortable way possible for the end user. If you have
in the most comfortable way possible for the end user. If you have not noticed not noticed any activity on the main branch, consider taking a look at the
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 [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 _testing_ those release branches to get access to new features ahead of time and
better prepare to breaking changes. better prepare to breaking changes.
**Q**: Will you support non-flake installations? **Q**: Will you support non-flake installations?
<br/> **A**: Quite possibly. **nvf** started as "neovim-flake", which does mean
**A**: Quite possibly. **nvf** started as "neovim-flake", which does mean it is it is and will remain flakes-first but we might consider non-flakes
and will remain flakes-first but we might consider non-flakes compatibility. compatibility. Though keep in mind that **nvf** under non-flake environments
Though keep in mind that **nvf** under non-flake environments would lose would lose customizability of plugin inputs, which is one of our primary
customizability of plugin inputs, which is one of our primary features. features.
**Q**: I prefer working with Lua, can I use nvf as a plugin manager while I use
an imperative path (e.g., `~/.config/nvim`) for my Neovim configuration instead
of a configuration generated from Nix?
**A**: Yes! Add `"~/.config.nvim"` to `vim.additionalRuntimePaths = [ ... ]` and
any plugins you want to load to `vim.startPlugins`. This will load your
configuration from `~/.config/nvim`. You may still use `vim.*` to modify
Neovim's behaviour with Nix.
## Credits ## Credits
### Co-Maintainers
Alongside myself, nvf is developed by those talented folk:
- [**@horriblename**](https://github.com/horriblename)
([Liberapay](https://liberapay.com/horriblename/))- For actively implementing
planned features and quality of life updates.
- [**@Diniamo**](https://github.com/Diniamo)
([Liberapay](https://en.liberapay.com/diniamo/)) - For actively submitting
pull requests, issues and assistance with maintenance of nvf.
Please do remember to extend your thanks (financially or otherwise) if this
project has been helpful to you.
### Contributors ### Contributors
[mnw]: https://github.com/gerg-l/mnw [mnw]: https://github.com/gerg-l/mnw
@ -265,39 +213,41 @@ project has been helpful to you.
nvf would not be what it is today without the awesome people below. Special, nvf would not be what it is today without the awesome people below. Special,
heart-felt thanks to heart-felt thanks to
- [**@fufexan**](https://github.com/fufexan) - For the transition to flake-parts - [@fufexan](https://github.com/fufexan) - For the transition to flake-parts and
and invaluable Nix assistance. invaluable Nix assistance.
- [**@FlafyDev**](https://github.com/FlafyDev) - For getting Home-Manager module - [@FlafyDev](https://github.com/FlafyDev) - For getting home-manager module to
to work and Nix assistance. work and Nix assistance.
- [**@n3oney**](https://github.com/n3oney) - For making custom keybinds finally - [@n3oney](https://github.com/n3oney) - For making custom keybinds finally
possible, and other module additions. possible, and other module additions.
- [**@Yavko**](https://github.com/Yavko) - For the amazing **nvf** logo - [@horriblename](https://github.com/horriblename) - For actively implementing
- [**@FrothyMarrow**](https://github.com/FrothyMarrow) - For seeing mistakes planned features and quality of life updates.
that I could not. - [@Yavko](https://github.com/Yavko) - For the amazing **nvf** logo
- [**@Gerg-l**](https://github.com/gerg-l) 🐸 - For the modern Neovim wrapper, - [@FrothyMarrow](https://github.com/FrothyMarrow) - For seeing mistakes that I
[mnw], and occasional code improvements. could not.
- [**@Soliprem**](https://github.com/soliprem) - Rigorously implementing missing - [@Diniamo](https://github.com/Diniamo) - For actively submitting pull
features and excellent work on new language modules. requests, issues and assistance with maintenance of nvf.
- [@Gerg-l](https://github.com/gerg-l) - For the modern Neovim wrapper, [mnw],
and occasional code improvements.
and everyone who has submitted issues or pull requests! and everyone who has submitted issues or pull requests!
### Inspiration ### Inspiration
This configuration borrows from, and is based on a few other configurations, This configuration borrows from and is based on a few other configurations,
including: including:
- [@jordanisaacs's](https://github.com/jordanisaacs) - [@jordanisaacs's](https://github.com/jordanisaacs)
[**neovim-flake**](https://github.com/jordanisaacs/neovim-flake) that this [neovim-flake](https://github.com/jordanisaacs/neovim-flake) that this flake
flake is originally based on. is originally based on.
- [@sioodmy's](https://github.com/sioodmy)
[dotfiles](https://github.com/sioodmy/dotfiles) that inspired the design
choices for UI and plugin defaults.
- [@wiltaylor's](https://github.com/wiltaylor) - [@wiltaylor's](https://github.com/wiltaylor)
[neovim-flake](https://github.com/wiltaylor/neovim-flake) for plugin and [neovim-flake](https://github.com/wiltaylor/neovim-flake) for plugin and
design ideas. design ideas.
- [@gvolpe's](https://github.com/gvolpe) - [@gvolpe's](https://github.com/gvolpe)
[neovim-flake](https://github.com/gvolpe/neovim-flake) for plugin, design and [neovim-flake](https://github.com/gvolpe/neovim-flake) for plugin, design and
nix concepts. nix concepts.
- [@sioodmy's](https://github.com/sioodmy)
[dotfiles](https://github.com/sioodmy/dotfiles) that inspired the design
choices for UI and plugin defaults.
I am grateful for their previous work and inspiration, and I wholeheartedly I am grateful for their previous work and inspiration, and I wholeheartedly
recommend checking their work out. recommend checking their work out.
@ -305,12 +255,12 @@ recommend checking their work out.
## License ## License
Following the license of Following the license of the
[the original neovim-flake](https://github.com/jordanisaacs/neovim-flake), nvf [original neovim-flake](https://github.com/jordanisaacs/neovim-flake), nvf has
has been made available under the [**MIT License**](LICENSE). However, all been made available under the [**MIT License**](LICENSE). However, all assets
assets and documentation are published under the and documentation are published under the
[**CC BY License**](https://github.com/NotAShelf/nvf/blob/main/.github/assets/LICENSE) [**CC BY License**](https://github.com/NotAShelf/nvf/blob/main/.github/assets/LICENSE)
under explicit permission by the author or authors. under explicit permission by the artist.
<h6 align="center">Yes, this includes the logo work too. Stop taking artwork that is not yours!</h6> <h6 align="center">Yes, this includes the logo work too. Stop taking artwork that is not yours!</h6>

3
.github/typos.toml vendored
View file

@ -1,5 +1,2 @@
default.extend-ignore-words-re = ["(?i)(noice)", "befores", "annote", "viw"] default.extend-ignore-words-re = ["(?i)(noice)", "befores", "annote", "viw"]
files.extend-exclude = [
"npins/sources.json"
]

View file

@ -35,6 +35,7 @@ jobs:
- name: Install Nix - name: Install Nix
uses: DeterminateSystems/nix-installer-action@main uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- uses: cachix/cachix-action@v15 - uses: cachix/cachix-action@v15
with: with:

View file

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

View file

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

View file

@ -1,184 +0,0 @@
name: Build and Preview Manual
on:
workflow_dispatch:
pull_request_target:
types: [opened, synchronize, reopened, closed]
paths:
- ".github/workflows/docs-preview.yml"
- "modules/**"
- "docs/**"
# Defining permissions here passes it to all workflows.
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/controlling-permissions-for-github_token
permissions:
contents: write
pull-requests: write
issues: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-preview:
runs-on: ubuntu-latest
steps:
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main
- name: Checkout
uses: actions/checkout@v4
- name: Set default git branch (to reduce log spam)
run: git config --global init.defaultBranch main
- name: Build documentation packages
run: nix build .#docs-html --print-build-logs
- name: Deploy to GitHub Pages preview
run: |
PR_NUMBER=${{ github.event.pull_request.number }}
BRANCH_NAME="gh-pages"
PREVIEW_DIR="docs-preview-${PR_NUMBER}"
# Clone the gh-pages branch and move to the preview subdirectory
git clone --single-branch --branch $BRANCH_NAME https://github.com/${{ github.repository }} gh-pages
cd gh-pages
mkdir -p $PREVIEW_DIR
# Copy the build files to the preview subdirectory
cp -rvf ../result/share/doc/nvf/* ./$PREVIEW_DIR
# Configure git to use the GitHub Actions token for authentication
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
# Set the GitHub token for authentication
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
# Add and commit the changes
git add --all
git commit -m "Deploy PR #${PR_NUMBER} preview" || echo "No changes to commit"
git push --force origin $BRANCH_NAME
comment-url:
needs: build-preview
runs-on: ubuntu-latest
steps:
- name: Prepare Environment
id: prelude
run: |
PR_NUMBER=${{ github.event.pull_request.number }}
URL="https://${{ github.repository_owner }}.github.io/nvf/docs-preview-${PR_NUMBER}/"
# Propagate non-interpolatable environment vars
echo "URL=$URL" >> "$GITHUB_OUTPUT"
echo "REV=$GITHUB_SHA" >> "$GITHUB_OUTPUT"
echo "ACTOR=$GITHUB_ACTOR" >> "$GITHUB_OUTPUT"
echo "REF=$GITHUB_HEAD_REF" >> "$GITHUB_OUTPUT"
echo "RUNS=$GITHUB_RUN_NUMBER" >> "$GITHUB_OUTPUT"
echo "Live Preview URL: $URL"
echo "Rev: $GITHUB_SHA"
echo "Actor: $GITHUB_ACTOR"
echo "Ref: "$GITHUB_HEAD_REF"
echo "Reruns: "$GITHUB_RUN_NUMBER"
echo "### :rocket: Live Preview Deployed " >> "$GITHUB_STEP_SUMMARY"
echo "Preview can be found at ${URL}" >> "$GITHUB_STEP_SUMMARY"
- name: Find Comment
uses: peter-evans/find-comment@v3
id: fc
with:
comment-author: "github-actions[bot]"
issue-number: ${{ github.event.pull_request.number }}
body-includes: "Live preview deployed"
- name: Post live preview comment
uses: peter-evans/create-or-update-comment@v4
env:
COMMENT_ID: ${{ steps.fc.outputs.comment-id }}
URL: ${{ steps.prelude.outputs.URL }}
GITHUB_SHA: ${{ steps.prelude.outputs.REV }}
ACTOR: ${{ steps.prelude.outputs.ACTOR }}
REF: ${{ steps.prelude.outputs.REF }}
RUNS: ${{ steps.prelude.outputs.RUNS }}
with:
comment-id: ${{ env.COMMENT_ID }}
issue-number: ${{ github.event.pull_request.number }} # issue number also applies to pull requests
edit-mode: replace # replace previous body
body: |
### :rocket: Live preview deployed from ${{ env.GITHUB_SHA }}
View it [here](${{ env.URL }}):
<details>
<summary><strong>Debug Information</strong></summary>
<p>Triggered by: ${{ env.ACTOR }}</p>
<p><code>HEAD</code> at: ${{ env.REF }}</p>
<p>Reruns: ${{ env.RUNS }}</p>
</details>
cleanup:
if: ${{ github.event.pull_request.merged == true || github.event.pull_request.state == 'closed' }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Delete preview for closed/merged PR
run: |
PR_NUMBER=${{ github.event.pull_request.number }}
BRANCH_NAME="gh-pages"
PREVIEW_DIR="docs-preview-${PR_NUMBER}"
# Clone the gh-pages branch
git clone --single-branch --branch $BRANCH_NAME https://github.com/${{ github.repository }} gh-pages
cd gh-pages
# Check if the preview directory exists, and delete it if it does
if [ -d "$PREVIEW_DIR" ]; then
echo "Deleting preview directory $PREVIEW_DIR"
rm -rf $PREVIEW_DIR
else
echo "Preview directory $PREVIEW_DIR does not exist. Skipping deletion."
fi
# Configure git to use the GitHub Actions token for authentication
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
# Set the GitHub token for authentication
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
# Add and commit the changes (only if there's something to delete)
git add .
git diff --quiet || git commit -m "Remove preview for PR #${PR_NUMBER}"
git push origin $BRANCH_NAME
cleanup-comment:
needs: cleanup
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Double check preview directory deletion
run: |
# Check if the preview directory exists, and delete it if it does
if [ -d "docs-preview-${{ github.event.pull_request.number }}" ]; then
echo "Something went wrong, preview directory is not deleted."
exit 1
else
echo "Preview directory has been deleted successfully, proceeding."
fi
- name: Post cleanup verification
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
✅ Preview has been deleted successfully!

View file

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

View file

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

View file

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

View file

@ -1,16 +1,13 @@
.TH "nvf" "5" "January 1, 1980" "nvf" .TH "nvf" "5" "01/01/1980" "nvf"
.\" disable hyphenation .\" disable hyphenation
.nh .nh
.\" disable justification (adjust text to left margin only) .\" disable justification (adjust text to left margin only)
.ad l .ad l
.\" enable line breaks after slashes .\" enable line breaks after slashes
.cflags 4 / .cflags 4 /
.SH "NAME" .SH "NAME"
nvf \- Configuration specification for the nvf. nvf configuration specification
.SH "OPTIONS"
.SH "DESCRIPTION" .PP
The nvf configuration specification provides a declarative structure for configuring Neovim using Nix with few You can use the following options to configure nvf:
lines of Nix. This document outlines the available options and their usage to create modular, reusable, and .PP
reproducible configurations using nvf's module system options. For tips, tricks and possible quirks with available
plugins please visit https://notashelf.github.io/nvf/

View file

@ -1,5 +1,5 @@
.Dd January 1, 1980 .Dd January 1, 1980
.Dt NVF 1 .Dt nvf 1
.Os nvf .Os nvf
.\" disable hyphenation .\" disable hyphenation
.nh .nh
@ -7,46 +7,27 @@
.ad l .ad l
.\" enable line breaks after slashes .\" enable line breaks after slashes
.cflags 4 / .cflags 4 /
.Sh NAME .Sh NAME
.Nm nvf .Nm nvf
.Nd A modular, extensible, and distro-agnostic Neovim configuration framework for Nix/NixOS. .Nd A highly modular, extensible and distro-agnostic Neovim configuration framework for Nix/NixOS.
.
.Sh DESCRIPTION
.Nm 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.
.Sh COMMANDS
The following commands are bundled with nvf to allow easier debugging of your configuration.
.Bl -tag -width Ds
.It Nm nvf-print-config
Outputs the full configuration of the current `nvf` setup. This command is useful for debugging
or inspecting the applied configuration.
.Pp
.It Nm nvf-print-config-path
Prints the file path to the configuration file currently in use. This command is helpful for locating
the source configuration file for troubleshooting or easily sharing it via online paste utilities.
.El
.Sh BUGS .Sh BUGS
.Pp .Pp
Please report any bugs on the project issue tracker: Please report any bugs that you might encounter on the
.Lk https://github.com/notashelf/nvf/issues \m[blue]\fBproject issue tracker\fR\m[]\&.
.Sh SEE ALSO .Sh SEE ALSO
.Pp .Pp
.Fn nvf 5 \fBnvf\fR(5)
.Sh AUTHOR .Sh AUTHOR
.Pp .Pp
.Fn nvf contributors \fBnvf contributors\fR
.RS 4 .RS 4
Primary contributors and maintainers of the project. Author.
.RE .RE
.Sh COPYRIGHT .Sh COPYRIGHT
.Pp .br
Copyright (c) 20232025 nvf contributors. Copyright \(co 2023\(en2024 nvf contributors
.br

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -14,11 +14,14 @@ necessarily) before you start developing.
## Adding Documentation {#sec-guidelines-documentation} ## Adding Documentation {#sec-guidelines-documentation}
[Nixpkgs Flavoured Markdown]: https://github.com/NixOS/nixpkgs/blob/master/doc/README.md#syntax Most, if not all, changes warrant changes to the documentation. Module options
should be documented with
[Nixpkgs-flavoured Markdown](https://nixos.org/manual/nixpkgs/unstable/#sec-contributing-markup),
albeit with exceptions.
Almost all changes warrant updates to the documentation: at the very least, you ::: {.note} As of **v0.5**, **nvf** is itself documented using full markdown in
must update the changelog. Both the manual and module options use both module options and the manual. With **v0.6**, this manual has also been
[Nixpkgs Flavoured Markdown]. converted to markdown in full. :::
The HTML version of this manual containing both the module option descriptions The HTML version of this manual containing both the module option descriptions
and the documentation of **nvf** (such as this page) can be generated and opened and the documentation of **nvf** (such as this page) can be generated and opened
@ -114,11 +117,10 @@ applies to string literals and module descriptions and documentation.
### Nix {#sec-code-style-nix} ### Nix {#sec-code-style-nix}
[alejandra]: https://github.com/kamadorueda/alejandra **nvf** is formatted by the
[alejandra](https://github.com/kamadorueda/alejandra) tool and the formatting is
**nvf** is formatted by the [alejandra] tool and the formatting is checked in checked in the pull request and push workflows. Run the `nix fmt` command inside
the pull request and push workflows. Run the `nix fmt` command inside the the project repository before submitting your pull request.
project repository before submitting your pull request.
While Alejandra is mostly opinionated on how code looks after formatting, While Alejandra is mostly opinionated on how code looks after formatting,
certain changes are done at the user's discretion based on how the original code certain changes are done at the user's discretion based on how the original code
@ -136,14 +138,10 @@ module = {
# same as parent modules, unfold submodules # same as parent modules, unfold submodules
subModule = { subModule = {
# this is an option that contains more than one nested value # this is an option that contains more than one nested value
# Note: try to be careful about the ordering of `mkOption` arguments.
# General rule of thumb is to order from least to most likely to change.
# This is, for most cases, type < default < description.
# Example, if present, would be between default and description
someOtherValue = mkOption { someOtherValue = mkOption {
type = lib.types.bool; type = lib.types.bool;
default = true;
description = "Some other description"; description = "Some other description";
default = true;
}; };
}; };
} }

View file

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

View file

@ -10,18 +10,12 @@ To use it, we first add the input flake.
```nix ```nix
{ {
inputs = { inputs = {
# Optional, if you intend to follow nvf's obsidian-nvim input
# you must also add it as a flake input.
obsidian-nvim.url = "github:epwalsh/obsidian.nvim"; obsidian-nvim.url = "github:epwalsh/obsidian.nvim";
# Required, nvf works best and only directly supports flakes
nvf = { nvf = {
url = "github:notashelf/nvf"; url = "github:notashelf/nvf";
# You can override the input nixpkgs to follow your system's # you can override input nixpkgs
# instance of nixpkgs. This is safe to do as nvf does not depend
# on a binary cache.
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
# Optionally, you can also override individual plugins # you can also override individual plugins
# for example: # for example:
inputs.obsidian-nvim.follows = "obsidian-nvim"; # <- this will use the obsidian-nvim from your inputs inputs.obsidian-nvim.follows = "obsidian-nvim"; # <- this will use the obsidian-nvim from your inputs
}; };
@ -33,8 +27,8 @@ Followed by importing the home-manager module somewhere in your configuration.
```nix ```nix
{ {
# Assuming "nvf" is in your inputs and inputs is in the argument set. # assuming nvf is in your inputs and inputs is in the argset
# See example installation below # see example below
imports = [ inputs.nvf.homeManagerModules.default ]; imports = [ inputs.nvf.homeManagerModules.default ];
} }
``` ```
@ -49,13 +43,13 @@ Followed by importing the home-manager module somewhere in your configuration.
nvf.url = "github:notashelf/nvf"; nvf.url = "github:notashelf/nvf";
}; };
outputs = { nixpkgs, home-manager, nvf, ... }: { outputs = { nixpkgs, home-manager, nvf, ... }: let
system = "x86_64-linux"; in {
# ↓ this is your home output in the flake schema, expected by home-manager # ↓ this is your home output in the flake schema, expected by home-manager
"your-username@your-hostname" = home-manager.lib.homeManagerConfiguration { "your-username@your-hostname" = home-manager.lib.homeManagerConfiguration
pkgs = nixpkgs.legacyPackages.x86_64-linux;
modules = [ modules = [
nvf.homeManagerModules.default # <- this imports the home-manager module that provides the options nvf.homeManagerModules.default # <- this imports the home-manager module that provides the options
./home.nix # <- your home entrypoint, `programs.nvf.*` may be defined here ./home.nix # <- your home entrypoint
]; ];
}; };
}; };

View file

@ -10,18 +10,12 @@ To use it, we first add the input flake.
```nix ```nix
{ {
inputs = { inputs = {
# Optional, if you intend to follow nvf's obsidian-nvim input
# you must also add it as a flake input.
obsidian-nvim.url = "github:epwalsh/obsidian.nvim"; obsidian-nvim.url = "github:epwalsh/obsidian.nvim";
# Required, nvf works best and only directly supports flakes
nvf = { nvf = {
url = "github:notashelf/nvf"; url = "github:notashelf/nvf";
# You can override the input nixpkgs to follow your system's # you can override input nixpkgs
# instance of nixpkgs. This is safe to do as nvf does not depend
# on a binary cache.
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
# Optionally, you can also override individual plugins # you can also override individual plugins
# for example: # for example:
inputs.obsidian-nvim.follows = "obsidian-nvim"; # <- this will use the obsidian-nvim from your inputs inputs.obsidian-nvim.follows = "obsidian-nvim"; # <- this will use the obsidian-nvim from your inputs
}; };
@ -48,12 +42,13 @@ Followed by importing the NixOS module somewhere in your configuration.
nvf.url = "github:notashelf/nvf"; nvf.url = "github:notashelf/nvf";
}; };
outputs = { nixpkgs, nvf, ... }: { outputs = { nixpkgs, nvf, ... }: let
system = "x86_64-linux"; in {
# ↓ this is your host output in the flake schema # ↓ this is your host output in the flake schema
nixosConfigurations."your-hostname" = nixpkgs.lib.nixosSystem { nixosConfigurations."yourUsername»" = nixpkgs.lib.nixosSystem {
modules = [ modules = [
nvf.nixosModules.default # <- this imports the NixOS module that provides the options nvf.nixosModules.default # <- this imports the NixOS module that provides the options
./configuration.nix # <- your host entrypoint, `programs.nvf.*` may be defined here ./configuration.nix # <- your host entrypoint
]; ];
}; };
}; };

View file

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

View file

@ -11,7 +11,6 @@ try-it-out.md
default-configs.md default-configs.md
installation.md installation.md
configuring.md configuring.md
tips.md
``` ```
```{=include=} chapters ```{=include=} chapters

View file

@ -1,13 +1,9 @@
# nvf Configuration Options {#ch-options} # Neovim Flake Configuration Options {#ch-options}
Below are the module options provided by nvf, in no particular order. Most Below are the module options provided by nvf, in no particular order. Most
options will include useful comments, warnings or setup tips on how a module options will include useful comments, warnings or setup tips on how a module
option is meant to be used as well as examples in complex cases. option is meant to be used as well as examples in complex cases.
An offline version of this page is bundled with nvf as a part of the manpages
which you can access with `man 5 nvf`. Please us know if you believe any of the
options below are missing useful examples.
<!-- <!--
In the manual, individual options may be referenced in Hyperlinks as follows: In the manual, individual options may be referenced in Hyperlinks as follows:
[](#opt-vim.*) If changing the prefix here, do keep in mind the #opt- suffix will have [](#opt-vim.*) If changing the prefix here, do keep in mind the #opt- suffix will have

View file

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

View file

@ -1,25 +0,0 @@
# Debugging nvf {#sec-debugging-nvf}
There may be instances where the your Nix configuration evaluates to invalid
Lua, or times when you will be asked to provide your built Lua configuration for
easier debugging by nvf maintainers. nvf provides two helpful utilities out of
the box.
**nvf-print-config** and **nvf-print-config-path** will be bundled with nvf as
lightweight utilities to help you view or share your built configuration when
necessary.
To view your configuration with syntax highlighting, you may use the
[bat pager](https://github.com/sharkdp/bat).
```bash
nvf-print-config | bat --language=lua
```
Alternatively, `cat` or `less` may also be used.
## Accessing `neovimConfig` {#sec-accessing-config}
It is also possible to access the configuration for the wrapped package. The
_built_ Neovim package will contain a `neovimConfig` attribute in its
`passthru`.

View file

@ -1,11 +0,0 @@
# Offline Documentation {#sec-offline-documentation}
[https://notashelf.github.io/nvf/options.html]: https://notashelf.github.io/nvf/options.html
The manpages provided by nvf contains an offline version of the option search
normally available at [https://notashelf.github.io/nvf/options.html]. You may
use the `man 5 nvf` command to view option documentation from the comfort of
your terminal.
Note that this is only available for NixOS and Home-Manager module
installations.

View file

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

View file

@ -28,11 +28,11 @@ configuration formats.
### `vim.maps` rewrite {#sec-vim-maps-rewrite} ### `vim.maps` rewrite {#sec-vim-maps-rewrite}
Instead of specifying map modes using submodules (e.g., `vim.maps.normal`), a Instead of specifying map modes using submodules (eg.: `vim.maps.normal`), a new
new `vim.keymaps` submodule with support for a `mode` option has been `vim.keymaps` submodule with support for a `mode` option has been introduced. It
introduced. It can be either a string, or a list of strings, where a string can be either a string, or a list of strings, where a string represents the
represents the short-name of the map mode(s), that the mapping should be set short-name of the map mode(s), that the mapping should be set for. See
for. See `:help map-modes` for more information. `:help map-modes` for more information.
For example: For example:

View file

@ -1,184 +1,23 @@
# Release 0.8 {#sec-release-0.8} # Release 0.8 {#sec-release-0.8}
## Breaking changes
- `git-conflict` keybinds are now prefixed with `<leader>` to avoid conflicting
with builtins
[NotAShelf](https://github.com/notashelf): [NotAShelf](https://github.com/notashelf):
[typst-preview.nvim]: https://github.com/chomosuke/typst-preview.nvim [typst-preview.nvim]: https://github.com/chomosuke/typst-preview.nvim
[render-markdown.nvim]: https://github.com/MeanderingProgrammer/render-markdown.nvim
[yanky.nvim]: https://github.com/gbprod/yanky.nvim
- Add [typst-preview.nvim] under - Add [typst-preview.nvim] under
`languages.typst.extensions.typst-preview-nvim`. `languages.typst.extensions.typst-preview-nvim`.
- Add a search widget to the options page in the nvf manual. - Add a search widget to the options page in the nvf manual.
- Add [render-markdown.nvim] under
`languages.markdown.extensions.render-markdown-nvim`
- Implement [](#opt-vim.git.gitsigns.setupOpts) for user-specified setup table
in gitsigns configuration.
- [](#opt-vim.options.mouse) no longer compares values to an enum of available
mouse modes. This means you can provide any string without the module system
warning you that it is invalid. Do keep in mind that this value is no longer
checked, so you will be responsible for ensuring its validity.
- Deprecate `vim.enableEditorconfig` in favor of
[](#opt-vim.globals.editorconfig).
- Deprecate rnix-lsp as it has been abandoned and archived upstream.
- Hardcoded indentation values for the Nix language module have been removed. To
replicate previous behaviour, you must either consolidate Nix indentation in
your Editorconfig configuration, or use an autocommand to set indentation
values for buffers with the Nix filetype.
- Add [](#opt-vim.lsp.lightbulb.autocmd.enable) for manually managing the
previously managed lightbulb autocommand.
- A warning will occur if [](#opt-vim.lsp.lightbulb.autocmd.enable) and
`vim.lsp.lightbulb.setupOpts.autocmd.enabled` are both set at the same time.
Pick only one.
- Add [yanky.nvim] to available plugins, under `vim.utility.yanky-nvim`.
[amadaluzia](https://github.com/amadaluzia): [amadaluzia](https://github.com/amadaluzia):
[haskell-tools.nvim]: https://github.com/MrcJkb/haskell-tools.nvim [haskell-tools.nvim]: https://github.com/MrcJkb/haskell-tools.nvim
- Add Haskell support under `vim.languages.haskell` using [haskell-tools.nvim]. - Add Haskell support under `vim.languages.haskell` using [haskell-tools.nvim].
[horriblename](https://github.com/horriblename):
[blink.cmp]: https://github.com/saghen/blink.cmp
- Add [blink.cmp] support
[diniamo](https://github.com/diniamo): [diniamo](https://github.com/diniamo):
- Add Odin support under `vim.languages.odin`. - Add Odin support under `vim.languages.odin`.
- Disable the built-in format-on-save feature of zls. Use `vim.lsp.formatOnSave` - Disable the built-in format-on-save feature of zls. Use `vim.lsp.formatOnSave`
instead. instead.
[horriblename](https://github.com/horriblename):
[aerial.nvim]: (https://github.com/stevearc/aerial.nvim)
[nvim-ufo]: (https://github.com/kevinhwang91/nvim-ufo)
- Add [aerial.nvim]
- Add [nvim-ufo]
[LilleAila](https://github.com/LilleAila):
- Remove `vim.notes.obsidian.setupOpts.dir`, which was set by default. Fixes
issue with setting the workspace directory.
- Add `vim.snippets.luasnip.setupOpts`, which was previously missing.
- Add `"prettierd"` as a formatter option in
`vim.languages.markdown.format.type`.
- Add the following plugins from
[mini.nvim](https://github.com/echasnovski/mini.nvim)
- `mini.ai`
- `mini.align`
- `mini.animate`
- `mini.base16`
- `mini.basics`
- `mini.bracketed`
- `mini.bufremove`
- `mini.clue`
- `mini.colors`
- `mini.comment`
- `mini.completion`
- `mini.deps`
- `mini.diff`
- `mini.doc`
- `mini.extra`
- `mini.files`
- `mini.fuzzy`
- `mini.git`
- `mini.hipatterns`
- `mini.hues`
- `mini.icons`
- `mini.indentscope`
- `mini.jump`
- `mini.jump2d`
- `mini.map`
- `mini.misc`
- `mini.move`
- `mini.notify`
- `mini.operators`
- `mini.pairs`
- `mini.pick`
- `mini.sessions`
- `mini.snippets`
- `mini.splitjoin`
- `mini.starter`
- `mini.statusline`
- `mini.surround`
- `mini.tabline`
- `mini.test`
- `mini.trailspace`
- `mini.visits`
- Add [fzf-lua](https://github.com/ibhagwan/fzf-lua) in `vim.fzf-lua`
- Add [rainbow-delimiters](https://github.com/HiPhish/rainbow-delimiters.nvim)
in `vim.visuals.rainbow-delimiters`
- Add options to define highlights under [](#opt-vim.highlight)
[kaktu5](https://github.com/kaktu5):
- Add WGSL support under `vim.languages.wgsl`.
[tomasguinzburg](https://github.com/tomasguinzburg):
[solargraph]: https://github.com/castwide/solargraph
[gbprod/nord.nvim]: https://github.com/gbprod/nord.nvim
- Add Ruby support under `vim.languages.ruby` using [solargraph].
- Add `nord` theme from [gbprod/nord.nvim].
[thamenato](https://github.com/thamenato):
[ruff]: (https://github.com/astral-sh/ruff)
- Add [ruff] as a formatter option in `vim.languages.python.format.type`.
[ARCIII](https://github.com/ArmandoCIII):
[leetcode.nvim]: https://github.com/kawre/leetcode.nvim
- Add `vim.languages.zig.dap` support through pkgs.lldb dap adapter. Code
Inspiration from `vim.languages.clang.dap` implementation.
- Add [leetcode.nvim] plugin under `vim.utility.leetcode-nvim`.
[nezia1](https://github.com/nezia1)
- Add support for [nixd](https://github.com/nix-community/nixd) language server.
[jahanson](https://github.com/jahanson):
- Add [multicursors.nvim](https://github.com/smoka7/multicursors.nvim) to
available plugins, under `vim.utility.multicursors`.
- Add [hydra.nvim](https://github.com/nvimtools/hydra.nvim) as dependency for
`multicursors.nvim` and lazy loads by default.
[folospior](https://github.com/folospior)
- Fix plugin name for lsp/lspkind.
[iynaix](https://github.com/iynaix)
- Add lsp options support for [nixd](https://github.com/nix-community/nixd)
language server.
[Mr-Helpful](https://github.com/Mr-Helpful)
- Corrects pin names used for nvim themes
[Libadoxon](https://github.com/Libadoxon)
- Add [git-conflict](https://github.com/akinsho/git-conflict.nvim) plugin for resolving git conflicts
- Add formatters for go: [gofmt](https://go.dev/blog/gofmt), [golines](https://github.com/segmentio/golines) and [gofumpt](https://github.com/mvdan/gofumpt)

2087
flake.lock generated

File diff suppressed because it is too large Load diff

643
flake.nix
View file

@ -5,9 +5,9 @@
self, self,
... ...
} @ inputs: let } @ inputs: let
# call the extended library with `inputs` # call the extedended library with `inputs`
# inputs is used to get the original standard library, and to pass inputs to the plugin autodiscovery function # inputs is used to get the original standard library, and to pass inputs to the plugin autodiscovery function
lib = import ./lib/stdlib-extended.nix {inherit inputs self;}; lib = import ./lib/stdlib-extended.nix inputs;
in in
flake-parts.lib.mkFlake { flake-parts.lib.mkFlake {
inherit inputs; inherit inputs;
@ -17,8 +17,6 @@
# «https://github.com/nix-systems/nix-systems» # «https://github.com/nix-systems/nix-systems»
systems = import inputs.systems; systems = import inputs.systems;
imports = [ imports = [
./flake/templates
./flake/apps.nix ./flake/apps.nix
./flake/legacyPackages.nix ./flake/legacyPackages.nix
./flake/overlays.nix ./flake/overlays.nix
@ -33,7 +31,7 @@
}; };
homeManagerModules = { homeManagerModules = {
nvf = import ./flake/modules/home-manager.nix {inherit lib inputs;}; nvf = import ./flake/modules/home-manager.nix self.packages lib;
default = self.homeManagerModules.nvf; default = self.homeManagerModules.nvf;
neovim-flake = neovim-flake =
lib.warn '' lib.warn ''
@ -44,7 +42,7 @@
}; };
nixosModules = { nixosModules = {
nvf = import ./flake/modules/nixos.nix {inherit lib inputs;}; nvf = import ./flake/modules/nixos.nix self.packages lib;
default = self.nixosModules.nvf; default = self.nixosModules.nvf;
neovim-flake = neovim-flake =
lib.warn '' lib.warn ''
@ -53,8 +51,6 @@
'' ''
self.nixosModules.nvf; self.nixosModules.nvf;
}; };
inherit (lib.importJSON ./npins/sources.json) pins;
}; };
perSystem = {pkgs, ...}: { perSystem = {pkgs, ...}: {
@ -93,10 +89,641 @@
}; };
# Language servers (use master instead of nixpkgs) # Language servers (use master instead of nixpkgs)
rnix-lsp.url = "github:nix-community/rnix-lsp";
nil = { nil = {
url = "github:oxalica/nil"; url = "github:oxalica/nil";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils"; inputs.flake-utils.follows = "flake-utils";
}; };
## Plugins
# Lazy loading
plugin-lz-n = {
url = "github:nvim-neorocks/lz.n";
flake = false;
};
plugin-lzn-auto-require = {
url = "github:horriblename/lzn-auto-require/require-rewrite";
flake = false;
};
plugin-rtp-nvim = {
url = "github:nvim-neorocks/rtp.nvim";
flake = false;
};
# LSP plugins
plugin-nvim-lspconfig = {
url = "github:neovim/nvim-lspconfig";
flake = false;
};
plugin-lspsaga = {
url = "github:tami5/lspsaga.nvim";
flake = false;
};
plugin-lspkind = {
url = "github:onsails/lspkind-nvim";
flake = false;
};
plugin-trouble = {
url = "github:folke/trouble.nvim";
flake = false;
};
plugin-nvim-treesitter-context = {
url = "github:nvim-treesitter/nvim-treesitter-context";
flake = false;
};
plugin-nvim-lightbulb = {
url = "github:kosayoda/nvim-lightbulb";
flake = false;
};
plugin-fastaction-nvim = {
url = "github:Chaitanyabsprip/fastaction.nvim";
flake = false;
};
plugin-lsp-signature = {
url = "github:ray-x/lsp_signature.nvim";
flake = false;
};
plugin-lsp-lines = {
url = "sourcehut:~whynothugo/lsp_lines.nvim";
flake = false;
};
plugin-none-ls = {
# https://github.com/nvimtools/none-ls.nvim/issues/58
url = "github:nvimtools/none-ls.nvim/bb680d752cec37949faca7a1f509e2fe67ab418a";
flake = false;
};
plugin-nvim-docs-view = {
url = "github:amrbashir/nvim-docs-view";
flake = false;
};
plugin-otter-nvim = {
url = "github:jmbuhr/otter.nvim";
flake = false;
};
# Language support
plugin-sqls-nvim = {
url = "github:nanotee/sqls.nvim";
flake = false;
};
plugin-rustaceanvim = {
url = "github:mrcjkb/rustaceanvim";
flake = false;
};
plugin-flutter-tools = {
url = "github:akinsho/flutter-tools.nvim";
flake = false;
};
plugin-neodev-nvim = {
url = "github:folke/neodev.nvim";
flake = false;
};
plugin-elixir-tools = {
url = "github:elixir-tools/elixir-tools.nvim";
flake = false;
};
plugin-ts-error-translator = {
url = "github:dmmulroy/ts-error-translator.nvim";
flake = false;
};
plugin-typst-preview-nvim = {
url = "github:chomosuke/typst-preview.nvim";
flake = false;
};
plugin-nvim-metals = {
url = "github:scalameta/nvim-metals";
flake = false;
};
plugin-omnisharp-extended = {
url = "github:Hoffs/omnisharp-extended-lsp.nvim";
flake = false;
};
plugin-csharpls-extended = {
url = "github:Decodetalkers/csharpls-extended-lsp.nvim";
flake = false;
};
# Copying/Registers
plugin-registers = {
url = "github:tversteeg/registers.nvim";
flake = false;
};
plugin-nvim-neoclip = {
url = "github:AckslD/nvim-neoclip.lua";
flake = false;
};
# Telescope
plugin-telescope = {
url = "github:nvim-telescope/telescope.nvim";
flake = false;
};
# Runners
plugin-run-nvim = {
url = "github:diniamo/run.nvim";
flake = false;
};
# Debuggers
plugin-nvim-dap = {
url = "github:mfussenegger/nvim-dap";
flake = false;
};
plugin-nvim-dap-ui = {
url = "github:rcarriga/nvim-dap-ui";
flake = false;
};
plugin-nvim-dap-go = {
url = "github:leoluz/nvim-dap-go";
flake = false;
};
# Filetrees
plugin-nvim-tree-lua = {
url = "github:nvim-tree/nvim-tree.lua";
flake = false;
};
plugin-neo-tree-nvim = {
url = "github:nvim-neo-tree/neo-tree.nvim";
flake = false;
};
# Tablines
plugin-nvim-bufferline-lua = {
url = "github:akinsho/nvim-bufferline.lua";
flake = false;
};
# Statuslines
plugin-lualine = {
url = "github:hoob3rt/lualine.nvim";
flake = false;
};
plugin-nvim-cmp = {
url = "github:hrsh7th/nvim-cmp";
flake = false;
};
plugin-cmp-buffer = {
url = "github:hrsh7th/cmp-buffer";
flake = false;
};
plugin-cmp-nvim-lsp = {
url = "github:hrsh7th/cmp-nvim-lsp";
flake = false;
};
plugin-cmp-path = {
url = "github:hrsh7th/cmp-path";
flake = false;
};
plugin-cmp-treesitter = {
url = "github:ray-x/cmp-treesitter";
flake = false;
};
plugin-cmp-luasnip = {
url = "github:saadparwaiz1/cmp_luasnip";
flake = false;
};
# snippets
plugin-luasnip = {
url = "github:L3MON4D3/LuaSnip";
flake = false;
};
plugin-friendly-snippets = {
url = "github:rafamadriz/friendly-snippets";
flake = false;
};
# Presence
plugin-neocord = {
url = "github:IogaMaster/neocord";
flake = false; # uses flake-utils, avoid the flake
};
# Autopairs
plugin-nvim-autopairs = {
url = "github:windwp/nvim-autopairs";
flake = false;
};
plugin-nvim-ts-autotag = {
url = "github:windwp/nvim-ts-autotag";
flake = false;
};
# Commenting
plugin-comment-nvim = {
url = "github:numToStr/Comment.nvim";
flake = false;
};
plugin-todo-comments = {
url = "github:folke/todo-comments.nvim";
flake = false;
};
# Buffer tools
plugin-bufdelete-nvim = {
url = "github:famiu/bufdelete.nvim";
flake = false;
};
# Dashboard Utilities
plugin-dashboard-nvim = {
url = "github:glepnir/dashboard-nvim";
flake = false;
};
plugin-alpha-nvim = {
url = "github:goolord/alpha-nvim";
flake = false;
};
plugin-vim-startify = {
url = "github:mhinz/vim-startify";
flake = false;
};
# Themes
plugin-base16 = {
url = "github:rrethy/base16-nvim";
flake = false;
};
plugin-tokyonight = {
url = "github:folke/tokyonight.nvim";
flake = false;
};
plugin-onedark = {
url = "github:navarasu/onedark.nvim";
flake = false;
};
plugin-catppuccin = {
url = "github:catppuccin/nvim";
flake = false;
};
plugin-dracula = {
url = "github:Mofiqul/dracula.nvim";
flake = false;
};
plugin-oxocarbon = {
url = "github:nyoom-engineering/oxocarbon.nvim";
flake = false;
};
plugin-gruvbox = {
url = "github:ellisonleao/gruvbox.nvim";
flake = false;
};
plugin-rose-pine = {
url = "github:rose-pine/neovim";
flake = false;
};
# Rust crates
plugin-crates-nvim = {
url = "github:Saecki/crates.nvim";
flake = false;
};
# Project Management
plugin-project-nvim = {
url = "github:ahmedkhalf/project.nvim";
flake = false;
};
# Visuals
plugin-nvim-cursorline = {
url = "github:yamatsum/nvim-cursorline";
flake = false;
};
plugin-nvim-scrollbar = {
url = "github:petertriho/nvim-scrollbar";
flake = false;
};
plugin-cinnamon-nvim = {
url = "github:declancm/cinnamon.nvim";
flake = false;
};
plugin-cellular-automaton = {
url = "github:Eandrju/cellular-automaton.nvim";
flake = false;
};
plugin-indent-blankline = {
url = "github:lukas-reineke/indent-blankline.nvim";
flake = false;
};
plugin-nvim-web-devicons = {
url = "github:nvim-tree/nvim-web-devicons";
flake = false;
};
plugin-tiny-devicons-auto-colors = {
url = "github:rachartier/tiny-devicons-auto-colors.nvim";
flake = false;
};
plugin-gitsigns-nvim = {
url = "github:lewis6991/gitsigns.nvim";
flake = false;
};
plugin-vim-fugitive = {
url = "github:tpope/vim-fugitive";
flake = false;
};
plugin-fidget-nvim = {
url = "github:j-hui/fidget.nvim";
flake = false;
};
plugin-highlight-undo = {
url = "github:tzachar/highlight-undo.nvim";
flake = false;
};
# Minimap
plugin-minimap-vim = {
url = "github:wfxr/minimap.vim";
flake = false;
};
plugin-codewindow-nvim = {
url = "github:gorbit99/codewindow.nvim";
flake = false;
};
# Notifications
plugin-nvim-notify = {
url = "github:rcarriga/nvim-notify";
flake = false;
};
# Utilities
plugin-ccc = {
url = "github:uga-rosa/ccc.nvim";
flake = false;
};
plugin-diffview-nvim = {
url = "github:sindrets/diffview.nvim";
flake = false;
};
plugin-icon-picker-nvim = {
url = "github:ziontee113/icon-picker.nvim";
flake = false;
};
plugin-which-key = {
url = "github:folke/which-key.nvim";
flake = false;
};
plugin-cheatsheet-nvim = {
url = "github:sudormrfbin/cheatsheet.nvim";
flake = false;
};
plugin-gesture-nvim = {
url = "github:notomo/gesture.nvim";
flake = false;
};
plugin-hop-nvim = {
url = "github:phaazon/hop.nvim";
flake = false;
};
plugin-leap-nvim = {
url = "github:ggandor/leap.nvim";
flake = false;
};
plugin-smartcolumn = {
url = "github:m4xshen/smartcolumn.nvim";
flake = false;
};
plugin-nvim-surround = {
url = "github:kylechui/nvim-surround";
flake = false;
};
plugin-glow-nvim = {
url = "github:ellisonleao/glow.nvim";
flake = false;
};
plugin-image-nvim = {
url = "github:3rd/image.nvim";
flake = false;
};
plugin-precognition-nvim = {
url = "github:tris203/precognition.nvim";
flake = false;
};
# Note-taking
plugin-obsidian-nvim = {
url = "github:epwalsh/obsidian.nvim";
flake = false;
};
plugin-orgmode-nvim = {
url = "github:nvim-orgmode/orgmode";
flake = false;
};
plugin-mind-nvim = {
url = "github:phaazon/mind.nvim";
flake = false;
};
# Spellchecking
plugin-vim-dirtytalk = {
url = "github:psliwka/vim-dirtytalk";
flake = false;
};
# Terminal
plugin-toggleterm-nvim = {
url = "github:akinsho/toggleterm.nvim";
flake = false;
};
# UI
plugin-nvim-navbuddy = {
url = "github:SmiteshP/nvim-navbuddy";
flake = false;
};
plugin-nvim-navic = {
url = "github:SmiteshP/nvim-navic";
flake = false;
};
plugin-noice-nvim = {
url = "github:folke/noice.nvim";
flake = false;
};
plugin-modes-nvim = {
url = "github:mvllow/modes.nvim";
flake = false;
};
plugin-nvim-colorizer-lua = {
url = "github:NvChad/nvim-colorizer.lua";
flake = false;
};
plugin-vim-illuminate = {
url = "github:RRethy/vim-illuminate";
flake = false;
};
# Assistant
plugin-chatgpt = {
url = "github:jackMort/ChatGPT.nvim";
flake = false;
};
plugin-copilot-lua = {
url = "github:zbirenbaum/copilot.lua";
flake = false;
};
plugin-copilot-cmp = {
url = "github:zbirenbaum/copilot-cmp";
flake = false;
};
# Session management
plugin-nvim-session-manager = {
url = "github:Shatur/neovim-session-manager";
flake = false;
};
# Dependencies
plugin-plenary-nvim = {
# (required by crates-nvim)
url = "github:nvim-lua/plenary.nvim";
flake = false;
};
plugin-dressing-nvim = {
# (required by icon-picker-nvim)
url = "github:stevearc/dressing.nvim";
flake = false;
};
plugin-vim-markdown = {
# (required by obsidian-nvim)
url = "github:preservim/vim-markdown";
flake = false;
};
plugin-tabular = {
# (required by vim-markdown)
url = "github:godlygeek/tabular";
flake = false;
};
plugin-lua-utils-nvim = {
url = "github:nvim-neorg/lua-utils.nvim";
flake = false;
};
plugin-pathlib-nvim = {
url = "github:pysan3/pathlib.nvim";
flake = false;
};
plugin-neorg = {
url = "github:nvim-neorg/neorg";
flake = false;
};
plugin-neorg-telescope = {
url = "github:nvim-neorg/neorg-telescope";
flake = false;
};
plugin-nui-nvim = {
# (required by noice.nvim)
url = "github:MunifTanjim/nui.nvim";
flake = false;
};
plugin-vim-repeat = {
# (required by leap.nvim)
url = "github:tpope/vim-repeat";
flake = false;
};
plugin-nvim-nio = {
# (required by nvim-dap-ui)
url = "github:nvim-neotest/nvim-nio";
flake = false;
};
plugin-new-file-template-nvim = {
# (required by new-file-template.nvim)
url = "github:otavioschwanck/new-file-template.nvim";
flake = false;
};
plugin-haskell-tools-nvim = {
url = "github:mrcjkb/haskell-tools.nvim";
flake = false;
};
}; };
} }

View file

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

View file

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

View file

@ -1,38 +0,0 @@
{
rustPlatform,
hostPlatform,
vimUtils,
git,
src,
version,
}: let
blink-fuzzy-lib = rustPlatform.buildRustPackage {
pname = "blink-fuzzy-lib";
inherit version src;
# TODO: remove this if plugin stops using nightly rust
env.RUSTC_BOOTSTRAP = true;
nativeBuildInputs = [git];
cargoLock = {
lockFile = "${src}/Cargo.lock";
allowBuiltinFetchGit = true;
};
};
libExt =
if hostPlatform.isDarwin
then "dylib"
else "so";
in
vimUtils.buildVimPlugin {
pname = "blink-cmp";
inherit version src;
# blink references a repro.lua which is placed outside the lua/ directory
doCheck = false;
preInstall = ''
mkdir -p target/release
ln -s ${blink-fuzzy-lib}/lib/libblink_cmp_fuzzy.${libExt} target/release/libblink_cmp_fuzzy.${libExt}
'';
}

View file

@ -1,28 +1,22 @@
# Home Manager module # Home Manager module
{ packages: lib: {
inputs,
lib,
}: {
config, config,
pkgs, pkgs,
... ...
}: let }: let
inherit (inputs.self) packages;
inherit (lib) maintainers; inherit (lib) maintainers;
inherit (lib.modules) mkIf mkAliasOptionModule; inherit (lib.modules) mkIf mkAliasOptionModule;
inherit (lib.lists) optional; inherit (lib.lists) optional;
inherit (lib.options) mkOption mkEnableOption literalExpression; inherit (lib.options) mkOption mkEnableOption literalExpression;
inherit (lib.types) anything bool submoduleWith; inherit (lib.types) attrsOf anything bool;
inherit (lib.nvim) neovimConfiguration;
inherit (lib.nvim.types) anythingConcatLists;
cfg = config.programs.nvf; cfg = config.programs.nvf;
nvfModule = submoduleWith { neovimConfigured = neovimConfiguration {
description = "Nvf module"; inherit pkgs;
class = "nvf"; modules = [cfg.settings];
specialArgs = {
inherit pkgs lib inputs;
};
modules = import ../../modules/modules.nix {inherit pkgs lib;};
}; };
in { in {
imports = [ imports = [
@ -61,7 +55,7 @@ in {
}; };
settings = mkOption { settings = mkOption {
type = nvfModule; type = attrsOf anythingConcatLists;
default = {}; default = {};
description = "Attribute set of nvf preferences."; description = "Attribute set of nvf preferences.";
example = literalExpression '' example = literalExpression ''
@ -84,7 +78,7 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
programs.nvf.finalPackage = cfg.settings.vim.build.finalPackage; programs.nvf.finalPackage = neovimConfigured.neovim;
home = { home = {
sessionVariables = mkIf cfg.defaultEditor {EDITOR = "nvim";}; sessionVariables = mkIf cfg.defaultEditor {EDITOR = "nvim";};

View file

@ -1,28 +1,22 @@
# NixOS module # NixOS module
{ packages: lib: {
inputs,
lib,
}: {
config, config,
pkgs, pkgs,
... ...
}: let }: let
inherit (inputs.self) packages;
inherit (lib) maintainers; inherit (lib) maintainers;
inherit (lib.modules) mkIf mkOverride mkAliasOptionModule; inherit (lib.modules) mkIf mkOverride mkAliasOptionModule;
inherit (lib.lists) optional; inherit (lib.lists) optional;
inherit (lib.options) mkOption mkEnableOption literalExpression; inherit (lib.options) mkOption mkEnableOption literalExpression;
inherit (lib.types) anything bool submoduleWith; inherit (lib.types) attrsOf anything bool;
inherit (lib.nvim) neovimConfiguration;
inherit (lib.nvim.types) anythingConcatLists;
cfg = config.programs.nvf; cfg = config.programs.nvf;
nvfModule = submoduleWith { neovimConfigured = neovimConfiguration {
description = "Nvf module"; inherit pkgs;
class = "nvf"; modules = [cfg.settings];
specialArgs = {
inherit pkgs lib inputs;
};
modules = import ../../modules/modules.nix {inherit pkgs lib;};
}; };
in { in {
imports = [ imports = [
@ -61,7 +55,7 @@ in {
}; };
settings = mkOption { settings = mkOption {
type = nvfModule; type = attrsOf anythingConcatLists;
default = {}; default = {};
description = "Attribute set of nvf preferences."; description = "Attribute set of nvf preferences.";
example = literalExpression '' example = literalExpression ''
@ -84,7 +78,7 @@ in {
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
programs.nvf.finalPackage = cfg.settings.vim.build.finalPackage; programs.nvf.finalPackage = neovimConfigured.neovim;
environment = { environment = {
variables.EDITOR = mkIf cfg.defaultEditor (mkOverride 900 "nvim"); variables.EDITOR = mkIf cfg.defaultEditor (mkOverride 900 "nvim");

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -5,6 +5,8 @@
inherit (lib.types) bool; inherit (lib.types) bool;
inherit (lib.nvim.attrsets) mapListToAttrs; inherit (lib.nvim.attrsets) mapListToAttrs;
in { in {
# Converts a boolean to a yes/no string. This is used in lots of
# configuration formats.
diagnosticsToLua = { diagnosticsToLua = {
lang, lang,
config, config,
@ -28,8 +30,8 @@ in {
mkEnable = desc: mkEnable = desc:
mkOption { mkOption {
default = false;
type = bool;
description = "Turn on ${desc} for enabled languages by default"; description = "Turn on ${desc} for enabled languages by default";
type = bool;
default = false;
}; };
} }

View file

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

View file

@ -1,8 +1,57 @@
{lib}: let {lib}: let
inherit (lib.options) mergeEqualOption; inherit (lib.options) showOption showFiles getFiles mergeOneOption mergeEqualOption;
inherit (lib.strings) isString stringLength match; inherit (lib.strings) isString isStringLike;
inherit (lib.types) listOf mkOptionType; inherit (lib.types) anything attrsOf listOf mkOptionType;
inherit (lib.nvim.types) anythingConcatLists;
inherit (builtins) typeOf isAttrs any head concatLists stringLength match;
in { 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;
};
mergelessListOf = elemType: let mergelessListOf = elemType: let
super = listOf elemType; super = listOf elemType;
in in

View file

@ -1,11 +1,15 @@
{lib}: let {
inputs,
lib,
...
}: let
typesDag = import ./dag.nix {inherit lib;}; typesDag = import ./dag.nix {inherit lib;};
typesPlugin = import ./plugins.nix {inherit lib;}; typesPlugin = import ./plugins.nix {inherit inputs lib;};
typesLanguage = import ./languages.nix {inherit lib;}; typesLanguage = import ./languages.nix {inherit lib;};
customTypes = import ./custom.nix {inherit lib;}; customTypes = import ./custom.nix {inherit lib;};
in { in {
inherit (typesDag) dagOf; inherit (typesDag) dagOf;
inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption luaInline pluginType borderType; inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption luaInline pluginType borderType;
inherit (typesLanguage) diagnostics mkGrammarOption; inherit (typesLanguage) diagnostics mkGrammarOption;
inherit (customTypes) char hexColor mergelessListOf; inherit (customTypes) anythingConcatLists char hexColor mergelessListOf;
} }

View file

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

View file

@ -1,5 +1,4 @@
{ {
self,
inputs, inputs,
lib, lib,
}: { }: {
@ -10,8 +9,9 @@
extraModules ? [], extraModules ? [],
configuration ? {}, configuration ? {},
}: let }: let
inherit (lib.strings) toString; inherit (pkgs) vimPlugins;
inherit (lib.lists) concatLists; inherit (lib.strings) isString toString;
inherit (lib.lists) filter map concatLists;
# import modules.nix with `check`, `pkgs` and `lib` as arguments # import modules.nix with `check`, `pkgs` and `lib` as arguments
# check can be disabled while calling this file is called # check can be disabled while calling this file is called
@ -21,12 +21,7 @@
# evaluate the extended library with the modules # evaluate the extended library with the modules
# optionally with any additional modules passed by the user # optionally with any additional modules passed by the user
module = lib.evalModules { module = lib.evalModules {
specialArgs = specialArgs = extraSpecialArgs // {modulesPath = toString ./.;};
extraSpecialArgs
// {
inherit self inputs;
modulesPath = toString ./.;
};
modules = concatLists [ modules = concatLists [
nvimModules nvimModules
modules modules
@ -41,11 +36,102 @@
extraModules)) 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
);
buildTreesitterPlug = grammars: vimPlugins.nvim-treesitter.withPlugins (_: grammars);
pluginBuilders = {
nvim-treesitter = buildTreesitterPlug vimOptions.treesitter.grammars;
flutter-tools-patched = buildPlug {
pname = "flutter-tools";
patches = [../patches/flutter-tools.patch];
};
};
buildConfigPlugins = plugins:
map (
plug:
if (isString plug)
then pluginBuilders.${plug} or (noBuildPlug {pname = plug;})
else plug
) (filter (f: f != null) plugins);
# built (or "normalized") plugins that are modified
builtStartPlugins = buildConfigPlugins vimOptions.startPlugins;
builtOptPlugins = map (package: package // {optional = true;}) (buildConfigPlugins vimOptions.optPlugins);
# additional Lua and Python3 packages, mapped to their respective functions
# to conform to the format mnw 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;
inherit (vimOptions) viAlias vimAlias withRuby withNodeJs withPython3;
inherit extraLuaPackages extraPython3Packages;
};
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}";
in { in {
inherit (module) options config; inherit (module) options config;
inherit (module._module.args) pkgs; inherit (module._module.args) pkgs;
# Expose wrapped neovim-package for userspace # Expose wrapped neovim-package for userspace
# or module consumption. # or module consumption.
neovim = module.config.vim.build.finalPackage; neovim = pkgs.symlinkJoin {
name = "nvf-with-helpers";
paths = [neovim-wrapped printConfig printConfigPath];
postBuild = "echo Helpers added";
# Allow evaluating vimOptions, i.e., config.vim from the packages' passthru
# attribute. For example, packages.x86_64-linux.neovim.passthru.neovimConfig
# will return the configuration in full.
passthru.neovimConfig = vimOptions;
meta =
neovim-wrapped.meta
// {
description = "Wrapped Neovim package with helper scripts to print the config (path)";
};
};
} }

View file

@ -4,7 +4,6 @@
inherit (lib.nvim.config) batchRenameOptions; inherit (lib.nvim.config) batchRenameOptions;
renamedVimOpts = batchRenameOptions ["vim"] ["vim" "options"] { renamedVimOpts = batchRenameOptions ["vim"] ["vim" "options"] {
# 2024-12-01
colourTerm = "termguicolors"; colourTerm = "termguicolors";
mouseSupport = "mouse"; mouseSupport = "mouse";
cmdHeight = "cmdheight"; cmdHeight = "cmdheight";
@ -15,10 +14,6 @@
splitRight = "splitright"; splitRight = "splitright";
autoIndent = "autoindent"; autoIndent = "autoindent";
wordWrap = "wrap"; wordWrap = "wrap";
showSignColumn = "signcolumn";
# 2025-02-07
scrollOff = "scrolloff";
}; };
in { in {
imports = concatLists [ imports = concatLists [
@ -40,28 +35,23 @@ in {
vim.autopairs.enable has been removed in favor of per-plugin modules. vim.autopairs.enable has been removed in favor of per-plugin modules.
You can enable nvim-autopairs with vim.autopairs.nvim-autopairs.enable instead. You can enable nvim-autopairs with vim.autopairs.nvim-autopairs.enable instead.
'') '')
(mkRemovedOptionModule ["vim" "autopairs" "type"] '' (mkRemovedOptionModule ["vim" "autopairs" "type"] ''
vim.autopairs.type has been removed in favor of per-plugin modules. vim.autopairs.type has been removed in favor of per-plugin modules.
You can enable nvim-autopairs with vim.autopairs.nvim-autopairs.enable instead. You can enable nvim-autopairs with vim.autopairs.nvim-autopairs.enable instead.
'') '')
(mkRemovedOptionModule ["vim" "autocomplete" "enable"] '' (mkRemovedOptionModule ["vim" "autocomplete" "enable"] ''
vim.autocomplete.enable has been removed in favor of per-plugin modules. vim.autocomplete.enable has been removed in favor of per-plugin modules.
You can enable nvim-cmp with vim.autocomplete.nvim-cmp.enable instead. You can enable nvim-cmp with vim.autocomplete.nvim-cmp.enable instead.
'') '')
(mkRemovedOptionModule ["vim" "autocomplete" "type"] '' (mkRemovedOptionModule ["vim" "autocomplete" "type"] ''
vim.autocomplete.type has been removed in favor of per-plugin modules. vim.autocomplete.type has been removed in favor of per-plugin modules.
You can enable nvim-cmp with vim.autocomplete.nvim-cmp.enable instead. You can enable nvim-cmp with vim.autocomplete.nvim-cmp.enable instead.
'') '')
(mkRemovedOptionModule ["vim" "autocomplete" "sources"] '' (mkRemovedOptionModule ["vim" "autocomplete" "sources"] ''
vim.autocomplete.sources has been removed in favor of per-plugin modules. vim.autocomplete.sources has been removed in favor of per-plugin modules.
You can add nvim-cmp sources with vim.autocomplete.nvim-cmp.sources You can add nvim-cmp sources with vim.autocomplete.nvim-cmp.sources
instead. instead.
'') '')
(mkRemovedOptionModule ["vim" "snippets" "vsnip" "enable"] '' (mkRemovedOptionModule ["vim" "snippets" "vsnip" "enable"] ''
vim.snippets.vsnip.enable has been removed in favor of the more modern luasnip. vim.snippets.vsnip.enable has been removed in favor of the more modern luasnip.
'') '')
@ -94,18 +84,9 @@ in {
`tabstop` and `shiftwidth` manually in `vim.options` or per-filetype in a `tabstop` and `shiftwidth` manually in `vim.options` or per-filetype in a
`ftplugin` directory added to your runtime path. `ftplugin` directory added to your runtime path.
'') '')
# 2024-12-02
(mkRenamedOptionModule ["vim" "enableEditorconfig"] ["vim" "globals" "editorconfig"])
# 2025-02-06
(mkRemovedOptionModule ["vim" "disableArrows"] ''
Top-level convenience options are now in the process of being removed from nvf as
their behaviour was abstract, and confusing. Please use 'vim.options' or 'vim.luaConfigRC'
to replicate previous behaviour.
'')
] ]
# 2024-12-1
# Migrated via batchRenameOptions. Further batch renames must be below this line. # Migrated via batchRenameOptions. Further batch renames must be below this line.
renamedVimOpts renamedVimOpts
]; ];

View file

@ -23,13 +23,10 @@
"completion" "completion"
"dashboard" "dashboard"
"debugger" "debugger"
"diagnostics"
"filetree" "filetree"
"formatter"
"git" "git"
"languages" "languages"
"lsp" "lsp"
"mini"
"minimap" "minimap"
"notes" "notes"
"projects" "projects"
@ -52,7 +49,6 @@
# using the configuration passed in `neovim` and `plugins` modules. # using the configuration passed in `neovim` and `plugins` modules.
wrapper = map (p: ./wrapper + "/${p}") [ wrapper = map (p: ./wrapper + "/${p}") [
"build" "build"
"environment"
"rc" "rc"
"warnings" "warnings"
"lazy" "lazy"

View file

@ -5,7 +5,6 @@
}: let }: let
inherit (lib.options) mkOption mkEnableOption literalMD; inherit (lib.options) mkOption mkEnableOption literalMD;
inherit (lib.strings) optionalString; inherit (lib.strings) optionalString;
inherit (lib.attrsets) optionalAttrs;
inherit (lib.types) enum bool str int either; inherit (lib.types) enum bool str int either;
inherit (lib.generators) mkLuaInline; inherit (lib.generators) mkLuaInline;
inherit (lib.nvim.dag) entryAfter; inherit (lib.nvim.dag) entryAfter;
@ -16,6 +15,12 @@
cfg = config.vim; cfg = config.vim;
in { in {
options.vim = { options.vim = {
disableArrows = mkOption {
type = bool;
default = false;
description = "Set to prevent arrow keys from moving cursor";
};
hideSearchHighlight = mkOption { hideSearchHighlight = mkOption {
type = bool; type = bool;
default = false; default = false;
@ -49,14 +54,14 @@ in {
preventJunkFiles = mkOption { preventJunkFiles = mkOption {
type = bool; type = bool;
default = true; default = false;
example = false; description = "Prevent swapfile and backupfile from being created";
description = '' };
Prevent swapfile and backupfile from being created.
`false` is the default Neovim behaviour. If you wish to create showSignColumn = mkOption {
backup and swapfiles, set this option to `false`. type = bool;
''; default = true;
description = "Show the sign column";
}; };
bell = mkOption { bell = mkOption {
@ -65,6 +70,12 @@ in {
description = "Set how bells are handled. Options: on, visual or none"; description = "Set how bells are handled. Options: on, visual or none";
}; };
enableEditorconfig = mkOption {
type = bool;
default = true;
description = "Follow editorconfig rules in current directory";
};
searchCase = mkOption { searchCase = mkOption {
type = enum ["ignore" "smart" "sensitive"]; type = enum ["ignore" "smart" "sensitive"];
default = "sensitive"; default = "sensitive";
@ -95,55 +106,63 @@ in {
# Set options that were previously interpolated in 'luaConfigRC.basic' as vim.options (vim.o) # Set options that were previously interpolated in 'luaConfigRC.basic' as vim.options (vim.o)
# and 'vim.globals' (vim.g). Future options, if possible, should be added here instead of the # and 'vim.globals' (vim.g). Future options, if possible, should be added here instead of the
# luaConfigRC section below. # luaConfigRC section below.
options = pushDownDefault (lib.mergeAttrsList [ options = pushDownDefault {
{ encoding = "utf-8";
# Options that are always set, with a lower priority hidden = true;
encoding = "utf-8"; expandtab = true;
hidden = true; };
expandtab = true;
# Junkfile Behaviour globals = pushDownDefault {
swapfile = !cfg.preventJunkFiles; editorconfig = cfg.enableEditorconfig;
backup = !cfg.preventJunkFiles; };
writebackup = !cfg.preventJunkFiles;
}
(optionalAttrs cfg.undoFile.enable { # Options that are more difficult to set through 'vim.options'. Fear not, though
undofile = true; # as the Lua DAG is still as powerful as it could be.
undodir = cfg.undoFile.path;
})
(optionalAttrs (cfg.bell == "none") {
errorbells = false;
visualbell = false;
})
(optionalAttrs (cfg.bell == "on") {
visualbell = false;
})
(optionalAttrs (cfg.bell == "visual") {
visualbell = false;
})
(optionalAttrs (cfg.lineNumberMode == "relative") {
relativenumber = true;
})
(optionalAttrs (cfg.lineNumberMode == "number") {
number = true;
})
(optionalAttrs (cfg.lineNumberMode == "relNumber") {
number = true;
relativenumber = true;
})
]);
# Options that are more difficult to set through 'vim.options'. Namely, appending values
# to pre-set Neovim options. Fear not, though as the Lua DAG is still as powerful as it
# could be.
luaConfigRC.basic = entryAfter ["globalsScript"] '' luaConfigRC.basic = entryAfter ["globalsScript"] ''
-- Settings that are set for everything
vim.opt.shortmess:append("c")
${optionalString cfg.undoFile.enable ''
vim.o.undofile = true
vim.o.undodir = ${toLuaObject cfg.undoFile.path}
''}
${optionalString cfg.showSignColumn ''
vim.o.signcolumn = "yes"
''}
${optionalString cfg.preventJunkFiles ''
vim.o.swapfile = false
vim.o.backup = false
vim.o.writebackup = false
''}
${optionalString (cfg.bell == "none") ''
vim.o.errorbells = false
vim.o.visualbell = false
''}
${optionalString (cfg.bell == "on") ''
vim.o.visualbell = false
''}
${optionalString (cfg.bell == "visual") ''
vim.o.errorbells = false
''}
${optionalString (cfg.lineNumberMode == "relative") ''
vim.o.relativenumber = true
''}
${optionalString (cfg.lineNumberMode == "number") ''
vim.o.number = true
''}
${optionalString (cfg.lineNumberMode == "relNumber") ''
vim.o.number = true
vim.o.relativenumber = true
''}
${optionalString cfg.useSystemClipboard '' ${optionalString cfg.useSystemClipboard ''
vim.opt.clipboard:append("unnamedplus") vim.opt.clipboard:append("unnamedplus")
''} ''}

View file

@ -2,7 +2,6 @@
imports = [ imports = [
./basic.nix ./basic.nix
./debug.nix ./debug.nix
./highlight.nix
./spellcheck.nix ./spellcheck.nix
]; ];
} }

View file

@ -1,119 +0,0 @@
{
config,
lib,
...
}: let
inherit (lib.options) mkOption;
inherit (lib.types) nullOr attrsOf listOf submodule bool ints str enum;
inherit (lib.strings) hasPrefix concatLines;
inherit (lib.attrsets) mapAttrsToList;
inherit (lib.nvim.dag) entryBetween;
inherit (lib.nvim.lua) toLuaObject;
inherit (lib.nvim.types) hexColor;
mkColorOption = target:
mkOption {
type = nullOr hexColor;
default = null;
example = "#ebdbb2";
description = ''
The ${target} color to use. Written as color name or hex "#RRGGBB".
'';
};
mkBoolOption = name:
mkOption {
type = nullOr bool;
default = null;
example = false;
description = "Whether to enable ${name}";
};
cfg = config.vim.highlight;
in {
options.vim.highlight = mkOption {
type = attrsOf (submodule {
# See :h nvim_set_hl
options = {
bg = mkColorOption "background";
fg = mkColorOption "foreground";
sp = mkColorOption "special";
blend = mkOption {
type = nullOr (ints.between 0 100);
default = null;
description = "Blend as an integer between 0 and 100";
};
bold = mkBoolOption "bold";
standout = mkBoolOption "standout";
underline = mkBoolOption "underline";
undercurl = mkBoolOption "undercurl";
underdouble = mkBoolOption "underdouble";
underdotted = mkBoolOption "underdotted";
underdashed = mkBoolOption "underdashed";
strikethrough = mkBoolOption "strikethrough";
italic = mkBoolOption "italic";
reverse = mkBoolOption "reverse";
nocombine = mkBoolOption "nocombine";
link = mkOption {
type = nullOr str;
default = null;
description = "The name of another highlight group to link to";
};
default = mkOption {
type = nullOr bool;
default = null;
description = "Don't override existing definition";
};
ctermfg = mkOption {
type = nullOr str;
default = null;
description = "The cterm foreground color to use";
};
ctermbg = mkOption {
type = nullOr str;
default = null;
description = "The cterm background color to use";
};
cterm = mkOption {
type = nullOr (listOf (enum [
"bold"
"underline"
"undercurl"
"underdouble"
"underdotted"
"underdashed"
"strikethrough"
"reverse"
"inverse"
"italic"
"standout"
"altfont"
"nocombine"
"NONE"
]));
default = null;
description = "The cterm arguments to use. See ':h highlight-args'";
};
force = mkBoolOption "force update";
};
});
default = {};
example = {
SignColumn = {
bg = "#282828";
};
};
description = "Custom highlights to apply";
};
config = {
vim.luaConfigRC.highlight = let
highlights =
mapAttrsToList (
name: value: ''vim.api.nvim_set_hl(0, ${toLuaObject name}, ${toLuaObject value})''
)
cfg;
in
entryBetween ["lazyConfigs" "pluginConfigs" "extraPluginConfigs"] ["theme"] (concatLines highlights);
};
}

View file

@ -6,7 +6,7 @@
}: let }: let
inherit (lib.modules) mkIf mkRenamedOptionModule; inherit (lib.modules) mkIf mkRenamedOptionModule;
inherit (lib.options) mkOption mkEnableOption literalExpression; inherit (lib.options) mkOption mkEnableOption literalExpression;
inherit (lib.strings) concatLines concatStringsSep optionalString; inherit (lib.strings) concatLines;
inherit (lib.attrsets) mapAttrsToList; inherit (lib.attrsets) mapAttrsToList;
inherit (lib.types) listOf str attrsOf; inherit (lib.types) listOf str attrsOf;
inherit (lib.nvim.lua) listToLuaTable; inherit (lib.nvim.lua) listToLuaTable;
@ -124,6 +124,7 @@ in {
nvim --headless --clean \ nvim --headless --clean \
--cmd "mkspell $out/spell/$name.add.spl $spellfile" -Es -n --cmd "mkspell $out/spell/$name.add.spl $spellfile" -Es -n
done done
''; '';
in in
mkIf (cfg.extraSpellWords != {}) [ mkIf (cfg.extraSpellWords != {}) [
@ -132,19 +133,10 @@ in {
compileJoinedSpellfiles.outPath compileJoinedSpellfiles.outPath
]; ];
options = { luaConfigRC.spellcheck = entryAfter ["basic"] ''
spell = true; vim.opt.spell = true
vim.opt.spelllang = ${listToLuaTable cfg.languages}
# Workaround for Neovim's spelllang setup. It can be
# - a string, e.g., "en"
# - multiple strings, separated with commas, e.g., "en,de"
# toLuaObject cannot generate the correct type here, unless we take a string here.
spelllang = concatStringsSep "," cfg.languages;
};
# Register an autocommand to disable spellchecking in buffers with given filetypes.
# If the list is empty, the autocommand does not need to be registered.
luaConfigRC.spellcheck = entryAfter ["basic"] (optionalString (cfg.ignoredFiletypes != []) ''
-- Disable spellchecking for certain filetypes -- Disable spellchecking for certain filetypes
-- as configured by `vim.spellcheck.ignoredFiletypes` -- as configured by `vim.spellcheck.ignoredFiletypes`
vim.api.nvim_create_augroup("nvf_autocmds", {clear = false}) vim.api.nvim_create_augroup("nvf_autocmds", {clear = false})
@ -155,7 +147,7 @@ in {
vim.opt_local.spell = false vim.opt_local.spell = false
end, end,
}) })
''); '';
}; };
}; };
} }

View file

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

View file

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

View file

@ -1,120 +0,0 @@
{lib, ...}: let
inherit (lib.options) mkEnableOption mkOption literalMD;
inherit (lib.types) listOf str either attrsOf submodule enum anything int nullOr;
inherit (lib.generators) mkLuaInline;
inherit (lib.nvim.types) mkPluginSetupOption luaInline;
inherit (lib.nvim.binds) mkMappingOption;
inherit (lib.nvim.config) mkBool;
keymapType = submodule {
freeformType = attrsOf (listOf (either str luaInline));
options = {
preset = mkOption {
type = enum ["default" "none" "super-tab" "enter"];
default = "none";
description = "keymap presets";
};
};
};
providerType = submodule {
freeformType = anything;
options = {
module = mkOption {
type = str;
description = "module of the provider";
};
};
};
in {
options.vim.autocomplete.blink-cmp = {
enable = mkEnableOption "blink.cmp";
setupOpts = mkPluginSetupOption "blink.cmp" {
sources = {
default = mkOption {
type = listOf str;
default = ["lsp" "path" "snippets" "buffer"];
description = "Default list of sources to enable for completion.";
};
cmdline = mkOption {
type = nullOr (listOf str);
default = [];
description = "List of sources to enable for cmdline. Null means use default source list.";
};
providers = mkOption {
type = attrsOf providerType;
default = {};
description = "Settings for completion providers";
};
transform_items = mkOption {
type = nullOr luaInline;
default = mkLuaInline "function(_, items) return items end";
defaultText = ''
Our default does nothing. If you want blink.cmp's default, which
lowers the score for snippets, set this option to null.
'';
description = ''
Function to use when transforming the items before they're returned
for all providers.
'';
};
};
completion = {
documentation = {
auto_show = mkBool true "Show documentation whenever an item is selected";
auto_show_delay_ms = mkOption {
type = int;
default = 200;
description = "Delay before auto show triggers";
};
};
};
keymap = mkOption {
type = keymapType;
default = {};
description = "blink.cmp keymap";
example = literalMD ''
```nix
vim.autocomplete.blink-cmp.setupOpts.keymap = {
preset = "none";
"<Up>" = ["select_prev" "fallback"];
"<C-n>" = [
(lib.generators.mkLuaInline ''''
function(cmp)
if some_condition then return end -- runs the next command
return true -- doesn't run the next command
end,
'''')
"select_next"
];
};
```
'';
};
fuzzy = {
prebuilt_binaries = {
download = mkBool false ''
Auto-downloads prebuilt binaries. Do not enable, it doesn't work on nix
'';
};
};
};
mappings = {
complete = mkMappingOption "Complete [blink.cmp]" "<C-Space>";
confirm = mkMappingOption "Confirm [blink.cmp]" "<CR>";
next = mkMappingOption "Next item [blink.cmp]" "<Tab>";
previous = mkMappingOption "Previous item [blink.cmp]" "<S-Tab>";
close = mkMappingOption "Close [blink.cmp]" "<C-e>";
scrollDocsUp = mkMappingOption "Scroll docs up [blink.cmp]" "<C-d>";
scrollDocsDown = mkMappingOption "Scroll docs down [blink.cmp]" "<C-f>";
};
};
}

View file

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

View file

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

View file

@ -1,34 +0,0 @@
{
lib,
config,
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.nvim.attrsets) mapListToAttrs;
inherit (builtins) typeOf tryEval;
cfg = config.vim.autocomplete;
getPluginName = plugin:
if typeOf plugin == "string"
then plugin
else if (plugin ? pname && (tryEval plugin.pname).success)
then plugin.pname
else plugin.name;
in {
config.vim = mkIf cfg.enableSharedCmpSources {
startPlugins = ["rtp-nvim"];
lazy.plugins =
mapListToAttrs (package: {
name = getPluginName package;
value = {
inherit package;
lazy = true;
after = ''
local path = vim.fn.globpath(vim.o.packpath, 'pack/*/opt/${getPluginName package}')
require("rtp_nvim").source_after_plugin_dir(path)
'';
};
})
cfg.nvim-cmp.sourcePlugins;
};
}

View file

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

View file

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

View file

@ -24,103 +24,114 @@
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim = { vim = {
lazy.plugins = { startPlugins = ["rtp-nvim"];
nvim-cmp = { lazy.plugins = mkMerge [
package = "nvim-cmp"; (mapListToAttrs (package: {
after = '' name = getPluginName package;
${optionalString luasnipEnable "local luasnip = require('luasnip')"} value = {
local cmp = require("cmp") inherit package;
lazy = true;
after = ''
local path = vim.fn.globpath(vim.o.packpath, 'pack/*/opt/${getPluginName package}')
require("rtp_nvim").source_after_plugin_dir(path)
'';
};
})
cfg.sourcePlugins)
{
nvim-cmp = {
package = "nvim-cmp";
after = ''
${optionalString luasnipEnable "local luasnip = require('luasnip')"}
local cmp = require("cmp")
local kinds = require("cmp.types").lsp.CompletionItemKind local kinds = require("cmp.types").lsp.CompletionItemKind
local deprio = function(kind) local deprio = function(kind)
return function(e1, e2) return function(e1, e2)
if e1:get_kind() == kind then if e1:get_kind() == kind then
return false return false
end
if e2:get_kind() == kind then
return true
end
return nil
end end
if e2:get_kind() == kind then
return true
end
return nil
end end
end
cmp.setup(${toLuaObject cfg.setupOpts}) cmp.setup(${toLuaObject cfg.setupOpts})
${optionalString config.vim.lazy.enable ${optionalString config.vim.lazy.enable
(concatStringsSep "\n" (map (concatStringsSep "\n" (map
(package: "require('lz.n').trigger_load(${toLuaObject (getPluginName package)})") (package: "require('lz.n').trigger_load(${toLuaObject (getPluginName package)})")
cfg.sourcePlugins))} cfg.sourcePlugins))}
''; '';
event = ["InsertEnter" "CmdlineEnter"]; event = ["InsertEnter" "CmdlineEnter"];
};
}
];
autocomplete.nvim-cmp = {
sources = {
nvim-cmp = null;
buffer = "[Buffer]";
path = "[Path]";
}; };
};
autocomplete = { sourcePlugins = ["cmp-buffer" "cmp-path"];
enableSharedCmpSources = true;
nvim-cmp = { setupOpts = {
sources = { sources = map (s: {name = s;}) (attrNames cfg.sources);
nvim-cmp = null;
buffer = "[Buffer]"; window = mkIf borders.enable {
path = "[Path]"; completion.border = borders.style;
documentation.border = borders.style;
}; };
sourcePlugins = ["cmp-buffer" "cmp-path"]; formatting.format = cfg.format;
setupOpts = { # `cmp` and `luasnip` are defined above, in the `nvim-cmp` section
sources = map (s: {name = s;}) (attrNames cfg.sources); mapping = {
${mappings.complete} = mkLuaInline "cmp.mapping.complete()";
${mappings.close} = mkLuaInline "cmp.mapping.abort()";
${mappings.scrollDocsUp} = mkLuaInline "cmp.mapping.scroll_docs(-4)";
${mappings.scrollDocsDown} = mkLuaInline "cmp.mapping.scroll_docs(4)";
${mappings.confirm} = mkLuaInline "cmp.mapping.confirm({ select = true })";
window = mkIf borders.enable { ${mappings.next} = mkLuaInline ''
completion.border = borders.style; cmp.mapping(function(fallback)
documentation.border = borders.style; local has_words_before = function()
}; local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end
formatting.format = cfg.format; if cmp.visible() then
cmp.select_next_item()
${optionalString luasnipEnable ''
elseif luasnip.locally_jumpable(1) then
luasnip.jump(1)
''}
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end)
'';
# `cmp` and `luasnip` are defined above, in the `nvim-cmp` section ${mappings.previous} = mkLuaInline ''
mapping = { cmp.mapping(function(fallback)
${mappings.complete} = mkLuaInline "cmp.mapping.complete()"; if cmp.visible() then
${mappings.close} = mkLuaInline "cmp.mapping.abort()"; cmp.select_prev_item()
${mappings.scrollDocsUp} = mkLuaInline "cmp.mapping.scroll_docs(-4)"; ${optionalString luasnipEnable ''
${mappings.scrollDocsDown} = mkLuaInline "cmp.mapping.scroll_docs(4)"; elseif luasnip.locally_jumpable(-1) then
${mappings.confirm} = mkLuaInline "cmp.mapping.confirm({ select = true })"; luasnip.jump(-1)
''}
${mappings.next} = mkLuaInline '' else
cmp.mapping(function(fallback) fallback()
local has_words_before = function() end
local line, col = unpack(vim.api.nvim_win_get_cursor(0)) end)
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil '';
end
if cmp.visible() then
cmp.select_next_item()
${optionalString luasnipEnable ''
elseif luasnip.locally_jumpable(1) then
luasnip.jump(1)
''}
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end)
'';
${mappings.previous} = mkLuaInline ''
cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
${optionalString luasnipEnable ''
elseif luasnip.locally_jumpable(-1) then
luasnip.jump(-1)
''}
else
fallback()
end
end)
'';
};
}; };
}; };
}; };

View file

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

View file

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

View file

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

View file

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

View file

@ -1,7 +1,7 @@
{ {
options,
config, config,
lib, lib,
pkgs,
... ...
}: let }: let
inherit (lib.strings) optionalString; inherit (lib.strings) optionalString;
@ -11,7 +11,8 @@
inherit (lib.nvim.binds) pushDownDefault; inherit (lib.nvim.binds) pushDownDefault;
cfg = config.vim.filetree.nvimTree; cfg = config.vim.filetree.nvimTree;
inherit (options.vim.filetree.nvimTree) mappings; self = import ./nvimtree.nix {inherit pkgs lib;};
inherit (self.options.vim.filetree.nvimTree) mappings;
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim = { vim = {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -7,7 +7,6 @@
inherit (lib.modules) mkIf mkMerge; inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetExprBinding mkSetLuaBinding pushDownDefault; inherit (lib.nvim.binds) addDescriptionsToMappings mkSetExprBinding mkSetLuaBinding pushDownDefault;
inherit (lib.nvim.dag) entryAnywhere; inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.git.gitsigns; cfg = config.vim.git.gitsigns;
@ -71,7 +70,7 @@ in {
}; };
pluginRC.gitsigns = entryAnywhere '' pluginRC.gitsigns = entryAnywhere ''
require('gitsigns').setup(${toLuaObject cfg.setupOpts}) require('gitsigns').setup{}
''; '';
}; };
} }

View file

@ -6,7 +6,6 @@
inherit (lib.options) mkEnableOption; inherit (lib.options) mkEnableOption;
inherit (lib.modules) mkRenamedOptionModule; inherit (lib.modules) mkRenamedOptionModule;
inherit (lib.nvim.binds) mkMappingOption; inherit (lib.nvim.binds) mkMappingOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in { in {
imports = [ imports = [
(mkRenamedOptionModule ["vim" "git" "gitsigns" "codeActions" "vim" "gitsigns" "codeActions"] ["vim" "git" "gitsigns" "codeActions" "enable"]) (mkRenamedOptionModule ["vim" "git" "gitsigns" "codeActions" "vim" "gitsigns" "codeActions"] ["vim" "git" "gitsigns" "codeActions" "enable"])
@ -14,7 +13,6 @@ in {
options.vim.git.gitsigns = { options.vim.git.gitsigns = {
enable = mkEnableOption "gitsigns" // {default = config.vim.git.enable;}; enable = mkEnableOption "gitsigns" // {default = config.vim.git.enable;};
setupOpts = mkPluginSetupOption "gitsigns" {};
codeActions.enable = mkEnableOption "gitsigns codeactions through null-ls"; codeActions.enable = mkEnableOption "gitsigns codeactions through null-ls";

View file

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

View file

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

View file

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

View file

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

View file

@ -130,6 +130,7 @@ in {
(mkIf cfg.lsp.enable { (mkIf cfg.lsp.enable {
vim.lsp.lspconfig.enable = true; vim.lsp.lspconfig.enable = true;
vim.lsp.lspconfig.sources.dart-lsp = servers.${cfg.lsp.server}.lspConfig; vim.lsp.lspconfig.sources.dart-lsp = servers.${cfg.lsp.server}.lspConfig;
}) })
@ -137,7 +138,7 @@ in {
vim.startPlugins = vim.startPlugins =
if ftcfg.enableNoResolvePatch if ftcfg.enableNoResolvePatch
then ["flutter-tools-patched"] then ["flutter-tools-patched"]
else ["flutter-tools-nvim"]; else ["flutter-tools"];
vim.pluginRC.flutter-tools = entryAnywhere '' vim.pluginRC.flutter-tools = entryAnywhere ''
require('flutter-tools').setup { require('flutter-tools').setup {

View file

@ -38,8 +38,6 @@ in {
./julia.nix ./julia.nix
./nu.nix ./nu.nix
./odin.nix ./odin.nix
./wgsl.nix
./ruby.nix
]; ];
options.vim.languages = { options.vim.languages = {

View file

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

View file

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

View file

@ -71,7 +71,7 @@ in {
cmd = ${ cmd = ${
if isList cfg.lsp.package if isList cfg.lsp.package
then expToLua cfg.lsp.package then expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/haskell-language-server-wrapper", "--lsp"}'' else ''{"${cfg.lsp.package}/bin/haskell-language-server-wrapper"}''
}, },
on_attach = function(client, bufnr, ht) on_attach = function(client, bufnr, ht)
default_on_attach(client, bufnr, ht) default_on_attach(client, bufnr, ht)

View file

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

View file

@ -4,14 +4,13 @@
lib, lib,
... ...
}: let }: let
inherit (builtins) attrNames; inherit (builtins) attrNames concatLists;
inherit (lib.modules) mkIf mkMerge; inherit (lib.modules) mkIf mkMerge;
inherit (lib.options) mkEnableOption mkOption; inherit (lib.options) mkEnableOption mkOption;
inherit (lib.lists) isList concatLists; inherit (lib.lists) isList;
inherit (lib.types) bool enum either package listOf str; inherit (lib.types) bool enum either package listOf str;
inherit (lib.nvim.lua) expToLua toLuaObject; inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.types) mkGrammarOption mkPluginSetupOption; inherit (lib.nvim.types) mkGrammarOption;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.languages.markdown; cfg = config.vim.languages.markdown;
defaultServer = "marksman"; defaultServer = "marksman";
@ -46,18 +45,6 @@
) )
''; '';
}; };
prettierd = {
package = pkgs.prettierd;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.prettierd.with({
filetypes = ${expToLua (concatLists [cfg.format.extraFiletypes ["markdown"]])},
command = "${cfg.format.package}/bin/prettierd",
})
)
'';
};
}; };
in { in {
options.vim.languages.markdown = { options.vim.languages.markdown = {
@ -111,29 +98,6 @@ in {
description = "Extra filetypes to format with the Markdown formatter"; description = "Extra filetypes to format with the Markdown formatter";
}; };
}; };
extensions = {
render-markdown-nvim = {
enable =
mkEnableOption ""
// {
description = ''
[render-markdown.nvim]: https://github.com/MeanderingProgrammer/render-markdown.nvim
Inline Markdown rendering with [render-markdown.nvim]
'';
};
setupOpts = mkPluginSetupOption "render-markdown" {
auto_override_publish_diagnostics = mkOption {
description = "Automatically override the publish_diagnostics handler";
type = bool;
default = true;
};
};
};
};
}; };
config = mkIf cfg.enable (mkMerge [ config = mkIf cfg.enable (mkMerge [
@ -151,13 +115,5 @@ in {
vim.lsp.null-ls.enable = true; vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources.markdown-format = formats.${cfg.format.type}.nullConfig; vim.lsp.null-ls.sources.markdown-format = formats.${cfg.format.type}.nullConfig;
}) })
# Extensions
(mkIf cfg.extensions.render-markdown-nvim.enable {
vim.startPlugins = ["render-markdown-nvim"];
vim.pluginRC.render-markdown-nvim = entryAnywhere ''
require("render-markdown").setup(${toLuaObject cfg.extensions.render-markdown-nvim.setupOpts})
'';
})
]); ]);
} }

View file

@ -10,9 +10,9 @@
inherit (lib.modules) mkIf mkMerge; inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) isList; inherit (lib.lists) isList;
inherit (lib.strings) optionalString; inherit (lib.strings) optionalString;
inherit (lib.types) anything attrsOf enum either listOf nullOr package str; inherit (lib.types) enum either listOf package str;
inherit (lib.nvim.types) mkGrammarOption diagnostics; inherit (lib.nvim.types) mkGrammarOption diagnostics;
inherit (lib.nvim.lua) expToLua toLuaObject; inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.languages) diagnosticsToLua; inherit (lib.nvim.languages) diagnosticsToLua;
cfg = config.vim.languages.nix; cfg = config.vim.languages.nix;
@ -26,6 +26,22 @@
then expToLua package then expToLua package
else ''{"${package}/bin/${defaultCmd}"}''; else ''{"${package}/bin/${defaultCmd}"}'';
servers = { servers = {
rnix = {
package = pkgs.rnix-lsp;
internalFormatter = cfg.format.type == "nixpkgs-fmt";
lspConfig = ''
lspconfig.rnix.setup{
capabilities = capabilities,
${
if (cfg.format.enable && cfg.format.type == "nixpkgs-fmt")
then useFormat
else noFormat
},
cmd = ${packageToCmd cfg.lsp.package "rnix-lsp"},
}
'';
};
nil = { nil = {
package = pkgs.nil; package = pkgs.nil;
internalFormatter = true; internalFormatter = true;
@ -59,41 +75,6 @@
} }
''; '';
}; };
nixd = {
package = pkgs.nixd;
internalFormatter = true;
lspConfig = ''
lspconfig.nixd.setup{
capabilities = capabilities,
${
if cfg.format.enable
then useFormat
else noFormat
},
cmd = ${packageToCmd cfg.lsp.package "nixd"},
${optionalString cfg.format.enable ''
settings = {
nixd = {
${optionalString (cfg.format.type == "alejandra")
''
formatting = {
command = {"${cfg.format.package}/bin/alejandra", "--quiet"},
},
''}
${optionalString (cfg.format.type == "nixfmt")
''
formatting = {
command = {"${cfg.format.package}/bin/nixfmt"},
},
''}
options = ${toLuaObject cfg.lsp.options},
},
},
''}
}
'';
};
}; };
defaultFormat = "alejandra"; defaultFormat = "alejandra";
@ -174,12 +155,6 @@ in {
type = either package (listOf str); type = either package (listOf str);
default = servers.${cfg.lsp.server}.package; default = servers.${cfg.lsp.server}.package;
}; };
options = mkOption {
type = nullOr (attrsOf anything);
default = null;
description = "Options to pass to nixd LSP server";
};
}; };
format = { format = {
@ -190,7 +165,6 @@ in {
type = enum (attrNames formats); type = enum (attrNames formats);
default = defaultFormat; default = defaultFormat;
}; };
package = mkOption { package = mkOption {
description = "Nix formatter package"; description = "Nix formatter package";
type = package; type = package;
@ -214,20 +188,20 @@ in {
assertions = [ assertions = [
{ {
assertion = cfg.format.type != "nixpkgs-fmt"; assertion = cfg.format.type != "nixpkgs-fmt";
message = '' message = "nixpkgs-fmt has been archived upstream. Please use one of the following instead: ${concatStringsSep ", " (attrNames formats)}";
nixpkgs-fmt has been archived upstream. Please use one of the following available formatters:
${concatStringsSep ", " (attrNames formats)}
'';
}
{
assertion = cfg.lsp.server != "rnix";
message = ''
rnix-lsp has been archived upstream. Please use one of the following available language servers:
${concatStringsSep ", " (attrNames servers)}
'';
} }
]; ];
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
})
'';
} }
(mkIf cfg.treesitter.enable { (mkIf cfg.treesitter.enable {

View file

@ -106,24 +106,6 @@
) )
''; '';
}; };
ruff = {
package = pkgs.writeShellApplication {
name = "ruff";
runtimeInputs = [pkgs.ruff];
text = ''
ruff format -
'';
};
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.ruff.with({
command = "${cfg.format.package}/bin/ruff",
})
)
'';
};
}; };
defaultDebugger = "debugpy"; defaultDebugger = "debugpy";

View file

@ -1,152 +0,0 @@
{
config,
pkgs,
lib,
...
}: let
inherit (builtins) attrNames;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.types) mkGrammarOption diagnostics;
inherit (lib.types) either listOf package str enum;
inherit (lib.nvim.languages) diagnosticsToLua;
cfg = config.vim.languages.ruby;
defaultServer = "rubyserver";
servers = {
rubyserver = {
package = pkgs.rubyPackages.solargraph;
lspConfig = ''
lspconfig.solargraph.setup {
capabilities = capabilities,
on_attach = attach_keymaps,
flags = {
debounce_text_changes = 150,
},
cmd = { "${pkgs.solargraph}/bin/solargraph", "stdio" }
}
'';
};
};
# testing
defaultFormat = "rubocop";
formats = {
rubocop = {
package = pkgs.rubyPackages.rubocop;
nullConfig = ''
local conditional = function(fn)
local utils = require("null-ls.utils").make_conditional_utils()
return fn(utils)
end
table.insert(
ls_sources,
null_ls.builtins.formatting.rubocop.with({
command="${pkgs.bundler}/bin/bundle",
args = vim.list_extend(
{"exec", "rubocop", "-a" },
null_ls.builtins.formatting.rubocop._opts.args
),
})
)
'';
};
};
defaultDiagnosticsProvider = ["rubocop"];
diagnosticsProviders = {
rubocop = {
package = pkgs.rubyPackages.rubocop;
nullConfig = pkg: ''
table.insert(
ls_sources,
null_ls.builtins.diagnostics.rubocop.with({
command = "${lib.getExe pkg}",
})
)
'';
};
};
in {
options.vim.languages.ruby = {
enable = mkEnableOption "Ruby language support";
treesitter = {
enable = mkEnableOption "Ruby treesitter" // {default = config.vim.languages.enableTreesitter;};
package = mkGrammarOption pkgs "ruby";
};
lsp = {
enable = mkEnableOption "Ruby LSP support" // {default = config.vim.languages.enableLSP;};
server = mkOption {
type = enum (attrNames servers);
default = defaultServer;
description = "Ruby LSP server to use";
};
package = mkOption {
type = either package (listOf str);
default = servers.${cfg.lsp.server}.package;
description = "Ruby LSP server package, or the command to run as a list of strings";
};
};
format = {
enable = mkEnableOption "Ruby formatter support" // {default = config.vim.languages.enableFormat;};
type = mkOption {
type = enum (attrNames formats);
default = defaultFormat;
description = "Ruby formatter to use";
};
package = mkOption {
type = package;
default = formats.${cfg.format.type}.package;
description = "Ruby formatter package";
};
};
extraDiagnostics = {
enable =
mkEnableOption "Ruby extra diagnostics support"
// {default = config.vim.languages.enableExtraDiagnostics;};
types = diagnostics {
langDesc = "Ruby";
inherit diagnosticsProviders;
inherit defaultDiagnosticsProvider;
};
};
};
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.ruby-lsp = servers.${cfg.lsp.server}.lspConfig;
})
(mkIf cfg.format.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources.ruby-format = formats.${cfg.format.type}.nullConfig;
})
(mkIf cfg.extraDiagnostics.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources = diagnosticsToLua {
lang = "ruby";
config = cfg.extraDiagnostics.types;
inherit diagnosticsProviders;
};
})
]);
}

View file

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

View file

@ -1,79 +0,0 @@
{
config,
lib,
pkgs,
...
}: let
inherit (builtins) attrNames;
inherit (lib.lists) isList;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.types) mkGrammarOption;
inherit (lib.options) literalExpression mkEnableOption mkOption;
inherit (lib.types) either enum listOf package str;
cfg = config.vim.languages.wgsl;
defaultServer = "wgsl-analyzer";
servers = {
wgsl-analyzer = {
package = pkgs.wgsl-analyzer;
internalFormatter = true;
lspConfig = ''
lspconfig.wgsl_analyzer.setup {
capabilities = capabilities,
on_attach = default_on_attach,
cmd = ${
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else "{'${cfg.lsp.package}/bin/wgsl_analyzer'}"
}
}
'';
};
};
in {
options.vim.languages.wgsl = {
enable = mkEnableOption "WGSL language support";
treesitter = {
enable = mkEnableOption "WGSL treesitter" // {default = config.vim.languages.enableTreesitter;};
package = mkGrammarOption pkgs "wgsl";
};
lsp = {
enable = mkEnableOption "WGSL LSP support" // {default = config.vim.languages.enableLSP;};
server = mkOption {
type = enum (attrNames servers);
default = defaultServer;
description = "WGSL LSP server to use";
};
package = mkOption {
description = "wgsl-analyzer package, or the command to run as a list of strings";
example = literalExpression "[(lib.getExe pkgs.wgsl-analyzer)]";
type = either package (listOf str);
default = pkgs.wgsl-analyzer;
};
};
};
config = mkIf cfg.enable (mkMerge [
(mkIf cfg.treesitter.enable {
vim.treesitter = {
enable = true;
grammars = [cfg.treesitter.package];
};
})
(mkIf cfg.lsp.enable {
vim = {
lsp.lspconfig = {
enable = true;
sources.wgsl_analyzer = servers.${cfg.lsp.server}.lspConfig;
};
};
})
]);
}

View file

@ -8,12 +8,10 @@
inherit (lib.options) mkEnableOption mkOption; inherit (lib.options) mkEnableOption mkOption;
inherit (lib.modules) mkIf mkMerge mkDefault; inherit (lib.modules) mkIf mkMerge mkDefault;
inherit (lib.lists) isList; inherit (lib.lists) isList;
inherit (lib.types) bool either listOf package str enum; inherit (lib.types) either listOf package str enum;
inherit (lib.nvim.lua) expToLua; inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.types) mkGrammarOption; inherit (lib.nvim.types) mkGrammarOption;
cfg = config.vim.languages.zig;
defaultServer = "zls"; defaultServer = "zls";
servers = { servers = {
zls = { zls = {
@ -33,35 +31,7 @@
}; };
}; };
# TODO: dap.adapter.lldb is duplicated when enabling the cfg = config.vim.languages.zig;
# vim.languages.clang.dap module. This does not cause
# breakage... but could be cleaner.
defaultDebugger = "lldb-vscode";
debuggers = {
lldb-vscode = {
package = pkgs.lldb;
dapConfig = ''
dap.adapters.lldb = {
type = 'executable',
command = '${cfg.dap.package}/bin/lldb-dap',
name = 'lldb'
}
dap.configurations.zig = {
{
name = 'Launch',
type = 'lldb',
request = 'launch',
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
cwd = "''${workspaceFolder}",
stopOnEntry = false,
args = {},
},
}
'';
};
};
in { in {
options.vim.languages.zig = { options.vim.languages.zig = {
enable = mkEnableOption "Zig language support"; enable = mkEnableOption "Zig language support";
@ -86,26 +56,6 @@ in {
default = pkgs.zls; default = pkgs.zls;
}; };
}; };
dap = {
enable = mkOption {
type = bool;
default = config.vim.languages.enableDAP;
description = "Enable Zig Debug Adapter";
};
debugger = mkOption {
type = enum (attrNames debuggers);
default = defaultDebugger;
description = "Zig debugger to use";
};
package = mkOption {
type = package;
default = debuggers.${cfg.dap.debugger}.package;
description = "Zig debugger package.";
};
};
}; };
config = mkIf cfg.enable (mkMerge [ config = mkIf cfg.enable (mkMerge [
@ -127,12 +77,5 @@ in {
globals.zig_fmt_autosave = mkDefault 0; globals.zig_fmt_autosave = mkDefault 0;
}; };
}) })
(mkIf cfg.dap.enable {
vim = {
debugger.nvim-dap.enable = true;
debugger.nvim-dap.sources.zig-debugger = debuggers.${cfg.dap.debugger}.dapConfig;
};
})
]); ]);
} }

View file

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

View file

@ -4,7 +4,6 @@
... ...
}: let }: let
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf;
inherit (lib.strings) optionalString;
inherit (lib.nvim.dag) entryAnywhere; inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject; inherit (lib.nvim.lua) toLuaObject;
@ -13,29 +12,13 @@ in {
config = mkIf (cfg.enable && cfg.lightbulb.enable) { config = mkIf (cfg.enable && cfg.lightbulb.enable) {
vim = { vim = {
startPlugins = ["nvim-lightbulb"]; startPlugins = ["nvim-lightbulb"];
pluginRC.lightbulb = entryAnywhere '' pluginRC.lightbulb = entryAnywhere ''
local nvim_lightbulb = require("nvim-lightbulb") vim.api.nvim_command('autocmd CursorHold,CursorHoldI * lua require\'nvim-lightbulb\'.update_lightbulb()')
nvim_lightbulb.setup(${toLuaObject cfg.lightbulb.setupOpts})
${optionalString cfg.lightbulb.autocmd.enable '' -- Enable trouble diagnostics viewer
vim.api.nvim_create_autocmd(${toLuaObject cfg.lightbulb.autocmd.events}, { require'nvim-lightbulb'.setup(${toLuaObject cfg.lightbulb.setupOpts})
pattern = ${toLuaObject cfg.lightbulb.autocmd.pattern},
callback = function()
nvim_lightbulb.update_lightbulb()
end,
})
''}
''; '';
}; };
warnings = [
# This could have been an assertion, but the chances of collision is very low and asserting here
# might be too dramatic. Let's only warn the user, *in case* this occurs and is not intended. No
# error will be thrown if 'lightbulb.setupOpts.autocmd.enable' has not been set by the user.
(mkIf (cfg.lightbulb.autocmd.enable -> (cfg.lightbulb.setupOpts.autocmd.enabled or false)) ''
Both 'vim.lsp.lightbulb.autocmd.enable' and 'vim.lsp.lightbulb.setupOpts.autocmd.enable' are set
simultaneously. This might have performance implications due to frequent updates. Please set only
one option to handle nvim-lightbulb autocmd.
'')
];
}; };
} }

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