This commit is contained in:
raf 2024-12-03 23:43:19 +00:00 committed by GitHub
commit 9d6ec7987a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
192 changed files with 6189 additions and 3818 deletions

View file

@ -8,23 +8,42 @@
## Welcome ## Welcome
I'm glad you are thinking about contributing to neovim-flake! If you're unsure about anything, just ask - or submit the issue or pull request anyway. The worst that can happen is you'll be politely asked to change something. Friendly contributions are always welcome. I'm glad you are thinking about contributing to nvf! If you're unsure about
anything, just ask - or submit the issue or pull request anyway. The worst that
can happen is you'll be politely asked to change something. Friendly
contributions are always welcome.
Before you contribute, I encourage you to read this project's CONTRIBUTING policy (you are here), its [LICENSE](LICENSE.md), and its [README](README.md). Before you contribute, I encourage you to read this project's CONTRIBUTING
policy (you are here) and its [LICENSE](../LICENSE) to understand how your
contributions are licensed.
If you have any questions regarding those files, feel free to open an issue or [shoot me an email](mailto:me@notashelf.dev). Discussions tab is also available for more informal discussions. If you have any questions regarding those files, feel free to open an issue or
[shoot me an email](mailto:me@notashelf.dev). Discussions tab is also available
for more informal discussions.
## Contributing ## Contributing
The contribution process is mostly documented in the [pull request template](pull_request_template.md). You will find a checklist of items to complete before submitting a pull request. Please make sure you complete it before submitting a pull request. If you are unsure about any of the items, please ask. The contribution process is mostly documented in the
[pull request template](PULL_REQUEST_TEMPLATE/pull_request_template.md). You
will find a checklist of items to complete before submitting a pull request.
Please make sure you complete it before submitting a pull request. If you are
unsure about any of the items, please ask.
### Guidelines ### Guidelines
We provide instructions on a healthy contribution to neovim-flake - including styling, commit formats, how-to guides for adding new modules and options. We provide instructions on a healthy contribution to neovim-flake - including
You are very well recommended to read the contributing guideliner over at [the documentation](https://notashelf.github.io/neovim-flake#hacking) styling, commit formats, how-to guides for adding new modules and options. You
are very well recommended to read the contributing guidelines over at
[the documentation](https://notashelf.github.io/nvf#hacking)
### Code of Conduct ### Code of Conduct
This project does not quite have a code of conduct yet. And to be honest, I'm not sure if I want one or if it will ever have one. I'm not expecting this project to be a hotbed of activity, but I do want to make sure that everyone who does contribute feels welcome and safe. As such, I will do my best to make sure that those who distrupt the project are dealt with swiftly and appropriately. This project does not quite have a code of conduct yet. And to be perfectly
honest, I'm not sure if I want one or if it will ever have one. I'm not
expecting this project to be a hotbed of activity, but I do want to make sure
that everyone who does contribute feels welcome and safe. As such, I will do my
best to make sure that those who distrupt the project are dealt with swiftly and
appropriately.
If you feel that you are not being treated with respect, please contact me directly. If you feel that you are not being treated with respect, please contact me
directly.

View file

@ -6,7 +6,7 @@ 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. this comment, and it will be closed when your pull request is merged.
--> -->
## Sanity Checking ## Sanity Checking
@ -23,20 +23,20 @@ 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
- [ ] 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
- 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
- [ ] My changes are consistent with the rest of the codebase. - [ ] My changes are consistent with the rest of the codebase
- If new changes are particularly complex: - If new changes are particularly complex:
- [ ] My code includes comments in particularly complex areas - [ ] My code includes comments in particularly complex areas
- [ ] 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` - [ ] `.#docs-html` (manual, must build)
- Tested on platform(s) - Tested on platform(s)
- [ ] `x86_64-linux` - [ ] `x86_64-linux`
- [ ] `aarch64-linux` - [ ] `aarch64-linux`

72
.github/README.md vendored
View file

@ -48,7 +48,7 @@
[Documentation]: #documentation [Documentation]: #documentation
[Help]: #help [Help]: #help
[Contribute]: #contributing [Contribute]: #contributing
[FAQ]: #faq [FAQ]: #frequently-asked-questions
[Credits]: #credits [Credits]: #credits
**[<kbd><br>Features <br></kbd>][Features]** **[<kbd><br>Features <br></kbd>][Features]**
@ -56,7 +56,7 @@
**[<kbd><br>Documentation<br></kbd>][Documentation]** **[<kbd><br>Documentation<br></kbd>][Documentation]**
**[<kbd><br>Help<br></kbd>][Help]** **[<kbd><br>Help<br></kbd>][Help]**
**[<kbd><br>Contribute<br></kbd>][Contribute]** **[<kbd><br>Contribute<br></kbd>][Contribute]**
**[<kbd><br>FAQ<br></kbd>][Faq]** **[<kbd><br>Credits<br></kbd>][Credits]** **[<kbd><br>FAQ<br></kbd>][FAQ]** **[<kbd><br>Credits<br></kbd>][Credits]**
</p></div> </p></div>
@ -64,12 +64,21 @@
## Features ## Features
[standalone]: https://notashelf.github.io/nvf/index.xhtml#ch-standalone-installation
[NixOS module]: https://notashelf.github.io/nvf/index.xhtml#ch-standalone-nixos
[Home-Manager module]: https://notashelf.github.io/nvf/index.xhtml#ch-standalone-hm
- **Simple**: One language to rule them all! Use Nix to configure everything,
with additional Lua Support
- **Reproducible**: Your configuration will behave the same _anywhere_. No - **Reproducible**: Your configuration will behave the same _anywhere_. No
surprises, promise! surprises, promise!
- **Portable**: nvf depends _solely_ on your Nix store, and nothing else. No - **Portable**: nvf depends _solely_ on your Nix store, and nothing else. No
more global binaries! Works on all platforms, without hassle. more global binaries! Works on all platforms, without hassle.
- Options to install [standalone], [NixOS module] or [Home-Manager module].
- **Customizable**: There are _almost no defaults_ to annoy you. nvf is fully - **Customizable**: There are _almost no defaults_ to annoy you. nvf is fully
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
can do just that, no unnecessary restrictions.
- **Well-documented**: Documentation is priority. You will _never_ face - **Well-documented**: Documentation is priority. You will _never_ face
undocumented, obscure behaviour. undocumented, obscure behaviour.
- **Idiomatic**: nvf does things ✨ _the right way_ ✨ - the codebase is, and - **Idiomatic**: nvf does things ✨ _the right way_ ✨ - the codebase is, and
@ -120,7 +129,9 @@ instructions.
## Documentation ## Documentation
The _recommended_ way of installing **nvf** is using either the NixOS or the ### Installation
The _recommended_ way of installing nvf is using either the NixOS or the
Home-Manager module, though it is completely possible and no less supported to Home-Manager module, though it is completely possible and no less supported to
install **nvf** as a standalone package, or a flake output. install **nvf** as a standalone package, or a flake output.
@ -138,11 +149,13 @@ Please create an issue on the [issue tracker] if you find the documentation
lacking or confusing. Any improvements to the documentation through pull lacking or confusing. Any improvements to the documentation through pull
requests are also welcome, and appreciated. requests are also welcome, and appreciated.
## Help ## Getting Help
You can create an issue on the [issue tracker] to ask questions or report bugs. If you are confused, stuck or would like to ask a simple question; you may
I am not yet on spaces like matrix or IRC, so please use the issue tracker for create an issue on the [issue tracker] to ask questions or report bugs.
now.
We are not not yet on spaces like matrix or IRC, so please use the issue tracker
for now.
## Contributing ## Contributing
@ -152,7 +165,7 @@ submitting a pull request. You can also create an issue on the [issue tracker]
before submitting a pull request if you would like to discuss a feature or bug before submitting a pull request if you would like to discuss a feature or bug
fix. fix.
## FAQ ## Frequently Asked Questions
[appropriate issue template]: https://github.com/NotAShelf/nvf/issues/new/choose [appropriate issue template]: https://github.com/NotAShelf/nvf/issues/new/choose
[list of branches]: https://github.com/NotAShelf/nvf/branches [list of branches]: https://github.com/NotAShelf/nvf/branches
@ -160,13 +173,15 @@ fix.
**Q**: What platforms are supported? **Q**: What platforms are supported?
<br/> **A**: nvf actively supports Linux and Darwin platforms using standalone <br/> **A**: nvf actively supports Linux and Darwin platforms using standalone
Nix, NixOS or Home-Manager. Please take a look at the Nix, NixOS or Home-Manager. Please take a look at the [nvf manual] for available
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 <br/> **A**: Maybe! It is not one of our goals to support each and every Neovim
plugin, however, I am always open to new modules and plugin setup additions to 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, PRs adding new features are also welcome. addition. As mentioned before, pull requests to add new features are also
welcome.
**Q**: A plugin I need is not available in **nvf**. What to do? **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 <br/> **A**: **nvf** exposes several APIs for you to be able to add your own
@ -185,22 +200,26 @@ better prepare to breaking changes.
### Contributors ### Contributors
Special, heart-felt thanks to [mnw]: https://github.com/gerg-l/mnw
- [@fufexan](https://github.com/fufexan) - For the transition to flake-parts nvf would not be what it is today without the awesome people below. Special,
- [@FlafyDev](https://github.com/FlafyDev) - For getting the home-manager to heart-felt thanks to
work
- [@fufexan](https://github.com/fufexan) - For the transition to flake-parts and
invaluable Nix assistance.
- [@FlafyDev](https://github.com/FlafyDev) - For getting home-manager module to
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 possible, and other module additions.
- [@horriblename](https://github.com/horriblename) - For actively implementing - [@horriblename](https://github.com/horriblename) - For actively implementing
planned features and quality of life updates planned features and quality of life updates.
- [@Yavko](https://github.com/Yavko) - For the amazing **nvf** logo - [@Yavko](https://github.com/Yavko) - For the amazing **nvf** logo
- [@FrothyMarrow](https://github.com/FrothyMarrow) - For seeing mistakes that I - [@FrothyMarrow](https://github.com/FrothyMarrow) - For seeing mistakes that I
could not could not.
- [@Diniamo](https://github.com/Diniamo) - For actively submitting PRs, pull - [@Diniamo](https://github.com/Diniamo) - For actively submitting pull
requests and overall assistence requests, issues and assistance with maintenance of nvf.
- [@Gerg-l](https://github.com/gerg-l) - For the modern Neovim wrapper, mnw and - [@Gerg-l](https://github.com/gerg-l) - For the modern Neovim wrapper, [mnw],
occasional code improvements and occasional code improvements.
and everyone who has submitted issues or pull requests! and everyone who has submitted issues or pull requests!
@ -214,7 +233,7 @@ including:
is originally based on. is originally based on.
- [@sioodmy's](https://github.com/sioodmy) - [@sioodmy's](https://github.com/sioodmy)
[dotfiles](https://github.com/sioodmy/dotfiles) that inspired the design [dotfiles](https://github.com/sioodmy/dotfiles) that inspired the design
choices. 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.
@ -229,10 +248,11 @@ recommend checking their work out.
## License ## License
Following the license of the Following the license of 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 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>

2
.github/typos.toml vendored Normal file
View file

@ -0,0 +1,2 @@
default.extend-ignore-words-re = ["(?i)(noice)", "befores", "annote", "viw"]

View file

@ -19,19 +19,12 @@ jobs:
- docs-manpages - docs-manpages
- docs-json - docs-json
steps: steps:
- uses: easimon/maximize-build-space@v10
with:
overprovision-lvm: true
remove-android: true
remove-dotnet: true
remove-haskell: true
- 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: DeterminateSystems/magic-nix-cache-action@main
- uses: actions/checkout@v4 - name: Checkout
name: Checkout uses: actions/checkout@v4
- name: Set default git branch (to reduce log spam) - name: Set default git branch (to reduce log spam)
run: git config --global init.defaultBranch main run: git config --global init.defaultBranch main
@ -49,3 +42,16 @@ jobs:
with: with:
name: "${{ matrix.package }}" name: "${{ matrix.package }}"
path: result/share/doc/nvf path: result/share/doc/nvf
flake-docs-linkcheck:
name: Validate hyperlinks in documentation sources
runs-on: ubuntu-latest
steps:
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- name: Checkout
uses: actions/checkout@v4
- name: Build documentation packages
run: nix build .#docs-linkcheck -Lv

View file

@ -15,7 +15,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: | run: |
gh api \ gh api \
repos/notashelf/neovim-flake/pulls/${{github.event.number}}/files --paginate \ repos/notashelf/nvf/pulls/${{github.event.number}}/files --paginate \
| jq '.[] | select(.status != "removed") | .filename' \ | jq '.[] | select(.status != "removed") | .filename' \
> "$HOME/changed_files" > "$HOME/changed_files"

View file

@ -47,7 +47,7 @@ jobs:
- uses: DeterminateSystems/nix-installer-action@main - uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main - uses: DeterminateSystems/magic-nix-cache-action@main
- run: | - run: |
nix build .#docs nix build .#docs -Lv
cp -r result/share/doc/nvf public cp -r result/share/doc/nvf public
- uses: peaceiris/actions-gh-pages@v4 - uses: peaceiris/actions-gh-pages@v4
with: with:

30
.github/workflows/typos.yml vendored Normal file
View file

@ -0,0 +1,30 @@
name: "Check for typos in the source tree"
permissions: read-all
on:
pull_request:
workflow_dispatch:
push:
jobs:
check-typos:
runs-on: ubuntu-latest
if: "!contains(github.event.pull_request.title, '[skip ci]')"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Check for typos
uses: crate-ci/typos@master
with:
config: .github/typos.toml
- name: Fail Gracefully
if: ${{ failure() }}
shell: bash
run: |
echo "::error:: Current codebase contains typos that were caught by the CI!"
echo "If those typos were intentional, please add them to the ignored regexes in .github/typos.toml"
echo "[skip ci] label may be used if this is a one-time issue"
exit 1

View file

@ -46,11 +46,15 @@ isMaximal: {
nix.enable = true; nix.enable = true;
# Assembly is not common, and the asm LSP is a major hit-or-miss
assembly.enable = false;
astro.enable = false;
markdown.enable = isMaximal; markdown.enable = isMaximal;
html.enable = isMaximal; html.enable = isMaximal;
css.enable = isMaximal; css.enable = isMaximal;
sql.enable = isMaximal; sql.enable = isMaximal;
java.enable = isMaximal; java.enable = isMaximal;
kotlin.enable = isMaximal;
ts.enable = isMaximal; ts.enable = isMaximal;
svelte.enable = isMaximal; svelte.enable = isMaximal;
go.enable = isMaximal; go.enable = isMaximal;
@ -61,35 +65,34 @@ isMaximal: {
python.enable = isMaximal; python.enable = isMaximal;
dart.enable = isMaximal; dart.enable = isMaximal;
bash.enable = isMaximal; bash.enable = isMaximal;
gleam.enable = false;
r.enable = isMaximal; r.enable = isMaximal;
tailwind.enable = isMaximal; tailwind.enable = isMaximal;
typst.enable = isMaximal; typst.enable = isMaximal;
clang = { clang.enable = isMaximal;
enable = isMaximal; scala.enable = isMaximal;
lsp.server = "clangd";
};
rust = { rust = {
enable = isMaximal; enable = isMaximal;
crates.enable = isMaximal; crates.enable = isMaximal;
}; };
csharp.enable = isMaximal;
julia.enable = isMaximal;
vala.enable = isMaximal;
nu.enable = false;
}; };
visuals = { visuals = {
enable = true; nvim-scrollbar.enable = isMaximal;
nvimWebDevicons.enable = true; nvim-web-devicons.enable = true;
scrollBar.enable = isMaximal; nvim-cursorline.enable = true;
smoothScroll.enable = true; cinnamon-nvim.enable = true;
cellularAutomaton.enable = false;
fidget-nvim.enable = true; fidget-nvim.enable = true;
highlight-undo.enable = true; highlight-undo.enable = true;
indent-blankline.enable = true;
indentBlankline.enable = true; # Fun
cellular-automaton.enable = false;
cursorline = {
enable = true;
lineTimeout = 0;
};
}; };
statusline = { statusline = {
@ -106,15 +109,13 @@ isMaximal: {
transparent = false; transparent = false;
}; };
autopairs.enable = true; autopairs.nvim-autopairs.enable = true;
autocomplete = { autocomplete.nvim-cmp.enable = true;
enable = true; snippets.luasnip.enable = true;
type = "nvim-cmp";
};
filetree = { filetree = {
nvimTree = { neo-tree = {
enable = true; enable = true;
}; };
}; };
@ -175,6 +176,7 @@ isMaximal: {
notes = { notes = {
obsidian.enable = false; # FIXME: neovim fails to build if obsidian is enabled obsidian.enable = false; # FIXME: neovim fails to build if obsidian is enabled
neorg.enable = false;
orgmode.enable = false; orgmode.enable = false;
mind-nvim.enable = isMaximal; mind-nvim.enable = isMaximal;
todo-comments.enable = true; todo-comments.enable = true;

View file

@ -1,63 +1,112 @@
{ {
lib, lib,
stdenvNoCC, stdenvNoCC,
fetchzip,
runCommandLocal,
# build inputs # build inputs
nixos-render-docs, nixos-render-docs,
documentation-highlighter, documentation-highlighter,
dart-sass,
path, path,
# nrd configuration # nrd configuration
release, release,
optionsJSON, optionsJSON,
}: } @ args: let
stdenvNoCC.mkDerivation { manual-release = args.release or "unstable";
name = "nvf-manual";
src = builtins.path { scss-reset = fetchzip {
path = lib.sourceFilesBySuffices ./manual [".md"]; url = "https://github.com/Frontend-Layers/scss-reset/archive/refs/tags/1.4.2.zip";
name = "nvf-manual"; hash = "sha256-cif5Sx8Ca5vxdw/mNAgpulLH15TwmzyJFNM7JURpoaE=";
}; };
nativeBuildInputs = [nixos-render-docs]; compileStylesheet = runCommandLocal "compile-nvf-stylesheet" {} ''
mkdir -p $out
buildPhase = '' tmpfile=$(mktemp -d)
dest="$out/share/doc/nvf" trap "rm -r $tmpfile" EXIT
mkdir -p "$(dirname "$dest")"
mkdir -p $dest/{highlightjs,media}
cp -vt $dest/highlightjs \ ln -s "${scss-reset}/build" "$tmpfile/scss-reset"
${documentation-highlighter}/highlight.pack.js \
${documentation-highlighter}/LICENSE \
${documentation-highlighter}/mono-blue.css \
${documentation-highlighter}/loader.js
substituteInPlace ./options.md \ ${dart-sass}/bin/sass --load-path "$tmpfile" \
--subst-var-by \ ${./static/style.scss} "$out/style.css"
OPTIONS_JSON \
${optionsJSON}/share/doc/nixos/options.json
substituteInPlace ./manual.md \ echo "Generated styles"
--subst-var-by \
NVF_VERSION \
${release}
# copy stylesheet
cp ${./static/style.css} "$dest/style.css"
# copy release notes
cp -vr ${./release-notes} release-notes
# generate manual from
nixos-render-docs manual html \
--manpage-urls ${path + "/doc/manpage-urls.json"} \
--revision ${lib.trivial.revisionWithDefault release} \
--stylesheet style.css \
--script highlightjs/highlight.pack.js \
--script highlightjs/loader.js \
--toc-depth 2 \
--section-toc-depth 1 \
manual.md \
"$dest/index.xhtml"
mkdir -p $out/nix-support/
echo "doc manual $dest index.html" >> $out/nix-support/hydra-build-products
''; '';
} in
stdenvNoCC.mkDerivation {
name = "nvf-manual";
src = builtins.path {
name = "nvf-manual-${manual-release}";
path = lib.sourceFilesBySuffices ./manual [".md" ".md.in"];
};
strictDependencies = true;
nativeBuildInputs = [nixos-render-docs];
postPatch = ''
ln -s ${optionsJSON}/share/doc/nixos/options.json ./config-options.json
'';
buildPhase = ''
dest="$out/share/doc/nvf"
mkdir -p "$(dirname "$dest")"
mkdir -p $dest/{highlightjs,script}
# Copy highlight scripts to /highlights in document root.
cp -vt $dest/highlightjs \
${documentation-highlighter}/highlight.pack.js \
${documentation-highlighter}/LICENSE \
${documentation-highlighter}/mono-blue.css \
${documentation-highlighter}/loader.js
# Copy anchor scripts to the script directory in document root.
cp -vt "$dest"/script \
${./static/script}/anchor-min.js \
${./static/script}/anchor-use.js
substituteInPlace ./options.md \
--subst-var-by OPTIONS_JSON ./config-options.json
substituteInPlace ./manual.md \
--subst-var-by NVF_VERSION ${manual-release}
substituteInPlace ./hacking/additional-plugins.md \
--subst-var-by NVF_REPO "https://github.com/notashelf/nvf/blob/${manual-release}"
# Move compiled stylesheet
cp -vt $dest \
${compileStylesheet}/style.css
# Move release notes
cp -vr ${./release-notes} release-notes
# Generate final manual from a set of parameters. Explanation of the CLI flags are
# as follows:
#
# 1. --manpage-urls will allow you to use manual pages as they are defined in
# the nixpkgs documentation.
# 2. --revision is the project revision as it is defined in 'release.json' in the
# repository root
# 3. --script will inject a given Javascript file into the resulting pages inside
# the <script> tag.
# 4. --toc-depth will determine the depth of the initial Table of Contents while
# --section-toc-depth will determine the depth of per-section Table of Contents
# sections.
nixos-render-docs manual html \
--manpage-urls ${path + "/doc/manpage-urls.json"} \
--revision ${lib.trivial.revisionWithDefault manual-release} \
--stylesheet "$dest"/style.css \
--script ./highlightjs/highlight.pack.js \
--script ./highlightjs/loader.js \
--script script/anchor-use.js \
--script script/anchor-min.js \
--toc-depth 2 \
--section-toc-depth 1 \
manual.md \
"$dest/index.xhtml"
# Hydra support. Probably not necessary.
mkdir -p $out/nix-support/
echo "doc manual $dest index.html" >> $out/nix-support/hydra-build-products
'';
}

View file

@ -3,6 +3,7 @@
```{=include=} chapters ```{=include=} chapters
configuring/custom-package.md configuring/custom-package.md
configuring/custom-plugins.md configuring/custom-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,8 +1,8 @@
# Custom Plugins {#ch-custom-plugins} # Custom Plugins {#ch-custom-plugins}
**nvf**, by default, exposes a wide variety of plugins as module options **nvf**, by default, exposes a wide variety of plugins as module options for
for your convenience and bundles necessary dependencies into **nvf**'s runtime. your convenience and bundles necessary dependencies into **nvf**'s runtime. In
In case a plugin is not available in **nvf**, you may consider making a pull case a plugin is not available in **nvf**, you may consider making a pull
request to **nvf** to include it as a module or you may add it to your request to **nvf** to include it as a module or you may add it to your
configuration locally. configuration locally.
@ -11,15 +11,16 @@ configuration locally.
There are multiple ways of adding custom plugins to your **nvf** configuration. There are multiple ways of adding custom plugins to your **nvf** configuration.
You can use custom plugins, before they are implemented in the flake. To add a You can use custom plugins, before they are implemented in the flake. To add a
plugin to the runtime, you need to add it to the `vim.startPlugins` list in plugin to the runtime, you need to add it to the [](#opt-vim.startPlugins) list
your configuration. in your configuration.
Adding a plugin to `startPlugins` will not allow you to configure the plugin Adding a plugin to `startPlugins` will not allow you to configure the plugin
that you have adeed, but **nvf** provides multiple way of configuring any that you have added, but **nvf** provides multiple way of configuring any custom
custom plugins that you might have added to your configuration. plugins that you might have added to your configuration.
```{=include=} sections ```{=include=} sections
custom-plugins/configuring.md custom-plugins/configuring.md
custom-plugins/new-method.md custom-plugins/lazy-method.md
custom-plugins/old-method.md custom-plugins/non-lazy-method.md
custom-plugins/legacy-method.md
``` ```

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,25 +1,23 @@
# Using DAGs {#ch-using-dags} # Using DAGs {#ch-using-dags}
We conform to the NixOS options types for the most part, however, a noteworthy We conform to the NixOS options types for the most part, however, a noteworthy
addition for certain options is the [**DAG addition for certain options is the
(Directed acyclic graph)**](https://en.wikipedia.org/wiki/Directed_acyclic_graph) [**DAG (Directed acyclic graph)**](https://en.wikipedia.org/wiki/Directed_acyclic_graph)
type which is borrowed from home-manager's extended library. This type is most type which is borrowed from home-manager's extended library. This type is most
used for topologically sorting strings. The DAG type allows the attribute set used for topologically sorting strings. The DAG type allows the attribute set
entries to express dependency relations among themselves. This can, for entries to express dependency relations among themselves. This can, for example,
example, be used to control the order of configuration sections in your be used to control the order of configuration sections in your `luaConfigRC`.
`luaConfigRC`.
The below section, mostly taken from the [home-manager The below section, mostly taken from the
manual](https://raw.githubusercontent.com/nix-community/home-manager/master/docs/manual/writing-modules/types.md) [home-manager manual](https://raw.githubusercontent.com/nix-community/home-manager/master/docs/manual/writing-modules/types.md)
explains in more detail the overall usage logic of the DAG type. explains in more detail the overall usage logic of the DAG type.
## entryAnywhere {#sec-types-dag-entryAnywhere} ## entryAnywhere {#sec-types-dag-entryAnywhere}
> `lib.dag.entryAnywhere (value: T) : DagEntry<T>` > `lib.dag.entryAnywhere (value: T) : DagEntry<T>`
Indicates that `value` can be placed anywhere within the DAG. Indicates that `value` can be placed anywhere within the DAG. This is also the
This is also the default for plain attribute set entries, that default for plain attribute set entries, that is
is
```nix ```nix
foo.bar = { foo.bar = {
@ -41,8 +39,8 @@ are equivalent.
> `lib.dag.entryAfter (afters: list string) (value: T) : DagEntry<T>` > `lib.dag.entryAfter (afters: list string) (value: T) : DagEntry<T>`
Indicates that `value` must be placed _after_ each of the Indicates that `value` must be placed _after_ each of the attribute names in the
attribute names in the given list. For example given list. For example
```nix ```nix
foo.bar = { foo.bar = {
@ -57,8 +55,8 @@ would place `b` after `a` in the graph.
> `lib.dag.entryBefore (befores: list string) (value: T) : DagEntry<T>` > `lib.dag.entryBefore (befores: list string) (value: T) : DagEntry<T>`
Indicates that `value` must be placed _before_ each of the Indicates that `value` must be placed _before_ each of the attribute names in
attribute names in the given list. For example the given list. For example
```nix ```nix
foo.bar = { foo.bar = {
@ -73,9 +71,8 @@ would place `b` before `a` in the graph.
> `lib.dag.entryBetween (befores: list string) (afters: list string) (value: T) : DagEntry<T>` > `lib.dag.entryBetween (befores: list string) (afters: list string) (value: T) : DagEntry<T>`
Indicates that `value` must be placed _before_ the attribute Indicates that `value` must be placed _before_ the attribute names in the first
names in the first list and _after_ the attribute names in the list and _after_ the attribute names in the second list. For example
second list. For example
```nix ```nix
foo.bar = { foo.bar = {
@ -87,18 +84,18 @@ foo.bar = {
would place `c` before `b` and after `a` in the graph. would place `c` before `b` and after `a` in the graph.
There are also a set of functions that generate a DAG from a list. There are also a set of functions that generate a DAG from a list. These are
These are convenient when you just want to have a linear list of DAG convenient when you just want to have a linear list of DAG entries, without
entries, without having to manually enter the relationship between having to manually enter the relationship between each entry. Each of these
each entry. Each of these functions take a `tag` as argument and the functions take a `tag` as argument and the DAG entries will be named
DAG entries will be named `${tag}-${index}`. `${tag}-${index}`.
## entriesAnywhere {#sec-types-dag-entriesAnywhere} ## entriesAnywhere {#sec-types-dag-entriesAnywhere}
> `lib.dag.entriesAnywhere (tag: string) (values: [T]) : Dag<T>` > `lib.dag.entriesAnywhere (tag: string) (values: [T]) : Dag<T>`
Creates a DAG with the given values with each entry labeled Creates a DAG with the given values with each entry labeled using the given tag.
using the given tag. For example For example
```nix ```nix
foo.bar = lib.dag.entriesAnywhere "a" [ 0 1 ]; foo.bar = lib.dag.entriesAnywhere "a" [ 0 1 ];
@ -117,9 +114,9 @@ foo.bar = {
> `lib.dag.entriesAfter (tag: string) (afters: list string) (values: [T]) : Dag<T>` > `lib.dag.entriesAfter (tag: string) (afters: list string) (values: [T]) : Dag<T>`
Creates a DAG with the given values with each entry labeled Creates a DAG with the given values with each entry labeled using the given tag.
using the given tag. The list of values are placed are placed The list of values are placed are placed _after_ each of the attribute names in
_after_ each of the attribute names in `afters`. For example `afters`. For example
```nix ```nix
foo.bar = foo.bar =
@ -140,13 +137,13 @@ foo.bar = {
> `lib.dag.entriesBefore (tag: string) (befores: list string) (values: [T]) : Dag<T>` > `lib.dag.entriesBefore (tag: string) (befores: list string) (values: [T]) : Dag<T>`
Creates a DAG with the given values with each entry labeled Creates a DAG with the given values with each entry labeled using the given tag.
using the given tag. The list of values are placed _before_ each The list of values are placed _before_ each of the attribute names in `befores`.
of the attribute names in `befores`. For example For example
```nix ```nix
foo.bar = foo.bar =
{ b = 0; } // lib.dag.entriesBefore "a" [ "b" ] [ 1 2 ]; { b = 0; } // lib.dag.entriesBefore "a" [ "b" ] [ 1 2 ];
``` ```
is equivalent to is equivalent to
@ -163,10 +160,9 @@ foo.bar = {
> `lib.dag.entriesBetween (tag: string) (befores: list string) (afters: list string) (values: [T]) : Dag<T>` > `lib.dag.entriesBetween (tag: string) (befores: list string) (afters: list string) (values: [T]) : Dag<T>`
Creates a DAG with the given values with each entry labeled Creates a DAG with the given values with each entry labeled using the given tag.
using the given tag. The list of values are placed _before_ each The list of values are placed _before_ each of the attribute names in `befores`
of the attribute names in `befores` and _after_ each of the and _after_ each of the attribute names in `afters`. For example
attribute names in `afters`. For example
```nix ```nix
foo.bar = foo.bar =

View file

@ -2,9 +2,9 @@
Language specific support means there is a combination of language specific Language specific support means there is a combination of language specific
plugins, `treesitter` support, `nvim-lspconfig` language servers, and `null-ls` plugins, `treesitter` support, `nvim-lspconfig` language servers, and `null-ls`
integration. This gets you capabilities ranging from autocompletion to formatting integration. This gets you capabilities ranging from autocompletion to
to diagnostics. The following languages have sections under the `vim.languages` formatting to diagnostics. The following languages have sections under the
attribute. `vim.languages` attribute.
- Rust: [vim.languages.rust.enable](#opt-vim.languages.rust.enable) - Rust: [vim.languages.rust.enable](#opt-vim.languages.rust.enable)
- Nix: [vim.languages.nix.enable](#opt-vim.languages.nix.enable) - Nix: [vim.languages.nix.enable](#opt-vim.languages.nix.enable)
@ -20,8 +20,8 @@ attribute.
- Lua: [vim.languages.lua.enable](#opt-vim.languages.lua.enable) - Lua: [vim.languages.lua.enable](#opt-vim.languages.lua.enable)
- PHP: [vim.languages.php.enable](#opt-vim.languages.php.enable) - PHP: [vim.languages.php.enable](#opt-vim.languages.php.enable)
Adding support for more languages, and improving support for existing ones are great places Adding support for more languages, and improving support for existing ones are
where you can contribute with a PR. great places where you can contribute with a PR.
```{=include=} sections ```{=include=} sections
languages/lsp.md languages/lsp.md

View file

@ -1,8 +1,8 @@
# LSP Custom Packages/Command {#sec-languages-custom-lsp-packages} # LSP Custom Packages/Command {#sec-languages-custom-lsp-packages}
In any of the `opt.languages.<language>.lsp.package` options you can provide In any of the `opt.languages.<language>.lsp.package` options you can provide
your own LSP package, or provide the command to launch the language server, as your own LSP package, or provide the command to launch the language server, as a
a list of strings. You can use this to skip automatic installation of a language list of strings. You can use this to skip automatic installation of a language
server, and instead use the one found in your `$PATH` during runtime, for server, and instead use the one found in your `$PATH` during runtime, for
example: example:

View file

@ -1,7 +1,8 @@
# Default Configs {#ch-default-configs} # Default Configs {#ch-default-configs}
While you can configure **nvf** yourself using the builder, you can also use the pre-built configs that are available. While you can configure **nvf** yourself using the builder, you can also use the
Here are a few default configurations you can use. pre-built configs that are available. Here are a few default configurations you
can use.
```{=include=} chapters ```{=include=} chapters
default-configs/maximal.md default-configs/maximal.md

View file

@ -7,7 +7,5 @@ $ nix shell github:notashelf/nvf#maximal test.nix
It is the same fully configured Neovim as with the [Nix](#sec-default-nix) It is the same fully configured Neovim as with the [Nix](#sec-default-nix)
configuration, but with every supported language enabled. configuration, but with every supported language enabled.
::: {.note} ::: {.note} Running the maximal config will download _a lot_ of packages as it
Running the maximal config will download _a lot_ of packages as it is is downloading language servers, formatters, and more. :::
downloading language servers, formatters, and more.
:::

View file

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

View file

@ -1,10 +1,9 @@
# Adding Plugins {#sec-additional-plugins} # Adding Plugins {#sec-additional-plugins}
To add a new Neovim plugin, first add the source url in the inputs section of `flake.nix` To add a new Neovim plugin, first add the source url in the inputs section of
with the prefix `plugin-` `flake.nix` with the prefix `plugin-`
```nix ```nix
{ {
inputs = { inputs = {
# ... # ...
@ -17,13 +16,18 @@ with the prefix `plugin-`
} }
``` ```
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 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 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` 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 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 built with the name and source URL from the flake input, allowing you to refer
refer to it as a **string**. to it as a **string**.
```nix ```nix
config.vim.startPlugins = ["neodev-nvim"]; config.vim.startPlugins = ["neodev-nvim"];
@ -33,11 +37,11 @@ config.vim.startPlugins = ["neodev-nvim"];
Most plugins is initialized with a call to `require('plugin').setup({...})`. Most plugins is initialized with a call to `require('plugin').setup({...})`.
We use a special function that lets you easily add support for such setup options in a modular way: We use a special function that lets you easily add support for such setup
`mkPluginSetupOption`. options in a modular way: `mkPluginSetupOption`.
Once you have added the source of the plugin as shown above, you can define the setup options like Once you have added the source of the plugin as shown above, you can define the
this: setup options like this:
```nix ```nix
# in modules/.../your-plugin/your-plugin.nix # in modules/.../your-plugin/your-plugin.nix
@ -86,7 +90,8 @@ require('plugin-name').setup({
}) })
``` ```
Now users can set any of the pre-defined option field, and can also add their own fields! Now users can set any of the pre-defined option field, and can also add their
own fields!
```nix ```nix
# in user's config # in user's config
@ -110,8 +115,8 @@ As you've seen above, `toLuaObject` is used to convert our nix attrSet
1. nix `null` converts to lua `nil` 1. nix `null` converts to lua `nil`
2. number and strings convert to their lua counterparts 2. number and strings convert to their lua counterparts
3. nix attrSet/list convert into lua tables 3. nix attrSet/list convert into lua tables
4. you can write raw lua code using `lib.generators.mkLuaInline`. This 4. you can write raw lua code using `lib.generators.mkLuaInline`. This function
function is part of nixpkgs. is part of nixpkgs.
Example: Example:
@ -124,3 +129,62 @@ vim.your-plugin.setupOpts = {
''; '';
} }
``` ```
## Lazy plugins {#sec-lazy-plugins}
If the plugin can be lazy-loaded, `vim.lazy.plugins` should be used to add it.
Lazy plugins are managed by `lz.n`.
```nix
# in modules/.../your-plugin/config.nix
{lib, config, ...}:
let
cfg = config.vim.your-plugin;
in {
vim.lazy.plugins.your-plugin = {
# instead of vim.startPlugins, use this:
package = "your-plugin";
# if your plugin uses the `require('your-plugin').setup{...}` pattern
setupModule = "your-plugin";
inherit (cfg) setupOpts;
# events that trigger this plugin to be loaded
event = ["DirChanged"];
cmd = ["YourPluginCommand"];
# keymaps
keys = [
# we'll cover this in detail in the keymaps section
{
key = "<leader>d";
mode = "n";
action = ":YourPluginCommand";
}
];
};
;
}
```
This results in the following lua code:
```lua
require('lz.n').load({
{
"name-of-your-plugin",
after = function()
require('your-plugin').setup({--[[ your setupOpts ]]})
end,
event = {"DirChanged"},
cmd = {"YourPluginCommand"},
keys = {
{"<leader>d", ":YourPluginCommand", mode = {"n"}},
},
}
})
```
A full list of options can be found
[here](https://notashelf.github.io/nvf/options.html#opt-vim.lazy.plugins

View file

@ -1,16 +1,17 @@
# Getting Started {#sec-contrib-getting-started} # Getting Started {#sec-contrib-getting-started}
You, naturally, would like to start by forking the repository to get started. If You, naturally, would like to start by forking the repository to get started. If
you are new to Git and GitHub, do have a look at GitHub's [Fork a repo guide](https://help.github.com/articles/fork-a-repo/) you are new to Git and GitHub, do have a look at GitHub's
for instructions on how you can do this. Once you have a fork of **nvf**, you [Fork a repo guide](https://help.github.com/articles/fork-a-repo/) for
should create a separate branch based on the msot recent `main` branch. Give instructions on how you can do this. Once you have a fork of **nvf**, you should
your branch a reasonably descriptive name (e.g. `feature/debugger` or create a separate branch based on the most recent `main` branch. Give your
branch a reasonably descriptive name (e.g. `feature/debugger` or
`fix/pesky-bug`) and you are ready to work on your changes `fix/pesky-bug`) and you are ready to work on your changes
Implement your changes and commit them to the newly created branch and when you Implement your changes and commit them to the newly created branch and when you
are happy with the result, and positive that it fullfills our [Contributing are happy with the result, and positive that it fulfills our
Guidelines](#sec-guidelines), push the branch to GitHub and [create a pull [Contributing Guidelines](#sec-guidelines), push the branch to GitHub and
request](https://help.github.com/articles/creating-a-pull-request). The default [create a pull request](https://help.github.com/articles/creating-a-pull-request).
pull request template available on the **nvf** repository will guide you through The default pull request template available on the **nvf** repository will guide
the rest of the process, and we'll gently nudge you in the correct direction if you through the rest of the process, and we'll gently nudge you in the correct
there are any mistakes. direction if there are any mistakes.

View file

@ -3,30 +3,29 @@
If your contribution tightly follows the guidelines, then there is a good chance If your contribution tightly follows the guidelines, then there is a good chance
it will be merged without too much trouble. Some of the guidelines will be it will be merged without too much trouble. Some of the guidelines will be
strictly enforced, others will remain as gentle nudges towards the correct strictly enforced, others will remain as gentle nudges towards the correct
direction. As we have no automated system enforcing those guidelines, please direction. As we have no automated system enforcing those guidelines, please try
try to double check your changes before making your pull request in order to to double check your changes before making your pull request in order to avoid
avoid "faulty" code slipping by. "faulty" code slipping by.
If you are uncertain how these rules affect the change you would like to make If you are uncertain how these rules affect the change you would like to make
then feel free to start a discussion in the [discussions tab](https://github.com/NotAShelf/nvf/discussions) then feel free to start a discussion in the
ideally (but not necessarily) before you start developing. [discussions tab](https://github.com/NotAShelf/nvf/discussions) ideally (but not
necessarily) before you start developing.
## Adding Documentation {#sec-guidelines-documentation} ## Adding Documentation {#sec-guidelines-documentation}
Most, if not all, changes warrant changes to the documentation. Module options 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), should be documented with
[Nixpkgs-flavoured Markdown](https://nixos.org/manual/nixpkgs/unstable/#sec-contributing-markup),
albeit with exceptions. albeit with exceptions.
::: {.note} ::: {.note} As of **v0.5**, **nvf** is itself documented using full markdown in
As of **v0.5**, **nvf** is itself documented using full markdown in both module both module options and the manual. With **v0.6**, this manual has also been
options and the manual. With **v0.6**, this manual has also been converted to converted to markdown in full. :::
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 and the documentation of **nvf** (such as this page) can be generated and opened
opened by typing the following in a shell within a clone of the **nvf** Git by typing the following in a shell within a clone of the **nvf** Git repository:
repository:
```console ```console
$ nix build .#docs-html $ nix build .#docs-html
@ -35,28 +34,28 @@ $ xdg-open $PWD/result/share/doc/nvf/index.html
## Formatting Code {#sec-guidelines-formatting} ## Formatting Code {#sec-guidelines-formatting}
Make sure your code is formatted as described in [code-style Make sure your code is formatted as described in
section](#sec-guidelines-code-style). To maintain consistency throughout the [code-style section](#sec-guidelines-code-style). To maintain consistency
project you are encouraged to browse through existing code and adopt its style throughout the project you are encouraged to browse through existing code and
also in new code. adopt its style also in new code.
## Formatting Commits {#sec-guidelines-commit-message-style} ## Formatting Commits {#sec-guidelines-commit-message-style}
Similar to [code style guidelines](#sec-guidelines-code-style) we encourage a Similar to [code style guidelines](#sec-guidelines-code-style) we encourage a
consistent commit message format as described in [commit style consistent commit message format as described in
guidelines](#sec-guidelines-commit-style). [commit style guidelines](#sec-guidelines-commit-style).
## Commit Style {#sec-guidelines-commit-style} ## Commit Style {#sec-guidelines-commit-style}
The commits in your pull request should be reasonably self-contained. Which The commits in your pull request should be reasonably self-contained. Which
means each and every commit in a pull request should make sense both on its means each and every commit in a pull request should make sense both on its own
own and in general context. That is, a second commit should not resolve an and in general context. That is, a second commit should not resolve an issue
issue that is introduced in an earlier commit. In particular, you will be that is introduced in an earlier commit. In particular, you will be asked to
asked to amend any commit that introduces syntax errors or similar problems amend any commit that introduces syntax errors or similar problems even if they
even if they are fixed in a later commit. are fixed in a later commit.
The commit messages should follow the [seven The commit messages should follow the
rules](https://chris.beams.io/posts/git-commit/#seven-rule), except for [seven rules](https://chris.beams.io/posts/git-commit/#seven-rule), except for
"Capitalize the subject line". We also ask you to include the affected code "Capitalize the subject line". We also ask you to include the affected code
component or module in the first line. A commit message ideally, but not component or module in the first line. A commit message ideally, but not
necessarily, follow the given template from home-manager's own documentation necessarily, follow the given template from home-manager's own documentation
@ -69,15 +68,16 @@ necessarily, follow the given template from home-manager's own documentation
where `{component}` refers to the code component (or module) your change where `{component}` refers to the code component (or module) your change
affects, `{description}` is a very brief description of your change, and affects, `{description}` is a very brief description of your change, and
`{long description}` is an optional clarifying description. As a rare `{long description}` is an optional clarifying description. As a rare exception,
exception, if there is no clear component, or your change affects many if there is no clear component, or your change affects many components, then the
components, then the `{component}` part is optional. See [example commit `{component}` part is optional. See
message](#sec-guidelines-ex-commit-message) for a commit message that [example commit message](#sec-guidelines-ex-commit-message) for a commit message
fulfills these requirements. that fulfills these requirements.
## Example Commit {#sec-guidelines-ex-commit-message} ## Example Commit {#sec-guidelines-ex-commit-message}
The commit [69f8e47e9e74c8d3d060ca22e18246b7f7d988ef](https://github.com/nix-community/home-manager/commit/69f8e47e9e74c8d3d060ca22e18246b7f7d988ef) The commit
[69f8e47e9e74c8d3d060ca22e18246b7f7d988ef](https://github.com/nix-community/home-manager/commit/69f8e47e9e74c8d3d060ca22e18246b7f7d988ef)
in home-manager contains the following commit message. in home-manager contains the following commit message.
``` ```
@ -93,10 +93,10 @@ the commit followed by the description:
``` ```
languages/ruby: init module languages/ruby: init module
Adds a language module for Ruby, adds appropriate formatters and Treesitter grammers Adds a language module for Ruby, adds appropriate formatters and Treesitter grammars
``` ```
Long description can be ommitted if the change is too simple to warrant it. A Long description can be omitted if the change is too simple to warrant it. A
minor fix in spelling or a formatting change does not warrant long description, minor fix in spelling or a formatting change does not warrant long description,
however, a module addition or removal does as you would like to provide the however, a module addition or removal does as you would like to provide the
relevant context, i.e. the reasoning behind it, for your commit. relevant context, i.e. the reasoning behind it, for your commit.
@ -112,21 +112,22 @@ to contain the parent as well - for example `languages/java: some major change`.
### Treewide {#sec-code-style-treewide} ### Treewide {#sec-code-style-treewide}
Keep lines at a reasonable width, ideally 80 characters or less. This also applies Keep lines at a reasonable width, ideally 80 characters or less. This also
to string literals and module descriptions and documentation. applies to string literals and module descriptions and documentation.
### Nix {#sec-code-style-nix} ### Nix {#sec-code-style-nix}
**nvf** is formatted by the [alejandra](https://github.com/kamadorueda/alejandra) **nvf** is formatted by the
tool and the formatting is checked in the pull request and push workflows. Run the [alejandra](https://github.com/kamadorueda/alejandra) tool and the formatting is
`nix fmt` command inside the project repository before submitting your pull request. checked in the pull request and push workflows. Run the `nix fmt` command inside
the 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 certain changes are done at the user's discretion based on how the original code
code was structured. was structured.
Please use one line code for attribute sets that contain only one subset. Please use one line code for attribute sets that contain only one subset. For
For example: example:
```nix ```nix
# parent modules should always be unfolded # parent modules should always be unfolded
@ -158,8 +159,8 @@ module = {
``` ```
For lists, it is mostly up to your own discretion how you want to format them, For lists, it is mostly up to your own discretion how you want to format them,
but please try to unfold lists if they contain multiple items and especially but please try to unfold lists if they contain multiple items and especially if
if they are to include comments. they are to include comments.
```nix ```nix
# this is ok # this is ok

View file

@ -1,115 +1,61 @@
# Keybinds {#sec-keybinds} # Keybinds {#sec-keybinds}
As of 0.4, there exists an API for writing your own keybinds and a couple of As of 0.4, there exists an API for writing your own keybinds and a couple of
useful utility functions are available in the [extended standard useful utility functions are available in the
library](https://github.com/NotAShelf/nvf/tree/main/lib). The following [extended standard library](https://github.com/NotAShelf/nvf/tree/main/lib). The
section contains a general overview to how you may utilize said functions. following section contains a general overview to how you may utilize said
functions.
## Custom Key Mappings Support for a Plugin {#sec-custom-key-mappings} ## Custom Key Mappings Support for a Plugin {#sec-custom-key-mappings}
To set a mapping, you should define it in `vim.maps.<<mode>>`. To set a mapping, you should define it in `vim.keymaps`.
The available modes are:
- normal
- insert
- select
- visual
- terminal
- normalVisualOp
- visualOnly
- operator
- insertCommand
- lang
- command
An example, simple keybinding, can look like this: An example, simple keybinding, can look like this:
```nix ```nix
{ {
vim.maps.normal = { vim.keymaps = [
"<leader>wq" = { {
key = "<leader>wq";
mode = ["n"];
action = ":wq<CR>"; action = ":wq<CR>";
silent = true; silent = true;
desc = "Save file and quit"; desc = "Save file and quit";
}; }
}; ];
} }
``` ```
There are many settings available in the options. Please refer to the There are many settings available in the options. Please refer to the
[documentation](https://notashelf.github.io/nvf/options.html#opt-vim.maps.command._name_.action) [documentation](https://notashelf.github.io/nvf/options.html#opt-vim.keymaps) to
to see a list of them. see a list of them.
**nvf** provides a list of helper commands, so that you don't have to write the **nvf** provides a helper function, so that you don't have to write the
mapping attribute sets every time: mapping attribute sets every time:
- `mkBinding = key: action: desc:` - makes a basic binding, with `silent` set - `mkKeymap`, which mimics neovim's `vim.keymap.set` function
to true.
- `mkExprBinding = key: action: desc:` - makes an expression binding, with
`lua`, `silent`, and `expr` set to true.
- `mkLuaBinding = key: action: desc:` - makes an expression binding, with
`lua`, and `silent` set to true.
Do note that the Lua in these bindings is actual Lua, and not pasted into a You can read the source code of some modules to see them in action, but the
`:lua` command. Therefore, you should either pass in a function like
`require('someplugin').some_function`, without actually calling it, or you
should define your own functions, for example
```lua
function()
require('someplugin').some_function()
end
```
Additionally, to not have to repeat the descriptions, there's another utility
function with its own set of functions: Utility function that takes two
attribute sets:
- `{ someKey = "some_value" }`
- `{ someKey = { description = "Some Description"; }; }`
and merges them into `{ someKey = { value = "some_value"; description = "Some Description"; }; }`
```nix
addDescriptionsToMappings = actualMappings: mappingDefinitions:
```
This function can be used in combination with the same `mkBinding` functions as
above, except they only take two arguments - `binding` and `action`, and have
different names:
- `mkSetBinding = binding: action:` - makes a basic binding, with `silent`
set to true.
- `mkSetExprBinding = binding: action:` - makes an expression binding, with
`lua`, `silent`, and `expr` set to true.
- `mkSetLuaBinding = binding: action:` - makes an expression binding, with
`lua`, and `silent` set to true.
You can read the source code of some modules to see them in action, but their
usage should look something like this: usage should look something like this:
```nix ```nix
# plugindefinition.nix # plugindefinition.nix
{lib, ...}: with lib; { {lib, ...}: let
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.binds) mkMappingOption;
in {
options.vim.plugin = { options.vim.plugin = {
enable = mkEnableOption "Enable plugin"; enable = mkEnableOption "Enable plugin";
# Mappings should always be inside an attrset called mappings # Mappings should always be inside an attrset called mappings
mappings = { mappings = {
# mkMappingOption is a helper function from lib, workspaceDiagnostics = mkMappingOption "Workspace diagnostics [trouble]" "<leader>lwd";
# that takes a description (which will also appear in which-key), documentDiagnostics = mkMappingOption "Document diagnostics [trouble]" "<leader>ld";
# and a default mapping (which can be null) lspReferences = mkMappingOption "LSP References [trouble]" "<leader>lr";
toggleCurrentLine = mkMappingOption "Toggle current line comment" "gcc"; quickfix = mkMappingOption "QuickFix [trouble]" "<leader>xq";
toggleCurrentBlock = mkMappingOption "Toggle current block comment" "gbc"; locList = mkMappingOption "LOCList [trouble]" "<leader>xl";
symbols = mkMappingOption "Symbols [trouble]" "<leader>xs";
toggleOpLeaderLine = mkMappingOption "Toggle line comment" "gc";
toggleOpLeaderBlock = mkMappingOption "Toggle block comment" "gb";
toggleSelectedLine = mkMappingOption "Toggle selected comment" "gc";
toggleSelectedBlock = mkMappingOption "Toggle selected block" "gb";
}; };
};
} }
``` ```
@ -117,62 +63,35 @@ usage should look something like this:
# config.nix # config.nix
{ {
config, config,
pkgs,
lib, lib,
options,
... ...
}: }: let
with lib; inherit (lib.modules) mkIf;
with builtins; let inherit (lib.nvim.binds) mkKeymap;
cfg = config.vim.plugin;
self = import ./plugindefinition.nix {inherit lib;};
mappingDefinitions = self.options.vim.plugin;
# addDescriptionsToMappings is a helper function from lib, cfg = config.vim.plugin;
# that merges mapping values and their descriptions
# into one nice attribute set keys = cfg.mappings;
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions; inherit (options.vim.lsp.trouble) mappings;
in { in {
config = mkIf (cfg.enable) { config = mkIf cfg.enable {
# ... vim.keymaps = [
vim.maps.normal = mkMerge [ (mkKeymap "n" keys.workspaceDiagnostics "<cmd>Trouble toggle diagnostics<CR>" {desc = mappings.workspaceDiagnostics.description;})
# mkSetBinding is another helper function from lib, (mkKeymap "n" keys.documentDiagnostics "<cmd>Trouble toggle diagnostics filter.buf=0<CR>" {desc = mappings.documentDiagnostics.description;})
# that actually adds the mapping with a description. (mkKeymap "n" keys.lspReferences "<cmd>Trouble toggle lsp_references<CR>" {desc = mappings.lspReferences.description;})
(mkSetBinding mappings.findFiles "<cmd> Telescope find_files<CR>") (mkKeymap "n" keys.quickfix "<cmd>Trouble toggle quickfix<CR>" {desc = mappings.quickfix.description;})
(mkSetBinding mappings.liveGrep "<cmd> Telescope live_grep<CR>") (mkKeymap "n" keys.locList "<cmd>Trouble toggle loclist<CR>" {desc = mappings.locList.description;})
(mkSetBinding mappings.buffers "<cmd> Telescope buffers<CR>") (mkKeymap "n" keys.symbols "<cmd>Trouble toggle symbols<CR>" {desc = mappings.symbols.description;})
(mkSetBinding mappings.helpTags "<cmd> Telescope help_tags<CR>")
(mkSetBinding mappings.open "<cmd> Telescope<CR>")
(mkSetBinding mappings.gitCommits "<cmd> Telescope git_commits<CR>")
(mkSetBinding mappings.gitBufferCommits "<cmd> Telescope git_bcommits<CR>")
(mkSetBinding mappings.gitBranches "<cmd> Telescope git_branches<CR>")
(mkSetBinding mappings.gitStatus "<cmd> Telescope git_status<CR>")
(mkSetBinding mappings.gitStash "<cmd> Telescope git_stash<CR>")
(mkIf config.vim.lsp.enable (mkMerge [
(mkSetBinding mappings.lspDocumentSymbols "<cmd> Telescope lsp_document_symbols<CR>")
(mkSetBinding mappings.lspWorkspaceSymbols "<cmd> Telescope lsp_workspace_symbols<CR>")
(mkSetBinding mappings.lspReferences "<cmd> Telescope lsp_references<CR>")
(mkSetBinding mappings.lspImplementations "<cmd> Telescope lsp_implementations<CR>")
(mkSetBinding mappings.lspDefinitions "<cmd> Telescope lsp_definitions<CR>")
(mkSetBinding mappings.lspTypeDefinitions "<cmd> Telescope lsp_type_definitions<CR>")
(mkSetBinding mappings.diagnostics "<cmd> Telescope diagnostics<CR>")
]))
(
mkIf config.vim.treesitter.enable
(mkSetBinding mappings.treesitter "<cmd> Telescope treesitter<CR>")
)
]; ];
# ...
}; };
} }
``` ```
::: {.note} ::: {.note}
If you have come across a plugin that has an API that doesn't seem to easily If you have come across a plugin that has an API that doesn't seem to easily
allow custom keybindings, don't be scared to implement a draft PR. We'll help allow custom keybindings, don't be scared to implement a draft PR. We'll help
you get it done. you get it done.
::: :::

View file

@ -1,15 +1,15 @@
# Testing Changes {#sec-testing-changes} # Testing Changes {#sec-testing-changes}
Once you have made your changes, you will need to test them throughly. If it is Once you have made your changes, you will need to test them thoroughly. If it is
a module, add your module option to `configuration.nix` (located in the root of a module, add your module option to `configuration.nix` (located in the root of
this project) inside `neovimConfiguration`. Enable it, and then run the maximal this project) inside `neovimConfiguration`. Enable it, and then run the maximal
configuration with `nix run .#maximal -Lv` to check for build errors. If neovim configuration with `nix run .#maximal -Lv` to check for build errors. If neovim
opens in the current directory without any error messages (you can check the opens in the current directory without any error messages (you can check the
output of `:messages` inside neovim to see if there are any errors), then your output of `:messages` inside neovim to see if there are any errors), then your
changes are good to go. Open your pull request, and it will be reviewed as soon changes are good to go. Open your pull request, and it will be reviewed as soon
as posssible. as possible.
If it is not a new module, but a change to an existing one, then make sure the If it is not a new module, but a change to an existing one, then make sure the
module you have changed is enabled in the maximal configuration by editing module you have changed is enabled in the maximal configuration by editing
`configuration.nix`, and then run it with `nix run .#maximal -Lv`. Same procedure `configuration.nix`, and then run it with `nix run .#maximal -Lv`. Same
as adding a new module will apply here. procedure as adding a new module will apply here.

View file

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

View file

@ -1,8 +1,9 @@
# Standalone Installation {#ch-standalone-installation} # Standalone Installation {#ch-standalone-installation}
It is possible to install **nvf** without depending on NixOS or home-manager as the parent It is possible to install nvf without depending on NixOS or Home-Manager as the
module system, using the `neovimConfiguration` function exposed by **nvf** extended library. parent module system, using the `neovimConfiguration` function exposed in the
It takes in the configuration as a module, and returns an attribute set as a result. extended library. This function will take `modules` and `extraSpecialArgs` as
arguments, and return the following schema as a result.
```nix ```nix
{ {
@ -13,6 +14,55 @@ It takes in the configuration as a module, and returns an attribute set as a res
} }
``` ```
An example flake that exposes your custom Neovim configuration might look like
```nix
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nvf.url = "github:notashelf/nvf";
};
outputs = {
self,
nixpkgs,
...
} @ inputs: {
packages."x86_64-linux" = let
neovimConfigured = (inputs.nvf.lib.neovimConfiguration {
inherit (nixpkgs.legacyPackages."x86_64-linux") pkgs;
modules = [{
config.vim = {
# Enable custom theming options
theme.enable = true;
# Enable Treesitter
tree-sitter.enable = true;
# Other options will go here. Refer to the config
# reference in Appendix B of the nvf manual.
# ...
};
}];
});
in {
# Set the default package to the wrapped instance of Neovim.
# This will allow running your Neovim configuration with
# `nix run` and in addition, sharing your configuration with
# other users in case your repository is public.
default = neovimConfigured.neovim;
};
};
}
```
<!-- TODO: mention the built-in flake template here when it is added -->
The above setup will allow to set up nvf as a standalone flake, which you can
build independently from your system configuration while also possibly sharing
it with others. The next two chapters will detail specific usage of such a setup
for a package output in the context of NixOS or Home-Manager installation.
```{=include=} chapters ```{=include=} chapters
standalone/nixos.md standalone/nixos.md
standalone/home-manager.md standalone/home-manager.md

View file

@ -1,5 +1,9 @@
# Module Installation {#ch-module-installation} # Module Installation {#ch-module-installation}
The below chapters will describe installing nvf as NixOS and Home-Manager
modules. Note that those methods are mutually exclusive, and will likely cause
path collisions if used simultaneously.
```{=include=} chapters ```{=include=} chapters
modules/nixos.md modules/nixos.md
modules/home-manager.md modules/home-manager.md

View file

@ -77,7 +77,9 @@ configure **nvf**.
``` ```
::: {.note} ::: {.note}
**nvf** exposes a lot of options, most of which are not referenced in the **nvf** exposes a lot of options, most of which are not referenced in the
installation sections of the manual. You may find all avaliable options installation sections of the manual. You may find all available options in the
in the [appendix](https://notashelf.github.io/nvf/options) [appendix](https://notashelf.github.io/nvf/options)
::: :::

View file

@ -76,7 +76,9 @@ configure **nvf**.
``` ```
::: {.note} ::: {.note}
**nvf** exposes a lot of options, most of which are not referenced in the **nvf** exposes a lot of options, most of which are not referenced in the
installation sections of the manual. You may find all avaliable options installation sections of the manual. You may find all available options in the
in the [appendix](https://notashelf.github.io/nvf/options) [appendix](https://notashelf.github.io/nvf/options)
::: :::

View file

@ -6,7 +6,7 @@ your system packages to make it available across your system.
The following is an example installation of `nvf` as a standalone package with The following is an example installation of `nvf` as a standalone package with
the default theme enabled. You may use other options inside `config.vim` in the default theme enabled. You may use other options inside `config.vim` in
`configModule`, but this example will not cover that. `configModule`, but this example will not cover that extensively.
```nix ```nix
{ {
@ -30,23 +30,22 @@ the default theme enabled. You may use other options inside `config.vim` in
}; };
customNeovim = nvf.lib.neovimConfiguration { customNeovim = nvf.lib.neovimConfiguration {
modules = [configModule];
inherit pkgs; inherit pkgs;
modules = [configModule];
}; };
in { in {
# this will make the package available as a flake input # This will make the package available as a flake output under 'packages'
packages.${system}.my-neovim = customNeovim.neovim; packages.${system}.my-neovim = customNeovim.neovim;
# this is an example home-manager configuration # Example Home-Manager configuration using the configured Neovim package
# using the built neovim package
homeConfigurations = { homeConfigurations = {
"your-username@your-hostname" = home-manager.lib.homeManagerConfiguration { "your-username@your-hostname" = home-manager.lib.homeManagerConfiguration {
# ... # ...
modules = [ modules = [
./home.nix # This will make Neovim available to users using the Home-Manager
# configuration. To make the package available to all users, prefer
# this will make wrapped neovim available in your system packages # environment.systemPackages in your NixOS configuration.
{environment.systemPackages = [customNeovim.neovim];} {home.packages = [customNeovim.neovim];}
]; ];
# ... # ...
}; };

View file

@ -6,7 +6,7 @@ your system packages to make it available across your system.
The following is an example installation of `nvf` as a standalone package with The following is an example installation of `nvf` as a standalone package with
the default theme enabled. You may use other options inside `config.vim` in the default theme enabled. You may use other options inside `config.vim` in
`configModule`, but this example will not cover that. `configModule`, but this example will not cover that extensively.
```nix ```nix
{ {
@ -30,21 +30,19 @@ the default theme enabled. You may use other options inside `config.vim` in
}; };
customNeovim = nvf.lib.neovimConfiguration { customNeovim = nvf.lib.neovimConfiguration {
modules = [configModule];
inherit pkgs; inherit pkgs;
modules = [configModule];
}; };
in { in {
# this will make the package available as a flake input # This will make the package available as a flake output under 'packages'
packages.${system}.my-neovim = customNeovim.neovim; packages.${system}.my-neovim = customNeovim.neovim;
# this is an example nixosConfiguration using the built neovim package # Example nixosConfiguration using the configured Neovim package
nixosConfigurations = { nixosConfigurations = {
yourHostName = nixpkgs.lib.nixosSystem { yourHostName = nixpkgs.lib.nixosSystem {
# ... # ...
modules = [ modules = [
./configuration.nix # or whatever your configuration is # This will make wrapped neovim available in your system packages
# this will make wrapped neovim available in your system packages
{environment.systemPackages = [customNeovim.neovim];} {environment.systemPackages = [customNeovim.neovim];}
]; ];
# ... # ...

View file

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

View file

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

View file

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

View file

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

13
docs/manual/quirks.md Normal file
View file

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

View file

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

View file

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

View file

@ -1,7 +1,7 @@
# Release Notes {#ch-release-notes} # Release Notes {#ch-release-notes}
This section lists the release notes for tagged version of **nvf** and This section lists the release notes for tagged version of **nvf** and the
the current main current main branch current main current main branch
```{=include=} chapters ```{=include=} chapters
rl-0.1.md rl-0.1.md

View file

@ -1,34 +1,42 @@
# Release 0.1 {#sec-release-0.1} # Release 0.1 {#sec-release-0.1}
This is the current master branch and information here is not final. These are changes from the v0.01 tag. This is the current master branch and information here is not final. These are
changes from the v0.1 tag.
Special thanks to [home-manager](https://github.com/nix-community/home-manager/) for this release. Special thanks to [home-manager](https://github.com/nix-community/home-manager/)
Docs/manual generation, the new module evaluation system, and DAG implementation are from them. for this release. Docs/manual generation, the new module evaluation system, and
DAG implementation are from them.
## Changelog {#sec-release-0.1-changelog} ## Changelog {#sec-release-0.1-changelog}
[jordanisaacs](https://github.com/jordanisaacs): [jordanisaacs](https://github.com/jordanisaacs):
- Removed hare language support (lsp/tree-sitter/etc). `vim.lsp.hare` is no longer defined. - Removed hare language support (lsp/tree-sitter/etc). `vim.lsp.hare` is no
If you use hare and would like it added back, please file an issue. longer defined. If you use hare and would like it added back, please file an
issue.
- [vim.stratPlugins](opt-vim.startPlugins) & [vim.optPlugins](opt-vim.optPlugins) are now - [](#opt-vim.startPlugins) & [](#opt-vim.optPlugins) are now an enum of
an enum of `string` for options sourced from the flake inputs. Users can still provide vim `string` for options sourced from the flake inputs. Users can still provide
plugin packages. vim plugin packages.
- If you are contributing and adding a new plugin, add the plugin name to `availablePlugins` in - If you are contributing and adding a new plugin, add the plugin name to
[types-plugin.nix](https://github.com/jordanisaacs/neovim-flake/blob/20cec032bd74bc3d20ac17ce36cd84786a04fd3e/modules/lib/types-plugin.nix). `availablePlugins` in [types-plugin.nix].
- `neovimBuilder` has been removed for configuration. Using an overlay is no longer required. - `neovimBuilder` has been removed for configuration. Using an overlay is no
See the manual for the new way to configuration. longer required. See the manual for the new way to configuration.
- Treesitter grammars are now configurable with [vim.treesitter.grammars](opt-vim.treesitter.grammars). [relevant discourse post]: https://discourse.nixos.org/t/psa-if-you-are-on-unstable-try-out-nvim-treesitter-withallgrammars/23321?u=snowytrees
Utilizes the nixpkgs `nvim-treesitter` plugin rather than a custom input in order to take advantage of build support of pinned versions.
See [relevant discourse post](https://discourse.nixos.org/t/psa-if-you-are-on-unstable-try-out-nvim-treesitter-withallgrammars/23321?u=snowytrees)
for more information. Packages can be found under the `vimPlugins.nvim-treesitter.builtGrammars` namespace.
- [vim.configRC](opt-vim.configRC) and [vim.luaConfigRC](opt-vim.luaConfigRC) are now of type DAG lines. - Treesitter grammars are now configurable with
This allows for ordering of the config. Usage is the same is in home-manager's `home.activation` option. [](#opt-vim.treesitter.grammars). Utilizes the nixpkgs `nvim-treesitter`
plugin rather than a custom input in order to take advantage of build support
of pinned versions. See the [relevant discourse post] for more information.
Packages can be found under the `vimPlugins.nvim-treesitter.builtGrammars`
namespace.
- `vim.configRC` and [](#opt-vim.luaConfigRC) are now of type DAG lines. This
allows for ordering of the config. Usage is the same is in home-manager's
`home.activation` option.
```nix ```nix
vim.luaConfigRC = lib.nvim.dag.entryAnywhere "config here" vim.luaConfigRC = lib.nvim.dag.entryAnywhere "config here"
@ -36,5 +44,5 @@ vim.luaConfigRC = lib.nvim.dag.entryAnywhere "config here"
[MoritzBoehme](https://github.com/MoritzBoehme): [MoritzBoehme](https://github.com/MoritzBoehme):
- `catppuccin` theme is now available as a neovim theme [vim.theme.style](opt-vim.theme.style) and lualine theme - `catppuccin` theme is now available as a neovim theme [](#opt-vim.theme.style)
[vim.statusline.lualine.theme](opt-vim.statusline.lualine.theme). and Lualine theme [](#opt-vim.statusline.lualine.theme).

View file

@ -6,48 +6,59 @@ Release notes for release 0.2
[notashelf](https://github.com/notashelf): [notashelf](https://github.com/notashelf):
- Added two minimap plugins under `vim.minimap`. `codewindow.nvim` is enabled by default, while `minimap.vim` is - Added two minimap plugins under `vim.minimap`. `codewindow.nvim` is enabled by
available with its code-minimap dependency. default, while `minimap.vim` is available with its code-minimap dependency.
- A complementary plugin, `obsidian.nvim` and the Neovim alternative for Emacs' orgmode with `orgmode.nvim` have been - A complementary plugin, `obsidian.nvim` and the Neovim alternative for Emacs'
added. Both will be disabled by default. orgmode with `orgmode.nvim` have been added. Both will be disabled by default.
- Smooth scrolling for ANY movement command is now available with `cinnamon.nvim` - Smooth scrolling for ANY movement command is now available with
`cinnamon.nvim`
- You will now notice a dashboard on startup. This is provided by the `alpha.nvim` plugin. You can use any of the - You will now notice a dashboard on startup. This is provided by the
three available dashboard plugins, or disable them entirely. `alpha.nvim` plugin. You can use any of the three available dashboard plugins,
or disable them entirely.
- There is now a scrollbar on active buffers, which can highlight errors by hooking to your LSPs. This is on by - There is now a scrollbar on active buffers, which can highlight errors by
default, but can be toggled off under `vim.visuals` if seen necessary. hooking to your LSPs. This is on by default, but can be toggled off under
`vim.visuals` if seen necessary.
- Discord Rich Presence has been added through `presence.nvim` for those who want to flex that they are using - Discord Rich Presence has been added through `presence.nvim` for those who
the _superior_ text editor. want to flex that they are using the _superior_ text editor.
- An icon picker is now available with telescope integration. You can use `:IconPickerInsert` or `:IconPickerYank` - An icon picker is now available with telescope integration. You can use
to add icons to your code. `:IconPickerInsert` or `:IconPickerYank` to add icons to your code.
- A general-purpose cheatsheet has been added through `cheatsheet.nvim`. Forget no longer! - A general-purpose cheatsheet has been added through `cheatsheet.nvim`. Forget
no longer!
- `ccc.nvim` has been added to the default plugins to allow picking colors with ease. - `ccc.nvim` has been added to the default plugins to allow picking colors with
ease.
- Most UI components of Neovim have been replaced through the help of `noice.nvim`. There are also notifications - Most UI components of Neovim have been replaced through the help of
and custom UI elements available for Neovim messages and prompts. `noice.nvim`. There are also notifications and custom UI elements available
for Neovim messages and prompts.
- A (floating by default) terminal has been added through `toggleterm.nvim`. - A (floating by default) terminal has been added through `toggleterm.nvim`.
- Harness the power of ethical (`tabnine.nvim`) and not-so-ethical (`copilot.lua`) AI by those new assistant plugins. - Harness the power of ethical (`tabnine.nvim`) and not-so-ethical
Both are off by default, TabNine needs to be wrapped before it's working. (`copilot.lua`) AI by those new assistant plugins. Both are off by default,
TabNine needs to be wrapped before it's working.
- Experimental mouse gestures have been added through `gesture.nvim`. See plugin page and the relevant module for - Experimental mouse gestures have been added through `gesture.nvim`. See plugin
more details on how to use. page and the relevant module for more details on how to use.
- Re-open last visited buffers via `nvim-session-manager`. Disabled by default as deleting buffers seems to be - Re-open last visited buffers via `nvim-session-manager`. Disabled by default
problematic at the moment. as deleting buffers seems to be problematic at the moment.
- Most of NvimTree's configuration options have been changed with some options being toggled to off by default. - Most of NvimTree's configuration options have been changed with some options
being toggled to off by default.
- Lualine had its configuration simplified and style toned down. Less color, more info. - Lualine had its configuration simplified and style toned down. Less color,
more info.
- Modules where multiple plugin configurations were in the same directory have been simplified. Each plugin inside - Modules where multiple plugin configurations were in the same directory have
a single module gets its directory to be imported. been simplified. Each plugin inside a single module gets its directory to be
imported.
- Separate config options with the same parent attribute have been merged into one for simplicity. - Separate config options with the same parent attribute have been merged into
one for simplicity.

View file

@ -1,67 +1,88 @@
# Release 0.3 {#sec-release-0.3} # Release 0.3 {#sec-release-0.3}
Release 0.3 had to come out beore I wanted it to due to Neovim 0.9 dropping into nixpkgs-unstable. Release 0.3 had to come out before I wanted it to due to Neovim 0.9 dropping
The treesitter changes have prompted a treesitter rework, which was followed by reworking the languages system. into nixpkgs-unstable. The Treesitter changes have prompted a Treesitter rework,
Most of the changes to those are downstreamed from the original repository. The feature requests that was originally which was followed by reworking the languages system. Most of the changes to
planned for 0.3 have been moved to 0.4, which should come out soon. those are downstreamed from the original repository. The feature requests that
was originally planned for 0.3 have been moved to 0.4, which should come out
soon.
## Changelog {#sec-release-0.3-changelog} ## Changelog {#sec-release-0.3-changelog}
- We have transitioned to flake-parts, from flake-utils to extend the flexibility of this flake. This means the flake structure - We have transitioned to flake-parts, from flake-utils to extend the
is different than usual, but the functionality remains the same. flexibility of this flake. This means the flake structure is different than
usual, but the functionality remains the same.
- We now provide a home-manager module. Do note that it is still far from perfect, but it works. - We now provide a home-manager module. Do note that it is still far from
perfect, but it works.
- `nodejs_16` is now bundled with `Copilot.lua` if the user has enabled Copilot assistant. - `nodejs_16` is now bundled with `Copilot.lua` if the user has enabled Copilot
assistant.
- which-key section titles have been fixed. This is to be changed once again in a possible keybind rewrite, but now it should - which-key section titles have been fixed. This is to be changed once again in
display the correct titles instad of `+prefix` a possible keybind rewrite, but now it should display the correct titles
instead of `+prefix`
- Most of `presence.nvim`'s options have been made fully configurable through your configuration file. - Most of `presence.nvim`'s options have been made fully configurable through
your configuration file.
- Most of the modules have been refactored to separate `config` and `options` attributes. - Most of the modules have been refactored to separate `config` and `options`
attributes.
- Darwin has been deprecated as the zig package is marked as broken. We will attempt to use the zig overlay to return Darwin - Darwin has been deprecated as the Zig package is marked as broken. We will
support. attempt to use the Zig overlay to return Darwin support.
- `Fidget.nvim` has been added as a neat visual addition for LSP installations. - `Fidget.nvim` has been added as a neat visual addition for LSP installations.
- `diffview.nvim` has been added to provide a convenient diff utility. - `diffview.nvim` has been added to provide a convenient diff utility.
- Treesitter grammars are now configurable with [vim.treesitter.grammars](vim.treesitter.grammars). [discourse]: https://discourse.nixos.org/t/psa-if-you-are-on-unstable-try-out-nvim-treesitter-withallgrammars/23321?u=snowytrees
Utilizes the nixpkgs `nvim-treesitter` plugin rather than a custom input in order to take advantage of build support of pinned versions.
See [discourse](https://discourse.nixos.org/t/psa-if-you-are-on-unstable-try-out-nvim-treesitter-withallgrammars/23321?u=snowytrees) for more information. - Treesitter grammars are now configurable with
Packages can be found under the `pkgs.vimPlugins.nvim-treesitter.builtGrammars` attribute. Treesitter grammars for supported languages should be [](#opt-vim.treesitter.grammars). Utilizes the nixpkgs `nvim-treesitter`
enabled within the module. By default no grammars are installed, thus the following grammars which do not have a language section are not included anymore: plugin rather than a custom input in order to take advantage of build support
**comment**, **toml**, **make**, **html**, **css**, **graphql**, **json**. of pinned versions. See [discourse] for more information. Packages can be
found under the `pkgs.vimPlugins.nvim-treesitter.builtGrammars` attribute.
Treesitter grammars for supported languages should be enabled within the
module. By default no grammars are installed, thus the following grammars
which do not have a language section are not included anymore: **comment**,
**toml**, **make**, **html**, **css**, **graphql**, **json**.
- A new section has been added for language support: `vim.languages.<language>`. - A new section has been added for language support: `vim.languages.<language>`.
- The options [vim.languages.enableLSP](vim.languages.enableLSP), [vim.languages.enableTreesitter](vim.languages.enableTreesitter), etc. - The options [](#opt-vim.languages.enableLSP),
will enable the respective section for all languages that have been enabled. [](#opt-vim.languages.enableTreesitter), etc. will enable the respective
section for all languages that have been enabled.
- All LSP languages have been moved here - All LSP languages have been moved here
- `plantuml` and `markdown` have been moved here - `plantuml` and `markdown` have been moved here
- A new section has been added for `html`. The old `vim.treesitter.autotagHtml` can be found at <<opt-vim.languages.html.treesitter.autotagHtml>>. - A new section has been added for `html`. The old
`vim.treesitter.autotagHtml` can be found at
[](#opt-vim.languages.html.treesitter.autotagHtml).
- [vim.git.gitsigns.codeActions](vim.git.gitsigns.codeActions) has been added allowing you to turn on gitsigns codeactions. - `vim.git.gitsigns.codeActions` has been added, allowing you to turn on
Gitsigns' code actions.
- Removed the plugins document in the docs. Was too unwieldy to keep updated. - Removed the plugins document in the docs. Was too unwieldy to keep updated.
- `vim.visual.lspkind` has been moved to [vim.lsp.lspkind.enable](vim.lsp.lspkind.enable) - `vim.visual.lspkind` has been moved to [](#opt-vim.lsp.lspkind.enable)
- Improved handling of completion formatting. When setting [vim.autocomplete.sources](vim.autocomplete.sources), can also include optional menu mapping. - Improved handling of completion formatting. When setting
And can provide your own function with [vim.autocomplete.formatting.format](vim.autocomplete.formatting.format). `vim.autocomplete.sources`, can also include optional menu mapping. And can
provide your own function with `vim.autocomplete.formatting.format`.
- For [vim.visuals.indentBlankline.fillChar](vim.visuals.indentBlankline.fillChar) and [vim.visuals.indentBlankline.eolChar](vim.visuals.indentBlankline.eolChar) - For `vim.visuals.indentBlankline.fillChar` and
turning them off should use `null` rather than `""` now. `vim.visuals.indentBlankline.eolChar` options, turning them off should be done
by using `null` rather than `""` now.
- Transparency has been made optional and has been disabled by default. [vim.theme.transparent](vim.theme.transparent) option can be used to enable or - Transparency has been made optional and has been disabled by default.
disable transparency for your configuration. [](#opt-vim.theme.transparent) option can be used to enable or disable
transparency for your configuration.
- Fixed deprecated configuration method for Tokyonight, and added new style "moon" - Fixed deprecated configuration method for Tokyonight, and added new style
"moon"
- Dart language support as well as extended flutter support has been added. Thanks to @FlafyDev for his contributions towards Dart - Dart language support as well as extended flutter support has been added.
language support. Thanks to @FlafyDev for his contributions towards Dart language support.
- Elixir language support has been added through `elixir-tools.nvim`. - Elixir language support has been added through `elixir-tools.nvim`.
@ -69,13 +90,14 @@ planned for 0.3 have been moved to 0.4, which should come out soon.
- `modes.nvim` has been added to the UI plugins as a minor error highlighter. - `modes.nvim` has been added to the UI plugins as a minor error highlighter.
- `smartcollumn.nvim` has been added to dynamically display a colorcolumn when the limit has been exceeded, providing - `smartcollumn.nvim` has been added to dynamically display a colorcolumn when
per-buftype column position and more. the limit has been exceeded, providing per-buftype column position and more.
- `project.nvim` has been added for better project management inside Neovim. - `project.nvim` has been added for better project management inside Neovim.
- More configuration options have been added to `nvim-session-manager`. - More configuration options have been added to `nvim-session-manager`.
- Editorconfig support has been added to the core functionality, with an enable option. - Editorconfig support has been added to the core functionality, with an enable
option.
- `venn-nvim` has been dropped due to broken keybinds. - `venn-nvim` has been dropped due to broken keybinds.

View file

@ -1,12 +1,16 @@
# Release 0.4 {#sec-release-0.4} # Release 0.4 {#sec-release-0.4}
Following the release of v0.3, I have decided to release v0.4 with a massive new change: customizable keybinds. Following the release of v0.3, I have decided to release v0.4 with a massive new
As of the 0.4 release, keybinds will no longer be hardcoded and instead provided by each module's own keybinds section. change: customizable keybinds. As of the 0.4 release, keybinds will no longer be
The old keybind system (`vim.keybinds = {}`) is now considered deprecated and the new lib functions are recommended to be hardcoded and instead provided by each module's own keybinds section. The old
used for adding keybinds for new plugins, or adding keybinds to existing plugins. keybind system (`vim.keybinds = {}`) is now considered deprecated and the new
lib functions are recommended to be used for adding keybinds for new plugins, or
adding keybinds to existing plugins.
Alongside customizable keybinds, there are a few quality of life updates, such as `lazygit` integration and the Alongside customizable keybinds, there are a few quality of life updates, such
new experimental Lua loader of Neovim 0.9 thanks to our awesome contributors who made this update possible during my absence. as `lazygit` integration and the new experimental Lua loader of Neovim 0.9
thanks to our awesome contributors who made this update possible during my
absence.
## Changelog {#sec-release-0.4-changelog} ## Changelog {#sec-release-0.4-changelog}
@ -18,7 +22,8 @@ new experimental Lua loader of Neovim 0.9 thanks to our awesome contributors who
- Simplified luaConfigRC and configRC setting - they can now just take strings - Simplified luaConfigRC and configRC setting - they can now just take strings
- Refactored the resolveDag function - you can just provide a string now, which will default to dag.entryAnywhere - Refactored the resolveDag function - you can just provide a string now, which
will default to dag.entryAnywhere
- Fixed formatting sometimes removing parts of files - Fixed formatting sometimes removing parts of files
@ -32,7 +37,8 @@ new experimental Lua loader of Neovim 0.9 thanks to our awesome contributors who
- Added `toggleterm` integration for `lazygit`. - Added `toggleterm` integration for `lazygit`.
- Added new option `enableluaLoader` to enable neovim's experimental module loader for faster startup time. - Added new option `enableluaLoader` to enable neovim's experimental module
loader for faster startup time.
- Fixed bug where flutter-tools can't find `dart` LSP - Fixed bug where flutter-tools can't find `dart` LSP
@ -40,23 +46,28 @@ new experimental Lua loader of Neovim 0.9 thanks to our awesome contributors who
[notashelf](https://github.com/notashelf): [notashelf](https://github.com/notashelf):
- Made Copilot's Node package configurable. It is recommended to keep as default, but providing a different NodeJS version is now possible. - Made Copilot's Node package configurable. It is recommended to keep as
default, but providing a different NodeJS version is now possible.
- Added [vim.cursorlineOpt](vim.cursorlineOpt) for configuring Neovim's cursorlineOpt. - Added `vim.cursorlineOpt` for configuring Neovim's `vim.o.cursorlineopt`.
- Added `filetree.nvimTreeLua.view.cursorline`, default false, to enable cursorline in nvimtre. - Added `filetree.nvimTreeLua.view.cursorline`, default false, to enable
cursorline in nvimtre.
- Added Fidget.nvim support for the Catppuccin theme. - Added Fidget.nvim support for the Catppuccin theme.
- Updated bundled NodeJS version used by `Copilot.lua`. v16 is now marked as insecure on Nixpkgs, and we updated to v18 - Updated bundled NodeJS version used by `Copilot.lua`. v16 is now marked as
insecure on Nixpkgs, and we updated to v18
- Enabled Catppuccin modules for plugins available by default. - Enabled Catppuccin modules for plugins available by default.
- Added experimental Svelte support under `vim.languages`. - Added experimental Svelte support under `vim.languages`.
- Removed unnecessary scrollbar element from notifications and codeaction warning UI. - Removed unnecessary scrollbar element from notifications and codeaction
warning UI.
- `vim.utility.colorizer` has been renamed to `vim.utility.ccc` after the plugin it uses - `vim.utility.colorizer` has been renamed to `vim.utility.ccc` after the plugin
it uses
- Color preview via `nvim-colorizer.lua` - Color preview via `nvim-colorizer.lua`
@ -66,7 +77,8 @@ new experimental Lua loader of Neovim 0.9 thanks to our awesome contributors who
- Added a module for enabling Neovim's spellchecker - Added a module for enabling Neovim's spellchecker
- Added prettierd as an alternative formatter to prettier - currently defaults to prettier - Added prettierd as an alternative formatter to prettier - currently defaults
to prettier
- Fixed presence.nvim inheriting the wrong client id - Fixed presence.nvim inheriting the wrong client id

View file

@ -16,33 +16,35 @@ Release notes for release 0.5
- Fixed a bug where cmp's close and scrollDocs mappings wasn't working - Fixed a bug where cmp's close and scrollDocs mappings wasn't working
- Streamlined and simplified extra plugin API with the addition of [vim.extraPlugins](vim.extraPlugins) - Streamlined and simplified extra plugin API with the addition of
[](#opt-vim.extraPlugins)
- Allow using command names in place of LSP packages to avoid automatic installation - Allow using command names in place of LSP packages to avoid automatic
installation
- Add lua LSP and treesitter support, and neodev.nvim plugin support - Add lua LSP and Treesitter support, and neodev.nvim plugin support
- Add [vim.lsp.mappings.toggleFormatOnSave](vim.lsp.mappings.toggleFormatOnSave) keybind - Add [](#opt-vim.lsp.mappings.toggleFormatOnSave) keybind
[amanse](https://github.com/amanse): [amanse](https://github.com/amanse):
- Added daily notes options for obsidian plugin - Added daily notes options for obsidian plugin
- Added jdt-language-server for Java - Added `jdt-language-server` for Java
[yavko](https://github.com/yavko): [yavko](https://github.com/yavko):
- Added Deno Language Server for javascript/typescript - Added Deno Language Server for Javascript/Typescript
- Added support for multiple languages [vim.spellChecking.languages](vim.spellChecking.languages), and added - Added support for multiple languages under `vim.spellChecking.languages`, and
vim-dirtytalk through [vim.spellChecking.enableProgrammingWordList](vim.spellChecking.enableProgrammingWordList) added vim-dirtytalk through `vim.spellChecking.enableProgrammingWordList`
[frothymarrow](https://github.com/FrothyMarrow): [frothymarrow](https://github.com/FrothyMarrow):
- Renamed `vim.visuals.cursorWordline` to [vim.visuals.cursorline.enable](vim.visuals.cursorline.enable) - Renamed `vim.visuals.cursorWordline` to `vim.visuals.cursorline.enable`
- Added [vim.visuals.cursorline.lineNumbersOnly](vim.visuals.cursorline.lineNumbersOnly) to display cursorline - Added `vim.visuals.cursorline.lineNumbersOnly` to display cursorline only in
only in the presence of line numbers the presence of line numbers
- Added Oxocarbon to the list of available themes. - Added Oxocarbon to the list of available themes.
@ -50,38 +52,44 @@ Release notes for release 0.5
- Added GitHub Copilot to nvim-cmp completion sources. - Added GitHub Copilot to nvim-cmp completion sources.
- Added [vim.ui.borders.enable](vim.ui.borders.enable) for global and individual plugin border configuration. - Added [](#opt-vim.ui.borders.enable) for global and individual plugin border
configuration.
- LSP integrated breadcrumbs with [vim.ui.breadcrumbs.enable](vim.ui.breadcrumbs.enable) through nvim-navic - LSP integrated breadcrumbs with [](#opt-vim.ui.breadcrumbs.enable) through
nvim-navic
- LSP navigation helper with nvim-navbuddy, depends on nvim-navic (automatically enabled if navic is enabled) - LSP navigation helper with nvim-navbuddy, depends on nvim-navic (automatically
enabled if navic is enabled)
- Addeed nvim-navic integration for catppuccin theme - Added nvim-navic integration for Catppuccin theme
- Fixed mismatching zig language description - Fixed mismatching Zig language description
- Added support for `statix` and `deadnix` through [vim.languages.nix.extraDiagnostics.types](vim.languages.nix.extraDiagnostics.types) - Added support for `statix` and `deadnix` through
[](#opt-vim.languages.nix.extraDiagnostics.types)
- Added `lsp_lines` plugin for showing diagnostic messages - Added `lsp_lines` plugin for showing diagnostic messages
- Added a configuration option for choosing the leader key - Added a configuration option for choosing the leader key
- The package used for neovim is now customizable by the user, using [vim.package](vim.package). - The package used for neovim is now customizable by the user, using
For best results, always use an unwrapped package [](#opt-vim.package). For best results, always use an unwrapped package
- Added highlight-undo plugin for highlighting undo/redo targets - Added highlight-undo plugin for highlighting undo/redo targets
- Added bash LSP and formatter support - Added bash LSP and formatter support
- Disabled Lualine LSP status indicator for toggleterm buffer - Disabled Lualine LSP status indicator for Toggleterm buffer
- Added `nvim-docs-view`, a plugin to display lsp hover documentation in a side panel - Added `nvim-docs-view`, a plugin to display LSP hover documentation in a side
panel
- Switched to `nixosOptionsDoc` in option documentation. - Switched to `nixosOptionsDoc` in option documentation. To quote home-manager
To quote home-manager commit: "Output is mostly unchanged aside from some minor typographical and commit: "Output is mostly unchanged aside from some minor typographical and
formatting changes, along with better source links." formatting changes, along with better source links."
- Updated indent-blankine.nvim to v3 - this comes with a few option changes, which will be migrated with `renamedOptionModule` - Updated indent-blankine.nvim to v3 - this comes with a few option changes,
which will be migrated with `renamedOptionModule`
[jacekpoz](https://jacekpoz.pl): [jacekpoz](https://jacekpoz.pl):
@ -99,9 +107,11 @@ Release notes for release 0.5
- Removed redundant "Enable ..." in `mkEnableOption` descriptions - Removed redundant "Enable ..." in `mkEnableOption` descriptions
- Add options to modify LSP key bindings and add proper whichkey descriptions - Add options to modify LSP key bindings and add proper which-key descriptions
- Changed type of `statusline.lualine.activeSection` and `statusline.lualine.inactiveSection` - Changed type of `statusline.lualine.activeSection` and
from `attrsOf str` to `attrsOf (listOf str)` `statusline.lualine.inactiveSection` from `attrsOf str` to
`attrsOf (listOf str)`
- Added `statusline.lualine.extraActiveSection` and `statusline.lualine.extraInactiveSection` - Added `statusline.lualine.extraActiveSection` and
`statusline.lualine.extraInactiveSection`

View file

@ -4,17 +4,21 @@ Release notes for release 0.6
## Breaking Changes and Migration Guide {#sec-breaking-changes-and-migration-guide} ## Breaking Changes and Migration Guide {#sec-breaking-changes-and-migration-guide}
In v0.6 we are introducing `setupOpts`: many plugin related options are moved into their respective `setupOpts` In v0.6 we are introducing `setupOpts`: many plugin related options are moved
submodule, e.g. `nvimTree.disableNetrw` is renamed to `nvimTree.setupOpts.disable_netrw`. into their respective `setupOpts` submodule, e.g. `nvimTree.disableNetrw` is
renamed to `nvimTree.setupOpts.disable_netrw`.
_Why?_ in short, you can now pass in anything to setupOpts and it will be passed to your `require'plugin'.setup{...}`. _Why?_ in short, you can now pass in anything to setupOpts and it will be passed
No need to wait for us to support every single plugin option. to your `require'plugin'.setup{...}`. No need to wait for us to support every
single plugin option.
The warnings when you rebuild your config should be enough to guide you through what you need to do, if there's an The warnings when you rebuild your config should be enough to guide you through
option that was renamed but wasn't listed in the warning, please file a bug report! what you need to do, if there's an option that was renamed but wasn't listed in
the warning, please file a bug report!
To make your migration process less annoying, here's a keybind that will help you with renaming stuff from camelCase to To make your migration process less annoying, here's a keybind that will help
snake_case (you'll be doing that a lot): you with renaming stuff from camelCase to snake_case (you'll be doing that a
lot):
```lua ```lua
-- paste this in a temp.lua file and load it in vim with :source /path/to/temp.lua -- paste this in a temp.lua file and load it in vim with :source /path/to/temp.lua
@ -43,8 +47,9 @@ vim.api.nvim_set_keymap('n', '<leader>a', ':lua camelToSnake()<CR>', { noremap =
- Added Terraform language support. - Added Terraform language support.
- Added `ChatGPT.nvim`, which can be enabled with [`vim.assistant.chatgpt`](vim.assistant.chatgpt). Do - Added `ChatGPT.nvim`, which can be enabled with
keep in mind that this option requires `OPENAI_API_KEY` environment variable to be set. [](#opt-vim.assistant.chatgpt.enable). Do keep in mind that this option
requires `OPENAI_API_KEY` environment variable to be set.
[donnerinoern](https://github.com/donnerinoern): [donnerinoern](https://github.com/donnerinoern):
@ -52,11 +57,13 @@ vim.api.nvim_set_keymap('n', '<leader>a', ':lua camelToSnake()<CR>', { noremap =
- Added marksman LSP for Markdown. - Added marksman LSP for Markdown.
- Fixed markdown preview with Glow not working and added an option for changing the preview keybind. - Fixed markdown preview with Glow not working and added an option for changing
the preview keybind.
- colorizer.nvim: switched to a maintained fork. - colorizer.nvim: switched to a maintained fork.
- Added `markdown-preview.nvim`, moved `glow.nvim` to a brand new `vim.utility.preview` category. - Added `markdown-preview.nvim`, moved `glow.nvim` to a brand new
`vim.utility.preview` category.
[elijahimmer](https://github.com/elijahimmer) [elijahimmer](https://github.com/elijahimmer)
@ -64,7 +71,8 @@ vim.api.nvim_set_keymap('n', '<leader>a', ':lua camelToSnake()<CR>', { noremap =
[jacekpoz](https://jacekpoz.pl): [jacekpoz](https://jacekpoz.pl):
- Added `vim.autocomplete.alwaysComplete`. Allows users to have the autocomplete window popup only when manually activated. - Added `vim.autocomplete.alwaysComplete`. Allows users to have the autocomplete
window popup only when manually activated.
[horriblename](https://github.com/horriblename): [horriblename](https://github.com/horriblename):
@ -80,11 +88,14 @@ vim.api.nvim_set_keymap('n', '<leader>a', ':lua camelToSnake()<CR>', { noremap =
- Added option `vim.luaPackages` to wrap neovim with extra Lua packages. - Added option `vim.luaPackages` to wrap neovim with extra Lua packages.
- Rewrote the entire `fidget.nvim` module to include extensive configuration options. Option `vim.fidget-nvim.align.bottom` has - Rewrote the entire `fidget.nvim` module to include extensive configuration
been removed in favor of [vim.fidget-nvim.notification.window.align](vim.fidget-nvim.notification.window.align), which now supports options. Option `vim.fidget-nvim.align.bottom` has been removed in favor of
`top` and `bottom` values. `vim.fidget-nvim.align.right` has no longer any equivalent and also has been removed. `vim.fidget-nvim.notification.window.align`, which now supports `top` and
`bottom` values. `vim.fidget-nvim.align.right` has no longer any equivalent
and also has been removed.
- `which-key.nvim` categories can now be customized through [vim.binds.whichKey.register](vim.binds.whichKey.register) - `which-key.nvim` categories can now be customized through
[vim.binds.whichKey.register](#opt-vim.binds.whichKey.register)
- Added `magick` to `vim.luaPackages` for `image.nvim`. - Added `magick` to `vim.luaPackages` for `image.nvim`.
@ -94,65 +105,79 @@ vim.api.nvim_set_keymap('n', '<leader>a', ':lua camelToSnake()<CR>', { noremap =
[notashelf](https://github.com/notashelf): [notashelf](https://github.com/notashelf):
- Finished moving to `nixosOptionsDoc` in the documentation and changelog. All documentation options - Finished moving to `nixosOptionsDoc` in the documentation and changelog. All
and files are fully free of Asciidoc, and will now use Nixpkgs flavored markdown. documentation options and files are fully free of Asciidoc, and will now use
Nixpkgs flavored markdown.
- Bumped plugin inputs to their latest versions. - Bumped plugin inputs to their latest versions.
- Deprecated `presence.nvim` in favor of `neocord`. This means `vim.rich-presence.presence-nvim` is removed and will throw - Deprecated `presence.nvim` in favor of `neocord`. This means
a warning if used. You are recommended to rewrite your neocord configuration from scratch based on the. `vim.rich-presence.presence-nvim` is removed and will throw a warning if used.
[official documentation](https://github.com/IogaMaster/neocord) You are recommended to rewrite your neocord configuration from scratch based
on the. [official documentation](https://github.com/IogaMaster/neocord)
- Removed Tabnine plugin due to the usage of imperative tarball downloads. If you'd like to see it back, please create an issue. - Removed Tabnine plugin due to the usage of imperative tarball downloads. If
you'd like to see it back, please create an issue.
- Added support for css and tailwindcss through vscode-language-servers-extracted & tailwind-language-server. - Added support for css and tailwindcss through
Those can be enabled through `vim.languages.css` and `vim.languages.tailwind`. vscode-language-servers-extracted & tailwind-language-server. Those can be
enabled through `vim.languages.css` and `vim.languages.tailwind`.
- Lualine module now allows customizing `always_divide_middle`, `ignore_focus` and `disabled_filetypes` through the new - Lualine module now allows customizing `always_divide_middle`, `ignore_focus`
options: [vim.statusline.lualine.alwaysDivideMiddle](vim.statusline.lualine.alwaysDivideMiddle), and `disabled_filetypes` through the new options:
[vim.statusline.lualine.ignoreFocus](vim.statusline.lualine.ignoreFocus) and [vim.statusline.lualine.alwaysDivideMiddle](#opt-vim.statusline.lualine.alwaysDivideMiddle),
[vim.statusline.lualine.disabledFiletypes](vim.statusline.lualine.disabledFiletypes). [vim.statusline.lualine.ignoreFocus](#opt-vim.statusline.lualine.ignoreFocus)
and
[vim.statusline.lualine.disabledFiletypes](#opt-vim.statusline.lualine.disabledFiletypes).
- Updated all plugin inputs to their latest versions (**21.04.2024**) - this brought minor color changes to the Catppuccin - Updated all plugin inputs to their latest versions (**21.04.2024**) - this
theme. brought minor color changes to the Catppuccin theme.
- Moved home-manager module entrypoint to `flake/modules` and added an experimental Nixos module. This requires further testing - Moved home-manager module entrypoint to `flake/modules` and added an
before it can be considered ready for use. experimental Nixos module. This requires further testing before it can be
considered ready for use.
- Made lib calls explicit. E.g. `lib.strings.optionalString` instead of `lib.optionalString`. This is a pattern expected - Made lib calls explicit. E.g. `lib.strings.optionalString` instead of
to be followed by all contributors in the future. `lib.optionalString`. This is a pattern expected to be followed by all
contributors in the future.
- Added `image.nvim` for image previews. - Added `image.nvim` for image previews.
- The final neovim package is now exposed. This means you can build the neovim package that will be added to your - The final neovim package is now exposed. This means you can build the neovim
package list without rebuilding your system to test if your configuration yields a broken package. package that will be added to your package list without rebuilding your system
to test if your configuration yields a broken package.
- Changed the tree structure to distinguish between core options and plugin options. - Changed the tree structure to distinguish between core options and plugin
options.
- Added plugin auto-discovery from plugin inputs. This is mostly from - Added plugin auto-discovery from plugin inputs. This is mostly from
[JordanIsaac's neovim-flake](https://github.com/jordanisaacs/neovim-flake). Allows contributors to add plugin inputs [JordanIsaac's neovim-flake](https://github.com/jordanisaacs/neovim-flake).
with the `plugin-` prefix to have them automatically discovered for the `plugin` type in `lib/types`. Allows contributors to add plugin inputs with the `plugin-` prefix to have
them automatically discovered for the `plugin` type in `lib/types`.
- Moved internal `wrapLuaConfig` to the extended library, structured its arguments to take `luaBefore`, `luaConfig` - Moved internal `wrapLuaConfig` to the extended library, structured its
and `luaAfter` as strings, which are then concatted inside a lua block. arguments to take `luaBefore`, `luaConfig` and `luaAfter` as strings, which
are then concatted inside a lua block.
- Added [`vim.luaConfigBefore`](vim.luaConfigBefore) and [`vim.luaConfigAfter`](vim.luaConfigAfter) - Added [](#opt-vim.luaConfigPre) and [](#opt-vim.luaConfigPost) for inserting
for inserting verbatim Lua configuration before and after the resolved Lua DAG respectively. Both of those options verbatim Lua configuration before and after the resolved Lua DAG respectively.
take strings as the type, so you may read the contents of a Lua file from a given path. Both of those options take strings as the type, so you may read the contents
of a Lua file from a given path.
- Added [`vim.spellChecking.ignoredFiletypes`](vim.spellChecking.ignoredFiletypes) - Added `vim.spellchecking.ignoredFiletypes` and
and [`vim.spellChecking.programmingWordlist.enable`](vim.spellChecking.programmingWordlist.enable) for ignoring certain filetypes `vim.spellChecking.programmingWordlist.enable` for ignoring certain filetypes
in spellchecking and enabling `vim-dirtytalk` respectively. The previously used `vim.spellcheck.vim-dirtytalk` aliases to the latter in spellchecking and enabling `vim-dirtytalk` respectively. The previously
option. used `vim.spellcheck.vim-dirtytalk` aliases to the latter option.
- Exposed `withRuby`, `withNodeJs`, `withPython3`, and `python3Packages` from the `makeNeovimConfig` function under their respective options. - Exposed `withRuby`, `withNodeJs`, `withPython3`, and `python3Packages` from
the `makeNeovimConfig` function under their respective options.
- Added [`vim.extraPackages`](vim.extraPackages) for appending additional packages to the wrapper PATH, making said packages available - Added [](#opt-vim.extraPackages) for appending additional packages to the
while inside the Neovim session. wrapper PATH, making said packages available while inside the Neovim session.
- Made treesitter options configurable, and moved `treesitter-context to - Made Treesitter options configurable, and moved treesitter-context to
`setupOpts` while it is enabled. `setupOpts` while it is enabled.
- Added `vim.notify.nvim-notify.setupOpts.render` which takes either a string of enum or - Added [](#opt-vim.notify.nvim-notify.setupOpts.render) which takes either a
a lua function. The default is "compact", but you may change it according to string of enum, or a Lua function. The default is "compact", but you may
nvim-notify documentation. change it according to nvim-notify documentation.

View file

@ -26,6 +26,32 @@ making good use of its extensive Lua API. Additionally, Vimscript is slow and
brings unnecessary performance overhead while working with different brings unnecessary performance overhead while working with different
configuration formats. configuration formats.
### `vim.maps` rewrite {#sec-vim-maps-rewrite}
Instead of specifying map modes using submodules (eg.: `vim.maps.normal`), a new
`vim.keymaps` submodule with support for a `mode` option has been introduced. It
can be either a string, or a list of strings, where a string represents the
short-name of the map mode(s), that the mapping should be set for. See
`:help map-modes` for more information.
For example:
```nix
vim.maps.normal."<leader>m" = { ... };
```
has to be replaced by
```nix
vim.keymaps = [
{
key = "<leader>m";
mode = "n";
}
...
];
```
### `vim.lsp.nvimCodeActionMenu` removed in favor of `vim.ui.fastaction` {#sec-nvim-code-action-menu-deprecation} ### `vim.lsp.nvimCodeActionMenu` removed in favor of `vim.ui.fastaction` {#sec-nvim-code-action-menu-deprecation}
The nvim-code-action-menu plugin has been archived and broken for a long time, The nvim-code-action-menu plugin has been archived and broken for a long time,
@ -37,6 +63,58 @@ Note that we are looking to add more alternatives in the future like
dressing.nvim and actions-preview.nvim, in case fastaction doesn't work for dressing.nvim and actions-preview.nvim, in case fastaction doesn't work for
everyone. everyone.
### `type` based modules removed {#sec-type-based-modules-removed}
As part of the autocompletion rewrite, modules that used to use a `type` option
have been replaced by per-plugin modules instead. Since both modules only had
one type, you can simply change
- `vim.autocomplete.*` -> `vim.autocomplete.nvim-cmp.*`
- `vim.autopairs.enable` -> `vim.autopairs.nvim-autopairs.enable`
### `nixpkgs-fmt` removed in favor of `nixfmt` {#sec-nixpkgs-fmt-deprecation}
`nixpkgs-fmt` has been archived for a while, and it's finally being removed in
favor of nixfmt (more information can be found
[here](https://github.com/nix-community/nixpkgs-fmt?tab=readme-ov-file#nixpkgs-fmt---nix-code-formatter-for-nixpkgs).
To migrate to `nixfmt`, simply change `vim.languages.nix.format.type` to
`nixfmt`.
### leader changes {#sec-leader-changes}
This has been deprecated in favor of using the more generic `vim.globals` (you
can use `vim.globals.mapleader` to change this instead).
Rust specific keymaps now use `maplocalleader` instead of `localleader` by
default. This is to avoid conflicts with other modules. You can change
`maplocalleader` with `vim.globals.maplocalleader`, but it's recommended to set
it to something other than `mapleader` to avoid conflicts.
### `vim.*` changes {#sec-vim-opt-changes}
Inline with the [leader changes](#sec-leader-changes), we have removed some
options that were under `vim` as convenient shorthands for `vim.o.*` options.
::: {.warning}
As v0.7 features the addition of [](#opt-vim.options), those options are now
considered as deprecated. You should migrate to the appropriate options in the
`vim.options` submodule.
:::
The changes are, in no particular order:
- `colourTerm`, `mouseSupport`, `cmdHeight`, `updateTime`, `mapTime`,
`cursorlineOpt`, `splitBelow`, `splitRight`, `autoIndent` and `wordWrap` have
been mapped to their [](#opt-vim.options) equivalents. Please see the module
definition for the updated options.
- `tabWidth` has been **removed** as it lead to confusing behaviour. You can
replicate the same functionality by setting `shiftwidth`, `tabstop` and
`softtabstop` under `vim.options` as you see fit.
## Changelog {#sec-release-0.7-changelog} ## Changelog {#sec-release-0.7-changelog}
[ItsSorae](https://github.com/ItsSorae): [ItsSorae](https://github.com/ItsSorae):
@ -67,6 +145,9 @@ everyone.
- Add dap-go for better dap configurations - Add dap-go for better dap configurations
- Make noice.nvim customizable - Make noice.nvim customizable
- Standardize border style options and add custom borders - Standardize border style options and add custom borders
- Remove `vim.disableDefaultRuntimePaths` in wrapper options.
- As nvf uses `$NVIM_APP_NAME` as of recent changes, we can safely assume any
configuration in `$XDG_CONFIG_HOME/nvf` is intentional.
[rust-tools.nvim]: https://github.com/simrat39/rust-tools.nvim [rust-tools.nvim]: https://github.com/simrat39/rust-tools.nvim
[rustaceanvim]: https://github.com/mrcjkb/rustaceanvim [rustaceanvim]: https://github.com/mrcjkb/rustaceanvim
@ -76,6 +157,11 @@ everyone.
recommended to go through rustacean.nvim's README to take a closer look at its recommended to go through rustacean.nvim's README to take a closer look at its
features and usage features and usage
[lz.n]: https://github.com/mrcjkb/lz.n
- Add [lz.n] support and lazy-load some builtin plugins.
- Add simpler helper functions for making keymaps
[jacekpoz](https://jacekpoz.pl): [jacekpoz](https://jacekpoz.pl):
[ocaml-lsp]: https://github.com/ocaml/ocaml-lsp [ocaml-lsp]: https://github.com/ocaml/ocaml-lsp
@ -124,10 +210,40 @@ everyone.
- Replace `vim.lsp.nvimCodeActionMenu` with `vim.ui.fastaction`, see the - Replace `vim.lsp.nvimCodeActionMenu` with `vim.ui.fastaction`, see the
breaking changes section above for more details breaking changes section above for more details
- Add a `setupOpts` option to nvim-surround, which allows modifying options that
aren't defined in nvf. Move the alternate nvim-surround keybinds to use
`setupOpts`.
- Remove `autopairs.type`, and rename `autopairs.enable` to
`autopairs.nvim-autopairs.enable`. The new
[](#opt-vim.autopairs.nvim-autopairs.enable) supports `setupOpts` format by
default.
- Refactor of `nvim-cmp` and completion related modules
- Remove `autocomplete.type` in favor of per-plugin enable options such as
[](#opt-vim.autocomplete.nvim-cmp.enable).
- Deprecate legacy Vimsnip in favor of Luasnip, and integrate
friendly-snippets for bundled snippets. [](#opt-vim.snippets.luasnip.enable)
can be used to toggle Luasnip.
- Add sorting function options for completion sources under
[](#opt-vim.autocomplete.nvim-cmp.setupOpts.sorting.comparators)
- Add C# support under `vim.languages.csharp`, with support for both
omnisharp-roslyn and csharp-language-server.
- Add Julia support under `vim.languages.julia`. Note that the entirety of Julia
is bundled with nvf, if you enable the module, since there is no way to
provide only the LSP server.
- Add [`run.nvim`](https://github.com/diniamo/run.nvim) support for running code
using cached commands.
[Neovim documentation on `vim.cmd`]: https://neovim.io/doc/user/lua.html#vim.cmd() [Neovim documentation on `vim.cmd`]: https://neovim.io/doc/user/lua.html#vim.cmd()
- Make Neovim's configuration file entirely Lua based. This comes with a few - Make Neovim's configuration file entirely Lua based. This comes with a few
breaking changes: breaking changes:
- `vim.configRC` has been removed. You will need to migrate your entries to - `vim.configRC` has been removed. You will need to migrate your entries to
Neovim-compliant Lua code, and add them to `vim.luaConfigRC` instead. Neovim-compliant Lua code, and add them to `vim.luaConfigRC` instead.
Existing vimscript configurations may be preserved in `vim.cmd` functions. Existing vimscript configurations may be preserved in `vim.cmd` functions.
@ -136,10 +252,13 @@ everyone.
has been introduced for setting up internal plugins. See the "DAG entries in has been introduced for setting up internal plugins. See the "DAG entries in
nvf" manual page for more information. nvf" manual page for more information.
- Rewrite `vim.maps`, see the breaking changes section above.
[NotAShelf](https://github.com/notashelf): [NotAShelf](https://github.com/notashelf):
[ts-error-translator.nvim]: https://github.com/dmmulroy/ts-error-translator.nvim [ts-error-translator.nvim]: https://github.com/dmmulroy/ts-error-translator.nvim
[credo]: https://github.com/rrrene/credo [credo]: https://github.com/rrrene/credo
[tiny-devicons-auto-colors]: https://github.com/rachartier/tiny-devicons-auto-colors.nvim
- Add `deno fmt` as the default Markdown formatter. This will be enabled - Add `deno fmt` as the default Markdown formatter. This will be enabled
automatically if you have autoformatting enabled, but can be disabled manually automatically if you have autoformatting enabled, but can be disabled manually
@ -198,25 +317,74 @@ everyone.
configuration for [dashboard.nvim](https://github.com/nvimdev/dashboard-nvim) configuration for [dashboard.nvim](https://github.com/nvimdev/dashboard-nvim)
- Update `lualine.nvim` input and add missing themes: - Update `lualine.nvim` input and add missing themes:
- Adds `ayu`, `gruvbox_dark`, `iceberg`, `moonfly`, `onedark`, - Adds `ayu`, `gruvbox_dark`, `iceberg`, `moonfly`, `onedark`,
`powerline_dark` and `solarized_light` themes. `powerline_dark` and `solarized_light` themes.
- Add [](#opt-vim.spellcheck.extraSpellWords) to allow adding arbitrary
spellfiles to Neovim's runtime with ease.
- Add combined nvf configuration (`config.vim`) into the final package's
`passthru` as `passthru.neovimConfiguration` for easier debugging.
- Add support for [tiny-devicons-auto-colors] under
`vim.visuals.tiny-devicons-auto-colors`
- Move options that used to set `vim.o` values (e.g. `vim.wordWrap`) into
`vim.options` as default values. Some are left as they don't have a direct
equivalent, but expect a switch eventually.
[ppenguin](https://github.com/ppenguin): [ppenguin](https://github.com/ppenguin):
- Telescope: - Telescope:
- Fixed `project-nvim` command and keybinding - Fixed `project-nvim` command and keybinding
- Added default ikeybind/command for `Telescope resume` (`<leader>fr`) - Added default ikeybind/command for `Telescope resume` (`<leader>fr`)
- Add `hcl` lsp/formatter (not the same as `terraform`, which is not useful for
e.g. `nomad` config files).
[Soliprem](https://github.com/Soliprem): [Soliprem](https://github.com/Soliprem):
- Add LSP and Treesitter support for R under `vim.languages.R`. - Add LSP and Treesitter support for R under `vim.languages.R`.
- Add formatter support for R, with styler and formatR as options
- Add Otter support under `vim.lsp.otter` and an assert to prevent conflict with - Add Otter support under `vim.lsp.otter` and an assert to prevent conflict with
ccc ccc
- Fixed typo in Otter's setupOpts
- Add Neorg support under `vim.notes.neorg`
- Add LSP, diagnostics, formatter and Treesitter support for Kotlin under
`vim.languages.kotlin`
- changed default keybinds for leap.nvim to avoid altering expected behavior
- Add LSP, formatter and Treesitter support for Vala under `vim.languages.vala`
- Add [Tinymist](https://github.com/Myriad-Dreamin/tinymist] as a formatter for
the Typst language module.
- Add LSP and Treesitter support for Assembly under `vim.languages.assembly`
- Move [which-key](https://github.com/folke/which-key.nvim) to the new spec
- Add LSP and Treesitter support for Nushell under `vim.languages.nu`
- Add LSP and Treesitter support for Gleam under `vim.languages.gleam`
[Bloxx12](https://github.com/Bloxx12): [Bloxx12](https://github.com/Bloxx12)
- Add support for [base16 theming](https://github.com/RRethy/base16-nvim) under
`vim.theme`
- Fix internal breakage in `elixir-tools` setup. - Fix internal breakage in `elixir-tools` setup.
[ksonj](https://github.com/ksonj):
- Add LSP support for Scala via
[nvim-metals](https://github.com/scalameta/nvim-metals)
[nezia1](https://github.com/nezia1):
- Add [biome](https://github.com/biomejs/biome) support for Typescript, CSS and
Svelte. Enable them via [](#opt-vim.languages.ts.format.type),
[](#opt-vim.languages.css.format.type) and
[](#opt-vim.languages.svelte.format.type) respectively.
- Replace [nixpkgs-fmt](https://github.com/nix-community/nixpkgs-fmt) with
[nixfmt](https://github.com/NixOS/nixfmt) (nixfmt-rfc-style).
[Nowaaru](https://github.com/Nowaaru): [Nowaaru](https://github.com/Nowaaru):
- Add `precognition-nvim`. - Add `precognition-nvim`.
[DamitusThyYeeticus123](https://github.com/DamitusThyYeetus123):
- Add support for [Astro](https://astro.build/) language server.

10
docs/static/script/anchor-min.js vendored Normal file

File diff suppressed because one or more lines are too long

4
docs/static/script/anchor-use.js vendored Normal file
View file

@ -0,0 +1,4 @@
document.addEventListener('DOMContentLoaded', function(event) {
anchors.add('h1[id]:not(div.note h1, div.warning h1, div.tip h1, div.caution h1, div.important h1), h2[id]:not(div.note h2, div.warning h2, div.tip h2, div.caution h2, div.important h2), h3[id]:not(div.note h3, div.warning h3, div.tip h3, div.caution h3, div.important h3), h4[id]:not(div.note h4, div.warning h4, div.tip h4, div.caution h4, div.important h4), h5[id]:not(div.note h5, div.warning h5, div.tip h5, div.caution h5, div.important h5), h6[id]:not(div.note h6, div.warning h6, div.tip h6, div.caution h6, div.important h6)');
});

827
docs/static/style.css vendored

File diff suppressed because one or more lines are too long

View file

@ -1,3 +1,5 @@
@use "scss-reset/reset";
:root { :root {
--nmd-color0: #0a3e68; --nmd-color0: #0a3e68;
--nmd-color1: #268598; --nmd-color1: #268598;
@ -32,8 +34,6 @@ $color-blue-700: #1d4ed8;
$color-blue-800: #1e40af; $color-blue-800: #1e40af;
$color-blue-900: #1e3a8a; $color-blue-900: #1e3a8a;
@use "scss-reset/reset";
@mixin boxed { @mixin boxed {
background: $color-gray-50; background: $color-gray-50;
margin: 2rem 16px; margin: 2rem 16px;

View file

@ -4,99 +4,4 @@
License: ~ MIT (or more permissive) [via base16-schemes-source] License: ~ MIT (or more permissive) [via base16-schemes-source]
Maintainer: @highlightjs/core-team Maintainer: @highlightjs/core-team
Version: 2021.09.0 Version: 2021.09.0
*/ */pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{color:#ccc;background:#2d2d2d}.hljs ::selection,.hljs::selection{background-color:#515151;color:#ccc}.hljs-comment{color:#999}.hljs-tag{color:#b4b7b4}.hljs-operator,.hljs-punctuation,.hljs-subst{color:#ccc}.hljs-operator{opacity:.7}.hljs-bullet,.hljs-deletion,.hljs-name,.hljs-selector-tag,.hljs-template-variable,.hljs-variable{color:#f2777a}.hljs-attr,.hljs-link,.hljs-literal,.hljs-number,.hljs-symbol,.hljs-variable.constant_{color:#f99157}.hljs-class .hljs-title,.hljs-title,.hljs-title.class_{color:#fc6}.hljs-strong{font-weight:700;color:#fc6}.hljs-addition,.hljs-code,.hljs-string,.hljs-title.class_.inherited__{color:#9c9}.hljs-built_in,.hljs-doctag,.hljs-keyword.hljs-atrule,.hljs-quote,.hljs-regexp{color:#6cc}.hljs-attribute,.hljs-function .hljs-title,.hljs-section,.hljs-title.function_,.ruby .hljs-property{color:#69c}.diff .hljs-meta,.hljs-keyword,.hljs-template-tag,.hljs-type{color:#c9c}.hljs-emphasis{color:#c9c;font-style:italic}.hljs-meta,.hljs-meta .hljs-keyword,.hljs-meta .hljs-string{color:#a3685a}.hljs-meta .hljs-keyword,.hljs-meta-keyword{font-weight:700}
pre code.hljs {
display: block;
overflow-x: auto;
padding: 1em;
}
code.hljs {
padding: 3px 5px;
}
.hljs {
color: #ccc;
background: #2d2d2d;
}
.hljs ::selection,
.hljs::selection {
background-color: #515151;
color: #ccc;
}
.hljs-comment {
color: #999;
}
.hljs-tag {
color: #b4b7b4;
}
.hljs-operator,
.hljs-punctuation,
.hljs-subst {
color: #ccc;
}
.hljs-operator {
opacity: 0.7;
}
.hljs-bullet,
.hljs-deletion,
.hljs-name,
.hljs-selector-tag,
.hljs-template-variable,
.hljs-variable {
color: #f2777a;
}
.hljs-attr,
.hljs-link,
.hljs-literal,
.hljs-number,
.hljs-symbol,
.hljs-variable.constant_ {
color: #f99157;
}
.hljs-class .hljs-title,
.hljs-title,
.hljs-title.class_ {
color: #fc6;
}
.hljs-strong {
font-weight: 700;
color: #fc6;
}
.hljs-addition,
.hljs-code,
.hljs-string,
.hljs-title.class_.inherited__ {
color: #9c9;
}
.hljs-built_in,
.hljs-doctag,
.hljs-keyword.hljs-atrule,
.hljs-quote,
.hljs-regexp {
color: #6cc;
}
.hljs-attribute,
.hljs-function .hljs-title,
.hljs-section,
.hljs-title.function_,
.ruby .hljs-property {
color: #69c;
}
.diff .hljs-meta,
.hljs-keyword,
.hljs-template-tag,
.hljs-type {
color: #c9c;
}
.hljs-emphasis {
color: #c9c;
font-style: italic;
}
.hljs-meta,
.hljs-meta .hljs-keyword,
.hljs-meta .hljs-string {
color: #a3685a;
}
.hljs-meta .hljs-keyword,
.hljs-meta-keyword {
font-weight: 700;
}

File diff suppressed because it is too large Load diff

124
flake.nix
View file

@ -21,6 +21,7 @@
./flake/legacyPackages.nix ./flake/legacyPackages.nix
./flake/overlays.nix ./flake/overlays.nix
./flake/packages.nix ./flake/packages.nix
./flake/develop.nix
]; ];
flake = { flake = {
@ -30,46 +31,29 @@
}; };
homeManagerModules = { homeManagerModules = {
nvf = import ./flake/modules/home-manager.nix self.packages lib;
default = self.homeManagerModules.nvf;
neovim-flake = neovim-flake =
lib.warn '' lib.warn ''
homeManagerModules.neovim-flake has been deprecated. 'homeManagerModules.neovim-flake' has been deprecated, and will be removed
Plese use the homeManagerModules.nvf instead in a future release. Please use 'homeManagerModules.nvf' instead.
'' ''
self.homeManagerModules.nvf; self.homeManagerModules.nvf;
nvf = import ./flake/modules/home-manager.nix self.packages lib;
default = self.homeManagerModules.nvf;
}; };
nixosModules = { nixosModules = {
nvf = import ./flake/modules/nixos.nix self.packages lib;
default = self.nixosModules.nvf;
neovim-flake = neovim-flake =
lib.warn '' lib.warn ''
nixosModules.neovim-flake has been deprecated. 'nixosModules.neovim-flake' has been deprecated, and will be removed
Please use the nixosModules.nvf instead in a future release. Please use 'nixosModules.nvf' instead.
'' ''
self.nixosModules.nvf; self.nixosModules.nvf;
nvf = import ./flake/modules/nixos.nix self.packages lib;
default = self.nixosModules.nvf;
}; };
}; };
perSystem = { perSystem = {pkgs, ...}: {
self',
config,
pkgs,
...
}: {
devShells = {
default = self'.devShells.lsp;
nvim-nix = pkgs.mkShell {packages = [config.packages.nix];};
lsp = pkgs.mkShell {
packages = with pkgs; [nil statix deadnix alejandra];
};
};
# Provide the default formatter. `nix fmt` in project root # Provide the default formatter. `nix fmt` in project root
# will format available files with the correct formatter. # will format available files with the correct formatter.
# P.S: Please do not format with nixfmt! It messes with many # P.S: Please do not format with nixfmt! It messes with many
@ -113,6 +97,22 @@
}; };
## Plugins ## Plugins
# Lazy loading
plugin-lz-n = {
url = "github:nvim-neorocks/lz.n";
flake = false;
};
plugin-lzn-auto-require = {
url = "github:horriblename/lzn-auto-require/require-rewrite";
flake = false;
};
plugin-rtp-nvim = {
url = "github:nvim-neorocks/rtp.nvim";
flake = false;
};
# LSP plugins # LSP plugins
plugin-nvim-lspconfig = { plugin-nvim-lspconfig = {
url = "github:neovim/nvim-lspconfig"; url = "github:neovim/nvim-lspconfig";
@ -206,6 +206,21 @@
flake = false; 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 # Copying/Registers
plugin-registers = { plugin-registers = {
url = "github:tversteeg/registers.nvim"; url = "github:tversteeg/registers.nvim";
@ -223,6 +238,12 @@
flake = false; flake = false;
}; };
# Runners
plugin-run-nvim = {
url = "github:diniamo/run.nvim";
flake = false;
};
# Debuggers # Debuggers
plugin-nvim-dap = { plugin-nvim-dap = {
url = "github:mfussenegger/nvim-dap"; url = "github:mfussenegger/nvim-dap";
@ -277,11 +298,6 @@
flake = false; flake = false;
}; };
plugin-cmp-vsnip = {
url = "github:hrsh7th/cmp-vsnip";
flake = false;
};
plugin-cmp-path = { plugin-cmp-path = {
url = "github:hrsh7th/cmp-path"; url = "github:hrsh7th/cmp-path";
flake = false; flake = false;
@ -292,9 +308,19 @@
flake = false; flake = false;
}; };
plugin-cmp-luasnip = {
url = "github:saadparwaiz1/cmp_luasnip";
flake = false;
};
# snippets # snippets
plugin-vim-vsnip = { plugin-luasnip = {
url = "github:hrsh7th/vim-vsnip"; url = "github:L3MON4D3/LuaSnip";
flake = false;
};
plugin-friendly-snippets = {
url = "github:rafamadriz/friendly-snippets";
flake = false; flake = false;
}; };
@ -349,6 +375,11 @@
}; };
# Themes # Themes
plugin-base16 = {
url = "github:rrethy/base16-nvim";
flake = false;
};
plugin-tokyonight = { plugin-tokyonight = {
url = "github:folke/tokyonight.nvim"; url = "github:folke/tokyonight.nvim";
flake = false; flake = false;
@ -402,7 +433,7 @@
flake = false; flake = false;
}; };
plugin-scrollbar-nvim = { plugin-nvim-scrollbar = {
url = "github:petertriho/nvim-scrollbar"; url = "github:petertriho/nvim-scrollbar";
flake = false; flake = false;
}; };
@ -427,6 +458,11 @@
flake = false; flake = false;
}; };
plugin-tiny-devicons-auto-colors = {
url = "github:rachartier/tiny-devicons-auto-colors.nvim";
flake = false;
};
plugin-gitsigns-nvim = { plugin-gitsigns-nvim = {
url = "github:lewis6991/gitsigns.nvim"; url = "github:lewis6991/gitsigns.nvim";
flake = false; flake = false;
@ -636,6 +672,26 @@
flake = false; 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 = { plugin-nui-nvim = {
# (required by noice.nvim) # (required by noice.nvim)
url = "github:MunifTanjim/nui.nvim"; url = "github:MunifTanjim/nui.nvim";

30
flake/develop.nix Normal file
View file

@ -0,0 +1,30 @@
{lib, ...}: {
perSystem = {
pkgs,
config,
self',
...
}: {
devShells = {
default = self'.devShells.lsp;
nvim-nix = pkgs.mkShellNoCC {packages = [config.packages.nix];};
lsp = pkgs.mkShellNoCC {
packages = with pkgs; [nil statix deadnix alejandra];
};
};
# This package exists to make development easier by providing the place and
# boilerplate to build a test nvf configuration. Feel free to use this for
# testing, but make sure to discard the changes before creating a pull
# request.
packages.dev = let
configuration = {};
customNeovim = lib.nvim.neovimConfiguration {
inherit pkgs;
modules = [configuration];
};
in
customNeovim.neovim;
};
}

View file

@ -14,12 +14,26 @@
docs-html = docs.manual.html; docs-html = docs.manual.html;
docs-manpages = docs.manPages; docs-manpages = docs.manPages;
docs-json = docs.options.json; docs-json = docs.options.json;
docs-linkcheck = let
site = config.packages.docs;
in
pkgs.testers.lycheeLinkCheck {
inherit site;
remap = {
"https://notashelf.github.io/nvf/" = site;
};
extraConfig = {
exclude = [];
include_mail = true;
include_verbatim = true;
};
};
# Build and open the built manual in your system browser # Build and open the built manual in your system browser
docs-html-wrapped = pkgs.writeScriptBin "docs-html-wrapped" '' docs-html-wrapped = pkgs.writeScriptBin "docs-html-wrapped" ''
#!${pkgs.stdenv.shell} #!${pkgs.stdenv.shell}
# use xdg-open to open the docs in the browser # use xdg-open to open the docs in the browser
${pkgs.xdg_utils}/bin/xdg-open ${docs.manual.html} ${pkgs.xdg-utils}/bin/xdg-open ${docs.manual.html}
''; '';
# Exposed neovim configurations # Exposed neovim configurations
@ -29,10 +43,10 @@
# Published docker images # Published docker images
docker-nix = let docker-nix = let
inherit (pkgs) bash gitFull buildEnv dockerTools; inherit (pkgs) bash gitFull buildEnv;
inherit (config.legacyPackages) neovim-nix; inherit (config.legacyPackages) neovim-nix;
in in
dockerTools.buildImage { pkgs.dockerTools.buildImage {
name = "nvf"; name = "nvf";
tag = "latest"; tag = "latest";

5
lib/attrsets.nix Normal file
View file

@ -0,0 +1,5 @@
{lib}: let
inherit (builtins) listToAttrs;
in {
mapListToAttrs = f: list: listToAttrs (map f list);
}

View file

@ -67,6 +67,8 @@
mkLuaBinding binding.value action binding.description; mkLuaBinding binding.value action binding.description;
pushDownDefault = attr: mapAttrs (_: mkDefault) attr; pushDownDefault = attr: mapAttrs (_: mkDefault) attr;
mkKeymap = mode: key: action: opt: opt // {inherit mode key action;};
}; };
in in
binds binds

View file

@ -10,6 +10,7 @@
dag = import ./dag.nix {inherit lib;}; dag = import ./dag.nix {inherit lib;};
languages = import ./languages.nix {inherit lib;}; languages = import ./languages.nix {inherit lib;};
lists = import ./lists.nix {inherit lib;}; lists = import ./lists.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 inputs lib;}; neovimConfiguration = import ../modules {inherit inputs lib;};
} }

View file

@ -2,8 +2,8 @@
{lib}: let {lib}: let
inherit (builtins) isString getAttr; inherit (builtins) isString getAttr;
inherit (lib.options) mkOption; inherit (lib.options) mkOption;
inherit (lib.attrsets) listToAttrs;
inherit (lib.types) bool; inherit (lib.types) bool;
inherit (lib.nvim.attrsets) mapListToAttrs;
in { in {
# Converts a boolean to a yes/no string. This is used in lots of # Converts a boolean to a yes/no string. This is used in lots of
# configuration formats. # configuration formats.
@ -12,21 +12,21 @@ in {
config, config,
diagnosticsProviders, diagnosticsProviders,
}: }:
listToAttrs mapListToAttrs
(map (v: let (v: let
type = type =
if isString v if isString v
then v then v
else getAttr v.type; else getAttr v.type;
package = package =
if isString v if isString v
then diagnosticsProviders.${type}.package then diagnosticsProviders.${type}.package
else v.package; else v.package;
in { in {
name = "${lang}-diagnostics-${type}"; name = "${lang}-diagnostics-${type}";
value = diagnosticsProviders.${type}.nullConfig package; value = diagnosticsProviders.${type}.nullConfig package;
}) })
config); config;
mkEnable = desc: mkEnable = desc:
mkOption { mkOption {

View file

@ -1,8 +1,9 @@
{lib}: let {lib}: let
inherit (lib) isStringLike showOption showFiles getFiles mergeOneOption mergeEqualOption mkOptionType; inherit (lib.options) showOption showFiles getFiles mergeOneOption mergeEqualOption;
inherit (lib.types) anything attrsOf; inherit (lib.strings) isString isStringLike;
inherit (lib.types) anything attrsOf listOf mkOptionType;
inherit (lib.nvim.types) anythingConcatLists; inherit (lib.nvim.types) anythingConcatLists;
inherit (builtins) typeOf isAttrs any head concatLists stringLength; inherit (builtins) typeOf isAttrs any head concatLists stringLength match;
in { in {
# HACK: Does this break anything in our case? # HACK: Does this break anything in our case?
# A modified version of the nixpkgs anything type that concatenates lists # A modified version of the nixpkgs anything type that concatenates lists
@ -51,6 +52,16 @@ in {
(mergeFunctions.${commonType} or mergeEqualOption) loc defs; (mergeFunctions.${commonType} or mergeEqualOption) loc defs;
}; };
mergelessListOf = elemType: let
super = listOf elemType;
in
super
// {
name = "mergelessListOf";
description = "mergeless ${super.description}";
merge = mergeEqualOption;
};
char = mkOptionType { char = mkOptionType {
name = "char"; name = "char";
description = "character"; description = "character";
@ -58,4 +69,11 @@ in {
check = value: stringLength value < 2; check = value: stringLength value < 2;
merge = mergeEqualOption; merge = mergeEqualOption;
}; };
hexColor = mkOptionType {
name = "hex-color";
descriptionClass = "noun";
description = "RGB color in hex format";
check = v: isString v && (match "#?[0-9a-fA-F]{6}" v) != null;
};
} }

View file

@ -6,10 +6,10 @@
typesDag = import ./dag.nix {inherit lib;}; typesDag = import ./dag.nix {inherit lib;};
typesPlugin = import ./plugins.nix {inherit inputs lib;}; typesPlugin = import ./plugins.nix {inherit inputs lib;};
typesLanguage = import ./languages.nix {inherit lib;}; typesLanguage = import ./languages.nix {inherit lib;};
typesCustom = import ./custom.nix {inherit lib;}; 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 (typesCustom) anythingConcatLists char; inherit (customTypes) anythingConcatLists char hexColor mergelessListOf;
} }

View file

@ -1,31 +1,37 @@
{lib}: {lib}: let
with lib; let inherit (lib.options) mkOption mkPackageOption;
inherit (lib.attrsets) attrNames;
inherit (lib.types) listOf either enum submodule package;
diagnosticSubmodule = _: { diagnosticSubmodule = _: {
options = { options = {
type = mkOption { type = mkOption {
description = "Type of diagnostic to enable"; description = "Type of diagnostic to enable";
type = attrNames diagnostics; type = attrNames diagnostics;
}; };
package = mkOption { package = mkOption {
type = package;
description = "Diagnostics package"; description = "Diagnostics package";
type = types.package;
}; };
}; };
}; };
in {
diagnostics = { diagnostics = {
langDesc, langDesc,
diagnosticsProviders, diagnosticsProviders,
defaultDiagnosticsProvider, defaultDiagnosticsProvider,
}: }:
mkOption { mkOption {
description = "List of ${langDesc} diagnostics to enable"; type = listOf (either (enum (attrNames diagnosticsProviders)) (submodule diagnosticSubmodule));
type = with types; listOf (either (enum (attrNames diagnosticsProviders)) (submodule diagnosticSubmodule));
default = defaultDiagnosticsProvider; default = defaultDiagnosticsProvider;
description = "List of ${langDesc} diagnostics to enable";
}; };
mkGrammarOption = pkgs: grammar: mkGrammarOption = pkgs: grammar:
mkPackageOption pkgs ["${grammar} treesitter"] { mkPackageOption pkgs ["${grammar} treesitter"] {
default = ["vimPlugins" "nvim-treesitter" "builtGrammars" grammar]; default = ["vimPlugins" "nvim-treesitter" "builtGrammars" grammar];
}; };
in {
inherit diagnostics diagnosticSubmodule mkGrammarOption;
} }

View file

@ -84,10 +84,7 @@
# built (or "normalized") plugins that are modified # built (or "normalized") plugins that are modified
builtStartPlugins = buildConfigPlugins vimOptions.startPlugins; builtStartPlugins = buildConfigPlugins vimOptions.startPlugins;
builtOptPlugins = map (package: { builtOptPlugins = map (package: package // {optional = true;}) (buildConfigPlugins vimOptions.optPlugins);
plugin = package;
optional = true;
}) (buildConfigPlugins vimOptions.optPlugins);
# additional Lua and Python3 packages, mapped to their respective functions # additional Lua and Python3 packages, mapped to their respective functions
# to conform to the format mnw expects. end user should # to conform to the format mnw expects. end user should
@ -126,9 +123,15 @@ in {
paths = [neovim-wrapped printConfig printConfigPath]; paths = [neovim-wrapped printConfig printConfigPath];
postBuild = "echo Helpers added"; postBuild = "echo Helpers added";
meta = { # Allow evaluating vimOptions, i.e., config.vim from the packages' passthru
description = "Wrapped version of Neovim with additional helper scripts"; # attribute. For example, packages.x86_64-linux.neovim.passthru.neovimConfig
mainProgram = "nvim"; # 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

@ -1,18 +1,93 @@
{lib, ...}: let {lib, ...}: let
inherit (lib.modules) mkRemovedOptionModule; inherit (lib.modules) mkRemovedOptionModule mkRenamedOptionModule;
in { inherit (lib.lists) concatLists;
imports = [ inherit (lib.nvim.config) batchRenameOptions;
# 2024-06-06
(mkRemovedOptionModule ["vim" "tidal"] ''
Tidalcycles language support has been removed as of 2024-06-06 as it was long unmaintained. If
you depended on this functionality, please open an issue.
'')
# 2024-07-20 renamedVimOpts = batchRenameOptions ["vim"] ["vim" "options"] {
(mkRemovedOptionModule ["vim" "lsp" "nvimCodeActionMenu"] '' colourTerm = "termguicolors";
nvimCodeActionMenu has been deprecated and removed upstream. As of 0.7, fastaction will be mouseSupport = "mouse";
available under `vim.ui.fastaction` as a replacement. Simply remove everything under cmdHeight = "cmdheight";
`vim.lsp.nvimCodeActionMenu`, and set `vim.ui.fastaction.enable` to `true`. updateTime = "updatetime";
'') mapTimeout = "tm";
cursorlineOpt = "cursorlineopt";
splitBelow = "splitbelow";
splitRight = "splitright";
autoIndent = "autoindent";
wordWrap = "wrap";
};
in {
imports = concatLists [
[
# 2024-06-06
(mkRemovedOptionModule ["vim" "tidal"] ''
Tidalcycles language support has been removed as of 2024-06-06 as it was long unmaintained. If
you depended on this functionality, please open an issue.
'')
# 2024-07-20
(mkRemovedOptionModule ["vim" "lsp" "nvimCodeActionMenu"] ''
nvimCodeActionMenu has been deprecated and removed upstream. As of 0.7, fastaction will be
available under `vim.ui.fastaction` as a replacement. Simply remove everything under
`vim.lsp.nvimCodeActionMenu`, and set `vim.ui.fastaction.enable` to `true`.
'')
(mkRemovedOptionModule ["vim" "autopairs" "enable"] ''
vim.autopairs.enable has been removed in favor of per-plugin modules.
You can enable nvim-autopairs with vim.autopairs.nvim-autopairs.enable instead.
'')
(mkRemovedOptionModule ["vim" "autopairs" "type"] ''
vim.autopairs.type has been removed in favor of per-plugin modules.
You can enable nvim-autopairs with vim.autopairs.nvim-autopairs.enable instead.
'')
(mkRemovedOptionModule ["vim" "autocomplete" "enable"] ''
vim.autocomplete.enable has been removed in favor of per-plugin modules.
You can enable nvim-cmp with vim.autocomplete.nvim-cmp.enable instead.
'')
(mkRemovedOptionModule ["vim" "autocomplete" "type"] ''
vim.autocomplete.type has been removed in favor of per-plugin modules.
You can enable nvim-cmp with vim.autocomplete.nvim-cmp.enable instead.
'')
(mkRemovedOptionModule ["vim" "autocomplete" "sources"] ''
vim.autocomplete.sources has been removed in favor of per-plugin modules.
You can add nvim-cmp sources with vim.autocomplete.nvim-cmp.sources
instead.
'')
(mkRemovedOptionModule ["vim" "snippets" "vsnip" "enable"] ''
vim.snippets.vsnip.enable has been removed in favor of the more modern luasnip.
'')
(mkRenamedOptionModule ["vim" "lsp" "lspkind" "mode"] ["vim" "lsp" "lspkind" "setupOpts" "mode"])
# 2024-10-14
(mkRemovedOptionModule ["vim" "configRC"] ''
Please migrate your configRC sections to Neovim's Lua format, and
add them to `vim.luaConfigRC`.
See the v0.7 release notes for more information on why and how to
migrate your existing configurations to the new format.
'')
(mkRemovedOptionModule ["vim" "disableDefaultRuntimePaths"] ''
Nvf now uses $NVIM_APP_NAME so there is no longer the problem of
(accidental) leaking of user configuration.
'')
(mkRemovedOptionModule ["vim" "lsp" "trouble" "mappings" "toggle"] ''
With Trouble having so many different modes, and breaking changes
upstream, it no longer makes sense, nor works, to toggle only Trouble.
'')
# 2024-11-30
(mkRenamedOptionModule ["vim" "leaderKey"] ["vim" "globals" "mapleader"])
(mkRemovedOptionModule ["vim" "tabWidth"] ''
Previous behaviour of this option was confusing and undocumented. Please set
`tabstop` and `shiftwidth` manually in `vim.options` or per-filetype in a
`ftplugin` directory added to your runtime path.
'')
]
# 2024-12-1
# Migrated via batchRenameOptions. Further batch renames must be below this line.
renamedVimOpts
]; ];
} }

View file

@ -31,6 +31,7 @@
"notes" "notes"
"projects" "projects"
"rich-presence" "rich-presence"
"runner"
"session" "session"
"snippets" "snippets"
# "spellcheck" # FIXME: see neovim/init/spellcheck.nix # "spellcheck" # FIXME: see neovim/init/spellcheck.nix
@ -50,6 +51,7 @@
"build" "build"
"rc" "rc"
"warnings" "warnings"
"lazy"
]; ];
# Extra modules, such as deprecation warnings # Extra modules, such as deprecation warnings

View file

@ -3,29 +3,18 @@
lib, lib,
... ...
}: let }: let
inherit (lib.options) mkOption mkEnableOption literalExpression literalMD; inherit (lib.options) mkOption mkEnableOption literalMD;
inherit (lib.strings) optionalString; inherit (lib.strings) optionalString;
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;
inherit (lib.nvim.binds) pushDownDefault;
inherit (lib.nvim.lua) toLuaObject; inherit (lib.nvim.lua) toLuaObject;
inherit (lib.nvim.types) luaInline; inherit (lib.nvim.types) luaInline;
cfg = config.vim; cfg = config.vim;
in { in {
options.vim = { options.vim = {
leaderKey = mkOption {
type = str;
default = " ";
description = "The leader key used for `<leader>` mappings";
};
colourTerm = mkOption {
type = bool;
default = true;
description = "Set terminal up for 256 colours";
};
disableArrows = mkOption { disableArrows = mkOption {
type = bool; type = bool;
default = false; default = false;
@ -44,12 +33,6 @@ in {
description = "Start scrolling this number of lines from the top or bottom of the page."; description = "Start scrolling this number of lines from the top or bottom of the page.";
}; };
wordWrap = mkOption {
type = bool;
default = true;
description = "Enable word wrapping.";
};
syntaxHighlighting = mkOption { syntaxHighlighting = mkOption {
type = bool; type = bool;
default = !config.vim.treesitter.highlight.enable; default = !config.vim.treesitter.highlight.enable;
@ -62,24 +45,10 @@ in {
description = "Make use of the clipboard for default yank and paste operations. Don't use * and +"; description = "Make use of the clipboard for default yank and paste operations. Don't use * and +";
}; };
mouseSupport = mkOption {
type = enum ["a" "n" "v" "i" "c"];
default = "a";
description = ''
Set modes for mouse support.
* a - all
* n - normal
* v - visual
* i - insert
* c - command
'';
};
lineNumberMode = mkOption { lineNumberMode = mkOption {
type = enum ["relative" "number" "relNumber" "none"]; type = enum ["relative" "number" "relNumber" "none"];
default = "relNumber"; default = "relNumber";
example = literalExpression "none"; example = "none";
description = "How line numbers are displayed."; description = "How line numbers are displayed.";
}; };
@ -89,30 +58,6 @@ in {
description = "Prevent swapfile and backupfile from being created"; description = "Prevent swapfile and backupfile from being created";
}; };
tabWidth = mkOption {
type = int;
default = 4;
description = "Set the width of tabs";
};
autoIndent = mkOption {
type = bool;
default = true;
description = "Enable auto indent";
};
cmdHeight = mkOption {
type = int;
default = 1;
description = "Height of the command pane";
};
updateTime = mkOption {
type = int;
default = 300;
description = "The number of milliseconds till Cursor Hold event is fired";
};
showSignColumn = mkOption { showSignColumn = mkOption {
type = bool; type = bool;
default = true; default = true;
@ -125,36 +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";
}; };
mapTimeout = mkOption {
type = int;
default = 500;
description = "Timeout in ms that neovim will wait for mapped action to complete";
};
splitBelow = mkOption {
type = bool;
default = true;
description = "New splits will open below instead of on top";
};
splitRight = mkOption {
type = bool;
default = true;
description = "New splits will open to the right";
};
enableEditorconfig = mkOption { enableEditorconfig = mkOption {
type = bool; type = bool;
default = true; default = true;
description = "Follow editorconfig rules in current directory"; description = "Follow editorconfig rules in current directory";
}; };
cursorlineOpt = mkOption {
type = enum ["line" "screenline" "number" "both"];
default = "line";
description = "Highlight the text line of the cursor with CursorLine hl-CursorLine";
};
searchCase = mkOption { searchCase = mkOption {
type = enum ["ignore" "smart" "sensitive"]; type = enum ["ignore" "smart" "sensitive"];
default = "sensitive"; default = "sensitive";
@ -181,46 +102,35 @@ in {
}; };
}; };
config = { config.vim = {
vim.luaConfigRC.basic = entryAfter ["globalsScript"] '' # 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
# luaConfigRC section below.
options = pushDownDefault {
encoding = "utf-8";
hidden = true;
expandtab = true;
};
globals = pushDownDefault {
editorconfig = cfg.enableEditorconfig;
};
# Options that are more difficult to set through 'vim.options'. Fear not, though
# as the Lua DAG is still as powerful as it could be.
luaConfigRC.basic = entryAfter ["globalsScript"] ''
-- Settings that are set for everything -- Settings that are set for everything
vim.o.encoding = "utf-8"
vim.o.hidden = true
vim.opt.shortmess:append("c") vim.opt.shortmess:append("c")
vim.o.expandtab = true
vim.o.mouse = ${toLuaObject cfg.mouseSupport}
vim.o.tabstop = ${toLuaObject cfg.tabWidth}
vim.o.shiftwidth = ${toLuaObject cfg.tabWidth}
vim.o.softtabstop = ${toLuaObject cfg.tabWidth}
vim.o.cmdheight = ${toLuaObject cfg.cmdHeight}
vim.o.updatetime = ${toLuaObject cfg.updateTime}
vim.o.tm = ${toLuaObject cfg.mapTimeout}
vim.o.cursorlineopt = ${toLuaObject cfg.cursorlineOpt}
vim.o.scrolloff = ${toLuaObject cfg.scrollOffset}
vim.g.mapleader = ${toLuaObject cfg.leaderKey}
vim.g.maplocalleader = ${toLuaObject cfg.leaderKey}
${optionalString cfg.undoFile.enable '' ${optionalString cfg.undoFile.enable ''
vim.o.undofile = true vim.o.undofile = true
vim.o.undodir = ${toLuaObject cfg.undoFile.path} vim.o.undodir = ${toLuaObject cfg.undoFile.path}
''} ''}
${optionalString cfg.splitBelow ''
vim.o.splitbelow = true
''}
${optionalString cfg.splitRight ''
vim.o.splitright = true
''}
${optionalString cfg.showSignColumn '' ${optionalString cfg.showSignColumn ''
vim.o.signcolumn = "yes" vim.o.signcolumn = "yes"
''} ''}
${optionalString cfg.autoIndent ''
vim.o.autoindent = true
''}
${optionalString cfg.preventJunkFiles '' ${optionalString cfg.preventJunkFiles ''
vim.o.swapfile = false vim.o.swapfile = false
vim.o.backup = false vim.o.backup = false
@ -261,23 +171,11 @@ in {
vim.cmd("syntax on") vim.cmd("syntax on")
''} ''}
${optionalString (!cfg.wordWrap) ''
vim.o.wrap = false
''}
${optionalString cfg.hideSearchHighlight '' ${optionalString cfg.hideSearchHighlight ''
vim.o.hlsearch = false vim.o.hlsearch = false
vim.o.incsearch = true vim.o.incsearch = true
''} ''}
${optionalString cfg.colourTerm ''
vim.o.termguicolors = true
''}
${optionalString (!cfg.enableEditorconfig) ''
vim.g.editorconfig = false
''}
${optionalString (cfg.searchCase == "ignore") '' ${optionalString (cfg.searchCase == "ignore") ''
vim.o.smartcase = false vim.o.smartcase = false
vim.o.ignorecase = true vim.o.ignorecase = true

View file

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

View file

@ -3,51 +3,75 @@
lib, lib,
... ...
}: let }: let
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf mkMerge;
inherit (lib.trivial) pipe;
inherit (lib.attrsets) mapAttrsToList;
inherit (lib.lists) flatten;
legacyMapModes = {
normal = ["n"];
insert = ["i"];
select = ["s"];
visual = ["v"];
terminal = ["t"];
normalVisualOp = ["n" "v" "o"];
visualOnly = ["n" "x"];
operator = ["o"];
insertCommand = ["i" "c"];
lang = ["l"];
command = ["c"];
};
cfg = config.vim; cfg = config.vim;
in { in {
config = { config = {
vim.maps = { vim.keymaps = mkMerge [
normal = mkIf cfg.disableArrows { (
"<up>" = { mkIf cfg.disableArrows [
action = "<nop>"; {
key = "<up>";
noremap = false; mode = ["n" "i"];
}; action = "<nop>";
"<down>" = { noremap = false;
action = "<nop>"; }
{
noremap = false; key = "<down>";
}; mode = ["n" "i"];
"<left>" = { action = "<nop>";
action = "<nop>"; noremap = false;
noremap = false; }
}; {
"<right>" = { key = "<left>";
action = "<nop>"; mode = ["n" "i"];
noremap = false; action = "<nop>";
}; noremap = false;
}; }
{
insert = mkIf cfg.disableArrows { key = "<right>";
"<up>" = { mode = ["n" "i"];
action = "<nop>"; action = "<nop>";
noremap = false; noremap = false;
}; }
"<down>" = { ]
action = "<nop>"; )
noremap = false; (
}; pipe cfg.maps
"<left>" = { [
action = "<nop>"; (mapAttrsToList (
noremap = false; oldMode: keybinds:
}; mapAttrsToList (
"<right>" = { key: bind:
action = "<nop>"; bind
noremap = false; // {
}; inherit key;
}; mode = legacyMapModes.${oldMode};
}; }
)
keybinds
))
flatten
]
)
];
}; };
} }

View file

@ -1,101 +1,97 @@
{lib, ...}: let {lib, ...}: let
inherit (lib.options) mkOption; inherit (lib.options) mkOption literalMD;
inherit (lib.types) bool str attrsOf nullOr submodule; inherit (lib.types) either str listOf attrsOf nullOr submodule;
inherit (lib.nvim.config) mkBool; inherit (lib.nvim.config) mkBool;
# Most of the keybindings code is highly inspired by pta2002/nixvim.
# Thank you!
mapConfigOptions = { mapConfigOptions = {
silent =
mkBool false
"Whether this mapping should be silent. Equivalent to adding <silent> to a map.";
nowait =
mkBool false
"Whether to wait for extra input on ambiguous mappings. Equivalent to adding <nowait> to a map.";
script =
mkBool false
"Equivalent to adding <script> to a map.";
expr =
mkBool false
"Means that the action is actually an expression. Equivalent to adding <expr> to a map.";
unique =
mkBool false
"Whether to fail if the map is already defined. Equivalent to adding <unique> to a map.";
noremap =
mkBool true
"Whether to use the 'noremap' variant of the command, ignoring any custom mappings on the defined action. It is highly advised to keep this on, which is the default.";
desc = mkOption { desc = mkOption {
type = nullOr str; type = nullOr str;
default = null; default = null;
description = "A description of this keybind, to be shown in which-key, if you have it enabled."; description = "A description of this keybind, to be shown in which-key, if you have it enabled.";
}; };
action = mkOption {
type = str;
description = "The command to execute.";
};
lua = mkBool false ''
If true, `action` is considered to be lua code.
Thus, it will not be wrapped in `""`.
'';
silent = mkBool true "Whether this mapping should be silent. Equivalent to adding <silent> to a map.";
nowait = mkBool false "Whether to wait for extra input on ambiguous mappings. Equivalent to adding <nowait> to a map.";
script = mkBool false "Equivalent to adding <script> to a map.";
expr = mkBool false "Means that the action is actually an expression. Equivalent to adding <expr> to a map.";
unique = mkBool false "Whether to fail if the map is already defined. Equivalent to adding <unique> to a map.";
noremap = mkBool true "Whether to use the 'noremap' variant of the command, ignoring any custom mappings on the defined action. It is highly advised to keep this on, which is the default.";
}; };
mapOption = submodule { mapType = submodule {
options = options =
mapConfigOptions mapConfigOptions
// { // {
action = mkOption { key = mkOption {
type = str; type = str;
description = "The action to execute."; description = "The key that triggers this keybind.";
}; };
mode = mkOption {
lua = mkOption { type = either str (listOf str);
type = bool;
description = '' description = ''
If true, `action` is considered to be lua code. The short-name of the mode to set the keymapping for. Passing an empty string is the equivalent of `:map`.
Thus, it will not be wrapped in `""`.
See `:help map-modes` for a list of modes.
''; '';
default = false; example = literalMD ''`["n" "v" "c"]` for normal, visual and command mode'';
}; };
}; };
}; };
mapOptions = mode: legacyMapOption = mode:
mkOption { mkOption {
description = "Mappings for ${mode} mode"; description = "Mappings for ${mode} mode";
type = attrsOf mapOption; type = attrsOf (submodule {
options = mapConfigOptions;
});
default = {}; default = {};
}; };
in { in {
options.vim = { options.vim = {
maps = mkOption { keymaps = mkOption {
type = submodule { type = listOf mapType;
options = { description = "Custom keybindings.";
normal = mapOptions "normal";
insert = mapOptions "insert";
select = mapOptions "select";
visual = mapOptions "visual and select";
terminal = mapOptions "terminal";
normalVisualOp = mapOptions "normal, visual, select and operator-pending (same as plain 'map')";
visualOnly = mapOptions "visual only";
operator = mapOptions "operator-pending";
insertCommand = mapOptions "insert and command-line";
lang = mapOptions "insert, command-line and lang-arg";
command = mapOptions "command-line";
};
};
default = {};
description = ''
Custom keybindings for any mode.
For plain maps (e.g. just 'map' or 'remap') use `maps.normalVisualOp`.
'';
example = '' example = ''
maps = { vim.keymaps = [
normal."<leader>m" = { {
key = "<leader>m";
mode = "n";
silent = true; silent = true;
action = "<cmd>make<CR>"; action = ":make<CR>";
}; # Same as nnoremap <leader>m <silent> <cmd>make<CR> }
}; {
key = "<leader>l";
mode = ["n" "x"];
silent = true;
action = "<cmd>cnext<CR>";
}
];
''; '';
default = {};
};
maps = {
normal = legacyMapOption "normal";
insert = legacyMapOption "insert";
select = legacyMapOption "select";
visual = legacyMapOption "visual and select";
terminal = legacyMapOption "terminal";
normalVisualOp = legacyMapOption "normal, visual, select and operator-pending (same as plain 'map')";
visualOnly = legacyMapOption "visual only";
operator = legacyMapOption "operator-pending";
insertCommand = legacyMapOption "insert and command-line";
lang = legacyMapOption "insert, command-line and lang-arg";
command = legacyMapOption "command-line";
}; };
}; };
} }

View file

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

View file

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

View file

@ -1,21 +1,14 @@
{lib, ...}: let {lib, ...}: let
inherit (lib) mkRemovedOptionModule; inherit (lib) mkRemovedOptionModule;
inherit (lib.options) mkEnableOption mkOption; inherit (lib.options) mkEnableOption;
inherit (lib.types) enum; inherit (lib.nvim.types) mkPluginSetupOption;
in { in {
imports = [ imports = [
(mkRemovedOptionModule ["vim" "autopairs" "nvim-compe"] "nvim-compe is deprecated and no longer suported.") (mkRemovedOptionModule ["vim" "autopairs" "nvim-compe"] "nvim-compe is deprecated and no longer supported.")
]; ];
options.vim = { options.vim.autopairs.nvim-autopairs = {
autopairs = { enable = mkEnableOption "autopairs";
enable = mkEnableOption "autopairs" // {default = false;}; setupOpts = mkPluginSetupOption "nvim-autopairs" {};
type = mkOption {
type = enum ["nvim-autopairs"];
default = "nvim-autopairs";
description = "Set the autopairs type. Options: nvim-autopairs [nvim-autopairs]";
};
};
}; };
} }

View file

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

View file

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

View file

@ -3,246 +3,138 @@
config, config,
... ...
}: let }: let
inherit (builtins) toJSON;
inherit (lib.modules) mkIf mkMerge; inherit (lib.modules) mkIf mkMerge;
inherit (lib.attrsets) attrNames mapAttrsToList; inherit (lib.strings) optionalString;
inherit (lib.strings) concatMapStringsSep concatStringsSep optionalString; inherit (lib.generators) mkLuaInline;
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetLuaBinding; inherit (lib.nvim.lua) toLuaObject;
inherit (lib.nvim.dag) entryAnywhere entryAfter; inherit (lib.nvim.attrsets) mapListToAttrs;
inherit (builtins) attrNames typeOf tryEval concatStringsSep;
cfg = config.vim.autocomplete; borders = config.vim.ui.borders.plugins.nvim-cmp;
lspkindEnabled = config.vim.lsp.enable && config.vim.lsp.lspkind.enable;
self = import ./nvim-cmp.nix {inherit lib;}; cfg = config.vim.autocomplete.nvim-cmp;
mappingDefinitions = self.options.vim.autocomplete.mappings; luasnipEnable = config.vim.snippets.luasnip.enable;
getPluginName = plugin:
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions; if typeOf plugin == "string"
then plugin
builtSources = else if (plugin ? pname && (tryEval plugin.pname).success)
concatMapStringsSep then plugin.pname
"\n" else plugin.name;
(n: "{ name = '${n}'},") inherit (cfg) mappings;
(attrNames cfg.sources);
builtMaps =
concatStringsSep
"\n"
(mapAttrsToList
(n: v:
if v == null
then ""
else "${n} = '${v}',")
cfg.sources);
dagPlacement =
if lspkindEnabled
then entryAfter ["lspkind"]
else entryAnywhere;
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim.startPlugins = [ vim = {
"nvim-cmp" startPlugins = ["rtp-nvim"];
"cmp-buffer" lazy.plugins = mkMerge [
"cmp-vsnip" (mapListToAttrs (package: {
"cmp-path" name = getPluginName package;
"vim-vsnip" value = {
]; inherit package;
lazy = true;
after = ''
local path = vim.fn.globpath(vim.o.packpath, 'pack/*/opt/${getPluginName package}')
require("rtp_nvim").source_after_plugin_dir(path)
'';
};
})
cfg.sourcePlugins)
{
nvim-cmp = {
package = "nvim-cmp";
after = ''
${optionalString luasnipEnable "local luasnip = require('luasnip')"}
local cmp = require("cmp")
vim.autocomplete.sources = { local kinds = require("cmp.types").lsp.CompletionItemKind
"nvim-cmp" = null; local deprio = function(kind)
"vsnip" = "[VSnip]"; return function(e1, e2)
"buffer" = "[Buffer]"; if e1:get_kind() == kind then
"crates" = "[Crates]"; return false
"path" = "[Path]"; end
"copilot" = "[Copilot]"; if e2:get_kind() == kind then
}; return true
end
return nil
end
end
vim.maps.insert = mkMerge [ cmp.setup(${toLuaObject cfg.setupOpts})
(mkSetLuaBinding mappings.complete ''
require('cmp').complete
'')
(let
defaultKeys =
if config.vim.autopairs.enable
then "require('nvim-autopairs').autopairs_cr()"
else "vim.api.nvim_replace_termcodes(${toJSON mappings.confirm.value}, true, false, true)";
in
mkSetLuaBinding mappings.confirm ''
function()
if not require('cmp').confirm({ select = true }) then
vim.fn.feedkeys(${defaultKeys}, 'n')
end
end
'')
(mkSetLuaBinding mappings.next ''
function()
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
local cmp = require('cmp') ${optionalString config.vim.lazy.enable
(concatStringsSep "\n" (map
(package: "require('lz.n').trigger_load(${toLuaObject (getPluginName package)})")
cfg.sourcePlugins))}
'';
local feedkey = function(key, mode) event = ["InsertEnter" "CmdlineEnter"];
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true) };
end
if cmp.visible() then
cmp.select_next_item()
elseif vim.fn['vsnip#available'](1) == 1 then
feedkey("<Plug>(vsnip-expand-or-jump)", "")
elseif has_words_before() then
cmp.complete()
else
local termcode = vim.api.nvim_replace_termcodes(${toJSON mappings.next.value}, true, false, true)
vim.fn.feedkeys(termcode, 'n')
end
end
'')
(mkSetLuaBinding mappings.previous ''
function()
local cmp = require('cmp')
local feedkey = function(key, mode)
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
end
if cmp.visible() then
cmp.select_prev_item()
elseif vim.fn['vsnip#available'](-1) == 1 then
feedkeys("<Plug>(vsnip-jump-prev)", "")
end
end
'')
(mkSetLuaBinding mappings.close ''
require('cmp').mapping.abort()
'')
(mkSetLuaBinding mappings.scrollDocsUp ''
require('cmp').mapping.scroll_docs(-4)
'')
(mkSetLuaBinding mappings.scrollDocsDown ''
require('cmp').mapping.scroll_docs(4)
'')
];
vim.maps.command = mkMerge [
(mkSetLuaBinding mappings.complete ''
require('cmp').complete
'')
(mkSetLuaBinding mappings.close ''
require('cmp').mapping.close()
'')
(mkSetLuaBinding mappings.scrollDocsUp ''
require('cmp').mapping.scroll_docs(-4)
'')
(mkSetLuaBinding mappings.scrollDocsDown ''
require('cmp').mapping.scroll_docs(4)
'')
];
vim.maps.select = mkMerge [
(mkSetLuaBinding mappings.next ''
function()
local cmp = require('cmp')
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
local feedkey = function(key, mode)
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
end
if cmp.visible() then
cmp.select_next_item()
elseif vim.fn['vsnip#available'](1) == 1 then
feedkey("<Plug>(vsnip-expand-or-jump)", "")
elseif has_words_before() then
cmp.complete()
else
local termcode = vim.api.nvim_replace_termcodes(${toJSON mappings.next.value}, true, false, true)
vim.fn.feedkeys(termcode, 'n')
end
end
'')
(mkSetLuaBinding mappings.previous ''
function()
local cmp = require('cmp')
local feedkey = function(key, mode)
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
end
if cmp.visible() then
cmp.select_prev_item()
elseif vim.fn['vsnip#available'](-1) == 1 then
feedkeys("<Plug>(vsnip-jump-prev)", "")
end
end
'')
];
# TODO: alternative snippet engines to vsnip
# https://github.com/hrsh7th/nvim-cmp/blob/main/doc/cmp.txt#L82
vim.pluginRC.completion = mkIf (cfg.type == "nvim-cmp") (dagPlacement ''
local nvim_cmp_menu_map = function(entry, vim_item)
-- name for each source
vim_item.menu = ({
${builtMaps}
})[entry.source.name]
return vim_item
end
${optionalString lspkindEnabled ''
lspkind_opts.before = ${cfg.formatting.format}
''}
local cmp = require'cmp'
cmp.setup({
${optionalString config.vim.ui.borders.enable ''
-- explicitly enabled by setting ui.borders.enable = true
-- TODO: try to get nvim-cmp to follow global border style
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
''}
snippet = {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body)
end,
},
sources = {
${builtSources}
},
completion = {
completeopt = 'menu,menuone,noinsert',
${optionalString (!cfg.alwaysComplete) "autocomplete = false"}
},
formatting = {
format =
${
if lspkindEnabled
then "lspkind.cmp_format(lspkind_opts)"
else cfg.formatting.format
},
} }
}) ];
${optionalString (config.vim.autopairs.enable && config.vim.autopairs.type == "nvim-autopairs") ''
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done({ map_char = { text = ""} }))
''}
'');
vim.snippets.vsnip.enable = autocomplete.nvim-cmp = {
if (cfg.type == "nvim-cmp") sources = {
then true nvim-cmp = null;
else config.vim.snippets.vsnip.enable; buffer = "[Buffer]";
path = "[Path]";
};
sourcePlugins = ["cmp-buffer" "cmp-path"];
setupOpts = {
sources = map (s: {name = s;}) (attrNames cfg.sources);
window = mkIf borders.enable {
completion.border = borders.style;
documentation.border = borders.style;
};
formatting.format = cfg.format;
# `cmp` and `luasnip` are defined above, in the `nvim-cmp` section
mapping = {
${mappings.complete} = mkLuaInline "cmp.mapping.complete()";
${mappings.close} = mkLuaInline "cmp.mapping.abort()";
${mappings.scrollDocsUp} = mkLuaInline "cmp.mapping.scroll_docs(-4)";
${mappings.scrollDocsDown} = mkLuaInline "cmp.mapping.scroll_docs(4)";
${mappings.confirm} = mkLuaInline "cmp.mapping.confirm({ select = true })";
${mappings.next} = mkLuaInline ''
cmp.mapping(function(fallback)
local has_words_before = function()
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end
if cmp.visible() then
cmp.select_next_item()
${optionalString luasnipEnable ''
elseif luasnip.locally_jumpable(1) then
luasnip.jump(1)
''}
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end)
'';
${mappings.previous} = mkLuaInline ''
cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
${optionalString luasnipEnable ''
elseif luasnip.locally_jumpable(-1) then
luasnip.jump(-1)
''}
else
fallback()
end
end)
'';
};
};
};
};
}; };
} }

View file

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

View file

@ -1,72 +1,117 @@
{lib, ...}: let {
inherit (lib.options) mkEnableOption mkOption literalMD; lib,
config,
...
}: let
inherit (lib.options) mkEnableOption mkOption literalExpression literalMD;
inherit (lib.types) str attrsOf nullOr either listOf;
inherit (lib.generators) mkLuaInline;
inherit (lib.nvim.binds) mkMappingOption; inherit (lib.nvim.binds) mkMappingOption;
inherit (lib.types) enum attrsOf nullOr str bool; inherit (lib.nvim.types) mkPluginSetupOption luaInline mergelessListOf pluginType;
inherit (lib.nvim.lua) toLuaObject;
inherit (builtins) isString;
cfg = config.vim.autocomplete.nvim-cmp;
in { in {
options.vim = { options.vim.autocomplete.nvim-cmp = {
autocomplete = { enable = mkEnableOption "nvim-cmp";
enable = mkEnableOption "autocomplete" // {default = false;}; setupOpts = mkPluginSetupOption "the autocomplete plugin" {
completion.completeopt = mkOption {
alwaysComplete = mkOption { type = str;
type = bool; default = "menu,menuone,noinsert";
description = "Automatically show completion.";
default = true;
};
mappings = {
complete = mkMappingOption "Complete [nvim-cmp]" "<C-Space>";
confirm = mkMappingOption "Confirm [nvim-cmp]" "<CR>";
next = mkMappingOption "Next item [nvim-cmp]" "<Tab>";
previous = mkMappingOption "Previous item [nvim-cmp]" "<S-Tab>";
close = mkMappingOption "Close [nvim-cmp]" "<C-e>";
scrollDocsUp = mkMappingOption "Scroll docs up [nvim-cmp]" "<C-d>";
scrollDocsDown = mkMappingOption "Scroll docs down [nvim-cmp]" "<C-f>";
};
type = mkOption {
type = enum ["nvim-cmp"];
default = "nvim-cmp";
description = "Set the autocomplete plugin. Options: [nvim-cmp]";
};
sources = mkOption {
description = '' description = ''
Attribute set of source names for nvim-cmp. A comma-separated list of options for completion.
If an attribute set is provided, then the menu value of See `:help completeopt` for the complete list.
`vim_item` in the format will be set to the value (if
utilizing the `nvim_cmp_menu_map` function).
Note: only use a single attribute name per attribute set
'';
type = attrsOf (nullOr str);
default = {};
example = ''
{nvim-cmp = null; buffer = "[Buffer]";}
''; '';
}; };
formatting = { sorting.comparators = mkOption {
format = mkOption { type = mergelessListOf (either str luaInline);
description = '' default = [
The function used to customize the appearance of the completion menu. (mkLuaInline "deprio(kinds.Text)")
(mkLuaInline "deprio(kinds.Snippet)")
"offset"
"exact"
"score"
"kind"
"length"
"sort_text"
];
description = ''
The comparator functions used for sorting completions.
If [](#opt-vim.lsp.lspkind.enable) is true, then the function You can either pass a valid inline lua function
will be called before modifications from lspkind. (see `:help cmp-config.sorting.comparators`),
or a string, in which case the builtin comparator with that name will
be used.
Default is to call the menu mapping function. A `deprio` function and a `kinds`
''; (`require("cmp.types").lsp.CompletionItemKind`) variable is provided
type = str; above `setupOpts`. By passing a type to the function, the returned
default = "nvim_cmp_menu_map"; function will be a comparator that always ranks the specified kind the
example = literalMD '' lowest.
```lua '';
function(entry, vim_item) apply = map (
return vim_item c:
end if isString c
``` then mkLuaInline ("cmp.config.compare." + c)
''; else c
}; );
}; };
}; };
mappings = {
complete = mkMappingOption "Complete [nvim-cmp]" "<C-Space>";
confirm = mkMappingOption "Confirm [nvim-cmp]" "<CR>";
next = mkMappingOption "Next item [nvim-cmp]" "<Tab>";
previous = mkMappingOption "Previous item [nvim-cmp]" "<S-Tab>";
close = mkMappingOption "Close [nvim-cmp]" "<C-e>";
scrollDocsUp = mkMappingOption "Scroll docs up [nvim-cmp]" "<C-d>";
scrollDocsDown = mkMappingOption "Scroll docs down [nvim-cmp]" "<C-f>";
};
format = mkOption {
type = nullOr luaInline;
default = mkLuaInline ''
function(entry, vim_item)
vim_item.menu = (${toLuaObject cfg.sources})[entry.source.name]
return vim_item
end
'';
defaultText = literalMD ''
```lua
function(entry, vim_item)
vim_item.menu = (''${toLuaObject config.vim.autocomplete.nvim-cmp.sources})[entry.source.name]
return vim_item
end
```
'';
description = ''
The function used to customize the completion menu entries. This is
outside of `setupOpts` to allow for an easier integration with
lspkind.nvim.
See `:help cmp-config.formatting.format`.
'';
};
sources = mkOption {
type = attrsOf (nullOr str);
default = {};
description = "The list of sources used by nvim-cmp";
example = literalExpression ''
{
nvim-cmp = null;
buffer = "[Buffer]";
}
'';
};
sourcePlugins = mkOption {
type = listOf pluginType;
default = [];
description = "List of source plugins used by nvim-cmp.";
};
}; };
} }

View file

@ -101,7 +101,7 @@ in {
customIndices = mkOption { customIndices = mkOption {
default = []; default = [];
description = "Specify a list of default charecters to use instead of numbers"; description = "Specify a list of default characters to use instead of numbers";
type = listOf str; type = listOf str;
}; };

View file

@ -1,4 +1,5 @@
{ {
options,
config, config,
lib, lib,
... ...
@ -6,67 +7,76 @@
inherit (lib.strings) optionalString; inherit (lib.strings) optionalString;
inherit (lib.modules) mkIf mkMerge; inherit (lib.modules) mkIf mkMerge;
inherit (lib.attrsets) mapAttrs; inherit (lib.attrsets) mapAttrs;
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetLuaBinding; inherit (lib.nvim.binds) mkKeymap;
inherit (lib.nvim.dag) entryAnywhere entryAfter; inherit (lib.nvim.dag) entryAnywhere entryAfter;
cfg = config.vim.debugger.nvim-dap; cfg = config.vim.debugger.nvim-dap;
self = import ./nvim-dap.nix {inherit lib;}; inherit (options.vim.debugger.nvim-dap) mappings;
mappingDefinitions = self.options.vim.debugger.nvim-dap.mappings;
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
in { in {
config = mkMerge [ config = mkMerge [
(mkIf cfg.enable { (mkIf cfg.enable {
vim.startPlugins = ["nvim-dap"]; vim = {
startPlugins = ["nvim-dap"];
vim.pluginRC = pluginRC =
{ {
# TODO customizable keymaps # TODO customizable keymaps
nvim-dap = entryAnywhere '' nvim-dap = entryAnywhere ''
local dap = require("dap") local dap = require("dap")
vim.fn.sign_define("DapBreakpoint", { text = "🛑", texthl = "ErrorMsg", linehl = "", numhl = "" }) vim.fn.sign_define("DapBreakpoint", { text = "🛑", texthl = "ErrorMsg", linehl = "", numhl = "" })
''; '';
} }
// mapAttrs (_: v: (entryAfter ["nvim-dap"] v)) cfg.sources; // mapAttrs (_: v: (entryAfter ["nvim-dap"] v)) cfg.sources;
vim.maps.normal = mkMerge [ keymaps = [
(mkSetLuaBinding mappings.continue "require('dap').continue") (mkKeymap "n" cfg.mappings.continue "require('dap').continue" {desc = mappings.continue.description;})
(mkSetLuaBinding mappings.restart "require('dap').restart") (mkKeymap "n" cfg.mappings.restart "require('dap').restart" {desc = mappings.restart.description;})
(mkSetLuaBinding mappings.terminate "require('dap').terminate") (mkKeymap "n" cfg.mappings.terminate "require('dap').terminate" {desc = mappings.terminate.description;})
(mkSetLuaBinding mappings.runLast "require('dap').run_last") (mkKeymap "n" cfg.mappings.runLast "require('dap').run_last" {desc = mappings.runLast.description;})
(mkSetLuaBinding mappings.toggleRepl "require('dap').repl.toggle") (mkKeymap "n" cfg.mappings.toggleRepl "require('dap').repl.toggle" {desc = mappings.toggleRepl.description;})
(mkSetLuaBinding mappings.hover "require('dap.ui.widgets').hover") (mkKeymap "n" cfg.mappings.hover "require('dap.ui.widgets').hover" {desc = mappings.hover.description;})
(mkSetLuaBinding mappings.toggleBreakpoint "require('dap').toggle_breakpoint") (mkKeymap "n" cfg.mappings.toggleBreakpoint "require('dap').toggle_breakpoint" {desc = mappings.toggleBreakpoint.description;})
(mkSetLuaBinding mappings.runToCursor "require('dap').run_to_cursor") (mkKeymap "n" cfg.mappings.runToCursor "require('dap').run_to_cursor" {desc = mappings.runToCursor.description;})
(mkSetLuaBinding mappings.stepInto "require('dap').step_into") (mkKeymap "n" cfg.mappings.stepInto "require('dap').step_into" {desc = mappings.stepInto.description;})
(mkSetLuaBinding mappings.stepOut "require('dap').step_out") (mkKeymap "n" cfg.mappings.stepOut "require('dap').step_out" {desc = mappings.stepOut.description;})
(mkSetLuaBinding mappings.stepOver "require('dap').step_over") (mkKeymap "n" cfg.mappings.stepOver "require('dap').step_over" {desc = mappings.stepOver.description;})
(mkSetLuaBinding mappings.stepBack "require('dap').step_back") (mkKeymap "n" cfg.mappings.stepBack "require('dap').step_back" {desc = mappings.stepBack.description;})
(mkSetLuaBinding mappings.goUp "require('dap').up") (mkKeymap "n" cfg.mappings.goUp "require('dap').up" {desc = mappings.goUp.description;})
(mkSetLuaBinding mappings.goDown "require('dap').down") (mkKeymap "n" cfg.mappings.goDown "require('dap').down" {desc = mappings.goDown.description;})
]; ];
};
}) })
(mkIf (cfg.enable && cfg.ui.enable) { (mkIf (cfg.enable && cfg.ui.enable) {
vim.startPlugins = ["nvim-dap-ui" "nvim-nio"]; vim = {
startPlugins = ["nvim-nio"];
vim.pluginRC.nvim-dap-ui = entryAfter ["nvim-dap"] ('' lazy.plugins.nvim-dap-ui = {
local dapui = require("dapui") package = "nvim-dap-ui";
dapui.setup() setupModule = "dapui";
'' inherit (cfg.ui) setupOpts;
+ optionalString cfg.ui.autoStart ''
dap.listeners.after.event_initialized["dapui_config"] = function() keys = [
dapui.open() (mkKeymap "n" cfg.mappings.toggleDapUI "function() require('dapui').toggle() end" {desc = mappings.toggleDapUI.description;})
end ];
dap.listeners.before.event_terminated["dapui_config"] = function() };
dapui.close()
end pluginRC.nvim-dap-ui = entryAfter ["nvim-dap"] (
dap.listeners.before.event_exited["dapui_config"] = function() optionalString cfg.ui.autoStart ''
dapui.close() dap.listeners.after.event_initialized["dapui_config"] = function()
end require("dapui").open()
''); end
vim.maps.normal = mkSetLuaBinding mappings.toggleDapUI "require('dapui').toggle"; dap.listeners.before.event_terminated["dapui_config"] = function()
require("dapui").close()
end
dap.listeners.before.event_exited["dapui_config"] = function()
require("dapui").close()
end
''
);
};
}) })
]; ];
} }

View file

@ -2,12 +2,16 @@
inherit (lib.options) mkEnableOption mkOption; inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) bool attrsOf str; inherit (lib.types) bool attrsOf str;
inherit (lib.nvim.binds) mkMappingOption; inherit (lib.nvim.binds) mkMappingOption;
inherit (lib.nvim.types) mkPluginSetupOption;
in { in {
options.vim.debugger.nvim-dap = { options.vim.debugger.nvim-dap = {
enable = mkEnableOption "debugging via nvim-dap"; enable = mkEnableOption "debugging via nvim-dap";
ui = { ui = {
enable = mkEnableOption "UI extension for nvim-dap"; enable = mkEnableOption "UI extension for nvim-dap";
setupOpts = mkPluginSetupOption "nvim-dap-ui" {};
autoStart = mkOption { autoStart = mkOption {
type = bool; type = bool;
default = true; default = true;
@ -22,7 +26,7 @@ in {
}; };
mappings = { mappings = {
continue = mkMappingOption "Contiue" "<leader>dc"; continue = mkMappingOption "Continue" "<leader>dc";
restart = mkMappingOption "Restart" "<leader>dR"; restart = mkMappingOption "Restart" "<leader>dR";
terminate = mkMappingOption "Terminate" "<leader>dq"; terminate = mkMappingOption "Terminate" "<leader>dq";
runLast = mkMappingOption "Re-run Last Debug Session" "<leader>d."; runLast = mkMappingOption "Re-run Last Debug Session" "<leader>d.";

View file

@ -5,7 +5,6 @@
}: let }: let
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere; inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.filetree.neo-tree; cfg = config.vim.filetree.neo-tree;
in { in {
@ -16,15 +15,37 @@ in {
"plenary-nvim" # commons library "plenary-nvim" # commons library
"image-nvim" # optional for image previews "image-nvim" # optional for image previews
"nui-nvim" # ui library "nui-nvim" # ui library
# neotree
"neo-tree-nvim"
]; ];
visuals.nvimWebDevicons.enable = true; lazy.plugins.neo-tree-nvim = {
package = "neo-tree-nvim";
setupModule = "neo-tree";
inherit (cfg) setupOpts;
pluginRC.neo-tree = entryAnywhere '' cmd = ["Neotree"];
require("neo-tree").setup(${toLuaObject cfg.setupOpts}) };
'';
visuals.nvim-web-devicons.enable = true;
# from https://github.com/nvim-neo-tree/neo-tree.nvim/discussions/1326
pluginRC.neo-tree =
mkIf (cfg.setupOpts.filesystem.hijack_netrw_behavior != "disabled" && config.vim.lazy.enable)
(entryAnywhere ''
vim.api.nvim_create_autocmd("BufEnter", {
group = vim.api.nvim_create_augroup("load_neo_tree", {}),
desc = "Loads neo-tree when opening a directory",
callback = function(args)
local stats = vim.uv.fs_stat(args.file)
if not stats or stats.type ~= "directory" then
return
end
require("lz.n").trigger_load("neo-tree-nvim")
return true
end,
})
'');
}; };
}; };
} }

View file

@ -1,5 +1,5 @@
{lib, ...}: let {lib, ...}: let
inherit (lib.types) bool str int submodule enum either listOf; inherit (lib.types) bool str enum either listOf;
inherit (lib.options) mkOption mkEnableOption literalExpression; inherit (lib.options) mkOption mkEnableOption literalExpression;
inherit (lib.nvim.types) mkPluginSetupOption; inherit (lib.nvim.types) mkPluginSetupOption;
in { in {
@ -150,6 +150,14 @@ in {
A list of filetypes that should not be replaced when opening a file A list of filetypes that should not be replaced when opening a file
''; '';
}; };
filesystem = {
hijack_netrw_behavior = mkOption {
type = enum ["disabled" "open_default" "open_current"];
default = "open_default";
description = "Hijack Netrw behavior";
};
};
}; };
}; };
} }

View file

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

View file

@ -0,0 +1,49 @@
{
config,
pkgs,
lib,
...
}: let
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.types) package;
inherit (lib.nvim.types) mkGrammarOption;
cfg = config.vim.languages.assembly;
in {
options.vim.languages.assembly = {
enable = mkEnableOption "Assembly support";
treesitter = {
enable = mkEnableOption "Assembly treesitter" // {default = config.vim.languages.enableTreesitter;};
package = mkGrammarOption pkgs "asm";
};
lsp = {
enable = mkEnableOption "Assembly LSP support (asm-lsp)" // {default = config.vim.languages.enableLSP;};
package = mkOption {
type = package;
default = pkgs.asm-lsp;
description = "asm-lsp package";
};
};
};
config = mkIf cfg.enable (mkMerge [
(mkIf cfg.treesitter.enable {
vim.treesitter.enable = true;
vim.treesitter.grammars = [cfg.treesitter.package];
})
(mkIf cfg.lsp.enable {
vim.lsp.lspconfig.enable = true;
vim.lsp.lspconfig.sources.asm-lsp = ''
lspconfig.asm_lsp.setup {
capabilities = capabilities,
on_attach = default_on_attach,
cmd = {"${cfg.lsp.package}/bin/asm-lsp"},
}
'';
})
]);
}

View file

@ -0,0 +1,159 @@
{
config,
pkgs,
lib,
...
}: let
inherit (builtins) attrNames;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) isList;
inherit (lib.meta) getExe;
inherit (lib.types) enum either listOf package str;
inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.languages) diagnosticsToLua;
inherit (lib.nvim.types) mkGrammarOption diagnostics;
cfg = config.vim.languages.astro;
defaultServer = "astro";
servers = {
astro = {
package = pkgs.astro-language-server;
lspConfig = ''
lspconfig.astro.setup {
capabilities = capabilities;
on_attach = attach_keymaps,
cmd = ${
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/astro-ls", "--stdio"}''
}
}
'';
};
};
# TODO: specify packages
defaultFormat = "prettier";
formats = {
prettier = {
package = pkgs.nodePackages.prettier;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.prettier.with({
command = "${cfg.format.package}/bin/prettier",
})
)
'';
};
biome = {
package = pkgs.biome;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.biome.with({
command = "${cfg.format.package}/bin/biome",
})
)
'';
};
};
# TODO: specify packages
defaultDiagnosticsProvider = ["eslint_d"];
diagnosticsProviders = {
eslint_d = {
package = pkgs.eslint_d;
nullConfig = pkg: ''
table.insert(
ls_sources,
null_ls.builtins.diagnostics.eslint_d.with({
command = "${getExe pkg}",
})
)
'';
};
};
in {
options.vim.languages.astro = {
enable = mkEnableOption "Astro language support";
treesitter = {
enable = mkEnableOption "Astro treesitter" // {default = config.vim.languages.enableTreesitter;};
astroPackage = mkGrammarOption pkgs "astro";
};
lsp = {
enable = mkEnableOption "Astro LSP support" // {default = config.vim.languages.enableLSP;};
server = mkOption {
description = "Astro LSP server to use";
type = enum (attrNames servers);
default = defaultServer;
};
package = mkOption {
description = "Astro LSP server package, or the command to run as a list of strings";
example = ''[lib.getExe pkgs.astro-language-server "--minify" "--stdio"]'';
type = either package (listOf str);
default = servers.${cfg.lsp.server}.package;
};
};
format = {
enable = mkEnableOption "Astro formatting" // {default = config.vim.languages.enableFormat;};
type = mkOption {
description = "Astro formatter to use";
type = enum (attrNames formats);
default = defaultFormat;
};
package = mkOption {
description = "Astro formatter package";
type = package;
default = formats.${cfg.format.type}.package;
};
};
extraDiagnostics = {
enable = mkEnableOption "extra Astro diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;};
types = diagnostics {
langDesc = "Astro";
inherit diagnosticsProviders;
inherit defaultDiagnosticsProvider;
};
};
};
config = mkIf cfg.enable (mkMerge [
(mkIf cfg.treesitter.enable {
vim.treesitter.enable = true;
vim.treesitter.grammars = [cfg.treesitter.astroPackage];
})
(mkIf cfg.lsp.enable {
vim.lsp.lspconfig.enable = true;
vim.lsp.lspconfig.sources.astro-lsp = servers.${cfg.lsp.server}.lspConfig;
})
(mkIf cfg.format.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources.astro-format = formats.${cfg.format.type}.nullConfig;
})
(mkIf cfg.extraDiagnostics.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources = diagnosticsToLua {
lang = "astro";
config = cfg.extraDiagnostics.types;
inherit diagnosticsProviders;
};
})
]);
}

View file

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

View file

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

View file

@ -2,23 +2,30 @@
inherit (lib.nvim.languages) mkEnable; inherit (lib.nvim.languages) mkEnable;
in { in {
imports = [ imports = [
./asm.nix
./astro.nix
./bash.nix ./bash.nix
./dart.nix ./dart.nix
./clang.nix ./clang.nix
./css.nix ./css.nix
./elixir.nix ./elixir.nix
./gleam.nix
./go.nix ./go.nix
./hcl.nix
./kotlin.nix
./html.nix ./html.nix
./java.nix ./java.nix
./lua.nix ./lua.nix
./markdown.nix ./markdown.nix
./nim.nix ./nim.nix
./vala.nix
./nix.nix ./nix.nix
./ocaml.nix ./ocaml.nix
./php.nix ./php.nix
./python.nix ./python.nix
./r.nix ./r.nix
./rust.nix ./rust.nix
./scala.nix
./sql.nix ./sql.nix
./svelte.nix ./svelte.nix
./tailwind.nix ./tailwind.nix
@ -26,6 +33,9 @@ in {
./ts.nix ./ts.nix
./typst.nix ./typst.nix
./zig.nix ./zig.nix
./csharp.nix
./julia.nix
./nu.nix
]; ];
options.vim.languages = { options.vim.languages = {

View file

@ -0,0 +1,71 @@
{
config,
pkgs,
lib,
...
}: let
inherit (builtins) attrNames;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) isList;
inherit (lib.types) enum either listOf package str;
inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.types) mkGrammarOption;
cfg = config.vim.languages.gleam;
defaultServer = "gleam";
servers = {
gleam = {
package = pkgs.gleam;
lspConfig = ''
lspconfig.gleam.setup{
capabilities = capabilities,
on_attach = default_on_attach,
cmd = ${
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/gleam", "lsp"}''
}
}
'';
};
};
in {
options.vim.languages.gleam = {
enable = mkEnableOption "Gleam language support";
treesitter = {
enable = mkEnableOption "Gleam treesitter" // {default = config.vim.languages.enableTreesitter;};
package = mkGrammarOption pkgs "gleam";
};
lsp = {
enable = mkEnableOption "Gleam LSP support" // {default = config.vim.languages.enableLSP;};
server = mkOption {
type = enum (attrNames servers);
default = defaultServer;
description = "Gleam LSP server to use";
};
package = mkOption {
type = either package (listOf str);
default = servers.${cfg.lsp.server}.package;
description = "Gleam LSP server package, or the command to run as a list of strings";
};
};
};
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.gleam-lsp = servers.${cfg.lsp.server}.lspConfig;
})
]);
}

View file

@ -0,0 +1,117 @@
{
config,
pkgs,
lib,
...
}: let
inherit (builtins) attrNames;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.types) package bool enum;
inherit (lib.nvim.types) mkGrammarOption;
cfg = config.vim.languages.hcl;
defaultServer = "terraform-ls";
servers = {
terraform-ls = {
package = pkgs.terraform-ls;
lspConfig = ''
lspconfig.terraformls.setup {
capabilities = capabilities,
on_attach=default_on_attach,
cmd = {"${lib.getExe cfg.lsp.package}", "serve"},
}
'';
};
};
defaultFormat = "hclfmt";
formats = {
hclfmt = {
package = pkgs.hclfmt;
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.hclfmt.with({
command = "${lib.getExe cfg.format.package}",
})
)
'';
};
};
in {
options.vim.languages.hcl = {
enable = mkEnableOption "HCL support";
treesitter = {
enable = mkEnableOption "HCL treesitter" // {default = config.vim.languages.enableTreesitter;};
package = mkGrammarOption pkgs "hcl";
};
lsp = {
enable = mkEnableOption "HCL LSP support (terraform-ls)" // {default = config.vim.languages.enableLSP;};
# TODO: (maybe, is it better?) it would be cooler to use vscode-extensions.hashicorp.hcl probably, shouldn't be too hard
package = mkOption {
type = package;
default = servers.${defaultServer}.package;
description = "HCL language server package (terraform-ls)";
};
};
format = {
enable = mkOption {
type = bool;
default = config.vim.languages.enableFormat;
description = "Enable HCL formatting";
};
type = mkOption {
type = enum (attrNames formats);
default = defaultFormat;
description = "HCL formatter to use";
};
package = mkOption {
type = package;
default = formats.${cfg.format.type}.package;
description = "HCL formatter package";
};
};
};
config = mkIf cfg.enable (mkMerge [
{
# hcl style official: https://developer.hashicorp.com/terraform/language/style#code-formatting
vim.pluginRC.hcl = ''
vim.api.nvim_create_autocmd("FileType", {
pattern = "hcl",
callback = function(opts)
local bo = vim.bo[opts.buf]
bo.tabstop = 2
bo.shiftwidth = 2
bo.softtabstop = 2
end
})
local ft = require('Comment.ft')
ft
.set('hcl', '#%s')
'';
}
(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 = lib.optionalAttrs (! config.vim.languages.terraform.lsp.enable) {
terraform-ls = servers.${cfg.lsp.server}.lspConfig;
};
})
(mkIf cfg.format.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources.hcl-format = formats.${cfg.format.type}.nullConfig;
})
]);
}

View file

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

View file

@ -0,0 +1,107 @@
{
config,
pkgs,
lib,
...
}: let
inherit (lib.options) mkEnableOption mkOption literalExpression;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.meta) getExe;
inherit (lib.nvim.languages) diagnosticsToLua;
inherit (lib.types) either package listOf str;
inherit (lib.nvim.types) mkGrammarOption diagnostics;
inherit (lib.lists) isList;
inherit (lib.nvim.lua) expToLua;
cfg = config.vim.languages.kotlin;
defaultDiagnosticsProvider = ["ktlint"];
diagnosticsProviders = {
ktlint = {
package = pkgs.ktlint;
nullConfig = pkg: ''
table.insert(
ls_sources,
null_ls.builtins.diagnostics.ktlint.with({
command = "${getExe pkg}",
})
)
'';
};
};
in {
options.vim.languages.kotlin = {
enable = mkEnableOption "Kotlin/HCL support";
treesitter = {
enable = mkEnableOption "Kotlin treesitter" // {default = config.vim.languages.enableTreesitter;};
package = mkGrammarOption pkgs "kotlin";
};
lsp = {
enable = mkEnableOption "Kotlin LSP support" // {default = config.vim.languages.enableLSP;};
package = mkOption {
description = "kotlin_language_server package with Kotlin runtime";
type = either package (listOf str);
example = literalExpression ''
pkgs.symlinkJoin {
name = "kotlin-language-server-wrapped";
paths = [pkgs.kotlin-language-server];
nativeBuildInputs = [pkgs.makeBinaryWrapper];
postBuild = '''
wrapProgram $out/bin/kotlin-language-server \
--prefix PATH : ''${pkgs.kotlin}/bin
''';
};
'';
default = pkgs.kotlin-language-server;
};
};
extraDiagnostics = {
enable = mkEnableOption "extra Kotlin diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;};
types = diagnostics {
langDesc = "Kotlin";
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.extraDiagnostics.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources = diagnosticsToLua {
lang = "kotlin";
config = cfg.extraDiagnostics.types;
inherit diagnosticsProviders;
};
})
(mkIf cfg.lsp.enable {
vim.lsp.lspconfig.enable = true;
vim.lsp.lspconfig.sources.kotlin_language_server = ''
lspconfig.kotlin_language_server.setup {
capabilities = capabilities,
root_dir = lspconfig.util.root_pattern("main.kt", ".git"),
on_attach=default_on_attach,
init_options = {
-- speeds up the startup time for the LSP
storagePath = vim.fn.stdpath('state') .. '/kotlin',
},
cmd = ${
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/kotlin-language-server"}''
},
}
'';
})
]);
}

View file

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

View file

@ -0,0 +1,70 @@
{
lib,
pkgs,
config,
...
}: let
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) str either package listOf;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.types) mkGrammarOption;
inherit (builtins) isList;
defaultServer = "nushell";
servers = {
nushell = {
package = pkgs.nushell;
lspConfig = ''
lspconfig.nushell.setup{
capabilities = capabilities,
on_attach = default_on_attach,
cmd = ${
if isList cfg.lsp.package
then expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/nu", "--no-config-file", "--lsp"}''
}
}
'';
};
};
cfg = config.vim.languages.nu;
in {
options.vim.languages.nu = {
enable = mkEnableOption "Nu language support";
treesitter = {
enable = mkEnableOption "Nu treesitter" // {default = config.vim.languages.enableTreesitter;};
package = mkGrammarOption pkgs "nu";
};
lsp = {
enable = mkEnableOption "Nu LSP support" // {default = config.vim.languages.enableLSP;};
server = mkOption {
type = str;
default = defaultServer;
description = "Nu LSP server to use";
};
package = mkOption {
type = either package (listOf str);
default = servers.${cfg.lsp.server}.package;
example = ''[(lib.getExe pkgs.nushell) "--lsp"]'';
description = "Nu LSP server package, or the command to run as a list of strings";
};
};
};
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.nu-lsp = servers.${cfg.lsp.server}.lspConfig;
})
]);
}

View file

@ -15,7 +15,38 @@
cfg = config.vim.languages.r; cfg = config.vim.languages.r;
r-with-languageserver = pkgs.rWrapper.override { r-with-languageserver = pkgs.rWrapper.override {
packages = with pkgs.rPackages; [languageserver]; packages = [pkgs.rPackages.languageserver];
};
defaultFormat = "format_r";
formats = {
styler = {
package = pkgs.rWrapper.override {
packages = [pkgs.rPackages.styler];
};
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.styler.with({
command = "${cfg.format.package}/bin/R",
})
)
'';
};
format_r = {
package = pkgs.rWrapper.override {
packages = [pkgs.rPackages.formatR];
};
nullConfig = ''
table.insert(
ls_sources,
null_ls.builtins.formatting.format_r.with({
command = "${cfg.format.package}/bin/R",
})
)
'';
};
}; };
defaultServer = "r_language_server"; defaultServer = "r_language_server";
@ -62,6 +93,22 @@ in {
default = servers.${cfg.lsp.server}.package; default = servers.${cfg.lsp.server}.package;
}; };
}; };
format = {
enable = mkEnableOption "R formatting" // {default = config.vim.languages.enableFormat;};
type = mkOption {
type = enum (attrNames formats);
default = defaultFormat;
description = "R formatter to use";
};
package = mkOption {
type = package;
default = formats.${cfg.format.type}.package;
description = "R formatter package";
};
};
}; };
config = mkIf cfg.enable (mkMerge [ config = mkIf cfg.enable (mkMerge [
@ -70,6 +117,11 @@ in {
vim.treesitter.grammars = [cfg.treesitter.package]; vim.treesitter.grammars = [cfg.treesitter.package];
}) })
(mkIf cfg.format.enable {
vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources.r-format = formats.${cfg.format.type}.nullConfig;
})
(mkIf cfg.lsp.enable { (mkIf cfg.lsp.enable {
vim.lsp.lspconfig.enable = true; vim.lsp.lspconfig.enable = true;
vim.lsp.lspconfig.sources.r-lsp = servers.${cfg.lsp.server}.lspConfig; vim.lsp.lspconfig.sources.r-lsp = servers.${cfg.lsp.server}.lspConfig;

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