mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-26 15:06:45 +00:00
Compare commits
56 commits
eb1f4cd98e
...
5987b911e8
Author | SHA1 | Date | |
---|---|---|---|
5987b911e8 | |||
2016ca1473 | |||
a831d229d4 | |||
49f751ee18 | |||
3e571d0e0c | |||
5c09def08e | |||
318e972a77 | |||
4435754702 | |||
a2b9e645eb | |||
3e0e9331f0 | |||
c1904bc9e5 | |||
94f6f7eceb | |||
2a2d1b6d2c | |||
07f6ac5db0 | |||
81eda5b340 | |||
f429379e34 | |||
688bb8d9ba | |||
|
21fcace3ed | ||
|
0e763161e2 | ||
|
c6453c4e69 | ||
1166e8aa1d | |||
42c5228dc1 | |||
|
665feee445 | ||
|
0aa557dac6 | ||
|
5ab1af9285 | ||
|
30a8a8fce0 | ||
|
da86e554a6 | ||
|
71e2ae1db4 | ||
|
e80520ddf3 | ||
|
3c4eced9d1 | ||
|
ff9b0eeb1f | ||
|
54ec473039 | ||
|
a7e0542fd0 | ||
|
94d2b837cf | ||
be81f19b5f | |||
|
f5d33f6a53 | ||
|
caaacbf59c | ||
|
c0790c5494 | ||
|
7dbd1cd8d1 | ||
ef413736e9 | |||
|
b39b84490f | ||
|
7a8b95cf7c | ||
|
b637f921d5 | ||
649f5513f9 | |||
18ae3e1f6c | |||
3299facbaa | |||
|
bdf777dc8a | ||
|
6670d752c7 | ||
5826aebdd3 | |||
a6c879e8a3 | |||
141a272747 | |||
|
941a2a6f2e | ||
|
e40cce5653 | ||
|
2fc7dc798b | ||
3ca7e3b841 | |||
|
b71bf75dcd |
100 changed files with 3235 additions and 1437 deletions
72
.github/README.md
vendored
72
.github/README.md
vendored
|
@ -48,7 +48,7 @@
|
|||
[Documentation]: #documentation
|
||||
[Help]: #help
|
||||
[Contribute]: #contributing
|
||||
[FAQ]: #faq
|
||||
[FAQ]: #frequently-asked-questions
|
||||
[Credits]: #credits
|
||||
|
||||
**[<kbd><br> Features <br></kbd>][Features]**
|
||||
|
@ -56,7 +56,7 @@
|
|||
**[<kbd><br> Documentation <br></kbd>][Documentation]**
|
||||
**[<kbd><br> Help <br></kbd>][Help]**
|
||||
**[<kbd><br> Contribute <br></kbd>][Contribute]**
|
||||
**[<kbd><br> FAQ <br></kbd>][Faq]** **[<kbd><br> Credits <br></kbd>][Credits]**
|
||||
**[<kbd><br> FAQ <br></kbd>][FAQ]** **[<kbd><br> Credits <br></kbd>][Credits]**
|
||||
|
||||
</p></div>
|
||||
|
||||
|
@ -64,12 +64,21 @@
|
|||
|
||||
## 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
|
||||
surprises, promise!
|
||||
- **Portable**: nvf depends _solely_ on your Nix store, and nothing else. No
|
||||
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 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
|
||||
undocumented, obscure behaviour.
|
||||
- **Idiomatic**: nvf does things ✨ _the right way_ ✨ - the codebase is, and
|
||||
|
@ -120,7 +129,9 @@ instructions.
|
|||
|
||||
## 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
|
||||
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
|
||||
requests are also welcome, and appreciated.
|
||||
|
||||
## Help
|
||||
## Getting Help
|
||||
|
||||
You can create an issue on the [issue tracker] to ask questions or report bugs.
|
||||
I am not yet on spaces like matrix or IRC, so please use the issue tracker for
|
||||
now.
|
||||
If you are confused, stuck or would like to ask a simple question; you may
|
||||
create an issue on the [issue tracker] to ask questions or report bugs.
|
||||
|
||||
We are not not yet on spaces like matrix or IRC, so please use the issue tracker
|
||||
for now.
|
||||
|
||||
## 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
|
||||
fix.
|
||||
|
||||
## FAQ
|
||||
## Frequently Asked Questions
|
||||
|
||||
[appropriate issue template]: https://github.com/NotAShelf/nvf/issues/new/choose
|
||||
[list of branches]: https://github.com/NotAShelf/nvf/branches
|
||||
|
@ -160,13 +173,15 @@ fix.
|
|||
|
||||
**Q**: What platforms are supported?
|
||||
<br/> **A**: nvf actively supports Linux and Darwin platforms using standalone
|
||||
Nix, NixOS or Home-Manager. Please take a look at the
|
||||
Nix, NixOS or Home-Manager. Please take a look at the [nvf manual] for available
|
||||
installation instructions.
|
||||
|
||||
**Q**: Can you add _X_?
|
||||
<br/> **A**: Maybe! It is not one of our goals to support each and every Neovim
|
||||
plugin, however, I am always open to new modules and plugin setup additions to
|
||||
**nvf**. Use the [appropriate issue template] and I will consider a module
|
||||
addition. As mentioned before, PRs adding new features are also welcome.
|
||||
addition. As mentioned before, pull requests to add new features are also
|
||||
welcome.
|
||||
|
||||
**Q**: A plugin I need is not available in **nvf**. What to do?
|
||||
<br/> **A**: **nvf** exposes several APIs for you to be able to add your own
|
||||
|
@ -185,22 +200,26 @@ better prepare to breaking changes.
|
|||
|
||||
### Contributors
|
||||
|
||||
Special, heart-felt thanks to
|
||||
[mnw]: https://github.com/gerg-l/mnw
|
||||
|
||||
- [@fufexan](https://github.com/fufexan) - For the transition to flake-parts
|
||||
- [@FlafyDev](https://github.com/FlafyDev) - For getting the home-manager to
|
||||
work
|
||||
nvf would not be what it is today without the awesome people below. Special,
|
||||
heart-felt thanks to
|
||||
|
||||
- [@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
|
||||
possible
|
||||
possible, and other module additions.
|
||||
- [@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
|
||||
- [@FrothyMarrow](https://github.com/FrothyMarrow) - For seeing mistakes that I
|
||||
could not
|
||||
- [@Diniamo](https://github.com/Diniamo) - For actively submitting PRs, pull
|
||||
requests and overall assistence
|
||||
- [@Gerg-l](https://github.com/gerg-l) - For the modern Neovim wrapper, mnw and
|
||||
occasional code improvements
|
||||
could not.
|
||||
- [@Diniamo](https://github.com/Diniamo) - For actively submitting pull
|
||||
requests, issues and assistance with maintenance of nvf.
|
||||
- [@Gerg-l](https://github.com/gerg-l) - For the modern Neovim wrapper, [mnw],
|
||||
and occasional code improvements.
|
||||
|
||||
and everyone who has submitted issues or pull requests!
|
||||
|
||||
|
@ -214,7 +233,7 @@ including:
|
|||
is originally based on.
|
||||
- [@sioodmy's](https://github.com/sioodmy)
|
||||
[dotfiles](https://github.com/sioodmy/dotfiles) that inspired the design
|
||||
choices.
|
||||
choices for UI and plugin defaults.
|
||||
- [@wiltaylor's](https://github.com/wiltaylor)
|
||||
[neovim-flake](https://github.com/wiltaylor/neovim-flake) for plugin and
|
||||
design ideas.
|
||||
|
@ -229,10 +248,11 @@ recommend checking their work out.
|
|||
## License
|
||||
|
||||
Following the license of the
|
||||
[original neovim-flake](https://github.com/jordanisaacs/neovim-flake), **nvf**
|
||||
has been made available under the [**MIT License**](LICENSE). However, all
|
||||
assets and documentation are published under the
|
||||
[**CC BY License**](https://github.com/NotAShelf/nvf/blob/main/.github/assets/LICENSE).
|
||||
[original neovim-flake](https://github.com/jordanisaacs/neovim-flake), nvf has
|
||||
been made available under the [**MIT License**](LICENSE). However, all assets
|
||||
and documentation are published under the
|
||||
[**CC BY License**](https://github.com/NotAShelf/nvf/blob/main/.github/assets/LICENSE)
|
||||
under explicit permission by the artist.
|
||||
|
||||
<h6 align="center">Yes, this includes the logo work too. Stop taking artwork that is not yours!</h6>
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@ isMaximal: {
|
|||
css.enable = isMaximal;
|
||||
sql.enable = isMaximal;
|
||||
java.enable = isMaximal;
|
||||
kotlin.enable = isMaximal;
|
||||
ts.enable = isMaximal;
|
||||
svelte.enable = isMaximal;
|
||||
go.enable = isMaximal;
|
||||
|
@ -64,15 +65,15 @@ isMaximal: {
|
|||
r.enable = isMaximal;
|
||||
tailwind.enable = isMaximal;
|
||||
typst.enable = isMaximal;
|
||||
clang = {
|
||||
enable = isMaximal;
|
||||
lsp.server = "clangd";
|
||||
};
|
||||
|
||||
clang.enable = isMaximal;
|
||||
scala.enable = isMaximal;
|
||||
rust = {
|
||||
enable = isMaximal;
|
||||
crates.enable = isMaximal;
|
||||
};
|
||||
csharp.enable = isMaximal;
|
||||
julia.enable = isMaximal;
|
||||
vala.enable = isMaximal;
|
||||
};
|
||||
|
||||
visuals = {
|
||||
|
@ -106,12 +107,10 @@ isMaximal: {
|
|||
transparent = false;
|
||||
};
|
||||
|
||||
autopairs.enable = true;
|
||||
autopairs.nvim-autopairs.enable = true;
|
||||
|
||||
autocomplete = {
|
||||
enable = true;
|
||||
type = "nvim-cmp";
|
||||
};
|
||||
autocomplete.nvim-cmp.enable = true;
|
||||
snippets.luasnip.enable = true;
|
||||
|
||||
filetree = {
|
||||
nvimTree = {
|
||||
|
@ -174,6 +173,7 @@ isMaximal: {
|
|||
|
||||
notes = {
|
||||
obsidian.enable = false; # FIXME: neovim fails to build if obsidian is enabled
|
||||
neorg.enable = false;
|
||||
orgmode.enable = false;
|
||||
mind-nvim.enable = isMaximal;
|
||||
todo-comments.enable = true;
|
||||
|
|
|
@ -20,6 +20,7 @@ custom plugins that you might have added to your configuration.
|
|||
|
||||
```{=include=} sections
|
||||
custom-plugins/configuring.md
|
||||
custom-plugins/new-method.md
|
||||
custom-plugins/old-method.md
|
||||
custom-plugins/lazy-method.md
|
||||
custom-plugins/non-lazy-method.md
|
||||
custom-plugins/legacy-method.md
|
||||
```
|
||||
|
|
|
@ -2,12 +2,34 @@
|
|||
|
||||
Just making the plugin to your Neovim configuration available might not always
|
||||
be enough. In that case, you can write custom lua config using either
|
||||
`config.vim.extraPlugins` (which has the `setup` field) or
|
||||
`config.vim.luaConfigRC`. The first option uses an attribute set, which maps DAG
|
||||
section names to a custom type, which has the fields `package`, `after`,
|
||||
`setup`. They allow you to set the package of the plugin, the sections its setup
|
||||
code should be after (note that the `extraPlugins` option has its own DAG
|
||||
scope), and the its setup code respectively. For example:
|
||||
`config.vim.lazy.plugins.*.setupOpts` `config.vim.extraPlugins.*.setup` or
|
||||
`config.vim.luaConfigRC`.
|
||||
|
||||
The first option uses an extended version of `lz.n`'s PluginSpec. `setupModule`
|
||||
and `setupOpt` can be used if the plugin uses a `require('module').setup(...)`
|
||||
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
|
||||
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.
|
||||
For example:
|
||||
|
||||
|
@ -36,13 +58,17 @@ For example:
|
|||
}
|
||||
```
|
||||
|
||||
:::{.note}
|
||||
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
|
||||
https://github.com/nix-community/home-manager/blob/master/modules/lib/dag.nix
|
||||
<!-- deno-fmt-ignore-start -->
|
||||
|
||||
::: {.note}
|
||||
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.
|
||||
:::
|
||||
|
||||
If you successfully made your plugin work, please feel free to create a PR to
|
||||
add it to **nvf** or open an issue with your findings so that we can make it
|
||||
available for everyone easily.
|
||||
<!-- deno-fmt-ignore-end -->
|
||||
|
|
40
docs/manual/configuring/custom-plugins/lazy-method.md
Normal file
40
docs/manual/configuring/custom-plugins/lazy-method.md
Normal 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 = {
|
||||
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>";
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
```
|
|
@ -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
|
||||
`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
|
||||
|
@ -8,13 +8,14 @@ the plugins is determined by DAGs.
|
|||
|
||||
## 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
|
||||
{pkgs, ...}: {
|
||||
# add a package from nixpkgs to startPlugins
|
||||
vim.startPlugins = [
|
||||
pkgs.vimPlugins.aerial-nvim ];
|
||||
# Add a Neovim plugin from Nixpkgs to the runtime.
|
||||
vim.startPlugins = [pkgs.vimPlugins.aerial-nvim];
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -23,7 +24,9 @@ provide configuration as a DAG using the **nvf** extended library.
|
|||
|
||||
```nix
|
||||
{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;
|
||||
in {
|
||||
vim.luaConfigRC.aerial-nvim= entryAnywhere ''
|
|
@ -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,
|
||||
under `vim.extraPlugins`. Instead of using DAGs exposed by the library, you may
|
|
@ -12,12 +12,14 @@ entries in nvf:
|
|||
2. `globalsScript` - used to set globals defined in `vim.globals`
|
||||
3. `basic` - used to set basic configuration options
|
||||
4. `optionsScript` - used to set options defined in `vim.o`
|
||||
5. `theme` (this is simply placed before `pluginConfigs`, meaning that
|
||||
surrounding entries don't depend on it) - used to set up the theme, which has
|
||||
to be done before other plugins
|
||||
6. `pluginConfigs` - the result of the nested `vim.pluginRC` (internal option,
|
||||
5. `theme` (this is simply placed before `pluginConfigs` and `lazyConfigs`, meaning that
|
||||
surrounding entries don't depend on it) - used to set up the theme, which has to be done before
|
||||
other plugins
|
||||
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
|
||||
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
|
||||
8. `mappings` - the result of `vim.maps`
|
||||
9. `mappings` - the result of `vim.maps`
|
||||
|
|
|
@ -1,16 +1,25 @@
|
|||
# Hacking nvf {#ch-hacking}
|
||||
|
||||
**nvf** is designed for developers as much as it is for the end user. I would like any potential contributor
|
||||
to be able to propagate their desired changes into the repository without the extra effort. As such, below are guides
|
||||
(and guidelines) to streamline the contribution process and ensure that your valuable input seamlessly integrates
|
||||
into **nvf**'s development without leaving question marks in your head.
|
||||
[open issues]: https://github.com/notashelf/nvf/issues
|
||||
[new issue]: https://github.com/notashelf/nvf/issues/new
|
||||
|
||||
This section is mainly directed towards those who wish to contribute code into **nvf**. If you wish to instead
|
||||
report a bug or discuss a potential feature implementation, first look among the
|
||||
already [open issues](https://github.com/notashelf/nvf/issues) and if no matching issue exists you may open
|
||||
a [new issue](https://github.com/notashelf/nvf/issues/new) 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.
|
||||
nvf is designed for the developer as much as it is designed for the end-user. We
|
||||
would like for any contributor to be able to propagate their changes, or add new
|
||||
features to the project with minimum possible friction. As such, below are the
|
||||
guides and guidelines written to streamline the contribution process and to
|
||||
ensure that your valuable input integrates into nvf's development as seamlessly
|
||||
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
|
||||
hacking/getting-started.md
|
||||
|
|
|
@ -124,3 +124,61 @@ 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
|
||||
|
|
|
@ -7,37 +7,26 @@ section contains a general overview to how you may utilize said functions.
|
|||
|
||||
## Custom Key Mappings Support for a Plugin {#sec-custom-key-mappings}
|
||||
|
||||
To set a mapping, you should define it in `vim.maps.<<mode>>`.
|
||||
The available modes are:
|
||||
|
||||
- normal
|
||||
- insert
|
||||
- select
|
||||
- visual
|
||||
- terminal
|
||||
- normalVisualOp
|
||||
- visualOnly
|
||||
- operator
|
||||
- insertCommand
|
||||
- lang
|
||||
- command
|
||||
To set a mapping, you should define it in `vim.keymaps`.
|
||||
|
||||
An example, simple keybinding, can look like this:
|
||||
|
||||
```nix
|
||||
{
|
||||
vim.maps.normal = {
|
||||
"<leader>wq" = {
|
||||
vim.keymaps = [
|
||||
{
|
||||
key = "<leader>wq";
|
||||
mode = ["n"];
|
||||
action = ":wq<CR>";
|
||||
silent = true;
|
||||
desc = "Save file and quit";
|
||||
};
|
||||
};
|
||||
}
|
||||
];
|
||||
}
|
||||
```
|
||||
|
||||
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 see a list of them.
|
||||
|
||||
**nvf** provides a list of helper commands, so that you don't have to write the
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
# Installing nvf {#ch-installation}
|
||||
|
||||
[module installation section]: #ch-module-installation
|
||||
|
||||
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
|
||||
be done on any system that has the Nix package manager or the appropriate modules
|
||||
for NixOS and home-manager as described in the [module installation section](#ch-module-installation)
|
||||
the standalone installation method, which does not depend on a module system and
|
||||
may be done on any system that has the Nix package manager or the appropriate
|
||||
modules for NixOS and home-manager as described in the
|
||||
[module installation section].
|
||||
|
||||
```{=include=} chapters
|
||||
installation/custom-configuration.md
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
# Standalone Installation {#ch-standalone-installation}
|
||||
|
||||
It is possible to install **nvf** without depending on NixOS or home-manager as the parent
|
||||
module system, using the `neovimConfiguration` function exposed by **nvf** extended library.
|
||||
It takes in the configuration as a module, and returns an attribute set as a result.
|
||||
It is possible to install nvf without depending on NixOS or Home-Manager as the
|
||||
parent module system, using the `neovimConfiguration` function exposed in the
|
||||
extended library. This function will take `modules` and `extraSpecialArgs` as
|
||||
arguments, and return the following schema as a result.
|
||||
|
||||
```nix
|
||||
{
|
||||
|
@ -13,6 +14,53 @@ 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 next two chapters will detail specific usage of standalone nvf
|
||||
configurations on NixOS and Home-Manager.
|
||||
|
||||
```{=include=} chapters
|
||||
standalone/nixos.md
|
||||
standalone/home-manager.md
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
# 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
|
||||
modules/nixos.md
|
||||
modules/home-manager.md
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Standalone Installation on Home-Manager {#ch-standalone-hm}
|
||||
|
||||
Your built Neoevim configuration can be exposed as a flake output to make it
|
||||
Your built Neovim configuration can be exposed as a flake output to make it
|
||||
easier to share across machines, repositories and so on. Or it can be added to
|
||||
your system packages to make it available across your system.
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Standalone Installation on NixOS {#ch-standalone-nixos}
|
||||
|
||||
Your built Neoevim configuration can be exposed as a flake output to make it
|
||||
Your built Neovim configuration can be exposed as a flake output to make it
|
||||
easier to share across machines, repositories and so on. Or it can be added to
|
||||
your system packages to make it available across your system.
|
||||
|
||||
|
|
|
@ -17,8 +17,8 @@ configuring.md
|
|||
hacking.md
|
||||
```
|
||||
|
||||
```{=include=} appendix html:into-file=//plugins.html
|
||||
plugins.md
|
||||
```{=include=} appendix html:into-file=//quirks.html
|
||||
quirks.md
|
||||
```
|
||||
|
||||
```{=include=} appendix html:into-file=//options.html
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
# Neovim Flake Configuration Options {#ch-options}
|
||||
|
||||
Below are the options provided by nvf provided in no particular order.
|
||||
They may include useful comments and warnings, or examples on how a module option
|
||||
is meant to be used.
|
||||
Below are the module options provided by nvf, in no particular order. Most
|
||||
options will include useful comments, warnings or setup tips on how a module
|
||||
option is meant to be used as well as examples in complex cases.
|
||||
|
||||
<!--
|
||||
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
|
||||
id-prefix: opt-
|
||||
|
|
|
@ -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
|
||||
```
|
||||
-->
|
|
@ -1,7 +1,20 @@
|
|||
# Preface {#ch-preface}
|
||||
|
||||
If you noticed a bug caused by **nvf** then please consider reporting it over
|
||||
[the issue tracker](https://github.com/notashelf/nvf/issues).
|
||||
## What is nvf {#sec-what-is-it}
|
||||
|
||||
Bugfixes, feature additions and upstreamed changes from your local configurations
|
||||
are always welcome in the [the pull requests tab](https://github.com/notashelf/nvf/pulls).
|
||||
nvf is a highly modular, configurable, extensible and easy to use Neovim
|
||||
configuration in Nix. Designed for flexibility and ease of use, nvf allows you
|
||||
to easily configure your fully featured Neovim instance with a few lines of Nix.
|
||||
|
||||
## 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
13
docs/manual/quirks.md
Normal 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
|
||||
```
|
|
@ -1,16 +1,22 @@
|
|||
# NodeJS {#ch-plugins-nodejs}
|
||||
# NodeJS {#ch-quirks-nodejs}
|
||||
|
||||
## eslint-plugin-prettier {#sec-eslint-plugin-prettier}
|
||||
|
||||
When working with NodeJS, everything works as expected, but some projects have settings that can fool nvf.
|
||||
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.
|
||||
|
||||
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-formating relying on your prettier config, while your
|
||||
eslint config diagnoses formatting
|
||||
[which it's not supposed to](https://prettier.io/docs/en/comparison.html))
|
||||
|
||||
In the end, you get discrepancies between what your editor does and what it wants.
|
||||
In the end, you get discrepancies between what your editor does and what it
|
||||
wants.
|
||||
|
||||
Solutions are:
|
||||
|
|
@ -1,25 +1,27 @@
|
|||
# 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.
|
||||
Below are the commands you may run to try out different configurations provided by this flake. As of v0.5, three
|
||||
Thanks to the portability of Nix, you can try out nvf without actually
|
||||
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:
|
||||
|
||||
- Nix
|
||||
- Maximal
|
||||
- **Nix** - Nix language server + simple utility plugins
|
||||
- **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
|
||||
$ 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
|
||||
once you garbage collect.
|
||||
Do keep in mind that this is **susceptible to garbage collection** meaning it
|
||||
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#maximal
|
||||
```
|
||||
|
@ -28,12 +30,19 @@ $ nix run github:notashelf/nvf#maximal
|
|||
|
||||
#### Nix {#sec-configs-nix}
|
||||
|
||||
`Nix` configuration by default provides LSP/diagnostic support for Nix alongisde a set of visual and functional plugins.
|
||||
By running `nix run .#`, which is the default package, you will build Neovim with this config.
|
||||
`Nix` configuration by default provides LSP/diagnostic support for Nix alongside
|
||||
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` is the ultimate configuration that will enable support for more commonly used language as well as additional
|
||||
complementary plugins. Keep in mind, however, that this will pull a lot of dependencies.
|
||||
`Maximal` is the ultimate configuration that will enable support for more
|
||||
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.
|
||||
|
||||
:::
|
||||
|
|
|
@ -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
|
||||
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}
|
||||
|
||||
The nvim-code-action-menu plugin has been archived and broken for a long time,
|
||||
|
@ -37,6 +63,24 @@ Note that we are looking to add more alternatives in the future like
|
|||
dressing.nvim and actions-preview.nvim, in case fastaction doesn't work for
|
||||
everyone.
|
||||
|
||||
### `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`.
|
||||
|
||||
## Changelog {#sec-release-0.7-changelog}
|
||||
|
||||
[ItsSorae](https://github.com/ItsSorae):
|
||||
|
@ -67,6 +111,9 @@ everyone.
|
|||
- Add dap-go for better dap configurations
|
||||
- Make noice.nvim customizable
|
||||
- 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
|
||||
[rustaceanvim]: https://github.com/mrcjkb/rustaceanvim
|
||||
|
@ -76,6 +123,10 @@ everyone.
|
|||
recommended to go through rustacean.nvim's README to take a closer look at its
|
||||
features and usage
|
||||
|
||||
- Add [lz.n] support and lazy-load some builtin plugins.
|
||||
|
||||
[lz.n]: https://github.com/mrcjkb/lz.n
|
||||
|
||||
[jacekpoz](https://jacekpoz.pl):
|
||||
|
||||
[ocaml-lsp]: https://github.com/ocaml/ocaml-lsp
|
||||
|
@ -124,10 +175,37 @@ everyone.
|
|||
- Replace `vim.lsp.nvimCodeActionMenu` with `vim.ui.fastaction`, see the
|
||||
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.
|
||||
|
||||
[Neovim documentation on `vim.cmd`]: https://neovim.io/doc/user/lua.html#vim.cmd()
|
||||
|
||||
- Make Neovim's configuration file entirely Lua based. This comes with a few
|
||||
breaking changes:
|
||||
|
||||
- `vim.configRC` has been removed. You will need to migrate your entries to
|
||||
Neovim-compliant Lua code, and add them to `vim.luaConfigRC` instead.
|
||||
Existing vimscript configurations may be preserved in `vim.cmd` functions.
|
||||
|
@ -136,6 +214,8 @@ everyone.
|
|||
has been introduced for setting up internal plugins. See the "DAG entries in
|
||||
nvf" manual page for more information.
|
||||
|
||||
- Rewrite `vim.maps`, see the breaking changes section above.
|
||||
|
||||
[NotAShelf](https://github.com/notashelf):
|
||||
|
||||
[ts-error-translator.nvim]: https://github.com/dmmulroy/ts-error-translator.nvim
|
||||
|
@ -198,9 +278,13 @@ everyone.
|
|||
configuration for [dashboard.nvim](https://github.com/nvimdev/dashboard-nvim)
|
||||
|
||||
- Update `lualine.nvim` input and add missing themes:
|
||||
|
||||
- Adds `ayu`, `gruvbox_dark`, `iceberg`, `moonfly`, `onedark`,
|
||||
`powerline_dark` and `solarized_light` themes.
|
||||
|
||||
- Add [](#opt-vim.spellcheck.extraSpellWords) to allow adding arbitrary
|
||||
spellfiles to Neovim's runtime with ease.
|
||||
|
||||
[ppenguin](https://github.com/ppenguin):
|
||||
|
||||
- Telescope:
|
||||
|
@ -212,7 +296,29 @@ everyone.
|
|||
- Add LSP and Treesitter support for R under `vim.languages.R`.
|
||||
- Add Otter support under `vim.lsp.otter` and an assert to prevent conflict with
|
||||
ccc
|
||||
- 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`
|
||||
|
||||
[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.
|
||||
|
||||
[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).
|
||||
|
|
279
flake.lock
279
flake.lock
|
@ -172,6 +172,22 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"plugin-base16": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1716483968,
|
||||
"narHash": "sha256-GRF/6AobXHamw8TZ3FjL7SI6ulcpwpcohsIuZeCSh2A=",
|
||||
"owner": "rrethy",
|
||||
"repo": "base16-nvim",
|
||||
"rev": "6ac181b5733518040a33017dde654059cd771b7c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "rrethy",
|
||||
"repo": "base16-nvim",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"plugin-bufdelete-nvim": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
|
@ -191,11 +207,11 @@
|
|||
"plugin-catppuccin": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1716704960,
|
||||
"narHash": "sha256-UDPS+1o8FQGkfqiG4GX4DNUI2pU5hIvagmfnWTKDb44=",
|
||||
"lastModified": 1728131011,
|
||||
"narHash": "sha256-j6F078taxuGzr3jngrc+Pc5I1kDdxTLMETgq6Xn4w/4=",
|
||||
"owner": "catppuccin",
|
||||
"repo": "nvim",
|
||||
"rev": "5215ea59df6d0a7e27da9a5cd1165e06d1b04cbe",
|
||||
"rev": "7be452ee067978cdc8b2c5f3411f0c71ffa612b9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -300,6 +316,22 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"plugin-cmp-luasnip": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1696878902,
|
||||
"narHash": "sha256-nUJJl2zyK/oSwz5RzI9j3gf9zpDfCImCYbPbVsyXgz8=",
|
||||
"owner": "saadparwaiz1",
|
||||
"repo": "cmp_luasnip",
|
||||
"rev": "05a9ab28b53f71d1aece421ef32fee2cb857a843",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "saadparwaiz1",
|
||||
"repo": "cmp_luasnip",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"plugin-cmp-nvim-lsp": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
|
@ -348,22 +380,6 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"plugin-cmp-vsnip": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1669100283,
|
||||
"narHash": "sha256-2mkN03noOr5vBvRbSb35xZKorSH+8savQNZtgM9+QcM=",
|
||||
"owner": "hrsh7th",
|
||||
"repo": "cmp-vsnip",
|
||||
"rev": "989a8a73c44e926199bfd05fa7a516d51f2d2752",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "hrsh7th",
|
||||
"repo": "cmp-vsnip",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"plugin-codewindow-nvim": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
|
@ -444,6 +460,22 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"plugin-csharpls-extended": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1728438370,
|
||||
"narHash": "sha256-sOLPV5IhOvQ0+u7CDAfG3X0ZbRCicz18QyYXQ0dxpwQ=",
|
||||
"owner": "Decodetalkers",
|
||||
"repo": "csharpls-extended-lsp.nvim",
|
||||
"rev": "b647e1bd1f9c0410f5ef4a1517a331cbac322d9a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "Decodetalkers",
|
||||
"repo": "csharpls-extended-lsp.nvim",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"plugin-dashboard-nvim": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
|
@ -572,6 +604,22 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"plugin-friendly-snippets": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1727061933,
|
||||
"narHash": "sha256-yTsuV5unoujY0mhLINssYYBWCeefe+nJaxQHJKm7hlk=",
|
||||
"owner": "rafamadriz",
|
||||
"repo": "friendly-snippets",
|
||||
"rev": "00ba9dd3df89509f95437b8d595553707c46d5ea",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "rafamadriz",
|
||||
"repo": "friendly-snippets",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"plugin-gesture-nvim": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
|
@ -796,6 +844,22 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"plugin-lua-utils-nvim": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1708177208,
|
||||
"narHash": "sha256-9ildzQEMkXKZ3LHq+khGFgRQFxlIXQclQ7QU3fcU1C4=",
|
||||
"owner": "nvim-neorg",
|
||||
"repo": "lua-utils.nvim",
|
||||
"rev": "e565749421f4bbb5d2e85e37c3cef9d56553d8bd",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nvim-neorg",
|
||||
"repo": "lua-utils.nvim",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"plugin-lualine": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
|
@ -812,6 +876,55 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"plugin-luasnip": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1726165831,
|
||||
"narHash": "sha256-nkaa1NGOI28Et2QitQB+Spv+J42QVdHE1oywteLcJJw=",
|
||||
"owner": "L3MON4D3",
|
||||
"repo": "LuaSnip",
|
||||
"rev": "e808bee352d1a6fcf902ca1a71cee76e60e24071",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "L3MON4D3",
|
||||
"repo": "LuaSnip",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"plugin-lz-n": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1729525284,
|
||||
"narHash": "sha256-fk+ejqcqqOQz3q4D3VB2Q+U/6wCpCDk1tiDMp2YrPNE=",
|
||||
"owner": "nvim-neorocks",
|
||||
"repo": "lz.n",
|
||||
"rev": "ffd9991400ba7137f4fa8560ff50bccd7f8fb3ee",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nvim-neorocks",
|
||||
"repo": "lz.n",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"plugin-lzn-auto-require": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1727636949,
|
||||
"narHash": "sha256-BAOzN+XOrFAJwHmsF8JtZ2EyjP9283FD/I2TbFqGSEw=",
|
||||
"owner": "horriblename",
|
||||
"repo": "lzn-auto-require",
|
||||
"rev": "55ecd60831dac8c01d6f3dcb63a30a63a1690eb8",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "horriblename",
|
||||
"ref": "require-rewrite",
|
||||
"repo": "lzn-auto-require",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"plugin-mind-nvim": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
|
@ -908,6 +1021,38 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"plugin-neorg": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1727821831,
|
||||
"narHash": "sha256-yfWQ6yKytu1jkWUtRZTVICslUWej6jVYv7frmSB7/6Q=",
|
||||
"owner": "nvim-neorg",
|
||||
"repo": "neorg",
|
||||
"rev": "afc9a37bf021acb0853e95714c4c6436e1588286",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nvim-neorg",
|
||||
"repo": "neorg",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"plugin-neorg-telescope": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1722358034,
|
||||
"narHash": "sha256-ei4uUqpIQjGKzu5ryu0Hlmis9TS9FJsYnjt4J4QdWlw=",
|
||||
"owner": "nvim-neorg",
|
||||
"repo": "neorg-telescope",
|
||||
"rev": "ddb2556644cae922699a239bbb0fe16e25b084b7",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nvim-neorg",
|
||||
"repo": "neorg-telescope",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"plugin-new-file-template-nvim": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
|
@ -1149,6 +1294,22 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"plugin-nvim-metals": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1728295172,
|
||||
"narHash": "sha256-ja/+MNxZ3H9io9jDwm5rhE6iKNi86a22eCOY75g19O8=",
|
||||
"owner": "scalameta",
|
||||
"repo": "nvim-metals",
|
||||
"rev": "f861db9fda55939797ac1b05238c49b0dcdc3bdb",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "scalameta",
|
||||
"repo": "nvim-metals",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"plugin-nvim-navbuddy": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
|
@ -1341,6 +1502,22 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"plugin-omnisharp-extended": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1719701797,
|
||||
"narHash": "sha256-P1ZCaW8w+e3H3oBhbEjDc7vuR+XuxJmb/7IbPL3KWi4=",
|
||||
"owner": "Hoffs",
|
||||
"repo": "omnisharp-extended-lsp.nvim",
|
||||
"rev": "aad7bf06b4ca0de816b919d475a75b30f5f62b61",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "Hoffs",
|
||||
"repo": "omnisharp-extended-lsp.nvim",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"plugin-onedark": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
|
@ -1405,6 +1582,22 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"plugin-pathlib-nvim": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1724943804,
|
||||
"narHash": "sha256-YhCJeNKlcjgg3q51UWFhuIEPzNueC8YTpeuPPJDndvw=",
|
||||
"owner": "pysan3",
|
||||
"repo": "pathlib.nvim",
|
||||
"rev": "57e5598af6fe253761c1b48e0b59b7cd6699e2c1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "pysan3",
|
||||
"repo": "pathlib.nvim",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"plugin-plenary-nvim": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
|
@ -1469,6 +1662,22 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"plugin-rtp-nvim": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1724409589,
|
||||
"narHash": "sha256-lmJbiD7I7MTEEpukESs67uAmLyn+p66hrUKLbEHp0Kw=",
|
||||
"owner": "nvim-neorocks",
|
||||
"repo": "rtp.nvim",
|
||||
"rev": "494ddfc888bb466555d90ace731856de1320fe45",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nvim-neorocks",
|
||||
"repo": "rtp.nvim",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"plugin-rustaceanvim": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
|
@ -1741,22 +1950,6 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"plugin-vim-vsnip": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1704937299,
|
||||
"narHash": "sha256-gvm6z4pgSULBVPukewRyjwxZ0vZgreQWbG/0kOB1QBo=",
|
||||
"owner": "hrsh7th",
|
||||
"repo": "vim-vsnip",
|
||||
"rev": "02a8e79295c9733434aab4e0e2b8c4b7cea9f3a9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "hrsh7th",
|
||||
"repo": "vim-vsnip",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"plugin-which-key": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
|
@ -1802,6 +1995,7 @@
|
|||
"nixpkgs": "nixpkgs",
|
||||
"nmd": "nmd",
|
||||
"plugin-alpha-nvim": "plugin-alpha-nvim",
|
||||
"plugin-base16": "plugin-base16",
|
||||
"plugin-bufdelete-nvim": "plugin-bufdelete-nvim",
|
||||
"plugin-catppuccin": "plugin-catppuccin",
|
||||
"plugin-ccc": "plugin-ccc",
|
||||
|
@ -1810,15 +2004,16 @@
|
|||
"plugin-cheatsheet-nvim": "plugin-cheatsheet-nvim",
|
||||
"plugin-cinnamon-nvim": "plugin-cinnamon-nvim",
|
||||
"plugin-cmp-buffer": "plugin-cmp-buffer",
|
||||
"plugin-cmp-luasnip": "plugin-cmp-luasnip",
|
||||
"plugin-cmp-nvim-lsp": "plugin-cmp-nvim-lsp",
|
||||
"plugin-cmp-path": "plugin-cmp-path",
|
||||
"plugin-cmp-treesitter": "plugin-cmp-treesitter",
|
||||
"plugin-cmp-vsnip": "plugin-cmp-vsnip",
|
||||
"plugin-codewindow-nvim": "plugin-codewindow-nvim",
|
||||
"plugin-comment-nvim": "plugin-comment-nvim",
|
||||
"plugin-copilot-cmp": "plugin-copilot-cmp",
|
||||
"plugin-copilot-lua": "plugin-copilot-lua",
|
||||
"plugin-crates-nvim": "plugin-crates-nvim",
|
||||
"plugin-csharpls-extended": "plugin-csharpls-extended",
|
||||
"plugin-dashboard-nvim": "plugin-dashboard-nvim",
|
||||
"plugin-diffview-nvim": "plugin-diffview-nvim",
|
||||
"plugin-dracula": "plugin-dracula",
|
||||
|
@ -1827,6 +2022,7 @@
|
|||
"plugin-fastaction-nvim": "plugin-fastaction-nvim",
|
||||
"plugin-fidget-nvim": "plugin-fidget-nvim",
|
||||
"plugin-flutter-tools": "plugin-flutter-tools",
|
||||
"plugin-friendly-snippets": "plugin-friendly-snippets",
|
||||
"plugin-gesture-nvim": "plugin-gesture-nvim",
|
||||
"plugin-gitsigns-nvim": "plugin-gitsigns-nvim",
|
||||
"plugin-glow-nvim": "plugin-glow-nvim",
|
||||
|
@ -1841,13 +2037,19 @@
|
|||
"plugin-lsp-signature": "plugin-lsp-signature",
|
||||
"plugin-lspkind": "plugin-lspkind",
|
||||
"plugin-lspsaga": "plugin-lspsaga",
|
||||
"plugin-lua-utils-nvim": "plugin-lua-utils-nvim",
|
||||
"plugin-lualine": "plugin-lualine",
|
||||
"plugin-luasnip": "plugin-luasnip",
|
||||
"plugin-lz-n": "plugin-lz-n",
|
||||
"plugin-lzn-auto-require": "plugin-lzn-auto-require",
|
||||
"plugin-mind-nvim": "plugin-mind-nvim",
|
||||
"plugin-minimap-vim": "plugin-minimap-vim",
|
||||
"plugin-modes-nvim": "plugin-modes-nvim",
|
||||
"plugin-neo-tree-nvim": "plugin-neo-tree-nvim",
|
||||
"plugin-neocord": "plugin-neocord",
|
||||
"plugin-neodev-nvim": "plugin-neodev-nvim",
|
||||
"plugin-neorg": "plugin-neorg",
|
||||
"plugin-neorg-telescope": "plugin-neorg-telescope",
|
||||
"plugin-new-file-template-nvim": "plugin-new-file-template-nvim",
|
||||
"plugin-noice-nvim": "plugin-noice-nvim",
|
||||
"plugin-none-ls": "plugin-none-ls",
|
||||
|
@ -1863,6 +2065,7 @@
|
|||
"plugin-nvim-docs-view": "plugin-nvim-docs-view",
|
||||
"plugin-nvim-lightbulb": "plugin-nvim-lightbulb",
|
||||
"plugin-nvim-lspconfig": "plugin-nvim-lspconfig",
|
||||
"plugin-nvim-metals": "plugin-nvim-metals",
|
||||
"plugin-nvim-navbuddy": "plugin-nvim-navbuddy",
|
||||
"plugin-nvim-navic": "plugin-nvim-navic",
|
||||
"plugin-nvim-neoclip": "plugin-nvim-neoclip",
|
||||
|
@ -1875,14 +2078,17 @@
|
|||
"plugin-nvim-ts-autotag": "plugin-nvim-ts-autotag",
|
||||
"plugin-nvim-web-devicons": "plugin-nvim-web-devicons",
|
||||
"plugin-obsidian-nvim": "plugin-obsidian-nvim",
|
||||
"plugin-omnisharp-extended": "plugin-omnisharp-extended",
|
||||
"plugin-onedark": "plugin-onedark",
|
||||
"plugin-orgmode-nvim": "plugin-orgmode-nvim",
|
||||
"plugin-otter-nvim": "plugin-otter-nvim",
|
||||
"plugin-oxocarbon": "plugin-oxocarbon",
|
||||
"plugin-pathlib-nvim": "plugin-pathlib-nvim",
|
||||
"plugin-plenary-nvim": "plugin-plenary-nvim",
|
||||
"plugin-project-nvim": "plugin-project-nvim",
|
||||
"plugin-registers": "plugin-registers",
|
||||
"plugin-rose-pine": "plugin-rose-pine",
|
||||
"plugin-rtp-nvim": "plugin-rtp-nvim",
|
||||
"plugin-rustaceanvim": "plugin-rustaceanvim",
|
||||
"plugin-scrollbar-nvim": "plugin-scrollbar-nvim",
|
||||
"plugin-smartcolumn": "plugin-smartcolumn",
|
||||
|
@ -1900,7 +2106,6 @@
|
|||
"plugin-vim-markdown": "plugin-vim-markdown",
|
||||
"plugin-vim-repeat": "plugin-vim-repeat",
|
||||
"plugin-vim-startify": "plugin-vim-startify",
|
||||
"plugin-vim-vsnip": "plugin-vim-vsnip",
|
||||
"plugin-which-key": "plugin-which-key",
|
||||
"rnix-lsp": "rnix-lsp",
|
||||
"systems": "systems_2"
|
||||
|
|
95
flake.nix
95
flake.nix
|
@ -30,29 +30,25 @@
|
|||
};
|
||||
|
||||
homeManagerModules = {
|
||||
nvf = import ./flake/modules/home-manager.nix self.packages lib;
|
||||
default = self.homeManagerModules.nvf;
|
||||
neovim-flake =
|
||||
lib.warn ''
|
||||
homeManagerModules.neovim-flake has been deprecated.
|
||||
Plese use the homeManagerModules.nvf instead
|
||||
'homeManagerModules.neovim-flake' has been deprecated, and will be removed
|
||||
in a future release. Please use 'homeManagerModules.nvf' instead.
|
||||
''
|
||||
self.homeManagerModules.nvf;
|
||||
|
||||
nvf = import ./flake/modules/home-manager.nix self.packages lib;
|
||||
|
||||
default = self.homeManagerModules.nvf;
|
||||
};
|
||||
|
||||
nixosModules = {
|
||||
nvf = import ./flake/modules/nixos.nix self.packages lib;
|
||||
default = self.nixosModules.nvf;
|
||||
neovim-flake =
|
||||
lib.warn ''
|
||||
nixosModules.neovim-flake has been deprecated.
|
||||
Please use the nixosModules.nvf instead
|
||||
'nixosModules.neovim-flake' has been deprecated, and will be removed
|
||||
in a future release. Please use 'nixosModules.nvf' instead.
|
||||
''
|
||||
self.nixosModules.nvf;
|
||||
|
||||
nvf = import ./flake/modules/nixos.nix self.packages lib;
|
||||
|
||||
default = self.nixosModules.nvf;
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -113,6 +109,22 @@
|
|||
};
|
||||
|
||||
## Plugins
|
||||
# Lazy loading
|
||||
plugin-lz-n = {
|
||||
url = "github:nvim-neorocks/lz.n";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
plugin-lzn-auto-require = {
|
||||
url = "github:horriblename/lzn-auto-require/require-rewrite";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
plugin-rtp-nvim = {
|
||||
url = "github:nvim-neorocks/rtp.nvim";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
# LSP plugins
|
||||
plugin-nvim-lspconfig = {
|
||||
url = "github:neovim/nvim-lspconfig";
|
||||
|
@ -206,6 +218,21 @@
|
|||
flake = false;
|
||||
};
|
||||
|
||||
plugin-nvim-metals = {
|
||||
url = "github:scalameta/nvim-metals";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
plugin-omnisharp-extended = {
|
||||
url = "github:Hoffs/omnisharp-extended-lsp.nvim";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
plugin-csharpls-extended = {
|
||||
url = "github:Decodetalkers/csharpls-extended-lsp.nvim";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
# Copying/Registers
|
||||
plugin-registers = {
|
||||
url = "github:tversteeg/registers.nvim";
|
||||
|
@ -277,11 +304,6 @@
|
|||
flake = false;
|
||||
};
|
||||
|
||||
plugin-cmp-vsnip = {
|
||||
url = "github:hrsh7th/cmp-vsnip";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
plugin-cmp-path = {
|
||||
url = "github:hrsh7th/cmp-path";
|
||||
flake = false;
|
||||
|
@ -292,9 +314,19 @@
|
|||
flake = false;
|
||||
};
|
||||
|
||||
plugin-cmp-luasnip = {
|
||||
url = "github:saadparwaiz1/cmp_luasnip";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
# snippets
|
||||
plugin-vim-vsnip = {
|
||||
url = "github:hrsh7th/vim-vsnip";
|
||||
plugin-luasnip = {
|
||||
url = "github:L3MON4D3/LuaSnip";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
plugin-friendly-snippets = {
|
||||
url = "github:rafamadriz/friendly-snippets";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
|
@ -349,6 +381,11 @@
|
|||
};
|
||||
|
||||
# Themes
|
||||
plugin-base16 = {
|
||||
url = "github:rrethy/base16-nvim";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
plugin-tokyonight = {
|
||||
url = "github:folke/tokyonight.nvim";
|
||||
flake = false;
|
||||
|
@ -631,6 +668,26 @@
|
|||
flake = false;
|
||||
};
|
||||
|
||||
plugin-lua-utils-nvim = {
|
||||
url = "github:nvim-neorg/lua-utils.nvim";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
plugin-pathlib-nvim = {
|
||||
url = "github:pysan3/pathlib.nvim";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
plugin-neorg = {
|
||||
url = "github:nvim-neorg/neorg";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
plugin-neorg-telescope = {
|
||||
url = "github:nvim-neorg/neorg-telescope";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
plugin-nui-nvim = {
|
||||
# (required by noice.nvim)
|
||||
url = "github:MunifTanjim/nui.nvim";
|
||||
|
|
5
lib/attrsets.nix
Normal file
5
lib/attrsets.nix
Normal file
|
@ -0,0 +1,5 @@
|
|||
{lib}: let
|
||||
inherit (builtins) listToAttrs;
|
||||
in {
|
||||
mapListToAttrs = f: list: listToAttrs (map f list);
|
||||
}
|
|
@ -67,6 +67,30 @@
|
|||
mkLuaBinding binding.value action binding.description;
|
||||
|
||||
pushDownDefault = attr: mapAttrs (_: mkDefault) attr;
|
||||
|
||||
mkLznBinding = mode: key: action: desc: {
|
||||
inherit mode desc key action;
|
||||
};
|
||||
|
||||
mkLznExprBinding = mode: key: action: desc: {
|
||||
inherit mode desc key action;
|
||||
lua = true;
|
||||
silent = true;
|
||||
expr = true;
|
||||
};
|
||||
|
||||
mkSetLznBinding = binding: action: {
|
||||
inherit action;
|
||||
key = binding.value;
|
||||
desc = binding.description;
|
||||
};
|
||||
|
||||
mkSetLuaLznBinding = binding: action: {
|
||||
inherit action;
|
||||
key = binding.value;
|
||||
lua = true;
|
||||
desc = binding.description;
|
||||
};
|
||||
};
|
||||
in
|
||||
binds
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
dag = import ./dag.nix {inherit lib;};
|
||||
languages = import ./languages.nix {inherit lib;};
|
||||
lists = import ./lists.nix {inherit lib;};
|
||||
attrsets = import ./attrsets.nix {inherit lib;};
|
||||
lua = import ./lua.nix {inherit lib;};
|
||||
neovimConfiguration = import ../modules {inherit inputs lib;};
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
{lib}: let
|
||||
inherit (builtins) isString getAttr;
|
||||
inherit (lib.options) mkOption;
|
||||
inherit (lib.attrsets) listToAttrs;
|
||||
inherit (lib.types) bool;
|
||||
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||
in {
|
||||
# Converts a boolean to a yes/no string. This is used in lots of
|
||||
# configuration formats.
|
||||
|
@ -12,21 +12,21 @@ in {
|
|||
config,
|
||||
diagnosticsProviders,
|
||||
}:
|
||||
listToAttrs
|
||||
(map (v: let
|
||||
type =
|
||||
if isString v
|
||||
then v
|
||||
else getAttr v.type;
|
||||
package =
|
||||
if isString v
|
||||
then diagnosticsProviders.${type}.package
|
||||
else v.package;
|
||||
in {
|
||||
name = "${lang}-diagnostics-${type}";
|
||||
value = diagnosticsProviders.${type}.nullConfig package;
|
||||
})
|
||||
config);
|
||||
mapListToAttrs
|
||||
(v: let
|
||||
type =
|
||||
if isString v
|
||||
then v
|
||||
else getAttr v.type;
|
||||
package =
|
||||
if isString v
|
||||
then diagnosticsProviders.${type}.package
|
||||
else v.package;
|
||||
in {
|
||||
name = "${lang}-diagnostics-${type}";
|
||||
value = diagnosticsProviders.${type}.nullConfig package;
|
||||
})
|
||||
config;
|
||||
|
||||
mkEnable = desc:
|
||||
mkOption {
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
{lib}: let
|
||||
inherit (lib) isStringLike showOption showFiles getFiles mergeOneOption mergeEqualOption mkOptionType;
|
||||
inherit (lib.types) anything attrsOf;
|
||||
inherit (lib.options) showOption showFiles getFiles mergeOneOption mergeEqualOption;
|
||||
inherit (lib.strings) isString isStringLike;
|
||||
inherit (lib.types) anything attrsOf listOf mkOptionType;
|
||||
inherit (lib.nvim.types) anythingConcatLists;
|
||||
inherit (builtins) typeOf isAttrs any head concatLists stringLength;
|
||||
inherit (builtins) typeOf isAttrs any head concatLists stringLength match;
|
||||
in {
|
||||
# HACK: Does this break anything in our case?
|
||||
# A modified version of the nixpkgs anything type that concatenates lists
|
||||
|
@ -51,6 +52,16 @@ in {
|
|||
(mergeFunctions.${commonType} or mergeEqualOption) loc defs;
|
||||
};
|
||||
|
||||
mergelessListOf = elemType: let
|
||||
super = listOf elemType;
|
||||
in
|
||||
super
|
||||
// {
|
||||
name = "mergelessListOf";
|
||||
description = "mergeless ${super.description}";
|
||||
merge = mergeEqualOption;
|
||||
};
|
||||
|
||||
char = mkOptionType {
|
||||
name = "char";
|
||||
description = "character";
|
||||
|
@ -58,4 +69,11 @@ in {
|
|||
check = value: stringLength value < 2;
|
||||
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;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
typesDag = import ./dag.nix {inherit lib;};
|
||||
typesPlugin = import ./plugins.nix {inherit inputs lib;};
|
||||
typesLanguage = import ./languages.nix {inherit lib;};
|
||||
typesCustom = import ./custom.nix {inherit lib;};
|
||||
customTypes = import ./custom.nix {inherit lib;};
|
||||
in {
|
||||
inherit (typesDag) dagOf;
|
||||
inherit (typesPlugin) pluginsOpt extraPluginType mkPluginSetupOption luaInline pluginType borderType;
|
||||
inherit (typesLanguage) diagnostics mkGrammarOption;
|
||||
inherit (typesCustom) anythingConcatLists char;
|
||||
inherit (customTypes) anythingConcatLists char hexColor mergelessListOf;
|
||||
}
|
||||
|
|
|
@ -84,10 +84,7 @@
|
|||
|
||||
# built (or "normalized") plugins that are modified
|
||||
builtStartPlugins = buildConfigPlugins vimOptions.startPlugins;
|
||||
builtOptPlugins = map (package: {
|
||||
plugin = package;
|
||||
optional = true;
|
||||
}) (buildConfigPlugins vimOptions.optPlugins);
|
||||
builtOptPlugins = map (package: package // {optional = true;}) (buildConfigPlugins vimOptions.optPlugins);
|
||||
|
||||
# additional Lua and Python3 packages, mapped to their respective functions
|
||||
# to conform to the format mnw expects. end user should
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.modules) mkRemovedOptionModule;
|
||||
inherit (lib.modules) mkRemovedOptionModule mkRenamedOptionModule;
|
||||
in {
|
||||
imports = [
|
||||
# 2024-06-06
|
||||
|
@ -14,5 +14,45 @@ in {
|
|||
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.
|
||||
'')
|
||||
];
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
"build"
|
||||
"rc"
|
||||
"warnings"
|
||||
"lazy"
|
||||
];
|
||||
|
||||
# Extra modules, such as deprecation warnings
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf mkRenamedOptionModule;
|
||||
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.dag) entryAfter;
|
||||
|
||||
|
@ -24,10 +27,48 @@ in {
|
|||
description = ''
|
||||
A list of languages that should be used for spellchecking.
|
||||
|
||||
To add your own language files, you may place your `spell`
|
||||
directory in either `~/.config/nvim` or the
|
||||
[additionalRuntimePaths](#opt-vim.additionalRuntimePaths)
|
||||
directory provided by **nvf**.
|
||||
To add your own language files, you may place your `spell` directory in either
|
||||
{file}`$XDG_CONFIG_HOME/nvf` or in a path that is included in the
|
||||
[additionalRuntimePaths](#opt-vim.additionalRuntimePaths) list 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 = ''
|
||||
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.
|
||||
:::
|
||||
'';
|
||||
};
|
||||
|
||||
/*
|
||||
# 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 ''
|
||||
vim-dirtytalk, a wordlist for programmers containing
|
||||
common programming terms.
|
||||
|
||||
Setting this value as `true` has the same effect
|
||||
as setting {option}`vim.spellCheck.enable`
|
||||
::: {.note}
|
||||
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 {
|
||||
vim.luaConfigRC.spellcheck = entryAfter ["basic"] ''
|
||||
vim.opt.spell = true
|
||||
vim.opt.spelllang = ${listToLuaTable cfg.languages}
|
||||
vim = {
|
||||
additionalRuntimePaths = let
|
||||
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
|
||||
-- as configured by `vim.spellcheck.ignoredFiletypes`
|
||||
vim.api.nvim_create_autocmd({ "FileType" }, {
|
||||
pattern = ${listToLuaTable cfg.ignoredFiletypes},
|
||||
callback = function()
|
||||
vim.opt_local.spell = false
|
||||
end,
|
||||
})
|
||||
'';
|
||||
spellfilesJoined = pkgs.symlinkJoin {
|
||||
name = "nvf-spellfiles-joined";
|
||||
paths = mapAttrsToList (name: value: pkgs.writeTextDir "spell/${name}.add" (concatLines value)) cfg.extraSpellWords;
|
||||
postBuild = "echo Spellfiles joined";
|
||||
};
|
||||
} ''
|
||||
# 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,
|
||||
})
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -3,51 +3,75 @@
|
|||
lib,
|
||||
...
|
||||
}: 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;
|
||||
in {
|
||||
config = {
|
||||
vim.maps = {
|
||||
normal = mkIf cfg.disableArrows {
|
||||
"<up>" = {
|
||||
action = "<nop>";
|
||||
|
||||
noremap = false;
|
||||
};
|
||||
"<down>" = {
|
||||
action = "<nop>";
|
||||
|
||||
noremap = false;
|
||||
};
|
||||
"<left>" = {
|
||||
action = "<nop>";
|
||||
noremap = false;
|
||||
};
|
||||
"<right>" = {
|
||||
action = "<nop>";
|
||||
noremap = false;
|
||||
};
|
||||
};
|
||||
|
||||
insert = mkIf cfg.disableArrows {
|
||||
"<up>" = {
|
||||
action = "<nop>";
|
||||
noremap = false;
|
||||
};
|
||||
"<down>" = {
|
||||
action = "<nop>";
|
||||
noremap = false;
|
||||
};
|
||||
"<left>" = {
|
||||
action = "<nop>";
|
||||
noremap = false;
|
||||
};
|
||||
"<right>" = {
|
||||
action = "<nop>";
|
||||
noremap = false;
|
||||
};
|
||||
};
|
||||
};
|
||||
vim.keymaps = mkMerge [
|
||||
(
|
||||
mkIf cfg.disableArrows [
|
||||
{
|
||||
key = "<up>";
|
||||
mode = ["n" "i"];
|
||||
action = "<nop>";
|
||||
noremap = false;
|
||||
}
|
||||
{
|
||||
key = "<down>";
|
||||
mode = ["n" "i"];
|
||||
action = "<nop>";
|
||||
noremap = false;
|
||||
}
|
||||
{
|
||||
key = "<left>";
|
||||
mode = ["n" "i"];
|
||||
action = "<nop>";
|
||||
noremap = false;
|
||||
}
|
||||
{
|
||||
key = "<right>";
|
||||
mode = ["n" "i"];
|
||||
action = "<nop>";
|
||||
noremap = false;
|
||||
}
|
||||
]
|
||||
)
|
||||
(
|
||||
pipe cfg.maps
|
||||
[
|
||||
(mapAttrsToList (
|
||||
oldMode: keybinds:
|
||||
mapAttrsToList (
|
||||
key: bind:
|
||||
bind
|
||||
// {
|
||||
inherit key;
|
||||
mode = legacyMapModes.${oldMode};
|
||||
}
|
||||
)
|
||||
keybinds
|
||||
))
|
||||
flatten
|
||||
]
|
||||
)
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,101 +1,97 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkOption;
|
||||
inherit (lib.types) bool str attrsOf nullOr submodule;
|
||||
inherit (lib.options) mkOption literalMD;
|
||||
inherit (lib.types) either str listOf attrsOf nullOr submodule;
|
||||
inherit (lib.nvim.config) mkBool;
|
||||
# Most of the keybindings code is highly inspired by pta2002/nixvim.
|
||||
# Thank you!
|
||||
|
||||
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 {
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
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 =
|
||||
mapConfigOptions
|
||||
// {
|
||||
action = mkOption {
|
||||
key = mkOption {
|
||||
type = str;
|
||||
description = "The action to execute.";
|
||||
description = "The key that triggers this keybind.";
|
||||
};
|
||||
|
||||
lua = mkOption {
|
||||
type = bool;
|
||||
mode = mkOption {
|
||||
type = either str (listOf str);
|
||||
description = ''
|
||||
If true, `action` is considered to be lua code.
|
||||
Thus, it will not be wrapped in `""`.
|
||||
The short-name of the mode to set the keymapping for. Passing an empty string is the equivalent of `:map`.
|
||||
|
||||
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 {
|
||||
description = "Mappings for ${mode} mode";
|
||||
type = attrsOf mapOption;
|
||||
type = attrsOf (submodule {
|
||||
options = mapConfigOptions;
|
||||
});
|
||||
default = {};
|
||||
};
|
||||
in {
|
||||
options.vim = {
|
||||
maps = mkOption {
|
||||
type = submodule {
|
||||
options = {
|
||||
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`.
|
||||
'';
|
||||
|
||||
keymaps = mkOption {
|
||||
type = listOf mapType;
|
||||
description = "Custom keybindings.";
|
||||
example = ''
|
||||
maps = {
|
||||
normal."<leader>m" = {
|
||||
vim.keymaps = [
|
||||
{
|
||||
key = "<leader>m";
|
||||
mode = "n";
|
||||
silent = true;
|
||||
action = "<cmd>make<CR>";
|
||||
}; # Same as nnoremap <leader>m <silent> <cmd>make<CR>
|
||||
};
|
||||
action = ":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";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -4,11 +4,8 @@
|
|||
...
|
||||
}: let
|
||||
inherit (builtins) toJSON;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
inherit (lib.lists) optionals;
|
||||
inherit (lib.nvim.binds) mkLuaBinding;
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.strings) optionalString;
|
||||
|
||||
cfg = config.vim.assistant.copilot;
|
||||
|
||||
|
@ -23,63 +20,68 @@
|
|||
end
|
||||
end
|
||||
'';
|
||||
|
||||
mkLuaKeymap = mode: key: action: desc: opts:
|
||||
opts
|
||||
// {
|
||||
inherit mode key action desc;
|
||||
lua = true;
|
||||
};
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins =
|
||||
[
|
||||
"copilot-lua"
|
||||
# cfg.copilotNodePackage
|
||||
]
|
||||
++ optionals cfg.cmp.enable [
|
||||
"copilot-cmp"
|
||||
];
|
||||
vim = {
|
||||
lazy.plugins = {
|
||||
copilot-lua = {
|
||||
package = "copilot-lua";
|
||||
setupModule = "copilot";
|
||||
inherit (cfg) setupOpts;
|
||||
after = mkIf cfg.cmp.enable "require('copilot_cmp').setup()";
|
||||
|
||||
vim.pluginRC.copilot = entryAnywhere ''
|
||||
require("copilot").setup(${toLuaObject cfg.setupOpts})
|
||||
cmd = ["Copilot" "CopilotAuth" "CopilotDetach" "CopilotPanel" "CopilotStop"];
|
||||
keys = [
|
||||
(mkLuaKeymap ["n"] cfg.mappings.panel.accept (wrapPanelBinding ''require("copilot.panel").accept'' cfg.mappings.panel.accept) "[copilot] Accept suggestion" {})
|
||||
(mkLuaKeymap ["n"] cfg.mappings.panel.jumpNext (wrapPanelBinding "require(\"copilot.panel\").jump_next" cfg.mappings.panel.jumpNext) "[copilot] Accept suggestion" {})
|
||||
(mkLuaKeymap ["n"] cfg.mappings.panel.jumpPrev (wrapPanelBinding "require(\"copilot.panel\").jump_prev" cfg.mappings.panel.jumpPrev) "[copilot] Accept suggestion" {})
|
||||
(mkLuaKeymap ["n"] cfg.mappings.panel.refresh (wrapPanelBinding "require(\"copilot.panel\").refresh" cfg.mappings.panel.refresh) "[copilot] Accept suggestion" {})
|
||||
(mkLuaKeymap ["n"] cfg.mappings.panel.open (wrapPanelBinding ''
|
||||
function() require("copilot.panel").open({ position = "${cfg.setupOpts.panel.layout.position}", ratio = ${toString cfg.setupOpts.panel.layout.ratio}, }) end
|
||||
''
|
||||
cfg.mappings.panel.open) "[copilot] Accept suggestion" {})
|
||||
|
||||
${lib.optionalString cfg.cmp.enable ''
|
||||
require("copilot_cmp").setup()
|
||||
''}
|
||||
'';
|
||||
|
||||
# Disable plugin handled keymaps.
|
||||
# Setting it here so that it doesn't show up in user docs
|
||||
vim.assistant.copilot.setupOpts = {
|
||||
panel.keymap = {
|
||||
jump_prev = lib.mkDefault false;
|
||||
jump_next = lib.mkDefault false;
|
||||
accept = lib.mkDefault false;
|
||||
refresh = lib.mkDefault false;
|
||||
open = lib.mkDefault false;
|
||||
(mkLuaKeymap ["i"] cfg.mappings.suggestion.accept "function() require('copilot.suggestion').accept() end" "[copilot] Accept suggestion" {})
|
||||
(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" {})
|
||||
(mkLuaKeymap ["i"] cfg.mappings.suggestion.prev "function() require('copilot.suggestion').prev() end" "[copilot] previous suggestion" {})
|
||||
];
|
||||
};
|
||||
};
|
||||
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;
|
||||
|
||||
autocomplete.nvim-cmp = {
|
||||
sources = {copilot = "[Copilot]";};
|
||||
sourcePlugins = ["copilot-cmp"];
|
||||
};
|
||||
|
||||
# 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")
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -4,16 +4,17 @@
|
|||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.trivial) boolToString;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
|
||||
cfg = config.vim.autopairs;
|
||||
cfg = config.vim.autopairs.nvim-autopairs;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = ["nvim-autopairs"];
|
||||
|
||||
vim.pluginRC.autopairs = entryAnywhere ''
|
||||
require("nvim-autopairs").setup({ map_cr = ${boolToString (!config.vim.autocomplete.enable)} })
|
||||
'';
|
||||
vim = {
|
||||
startPlugins = ["nvim-autopairs"];
|
||||
pluginRC.autopairs = entryAnywhere ''
|
||||
require('nvim-autopairs').setup(${toLuaObject cfg.setupOpts})
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,21 +1,14 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib) mkRemovedOptionModule;
|
||||
inherit (lib.options) mkEnableOption mkOption;
|
||||
inherit (lib.types) enum;
|
||||
inherit (lib.options) mkEnableOption;
|
||||
inherit (lib.nvim.types) mkPluginSetupOption;
|
||||
in {
|
||||
imports = [
|
||||
(mkRemovedOptionModule ["vim" "autopairs" "nvim-compe"] "nvim-compe is deprecated and no longer suported.")
|
||||
];
|
||||
|
||||
options.vim = {
|
||||
autopairs = {
|
||||
enable = mkEnableOption "autopairs" // {default = false;};
|
||||
|
||||
type = mkOption {
|
||||
type = enum ["nvim-autopairs"];
|
||||
default = "nvim-autopairs";
|
||||
description = "Set the autopairs type. Options: nvim-autopairs [nvim-autopairs]";
|
||||
};
|
||||
};
|
||||
options.vim.autopairs.nvim-autopairs = {
|
||||
enable = mkEnableOption "autopairs";
|
||||
setupOpts = mkPluginSetupOption "nvim-autopairs" {};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption;
|
||||
inherit (lib.nvim.binds) mkMappingOption;
|
||||
inherit (lib.nvim.types) mkPluginSetupOption;
|
||||
in {
|
||||
options.vim.comments.comment-nvim = {
|
||||
enable = mkEnableOption "smart and powerful comment plugin for neovim comment-nvim";
|
||||
|
@ -15,5 +16,12 @@ in {
|
|||
toggleSelectedLine = mkMappingOption "Toggle selected comment" "gc";
|
||||
toggleSelectedBlock = mkMappingOption "Toggle selected block" "gb";
|
||||
};
|
||||
|
||||
setupOpts = mkPluginSetupOption "Comment-nvim" {
|
||||
mappings = {
|
||||
basic = mkEnableOption "basic mappings";
|
||||
extra = mkEnableOption "extra mappings";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -3,48 +3,38 @@
|
|||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.nvim.binds) mkExprBinding mkBinding;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.nvim.binds) mkLznExprBinding mkLznBinding;
|
||||
|
||||
cfg = config.vim.comments.comment-nvim;
|
||||
self = import ./comment-nvim.nix {inherit lib;};
|
||||
inherit (self.options.vim.comments.comment-nvim) mappings;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = [
|
||||
"comment-nvim"
|
||||
];
|
||||
|
||||
vim.maps.normal = mkMerge [
|
||||
(mkBinding cfg.mappings.toggleOpLeaderLine "<Plug>(comment_toggle_linewise)" mappings.toggleOpLeaderLine.description)
|
||||
(mkBinding cfg.mappings.toggleOpLeaderBlock "<Plug>(comment_toggle_blockwise)" mappings.toggleOpLeaderBlock.description)
|
||||
|
||||
(mkExprBinding cfg.mappings.toggleCurrentLine ''
|
||||
function()
|
||||
return vim.api.nvim_get_vvar('count') == 0 and '<Plug>(comment_toggle_linewise_current)'
|
||||
or '<Plug>(comment_toggle_linewise_count)'
|
||||
end
|
||||
''
|
||||
mappings.toggleCurrentLine.description)
|
||||
(mkExprBinding cfg.mappings.toggleCurrentBlock ''
|
||||
function()
|
||||
return vim.api.nvim_get_vvar('count') == 0 and '<Plug>(comment_toggle_blockwise_current)'
|
||||
or '<Plug>(comment_toggle_blockwise_count)'
|
||||
end
|
||||
''
|
||||
mappings.toggleCurrentBlock.description)
|
||||
];
|
||||
|
||||
vim.maps.visualOnly = mkMerge [
|
||||
(mkBinding cfg.mappings.toggleSelectedLine "<Plug>(comment_toggle_linewise_visual)" mappings.toggleSelectedLine.description)
|
||||
(mkBinding cfg.mappings.toggleSelectedBlock "<Plug>(comment_toggle_blockwise_visual)" mappings.toggleSelectedBlock.description)
|
||||
];
|
||||
|
||||
vim.pluginRC.comment-nvim = entryAnywhere ''
|
||||
require('Comment').setup({
|
||||
mappings = { basic = false, extra = false, },
|
||||
})
|
||||
'';
|
||||
vim.lazy.plugins.comment-nvim = {
|
||||
package = "comment-nvim";
|
||||
setupModule = "Comment";
|
||||
inherit (cfg) setupOpts;
|
||||
keys = [
|
||||
(mkLznBinding ["n"] cfg.mappings.toggleOpLeaderLine "<Plug>(comment_toggle_linewise)" mappings.toggleOpLeaderLine.description)
|
||||
(mkLznBinding ["n"] cfg.mappings.toggleOpLeaderBlock "<Plug>(comment_toggle_blockwise)" mappings.toggleOpLeaderBlock.description)
|
||||
(mkLznExprBinding ["n"] cfg.mappings.toggleCurrentLine ''
|
||||
function()
|
||||
return vim.api.nvim_get_vvar('count') == 0 and '<Plug>(comment_toggle_linewise_current)'
|
||||
or '<Plug>(comment_toggle_linewise_count)'
|
||||
end
|
||||
''
|
||||
mappings.toggleCurrentLine.description)
|
||||
(mkLznExprBinding ["n"] cfg.mappings.toggleCurrentBlock ''
|
||||
function()
|
||||
return vim.api.nvim_get_vvar('count') == 0 and '<Plug>(comment_toggle_blockwise_current)'
|
||||
or '<Plug>(comment_toggle_blockwise_count)'
|
||||
end
|
||||
''
|
||||
mappings.toggleCurrentBlock.description)
|
||||
(mkLznBinding ["x"] cfg.mappings.toggleSelectedLine "<Plug>(comment_toggle_linewise_visual)" mappings.toggleSelectedLine.description)
|
||||
(mkLznBinding ["x"] cfg.mappings.toggleSelectedBlock "<Plug>(comment_toggle_blockwise_visual)" mappings.toggleSelectedBlock.description)
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -3,246 +3,123 @@
|
|||
config,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) toJSON;
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.attrsets) attrNames mapAttrsToList;
|
||||
inherit (lib.strings) concatMapStringsSep concatStringsSep optionalString;
|
||||
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetLuaBinding;
|
||||
inherit (lib.nvim.dag) entryAnywhere entryAfter;
|
||||
inherit (lib.strings) optionalString;
|
||||
inherit (lib.generators) mkLuaInline;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||
inherit (builtins) attrNames typeOf tryEval concatStringsSep;
|
||||
|
||||
cfg = config.vim.autocomplete;
|
||||
lspkindEnabled = config.vim.lsp.enable && config.vim.lsp.lspkind.enable;
|
||||
|
||||
self = import ./nvim-cmp.nix {inherit lib;};
|
||||
mappingDefinitions = self.options.vim.autocomplete.mappings;
|
||||
|
||||
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
|
||||
|
||||
builtSources =
|
||||
concatMapStringsSep
|
||||
"\n"
|
||||
(n: "{ name = '${n}'},")
|
||||
(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;
|
||||
cfg = config.vim.autocomplete.nvim-cmp;
|
||||
luasnipEnable = config.vim.snippets.luasnip.enable;
|
||||
getPluginName = plugin:
|
||||
if typeOf plugin == "string"
|
||||
then plugin
|
||||
else if (plugin ? pname && (tryEval plugin.pname).success)
|
||||
then plugin.pname
|
||||
else plugin.name;
|
||||
inherit (cfg) mappings;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = [
|
||||
"nvim-cmp"
|
||||
"cmp-buffer"
|
||||
"cmp-vsnip"
|
||||
"cmp-path"
|
||||
"vim-vsnip"
|
||||
];
|
||||
vim = {
|
||||
startPlugins = ["rtp-nvim"];
|
||||
lazy.plugins = mkMerge [
|
||||
(mapListToAttrs (package: {
|
||||
name = getPluginName package;
|
||||
value = {
|
||||
inherit package;
|
||||
lazy = true;
|
||||
after = ''
|
||||
local path = vim.fn.globpath(vim.o.packpath, 'pack/*/opt/${getPluginName package}')
|
||||
require("rtp_nvim").source_after_plugin_dir(path)
|
||||
'';
|
||||
};
|
||||
})
|
||||
cfg.sourcePlugins)
|
||||
{
|
||||
nvim-cmp = {
|
||||
package = "nvim-cmp";
|
||||
after = ''
|
||||
${optionalString luasnipEnable "local luasnip = require('luasnip')"}
|
||||
local cmp = require("cmp")
|
||||
cmp.setup(${toLuaObject cfg.setupOpts})
|
||||
|
||||
vim.autocomplete.sources = {
|
||||
"nvim-cmp" = null;
|
||||
"vsnip" = "[VSnip]";
|
||||
"buffer" = "[Buffer]";
|
||||
"crates" = "[Crates]";
|
||||
"path" = "[Path]";
|
||||
"copilot" = "[Copilot]";
|
||||
};
|
||||
${optionalString config.vim.lazy.enable
|
||||
(concatStringsSep "\n" (map
|
||||
(package: "require('lz.n').trigger_load(${toLuaObject (getPluginName package)})")
|
||||
cfg.sourcePlugins))}
|
||||
'';
|
||||
|
||||
vim.maps.insert = mkMerge [
|
||||
(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')
|
||||
|
||||
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
|
||||
'')
|
||||
(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
|
||||
},
|
||||
event = ["InsertEnter" "CmdlineEnter"];
|
||||
};
|
||||
}
|
||||
})
|
||||
${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 =
|
||||
if (cfg.type == "nvim-cmp")
|
||||
then true
|
||||
else config.vim.snippets.vsnip.enable;
|
||||
autocomplete.nvim-cmp = {
|
||||
sources = {
|
||||
nvim-cmp = null;
|
||||
buffer = "[Buffer]";
|
||||
path = "[Path]";
|
||||
};
|
||||
|
||||
sourcePlugins = ["cmp-buffer" "cmp-path"];
|
||||
|
||||
setupOpts = {
|
||||
sources = map (s: {name = s;}) (attrNames cfg.sources);
|
||||
|
||||
# TODO: try to get nvim-cmp to follow global border style
|
||||
window = mkIf config.vim.ui.borders.enable {
|
||||
completion = mkLuaInline "cmp.config.window.bordered()";
|
||||
documentation = mkLuaInline "cmp.config.window.bordered()";
|
||||
};
|
||||
|
||||
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)
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
_: {
|
||||
{
|
||||
imports = [
|
||||
./config.nix
|
||||
./nvim-cmp.nix
|
||||
|
|
|
@ -1,72 +1,109 @@
|
|||
{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.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 {
|
||||
options.vim = {
|
||||
autocomplete = {
|
||||
enable = mkEnableOption "autocomplete" // {default = false;};
|
||||
|
||||
alwaysComplete = mkOption {
|
||||
type = bool;
|
||||
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 {
|
||||
options.vim.autocomplete.nvim-cmp = {
|
||||
enable = mkEnableOption "nvim-cmp";
|
||||
setupOpts = mkPluginSetupOption "the autocomplete plugin" {
|
||||
completion.completeopt = mkOption {
|
||||
type = str;
|
||||
default = "menu,menuone,noinsert";
|
||||
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
|
||||
`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]";}
|
||||
See `:help completeopt` for the complete list.
|
||||
'';
|
||||
};
|
||||
|
||||
formatting = {
|
||||
format = mkOption {
|
||||
description = ''
|
||||
The function used to customize the appearance of the completion menu.
|
||||
sorting.comparators = mkOption {
|
||||
type = mergelessListOf (either str luaInline);
|
||||
default = [
|
||||
"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
|
||||
will be called before modifications from lspkind.
|
||||
|
||||
Default is to call the menu mapping function.
|
||||
'';
|
||||
type = str;
|
||||
default = "nvim_cmp_menu_map";
|
||||
example = literalMD ''
|
||||
```lua
|
||||
function(entry, vim_item)
|
||||
return vim_item
|
||||
end
|
||||
```
|
||||
'';
|
||||
};
|
||||
You can either pass a valid inline lua function
|
||||
(see `:help cmp-config.sorting.comparators`),
|
||||
or a string, in which case the builtin comparator with that name will
|
||||
be used.
|
||||
'';
|
||||
apply = map (
|
||||
c:
|
||||
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 = 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 entires. 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.";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
inherit (lib.strings) optionalString;
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.attrsets) mapAttrs;
|
||||
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetLuaBinding;
|
||||
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetLuaBinding mkSetLuaLznBinding;
|
||||
inherit (lib.nvim.dag) entryAnywhere entryAfter;
|
||||
|
||||
cfg = config.vim.debugger.nvim-dap;
|
||||
|
@ -16,57 +16,68 @@
|
|||
in {
|
||||
config = mkMerge [
|
||||
(mkIf cfg.enable {
|
||||
vim.startPlugins = ["nvim-dap"];
|
||||
vim = {
|
||||
startPlugins = ["nvim-dap"];
|
||||
|
||||
vim.pluginRC =
|
||||
{
|
||||
# TODO customizable keymaps
|
||||
nvim-dap = entryAnywhere ''
|
||||
local dap = require("dap")
|
||||
vim.fn.sign_define("DapBreakpoint", { text = "🛑", texthl = "ErrorMsg", linehl = "", numhl = "" })
|
||||
'';
|
||||
}
|
||||
// mapAttrs (_: v: (entryAfter ["nvim-dap"] v)) cfg.sources;
|
||||
pluginRC =
|
||||
{
|
||||
# TODO customizable keymaps
|
||||
nvim-dap = entryAnywhere ''
|
||||
local dap = require("dap")
|
||||
vim.fn.sign_define("DapBreakpoint", { text = "🛑", texthl = "ErrorMsg", linehl = "", numhl = "" })
|
||||
'';
|
||||
}
|
||||
// mapAttrs (_: v: (entryAfter ["nvim-dap"] v)) cfg.sources;
|
||||
|
||||
vim.maps.normal = mkMerge [
|
||||
(mkSetLuaBinding mappings.continue "require('dap').continue")
|
||||
(mkSetLuaBinding mappings.restart "require('dap').restart")
|
||||
(mkSetLuaBinding mappings.terminate "require('dap').terminate")
|
||||
(mkSetLuaBinding mappings.runLast "require('dap').run_last")
|
||||
maps.normal = mkMerge [
|
||||
(mkSetLuaBinding mappings.continue "require('dap').continue")
|
||||
(mkSetLuaBinding mappings.restart "require('dap').restart")
|
||||
(mkSetLuaBinding mappings.terminate "require('dap').terminate")
|
||||
(mkSetLuaBinding mappings.runLast "require('dap').run_last")
|
||||
|
||||
(mkSetLuaBinding mappings.toggleRepl "require('dap').repl.toggle")
|
||||
(mkSetLuaBinding mappings.hover "require('dap.ui.widgets').hover")
|
||||
(mkSetLuaBinding mappings.toggleBreakpoint "require('dap').toggle_breakpoint")
|
||||
(mkSetLuaBinding mappings.toggleRepl "require('dap').repl.toggle")
|
||||
(mkSetLuaBinding mappings.hover "require('dap.ui.widgets').hover")
|
||||
(mkSetLuaBinding mappings.toggleBreakpoint "require('dap').toggle_breakpoint")
|
||||
|
||||
(mkSetLuaBinding mappings.runToCursor "require('dap').run_to_cursor")
|
||||
(mkSetLuaBinding mappings.stepInto "require('dap').step_into")
|
||||
(mkSetLuaBinding mappings.stepOut "require('dap').step_out")
|
||||
(mkSetLuaBinding mappings.stepOver "require('dap').step_over")
|
||||
(mkSetLuaBinding mappings.stepBack "require('dap').step_back")
|
||||
(mkSetLuaBinding mappings.runToCursor "require('dap').run_to_cursor")
|
||||
(mkSetLuaBinding mappings.stepInto "require('dap').step_into")
|
||||
(mkSetLuaBinding mappings.stepOut "require('dap').step_out")
|
||||
(mkSetLuaBinding mappings.stepOver "require('dap').step_over")
|
||||
(mkSetLuaBinding mappings.stepBack "require('dap').step_back")
|
||||
|
||||
(mkSetLuaBinding mappings.goUp "require('dap').up")
|
||||
(mkSetLuaBinding mappings.goDown "require('dap').down")
|
||||
];
|
||||
(mkSetLuaBinding mappings.goUp "require('dap').up")
|
||||
(mkSetLuaBinding mappings.goDown "require('dap').down")
|
||||
];
|
||||
};
|
||||
})
|
||||
(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"] (''
|
||||
local dapui = require("dapui")
|
||||
dapui.setup()
|
||||
''
|
||||
+ optionalString cfg.ui.autoStart ''
|
||||
dap.listeners.after.event_initialized["dapui_config"] = function()
|
||||
dapui.open()
|
||||
end
|
||||
dap.listeners.before.event_terminated["dapui_config"] = function()
|
||||
dapui.close()
|
||||
end
|
||||
dap.listeners.before.event_exited["dapui_config"] = function()
|
||||
dapui.close()
|
||||
end
|
||||
'');
|
||||
vim.maps.normal = mkSetLuaBinding mappings.toggleDapUI "require('dapui').toggle";
|
||||
lazy.plugins.nvim-dap-ui = {
|
||||
package = "nvim-dap-ui";
|
||||
setupModule = "dapui";
|
||||
inherit (cfg.ui) setupOpts;
|
||||
|
||||
keys = [
|
||||
(mkSetLuaLznBinding mappings.toggleDapUI "function() require('dapui').toggle() end")
|
||||
];
|
||||
};
|
||||
|
||||
pluginRC.nvim-dap-ui = entryAfter ["nvim-dap"] (
|
||||
optionalString cfg.ui.autoStart ''
|
||||
dap.listeners.after.event_initialized["dapui_config"] = function()
|
||||
require("dapui").open()
|
||||
end
|
||||
dap.listeners.before.event_terminated["dapui_config"] = function()
|
||||
require("dapui").close()
|
||||
end
|
||||
dap.listeners.before.event_exited["dapui_config"] = function()
|
||||
require("dapui").close()
|
||||
end
|
||||
''
|
||||
);
|
||||
};
|
||||
})
|
||||
];
|
||||
}
|
||||
|
|
|
@ -2,12 +2,16 @@
|
|||
inherit (lib.options) mkEnableOption mkOption;
|
||||
inherit (lib.types) bool attrsOf str;
|
||||
inherit (lib.nvim.binds) mkMappingOption;
|
||||
inherit (lib.nvim.types) mkPluginSetupOption;
|
||||
in {
|
||||
options.vim.debugger.nvim-dap = {
|
||||
enable = mkEnableOption "debugging via nvim-dap";
|
||||
|
||||
ui = {
|
||||
enable = mkEnableOption "UI extension for nvim-dap";
|
||||
|
||||
setupOpts = mkPluginSetupOption "nvim-dap-ui" {};
|
||||
|
||||
autoStart = mkOption {
|
||||
type = bool;
|
||||
default = true;
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
|
||||
cfg = config.vim.filetree.neo-tree;
|
||||
in {
|
||||
|
@ -16,15 +14,17 @@ in {
|
|||
"plenary-nvim" # commons library
|
||||
"image-nvim" # optional for image previews
|
||||
"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 ''
|
||||
require("neo-tree").setup(${toLuaObject cfg.setupOpts})
|
||||
'';
|
||||
cmd = ["Neotree"];
|
||||
};
|
||||
|
||||
visuals.nvimWebDevicons.enable = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -5,10 +5,9 @@
|
|||
...
|
||||
}: let
|
||||
inherit (lib.strings) optionalString;
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.nvim.binds) mkBinding;
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.nvim.binds) mkLznBinding;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
inherit (lib.nvim.binds) pushDownDefault;
|
||||
|
||||
cfg = config.vim.filetree.nvimTree;
|
||||
|
@ -16,69 +15,74 @@
|
|||
inherit (self.options.vim.filetree.nvimTree) mappings;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = ["nvim-tree-lua"];
|
||||
vim = {
|
||||
binds.whichKey.register = pushDownDefault {
|
||||
"<leader>t" = "+NvimTree";
|
||||
};
|
||||
|
||||
vim.maps.normal = mkMerge [
|
||||
(mkBinding cfg.mappings.toggle ":NvimTreeToggle<cr>" mappings.toggle.description)
|
||||
(mkBinding cfg.mappings.refresh ":NvimTreeRefresh<cr>" mappings.refresh.description)
|
||||
(mkBinding cfg.mappings.findFile ":NvimTreeFindFile<cr>" mappings.findFile.description)
|
||||
(mkBinding cfg.mappings.focus ":NvimTreeFocus<cr>" mappings.focus.description)
|
||||
];
|
||||
lazy.plugins.nvim-tree-lua = {
|
||||
package = "nvim-tree-lua";
|
||||
setupModule = "nvim-tree";
|
||||
inherit (cfg) setupOpts;
|
||||
cmd = ["NvimTreeClipboard" "NvimTreeClose" "NvimTreeCollapse" "NvimTreeCollapseKeepBuffers" "NvimTreeFindFile" "NvimTreeFindFileToggle" "NvimTreeFocus" "NvimTreeHiTest" "NvimTreeOpen" "NvimTreeRefresh" "NvimTreeResize" "NvimTreeToggle"];
|
||||
keys = [
|
||||
(mkLznBinding ["n"] cfg.mappings.toggle ":NvimTreeToggle<cr>" mappings.toggle.description)
|
||||
(mkLznBinding ["n"] cfg.mappings.refresh ":NvimTreeRefresh<cr>" mappings.refresh.description)
|
||||
(mkLznBinding ["n"] cfg.mappings.findFile ":NvimTreeFindFile<cr>" mappings.findFile.description)
|
||||
(mkLznBinding ["n"] cfg.mappings.focus ":NvimTreeFocus<cr>" mappings.focus.description)
|
||||
];
|
||||
};
|
||||
|
||||
vim.binds.whichKey.register = pushDownDefault {
|
||||
"<leader>t" = "+NvimTree";
|
||||
pluginRC.nvimtreelua = entryAnywhere ''
|
||||
${
|
||||
optionalString cfg.setupOpts.disable_netrw ''
|
||||
-- disable netrew completely
|
||||
vim.g.loaded_netrw = 1
|
||||
vim.g.loaded_netrwPlugin = 1
|
||||
''
|
||||
}
|
||||
|
||||
${
|
||||
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 })
|
||||
''
|
||||
}
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
122
modules/plugins/languages/csharp.nix
Normal file
122
modules/plugins/languages/csharp.nix
Normal 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;
|
||||
})
|
||||
]);
|
||||
}
|
|
@ -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 {
|
||||
options.vim.languages.css = {
|
||||
|
|
|
@ -8,17 +8,20 @@ in {
|
|||
./css.nix
|
||||
./elixir.nix
|
||||
./go.nix
|
||||
./kotlin.nix
|
||||
./html.nix
|
||||
./java.nix
|
||||
./lua.nix
|
||||
./markdown.nix
|
||||
./nim.nix
|
||||
./vala.nix
|
||||
./nix.nix
|
||||
./ocaml.nix
|
||||
./php.nix
|
||||
./python.nix
|
||||
./r.nix
|
||||
./rust.nix
|
||||
./scala.nix
|
||||
./sql.nix
|
||||
./svelte.nix
|
||||
./tailwind.nix
|
||||
|
@ -26,6 +29,8 @@ in {
|
|||
./ts.nix
|
||||
./typst.nix
|
||||
./zig.nix
|
||||
./csharp.nix
|
||||
./julia.nix
|
||||
];
|
||||
|
||||
options.vim.languages = {
|
||||
|
|
126
modules/plugins/languages/julia.nix
Normal file
126
modules/plugins/languages/julia.nix
Normal 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;
|
||||
})
|
||||
]);
|
||||
}
|
107
modules/plugins/languages/kotlin.nix
Normal file
107
modules/plugins/languages/kotlin.nix
Normal 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"}''
|
||||
},
|
||||
}
|
||||
'';
|
||||
})
|
||||
]);
|
||||
}
|
|
@ -5,6 +5,7 @@
|
|||
...
|
||||
}: let
|
||||
inherit (builtins) attrNames;
|
||||
inherit (lib) concatStringsSep;
|
||||
inherit (lib.options) mkEnableOption mkOption;
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.lists) isList;
|
||||
|
@ -62,10 +63,10 @@
|
|||
command = {"${cfg.format.package}/bin/alejandra", "--quiet"},
|
||||
},
|
||||
''}
|
||||
${optionalString (cfg.format.type == "nixpkgs-fmt")
|
||||
${optionalString (cfg.format.type == "nixfmt")
|
||||
''
|
||||
formatting = {
|
||||
command = {"${cfg.format.package}/bin/nixpkgs-fmt"},
|
||||
command = {"${cfg.format.package}/bin/nixfmt"},
|
||||
},
|
||||
''}
|
||||
},
|
||||
|
@ -90,10 +91,19 @@
|
|||
'';
|
||||
};
|
||||
|
||||
nixpkgs-fmt = {
|
||||
package = pkgs.nixpkgs-fmt;
|
||||
# Never need to use null-ls for nixpkgs-fmt
|
||||
nixfmt = {
|
||||
package = pkgs.nixfmt-rfc-style;
|
||||
nullConfig = ''
|
||||
table.insert(
|
||||
ls_sources,
|
||||
null_ls.builtins.formatting.nixfmt.with({
|
||||
command = "${cfg.format.package}/bin/nixfmt"
|
||||
})
|
||||
)
|
||||
'';
|
||||
};
|
||||
|
||||
nixpkgs-fmt = null; # removed
|
||||
};
|
||||
|
||||
defaultDiagnosticsProvider = ["statix" "deadnix"];
|
||||
|
@ -135,7 +145,7 @@ in {
|
|||
enable = mkEnableOption "Nix LSP support" // {default = config.vim.languages.enableLSP;};
|
||||
server = mkOption {
|
||||
description = "Nix LSP server to use";
|
||||
type = str;
|
||||
type = enum (attrNames servers);
|
||||
default = defaultServer;
|
||||
};
|
||||
|
||||
|
@ -175,6 +185,12 @@ in {
|
|||
|
||||
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.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "nix",
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
inherit (lib.options) mkOption mkEnableOption;
|
||||
inherit (lib.strings) optionalString;
|
||||
inherit (lib.trivial) boolToString;
|
||||
inherit (lib.lists) isList optionals;
|
||||
inherit (lib.lists) isList;
|
||||
inherit (lib.types) bool package str listOf either enum;
|
||||
inherit (lib.nvim.types) mkGrammarOption;
|
||||
inherit (lib.nvim.lua) expToLua;
|
||||
|
@ -101,7 +101,7 @@ in {
|
|||
vim = {
|
||||
startPlugins = ["crates-nvim"];
|
||||
lsp.null-ls.enable = mkIf cfg.crates.codeActions true;
|
||||
autocomplete.sources = {"crates" = "[Crates]";};
|
||||
autocomplete.nvim-cmp.sources = {crates = "[Crates]";};
|
||||
pluginRC.rust-crates = entryAnywhere ''
|
||||
require('crates').setup {
|
||||
null_ls = {
|
||||
|
|
149
modules/plugins/languages/scala.nix
Normal file
149
modules/plugins/languages/scala.nix
Normal file
|
@ -0,0 +1,149 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.generators) mkLuaInline;
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.nvim.binds) mkMappingOption;
|
||||
inherit (lib.nvim.dag) entryAfter;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
inherit (lib.nvim.types) mkGrammarOption luaInline;
|
||||
inherit (lib.options) mkOption mkEnableOption mkPackageOption;
|
||||
inherit (lib.strings) optionalString;
|
||||
inherit (lib.types) attrsOf anything bool;
|
||||
|
||||
listCommandsAction =
|
||||
if config.vim.telescope.enable
|
||||
then ''require("telescope").extensions.metals.commands()''
|
||||
else ''require("metals").commands()'';
|
||||
|
||||
cfg = config.vim.languages.scala;
|
||||
|
||||
usingDap = config.vim.debugger.nvim-dap.enable && cfg.dap.enable;
|
||||
usingLualine = config.vim.statusline.lualine.enable;
|
||||
in {
|
||||
options.vim.languages.scala = {
|
||||
enable = mkEnableOption "Scala language support";
|
||||
|
||||
treesitter = {
|
||||
enable = mkEnableOption "Scala treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||
package = mkGrammarOption pkgs "scala";
|
||||
};
|
||||
|
||||
lsp = {
|
||||
enable = mkEnableOption "Scala LSP support (metals)" // {default = config.vim.languages.enableLSP;};
|
||||
package = mkPackageOption pkgs "metals" {
|
||||
default = ["metals"];
|
||||
};
|
||||
|
||||
extraMappings = {
|
||||
listCommands = mkMappingOption "List Metals commands" "<leader>lc";
|
||||
};
|
||||
|
||||
extraSettings = mkOption {
|
||||
type = attrsOf anything;
|
||||
description = "Extra settings passed to the metals config. Check nvim-metals docs for available options";
|
||||
default = {
|
||||
showImplicitArguments = true;
|
||||
showImplicitConversionsAndClasses = true;
|
||||
showInferredType = true;
|
||||
excludedPackages = [
|
||||
"akka.actor.typed.javadsl"
|
||||
"com.github.swagger.akka.javadsl"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
dap = {
|
||||
enable = mkEnableOption "Scala Debug Adapter support (metals)" // {default = config.vim.languages.enableDAP;};
|
||||
config = mkOption {
|
||||
description = "Lua configuration for dap";
|
||||
type = luaInline;
|
||||
default = mkLuaInline ''
|
||||
dap.configurations.scala = {
|
||||
{
|
||||
type = "scala",
|
||||
request = "launch",
|
||||
name = "RunOrTest",
|
||||
metals = {
|
||||
runType = "runOrTestFile",
|
||||
--args = { "firstArg", "secondArg", "thirdArg" }, -- here just as an example
|
||||
},
|
||||
},
|
||||
{
|
||||
type = "scala",
|
||||
request = "launch",
|
||||
name = "Test Target",
|
||||
metals = {
|
||||
runType = "testTarget",
|
||||
},
|
||||
},
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
fixShortmess = mkOption {
|
||||
type = bool;
|
||||
description = "Remove the 'F' flag from shortmess to allow messages to be shown. Without doing this, autocommands that deal with filetypes prohibit messages from being shown";
|
||||
default = true;
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable (
|
||||
mkMerge [
|
||||
(mkIf cfg.treesitter.enable {
|
||||
vim.treesitter.enable = true;
|
||||
vim.treesitter.grammars = [cfg.treesitter.package];
|
||||
})
|
||||
(mkIf (cfg.lsp.enable || cfg.dap.enable) {
|
||||
vim = {
|
||||
startPlugins = ["nvim-metals"];
|
||||
pluginRC.nvim-metals = entryAfter ["lsp-setup"] ''
|
||||
local metals_caps = capabilities -- from lsp-setup
|
||||
|
||||
local attach_metals_keymaps = function(client, bufnr)
|
||||
attach_keymaps(client, bufnr) -- from lsp-setup
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '${cfg.lsp.extraMappings.listCommands}', '<cmd>lua ${listCommandsAction}<CR>', {noremap=true, silent=true, desc='Show all Metals commands'})
|
||||
end
|
||||
|
||||
metals_config = require('metals').bare_config()
|
||||
${optionalString usingLualine "metals_config.init_options.statusBarProvider = 'on'"}
|
||||
|
||||
metals_config.capabilities = metals_caps
|
||||
metals_config.on_attach = function(client, bufnr)
|
||||
${optionalString usingDap "require('metals').setup_dap()"}
|
||||
attach_metals_keymaps(client, bufnr)
|
||||
end
|
||||
|
||||
metals_config.settings = ${toLuaObject cfg.lsp.extraSettings}
|
||||
metals_config.settings.metalsBinaryPath = "${cfg.lsp.package}/bin/metals"
|
||||
|
||||
metals_config.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
|
||||
vim.lsp.diagnostic.on_publish_diagnostics, {
|
||||
virtual_text = {
|
||||
prefix = '⚠',
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
${optionalString cfg.fixShortmess ''vim.opt_global.shortmess:remove("F")''}
|
||||
|
||||
local lsp_group = vim.api.nvim_create_augroup('lsp', { clear = true })
|
||||
|
||||
vim.api.nvim_create_autocmd('FileType', {
|
||||
group = lsp_group,
|
||||
pattern = {'java', 'scala', 'sbt'},
|
||||
callback = function()
|
||||
require('metals').initialize_or_attach(metals_config)
|
||||
end,
|
||||
})
|
||||
'';
|
||||
};
|
||||
})
|
||||
]
|
||||
);
|
||||
}
|
|
@ -48,6 +48,18 @@
|
|||
)
|
||||
'';
|
||||
};
|
||||
|
||||
biome = {
|
||||
package = pkgs.biome;
|
||||
nullConfig = ''
|
||||
table.insert(
|
||||
ls_sources,
|
||||
null_ls.builtins.formatting.biome.with({
|
||||
command = "${cfg.format.package}/bin/biome",
|
||||
})
|
||||
)
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
# TODO: specify packages
|
||||
|
|
|
@ -95,6 +95,18 @@
|
|||
)
|
||||
'';
|
||||
};
|
||||
|
||||
biome = {
|
||||
package = pkgs.biome;
|
||||
nullConfig = ''
|
||||
table.insert(
|
||||
ls_sources,
|
||||
null_ls.builtins.formatting.biome.with({
|
||||
command = "${cfg.format.package}/bin/biome",
|
||||
})
|
||||
)
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
# TODO: specify packages
|
||||
|
|
79
modules/plugins/languages/vala.nix
Normal file
79
modules/plugins/languages/vala.nix
Normal file
|
@ -0,0 +1,79 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) attrNames;
|
||||
inherit (lib.options) mkEnableOption mkOption;
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.lists) isList;
|
||||
inherit (lib.types) enum either listOf package str;
|
||||
inherit (lib.nvim.types) mkGrammarOption;
|
||||
inherit (lib.nvim.lua) expToLua;
|
||||
|
||||
cfg = config.vim.languages.vala;
|
||||
|
||||
defaultServer = "vala_ls";
|
||||
servers = {
|
||||
vala_ls = {
|
||||
package = pkgs.symlinkJoin {
|
||||
name = "vala-language-server-wrapper";
|
||||
paths = [pkgs.vala-language-server];
|
||||
buildInputs = [pkgs.makeBinaryWrapper];
|
||||
postBuild = ''
|
||||
wrapProgram $out/bin/vala-language-server \
|
||||
--prefix PATH : ${pkgs.uncrustify}/bin
|
||||
'';
|
||||
};
|
||||
internalFormatter = true;
|
||||
lspConfig = ''
|
||||
lspconfig.vala_ls.setup {
|
||||
capabilities = capabilities;
|
||||
on_attach = default_on_attach;
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then expToLua cfg.lsp.package
|
||||
else ''{"${cfg.lsp.package}/bin/vala-language-server"}''
|
||||
},
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
in {
|
||||
options.vim.languages.vala = {
|
||||
enable = mkEnableOption "Vala language support";
|
||||
|
||||
treesitter = {
|
||||
enable = mkEnableOption "Vala treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||
package = mkGrammarOption pkgs "vala";
|
||||
};
|
||||
|
||||
lsp = {
|
||||
enable = mkEnableOption "Vala LSP support" // {default = config.vim.languages.enableLSP;};
|
||||
server = mkOption {
|
||||
description = "Vala LSP server to use";
|
||||
type = enum (attrNames servers);
|
||||
default = defaultServer;
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
description = "Vala LSP server package, or the command to run as a list of strings";
|
||||
type = either package (listOf str);
|
||||
default = servers.${cfg.lsp.server}.package;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
(mkIf cfg.treesitter.enable {
|
||||
vim.treesitter.enable = true;
|
||||
vim.treesitter.grammars = [cfg.treesitter.package];
|
||||
})
|
||||
|
||||
(mkIf cfg.lsp.enable {
|
||||
vim.lsp.lspconfig.enable = true;
|
||||
vim.lsp.lspconfig.sources.vala_ls = servers.${cfg.lsp.server}.lspConfig;
|
||||
})
|
||||
]);
|
||||
}
|
|
@ -5,52 +5,52 @@
|
|||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.lists) optional;
|
||||
inherit (lib.strings) optionalString;
|
||||
inherit (lib.trivial) boolToString;
|
||||
inherit (lib.nvim.binds) addDescriptionsToMappings;
|
||||
|
||||
cfg = config.vim.lsp;
|
||||
usingNvimCmp = config.vim.autocomplete.enable && config.vim.autocomplete.type == "nvim-cmp";
|
||||
usingNvimCmp = config.vim.autocomplete.nvim-cmp.enable;
|
||||
self = import ./module.nix {inherit config lib pkgs;};
|
||||
|
||||
mappingDefinitions = self.options.vim.lsp.mappings;
|
||||
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
|
||||
mkBinding = binding: action:
|
||||
if binding.value != null
|
||||
then "vim.api.nvim_buf_set_keymap(bufnr, 'n', '${binding.value}', '<cmd>lua ${action}<CR>', {noremap=true, silent=true, desc='${binding.description}'})"
|
||||
then "vim.keymap.set('n', '${binding.value}', ${action}, {buffer=bufnr, noremap=true, silent=true, desc='${binding.description}'})"
|
||||
else "";
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim = {
|
||||
startPlugins = optional usingNvimCmp "cmp-nvim-lsp";
|
||||
|
||||
autocomplete.sources = {"nvim_lsp" = "[LSP]";};
|
||||
autocomplete.nvim-cmp = {
|
||||
sources = {nvim_lsp = "[LSP]";};
|
||||
sourcePlugins = ["cmp-nvim-lsp"];
|
||||
};
|
||||
|
||||
pluginRC.lsp-setup = ''
|
||||
vim.g.formatsave = ${boolToString cfg.formatOnSave};
|
||||
|
||||
local attach_keymaps = function(client, bufnr)
|
||||
${mkBinding mappings.goToDeclaration "vim.lsp.buf.declaration()"}
|
||||
${mkBinding mappings.goToDefinition "vim.lsp.buf.definition()"}
|
||||
${mkBinding mappings.goToType "vim.lsp.buf.type_definition()"}
|
||||
${mkBinding mappings.listImplementations "vim.lsp.buf.implementation()"}
|
||||
${mkBinding mappings.listReferences "vim.lsp.buf.references()"}
|
||||
${mkBinding mappings.nextDiagnostic "vim.diagnostic.goto_next()"}
|
||||
${mkBinding mappings.previousDiagnostic "vim.diagnostic.goto_prev()"}
|
||||
${mkBinding mappings.openDiagnosticFloat "vim.diagnostic.open_float()"}
|
||||
${mkBinding mappings.documentHighlight "vim.lsp.buf.document_highlight()"}
|
||||
${mkBinding mappings.listDocumentSymbols "vim.lsp.buf.document_symbol()"}
|
||||
${mkBinding mappings.addWorkspaceFolder "vim.lsp.buf.add_workspace_folder()"}
|
||||
${mkBinding mappings.removeWorkspaceFolder "vim.lsp.buf.remove_workspace_folder()"}
|
||||
${mkBinding mappings.listWorkspaceFolders "print(vim.inspect(vim.lsp.buf.list_workspace_folders()))"}
|
||||
${mkBinding mappings.listWorkspaceSymbols "vim.lsp.buf.workspace_symbol()"}
|
||||
${mkBinding mappings.hover "vim.lsp.buf.hover()"}
|
||||
${mkBinding mappings.signatureHelp "vim.lsp.buf.signature_help()"}
|
||||
${mkBinding mappings.renameSymbol "vim.lsp.buf.rename()"}
|
||||
${mkBinding mappings.codeAction "vim.lsp.buf.code_action()"}
|
||||
${mkBinding mappings.format "vim.lsp.buf.format()"}
|
||||
${mkBinding mappings.toggleFormatOnSave "vim.b.disableFormatSave = not vim.b.disableFormatSave"}
|
||||
${mkBinding mappings.goToDeclaration "vim.lsp.buf.declaration"}
|
||||
${mkBinding mappings.goToDefinition "vim.lsp.buf.definition"}
|
||||
${mkBinding mappings.goToType "vim.lsp.buf.type_definition"}
|
||||
${mkBinding mappings.listImplementations "vim.lsp.buf.implementation"}
|
||||
${mkBinding mappings.listReferences "vim.lsp.buf.references"}
|
||||
${mkBinding mappings.nextDiagnostic "vim.diagnostic.goto_next"}
|
||||
${mkBinding mappings.previousDiagnostic "vim.diagnostic.goto_prev"}
|
||||
${mkBinding mappings.openDiagnosticFloat "vim.diagnostic.open_float"}
|
||||
${mkBinding mappings.documentHighlight "vim.lsp.buf.document_highlight"}
|
||||
${mkBinding mappings.listDocumentSymbols "vim.lsp.buf.document_symbol"}
|
||||
${mkBinding mappings.addWorkspaceFolder "vim.lsp.buf.add_workspace_folder"}
|
||||
${mkBinding mappings.removeWorkspaceFolder "vim.lsp.buf.remove_workspace_folder"}
|
||||
${mkBinding mappings.listWorkspaceFolders "function() vim.notify(vim.inspect(vim.lsp.buf.list_workspace_folders())) end"}
|
||||
${mkBinding mappings.listWorkspaceSymbols "vim.lsp.buf.workspace_symbol"}
|
||||
${mkBinding mappings.hover "vim.lsp.buf.hover"}
|
||||
${mkBinding mappings.signatureHelp "vim.lsp.buf.signature_help"}
|
||||
${mkBinding mappings.renameSymbol "vim.lsp.buf.rename"}
|
||||
${mkBinding mappings.codeAction "vim.lsp.buf.code_action"}
|
||||
${mkBinding mappings.format "vim.lsp.buf.format"}
|
||||
${mkBinding mappings.toggleFormatOnSave "function() vim.b.disableFormatSave = not vim.b.disableFormatSave end"}
|
||||
end
|
||||
|
||||
-- Enable formatting
|
||||
|
@ -116,7 +116,60 @@ in {
|
|||
end
|
||||
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
${optionalString usingNvimCmp "capabilities = require('cmp_nvim_lsp').default_capabilities()"}
|
||||
${optionalString usingNvimCmp ''
|
||||
-- HACK: copied from cmp-nvim-lsp. If we ever lazy load lspconfig we
|
||||
-- should re-evaluate whether we can just use `default_capabilities`
|
||||
capabilities = {
|
||||
textDocument = {
|
||||
completion = {
|
||||
dynamicRegistration = false,
|
||||
completionItem = {
|
||||
snippetSupport = true,
|
||||
commitCharactersSupport = true,
|
||||
deprecatedSupport = true,
|
||||
preselectSupport = true,
|
||||
tagSupport = {
|
||||
valueSet = {
|
||||
1, -- Deprecated
|
||||
}
|
||||
},
|
||||
insertReplaceSupport = true,
|
||||
resolveSupport = {
|
||||
properties = {
|
||||
"documentation",
|
||||
"detail",
|
||||
"additionalTextEdits",
|
||||
"sortText",
|
||||
"filterText",
|
||||
"insertText",
|
||||
"textEdit",
|
||||
"insertTextFormat",
|
||||
"insertTextMode",
|
||||
},
|
||||
},
|
||||
insertTextModeSupport = {
|
||||
valueSet = {
|
||||
1, -- asIs
|
||||
2, -- adjustIndentation
|
||||
}
|
||||
},
|
||||
labelDetailsSupport = true,
|
||||
},
|
||||
contextSupport = true,
|
||||
insertTextMode = 1,
|
||||
completionList = {
|
||||
itemDefaults = {
|
||||
'commitCharacters',
|
||||
'editRange',
|
||||
'insertTextFormat',
|
||||
'insertTextMode',
|
||||
'data',
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
''}
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
|
|
@ -3,18 +3,32 @@
|
|||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
inherit (lib.modules) mkIf mkForce;
|
||||
inherit (lib.generators) mkLuaInline;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
|
||||
cfg = config.vim.lsp;
|
||||
cfg = config.vim.lsp.lspkind;
|
||||
in {
|
||||
config = mkIf (cfg.enable && cfg.lspkind.enable) {
|
||||
vim.startPlugins = ["lspkind"];
|
||||
vim.pluginRC.lspkind = entryAnywhere ''
|
||||
local lspkind = require'lspkind'
|
||||
local lspkind_opts = {
|
||||
mode = '${cfg.lspkind.mode}'
|
||||
config = mkIf cfg.enable {
|
||||
assertions = [
|
||||
{
|
||||
assertion = config.vim.autocomplete.nvim-cmp.enable;
|
||||
message = ''
|
||||
While lspkind supports Neovim's native lsp upstream, using that over
|
||||
nvim-cmp isn't recommended, nor supported by nvf.
|
||||
|
||||
Please migrate to nvim-cmp if you want to use lspkind.
|
||||
'';
|
||||
}
|
||||
'';
|
||||
];
|
||||
|
||||
vim = {
|
||||
startPlugins = ["lspkind"];
|
||||
|
||||
lsp.lspkind.setupOpts.before = config.vim.autocomplete.nvim-cmp.format;
|
||||
autocomplete.nvim-cmp.setupOpts.formatting.format = mkForce (mkLuaInline ''
|
||||
require("lspkind").cmp_format(${toLuaObject cfg.setupOpts})
|
||||
'');
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,16 +1,22 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption mkOption;
|
||||
inherit (lib.types) enum;
|
||||
inherit (lib.types) enum nullOr;
|
||||
inherit (lib.nvim.types) mkPluginSetupOption luaInline;
|
||||
in {
|
||||
options.vim.lsp = {
|
||||
lspkind = {
|
||||
enable = mkEnableOption "vscode-like pictograms for lsp [lspkind]";
|
||||
|
||||
options.vim.lsp.lspkind = {
|
||||
enable = mkEnableOption "vscode-like pictograms for lsp [lspkind]";
|
||||
setupOpts = mkPluginSetupOption "lspkind.nvim" {
|
||||
mode = mkOption {
|
||||
description = "Defines how annotations are shown";
|
||||
type = enum ["text" "text_symbol" "symbol_text" "symbol"];
|
||||
default = "symbol_text";
|
||||
};
|
||||
|
||||
before = mkOption {
|
||||
description = "The function that will be called before lspkind's modifications are applied";
|
||||
type = nullOr luaInline;
|
||||
default = null;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ in {
|
|||
|
||||
pluginRC.otter-nvim = entryAnywhere ''
|
||||
-- Enable otter diagnostics viewer
|
||||
require("otter").setup({${toLuaObject cfg.otter-nvim.setupOpts}})
|
||||
require("otter").setup(${toLuaObject cfg.otter-nvim.setupOpts})
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,41 +1,40 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
options,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetBinding pushDownDefault;
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetLznBinding pushDownDefault;
|
||||
|
||||
cfg = config.vim.lsp;
|
||||
|
||||
self = import ./trouble.nix {inherit lib;};
|
||||
mappingDefinitions = self.options.vim.lsp.trouble.mappings;
|
||||
mappingDefinitions = options.vim.lsp.trouble.mappings;
|
||||
mappings = addDescriptionsToMappings cfg.trouble.mappings mappingDefinitions;
|
||||
in {
|
||||
config = mkIf (cfg.enable && cfg.trouble.enable) {
|
||||
vim = {
|
||||
startPlugins = ["trouble"];
|
||||
lazy.plugins.trouble = {
|
||||
package = "trouble";
|
||||
setupModule = "trouble";
|
||||
inherit (cfg.trouble) setupOpts;
|
||||
|
||||
maps.normal = mkMerge [
|
||||
(mkSetBinding mappings.toggle "<cmd>TroubleToggle<CR>")
|
||||
(mkSetBinding mappings.workspaceDiagnostics "<cmd>TroubleToggle workspace_diagnostics<CR>")
|
||||
(mkSetBinding mappings.documentDiagnostics "<cmd>TroubleToggle document_diagnostics<CR>")
|
||||
(mkSetBinding mappings.lspReferences "<cmd>TroubleToggle lsp_references<CR>")
|
||||
(mkSetBinding mappings.quickfix "<cmd>TroubleToggle quickfix<CR>")
|
||||
(mkSetBinding mappings.locList "<cmd>TroubleToggle loclist<CR>")
|
||||
];
|
||||
cmd = "Trouble";
|
||||
keys = [
|
||||
(mkSetLznBinding mappings.toggle "<cmd>TroubleToggle<CR>")
|
||||
(mkSetLznBinding mappings.workspaceDiagnostics "<cmd>TroubleToggle workspace_diagnostics<CR>")
|
||||
(mkSetLznBinding mappings.documentDiagnostics "<cmd>TroubleToggle document_diagnostics<CR>")
|
||||
(mkSetLznBinding mappings.lspReferences "<cmd>TroubleToggle lsp_references<CR>")
|
||||
(mkSetLznBinding mappings.quickfix "<cmd>TroubleToggle quickfix<CR>")
|
||||
(mkSetLznBinding mappings.locList "<cmd>TroubleToggle loclist<CR>")
|
||||
];
|
||||
};
|
||||
|
||||
binds.whichKey.register = pushDownDefault {
|
||||
"<leader>l" = "Trouble";
|
||||
"<leader>x" = "+Trouble";
|
||||
"<leader>lw" = "Workspace";
|
||||
};
|
||||
|
||||
pluginRC.trouble = entryAnywhere ''
|
||||
-- Enable trouble diagnostics viewer
|
||||
require("trouble").setup {}
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption;
|
||||
inherit (lib.nvim.binds) mkMappingOption;
|
||||
inherit (lib.nvim.types) mkPluginSetupOption;
|
||||
in {
|
||||
options.vim.lsp = {
|
||||
trouble = {
|
||||
enable = mkEnableOption "trouble diagnostics viewer";
|
||||
|
||||
setupOpts = mkPluginSetupOption "Trouble" {};
|
||||
|
||||
mappings = {
|
||||
toggle = mkMappingOption "Toggle trouble [trouble]" "<leader>xx";
|
||||
workspaceDiagnostics = mkMappingOption "Workspace diagnostics [trouble]" "<leader>lwd";
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
imports = [
|
||||
./obsidian
|
||||
./orgmode
|
||||
./neorg
|
||||
./mind-nvim
|
||||
./todo-comments
|
||||
];
|
||||
|
|
41
modules/plugins/notes/neorg/config.nix
Normal file
41
modules/plugins/notes/neorg/config.nix
Normal file
|
@ -0,0 +1,41 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
inherit (lib.nvim.binds) pushDownDefault;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
|
||||
cfg = config.vim.notes.neorg;
|
||||
in {
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
{
|
||||
vim = {
|
||||
startPlugins = [
|
||||
"lua-utils-nvim"
|
||||
"nui-nvim"
|
||||
"nvim-nio"
|
||||
"pathlib-nvim"
|
||||
"plenary-nvim"
|
||||
"neorg"
|
||||
"neorg-telescope"
|
||||
];
|
||||
|
||||
binds.whichKey.register = pushDownDefault {
|
||||
"<leader>o" = "+Notes";
|
||||
};
|
||||
|
||||
pluginRC.neorg = entryAnywhere ''
|
||||
require('neorg').setup(${toLuaObject cfg.setupOpts})
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
||||
(mkIf cfg.treesitter.enable {
|
||||
vim.treesitter.enable = true;
|
||||
vim.treesitter.grammars = [cfg.treesitter.norgPackage];
|
||||
})
|
||||
]);
|
||||
}
|
6
modules/plugins/notes/neorg/default.nix
Normal file
6
modules/plugins/notes/neorg/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./neorg.nix
|
||||
./config.nix
|
||||
];
|
||||
}
|
50
modules/plugins/notes/neorg/neorg.nix
Normal file
50
modules/plugins/notes/neorg/neorg.nix
Normal file
|
@ -0,0 +1,50 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.options) mkEnableOption mkOption;
|
||||
inherit (lib.types) submodule listOf str;
|
||||
inherit (lib.nvim.types) mkGrammarOption mkPluginSetupOption;
|
||||
in {
|
||||
options.vim.notes.neorg = {
|
||||
enable = mkEnableOption ''
|
||||
Neorg: An intuitive note-taking and organization tool with a structured nested syntax.
|
||||
'';
|
||||
|
||||
setupOpts = mkPluginSetupOption "Neorg" {
|
||||
load = {
|
||||
"core.defaults" = mkOption {
|
||||
default = {};
|
||||
description = ''
|
||||
all of the most important modules that any user would want to have a "just works" experience
|
||||
'';
|
||||
|
||||
type = submodule {
|
||||
options = {
|
||||
enable = mkEnableOption ''
|
||||
all of the most important modules that any user would want to have a "just works" experience
|
||||
'';
|
||||
config = {
|
||||
disable = mkOption {
|
||||
description = ''
|
||||
list of modules from to be disabled from core.defaults
|
||||
'';
|
||||
type = listOf str;
|
||||
default = [];
|
||||
example = ["core.autocommands" "core.itero"];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
treesitter = {
|
||||
enable = mkEnableOption "Neorg treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||
norgPackage = mkGrammarOption pkgs "norg";
|
||||
};
|
||||
};
|
||||
}
|
|
@ -45,10 +45,10 @@ in {
|
|||
|
||||
completion = {
|
||||
nvim_cmp = mkOption {
|
||||
# if using nvim-cmp, otherwise set to false
|
||||
# If using nvim-cmp, otherwise set to false
|
||||
type = bool;
|
||||
description = "If using nvim-cmp, otherwise set to false";
|
||||
default = config.vim.autocomplete.type == "nvim-cmp";
|
||||
default = config.vim.autocomplete.nvim-cmp.enable;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
imports = [
|
||||
./vsnip
|
||||
./luasnip
|
||||
];
|
||||
}
|
||||
|
|
26
modules/plugins/snippets/luasnip/config.nix
Normal file
26
modules/plugins/snippets/luasnip/config.nix
Normal file
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
|
||||
cfg = config.vim.snippets.luasnip;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim = {
|
||||
lazy.plugins = {
|
||||
luasnip = {
|
||||
package = "luasnip";
|
||||
lazy = true;
|
||||
after = cfg.loaders;
|
||||
};
|
||||
};
|
||||
startPlugins = cfg.providers;
|
||||
autocomplete.nvim-cmp = {
|
||||
sources = {luasnip = "[LuaSnip]";};
|
||||
sourcePlugins = ["cmp-luasnip"];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
6
modules/plugins/snippets/luasnip/default.nix
Normal file
6
modules/plugins/snippets/luasnip/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./luasnip.nix
|
||||
./config.nix
|
||||
];
|
||||
}
|
36
modules/plugins/snippets/luasnip/luasnip.nix
Normal file
36
modules/plugins/snippets/luasnip/luasnip.nix
Normal file
|
@ -0,0 +1,36 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption mkOption literalExpression literalMD;
|
||||
inherit (lib.types) listOf lines;
|
||||
inherit (lib.nvim.types) pluginType;
|
||||
in {
|
||||
options.vim.snippets.luasnip = {
|
||||
enable = mkEnableOption "luasnip";
|
||||
providers = mkOption {
|
||||
type = listOf pluginType;
|
||||
default = ["friendly-snippets"];
|
||||
description = ''
|
||||
The snippet provider packages.
|
||||
|
||||
::: {.note}
|
||||
These are simply appended to {option} `vim.startPlugins`.
|
||||
:::
|
||||
'';
|
||||
example = literalExpression "[\"vimPlugins.vim-snippets\"]";
|
||||
};
|
||||
loaders = mkOption {
|
||||
type = lines;
|
||||
default = "require('luasnip.loaders.from_vscode').lazy_load()";
|
||||
defaultText = literalMD ''
|
||||
```lua
|
||||
require('luasnip.loaders.from_vscode').lazy_load()
|
||||
```
|
||||
'';
|
||||
description = "Lua code used to load snippet providers.";
|
||||
example = literalMD ''
|
||||
```lua
|
||||
require("luasnip.loaders.from_snipmate").lazy_load()
|
||||
```
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
|
||||
cfg = config.vim.snippets.vsnip;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = ["vim-vsnip"];
|
||||
};
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
{
|
||||
imports = [
|
||||
./vsnip.nix
|
||||
];
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption;
|
||||
in {
|
||||
options.vim.snippets.vsnip = {
|
||||
enable = mkEnableOption "vim-vsnip: snippet LSP/VSCode's format";
|
||||
};
|
||||
}
|
|
@ -7,16 +7,26 @@
|
|||
inherit (lib.nvim.dag) entryAfter;
|
||||
cfg = config.vim.spellcheck;
|
||||
in {
|
||||
config = mkIf (cfg.enable && cfg.programmingWordlist.enable) {
|
||||
config = mkIf cfg.programmingWordlist.enable {
|
||||
vim = {
|
||||
startPlugins = ["vim-dirtytalk"];
|
||||
|
||||
# vim-dirtytalk doesn't have any setup
|
||||
# but we would like to append programming to spelllang
|
||||
# as soon as possible while the plugin is enabled
|
||||
pluginRC.vim-dirtytalk = entryAfter ["basic"] ''
|
||||
-- append programming to spelllang
|
||||
vim.opt.spelllang:append("programming")
|
||||
spellcheck.enable = true;
|
||||
|
||||
# vim-dirtytalk doesn't have any setup but we would
|
||||
# like to append programming to spelllangs as soon as
|
||||
# possible while the plugin is enabled and the state
|
||||
# directory can be found.
|
||||
pluginRC.vim-dirtytalk = entryAfter ["spellcheck"] ''
|
||||
-- If Neovim can find (or access) the state directory
|
||||
-- then append "programming" wordlist from vim-dirtytalk
|
||||
-- to spelllang table. If path cannot be found, display
|
||||
-- an error and avoid appending the programming words
|
||||
if vim.fn.isdirectory(vim.fn.stdpath('state')) == 1 then
|
||||
vim.opt.spelllang:append("programming")
|
||||
else
|
||||
vim.notify("State path does not exist: " .. state_path, vim.log.levels.ERROR)
|
||||
end
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
|
|
@ -3,39 +3,31 @@
|
|||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) toJSON;
|
||||
inherit (lib.lists) optionals;
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.strings) optionalString;
|
||||
inherit (lib.lists) optional;
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.meta) getExe;
|
||||
inherit (lib.nvim.binds) mkBinding;
|
||||
inherit (lib.nvim.dag) entryAnywhere entryAfter;
|
||||
inherit (lib.nvim.binds) mkLznBinding;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
|
||||
cfg = config.vim.terminal.toggleterm;
|
||||
lazygitMapDesc = "Open lazygit [toggleterm]";
|
||||
in {
|
||||
config = mkMerge [
|
||||
(
|
||||
mkIf cfg.enable {
|
||||
vim = {
|
||||
startPlugins = [
|
||||
"toggleterm-nvim"
|
||||
];
|
||||
config = mkIf cfg.enable {
|
||||
vim = {
|
||||
lazy.plugins.toggleterm-nvim = {
|
||||
package = "toggleterm-nvim";
|
||||
cmd = ["ToggleTerm" "ToggleTermSendCurrentLine" "ToggleTermSendVisualLines" "ToggleTermSendVisualSelection" "ToggleTermSetName" "ToggleTermToggleAll"];
|
||||
keys =
|
||||
[(mkLznBinding ["n"] cfg.mappings.open "<Cmd>execute v:count . \"ToggleTerm\"<CR>" "Toggle terminal")]
|
||||
++ optional cfg.lazygit.enable {
|
||||
key = cfg.lazygit.mappings.open;
|
||||
desc = lazygitMapDesc;
|
||||
};
|
||||
|
||||
maps.normal = mkBinding cfg.mappings.open "<Cmd>execute v:count . \"ToggleTerm\"<CR>" "Toggle terminal";
|
||||
|
||||
pluginRC.toggleterm = entryAnywhere ''
|
||||
require("toggleterm").setup(${toLuaObject cfg.setupOpts})
|
||||
'';
|
||||
};
|
||||
}
|
||||
)
|
||||
(
|
||||
mkIf (cfg.enable && cfg.lazygit.enable)
|
||||
{
|
||||
vim.startPlugins = optionals (cfg.lazygit.package != null) [
|
||||
cfg.lazygit.package
|
||||
];
|
||||
vim.pluginRC.toggleterm-lazygit = entryAfter ["toggleterm"] ''
|
||||
setupModule = "toggleterm";
|
||||
inherit (cfg) setupOpts;
|
||||
after = optionalString cfg.lazygit.enable ''
|
||||
local terminal = require 'toggleterm.terminal'
|
||||
local lazygit = terminal.Terminal:new({
|
||||
cmd = '${
|
||||
|
@ -50,9 +42,9 @@ in {
|
|||
end
|
||||
})
|
||||
|
||||
vim.keymap.set('n', ${toJSON cfg.lazygit.mappings.open}, function() lazygit:toggle() end, {silent = true, noremap = true, desc = 'Open lazygit [toggleterm]'})
|
||||
vim.keymap.set('n', ${toLuaObject cfg.lazygit.mappings.open}, function() lazygit:toggle() end, {silent = true, noremap = true, desc = '${lazygitMapDesc}'})
|
||||
'';
|
||||
}
|
||||
)
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -4,7 +4,14 @@
|
|||
}: let
|
||||
inherit (lib.strings) optionalString;
|
||||
inherit (lib.trivial) boolToString warnIf;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
in {
|
||||
base16 = {
|
||||
setup = {base16-colors, ...}: ''
|
||||
-- Base16 theme
|
||||
require('base16-colorscheme').setup(${toLuaObject base16-colors})
|
||||
'';
|
||||
};
|
||||
onedark = {
|
||||
setup = {style ? "dark", ...}: ''
|
||||
-- OneDark theme
|
||||
|
@ -20,6 +27,7 @@ in {
|
|||
setup = {
|
||||
style ? "night",
|
||||
transparent,
|
||||
...
|
||||
}: ''
|
||||
require('tokyonight').setup {
|
||||
transparent = ${boolToString transparent};
|
||||
|
@ -42,6 +50,7 @@ in {
|
|||
setup = {
|
||||
style ? "mocha",
|
||||
transparent ? false,
|
||||
...
|
||||
}: ''
|
||||
-- Catppuccin theme
|
||||
require('catppuccin').setup {
|
||||
|
|
|
@ -5,31 +5,52 @@
|
|||
}: let
|
||||
inherit (lib.options) mkOption;
|
||||
inherit (lib.attrsets) attrNames;
|
||||
inherit (lib.strings) hasPrefix;
|
||||
inherit (lib.types) bool lines enum;
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||
inherit (lib.nvim.dag) entryBefore;
|
||||
inherit (lib.nvim.types) hexColor;
|
||||
|
||||
cfg = config.vim.theme;
|
||||
supportedThemes = import ./supported-themes.nix {
|
||||
inherit lib config;
|
||||
};
|
||||
|
||||
numbers = ["0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "A" "B" "C" "D" "E" "F"];
|
||||
base16Options =
|
||||
mapListToAttrs (n: {
|
||||
name = "base0${n}";
|
||||
value = mkOption {
|
||||
description = "The base0${n} color to use";
|
||||
type = hexColor;
|
||||
apply = v:
|
||||
if hasPrefix "#" v
|
||||
then v
|
||||
else "#${v}";
|
||||
};
|
||||
})
|
||||
numbers;
|
||||
in {
|
||||
options.vim.theme = {
|
||||
enable = mkOption {
|
||||
type = bool;
|
||||
description = "Enable theming";
|
||||
};
|
||||
|
||||
name = mkOption {
|
||||
type = enum (attrNames supportedThemes);
|
||||
description = "Supported themes can be found in `supportedThemes.nix`";
|
||||
description = ''
|
||||
Supported themes can be found in {file}`supportedThemes.nix`.
|
||||
Setting the theme to "base16" enables base16 theming and
|
||||
requires all of the colors in {option}`vim.theme.base16-colors` to be set.
|
||||
'';
|
||||
};
|
||||
base16-colors = base16Options;
|
||||
|
||||
style = mkOption {
|
||||
type = enum supportedThemes.${cfg.name}.styles;
|
||||
description = "Specific style for theme if it supports it";
|
||||
};
|
||||
|
||||
transparent = mkOption {
|
||||
type = bool;
|
||||
default = false;
|
||||
|
@ -45,9 +66,9 @@ in {
|
|||
config = mkIf cfg.enable {
|
||||
vim = {
|
||||
startPlugins = [cfg.name];
|
||||
luaConfigRC.theme = entryBefore ["pluginConfigs"] ''
|
||||
luaConfigRC.theme = entryBefore ["pluginConfigs" "lazyConfigs"] ''
|
||||
${cfg.extraConfig}
|
||||
${supportedThemes.${cfg.name}.setup {inherit (cfg) style transparent;}}
|
||||
${supportedThemes.${cfg.name}.setup {inherit (cfg) style transparent base16-colors;}}
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
|
|
@ -5,13 +5,12 @@
|
|||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.lists) optional optionals;
|
||||
inherit (lib.lists) optionals;
|
||||
inherit (lib.nvim.binds) mkSetBinding addDescriptionsToMappings;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
inherit (lib.nvim.dag) entryBefore entryAfter;
|
||||
|
||||
cfg = config.vim.treesitter;
|
||||
usingNvimCmp = config.vim.autocomplete.enable && config.vim.autocomplete.type == "nvim-cmp";
|
||||
|
||||
self = import ./treesitter.nix {inherit pkgs lib;};
|
||||
mappingDefinitions = self.options.vim.treesitter.mappings;
|
||||
|
@ -19,9 +18,13 @@
|
|||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim = {
|
||||
startPlugins = ["nvim-treesitter"] ++ optional usingNvimCmp "cmp-treesitter";
|
||||
startPlugins = ["nvim-treesitter"];
|
||||
|
||||
autocomplete.nvim-cmp = {
|
||||
sources = {treesitter = "[Treesitter]";};
|
||||
sourcePlugins = ["cmp-treesitter"];
|
||||
};
|
||||
|
||||
autocomplete.sources = {"treesitter" = "[Treesitter]";};
|
||||
treesitter.grammars = optionals cfg.addDefaultGrammars cfg.defaultGrammars;
|
||||
|
||||
maps = {
|
||||
|
|
|
@ -21,7 +21,7 @@ in {
|
|||
mkBool true "override the lsp markdown formatter with Noice";
|
||||
|
||||
"cmp.entry.get_documentation" =
|
||||
mkBool (config.vim.autocomplete.type == "nvim-cmp") "override cmp documentation with Noice";
|
||||
mkBool config.vim.autocomplete.nvim-cmp.enable "override cmp documentation with Noice";
|
||||
};
|
||||
|
||||
signature = {
|
||||
|
|
|
@ -4,15 +4,18 @@
|
|||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
inherit (lib.strings) optionalString;
|
||||
|
||||
cfg = config.vim.binds.cheatsheet;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = ["cheatsheet-nvim"];
|
||||
vim.lazy.plugins.cheatsheet-nvim = {
|
||||
package = "cheatsheet-nvim";
|
||||
setupModule = "cheatsheet";
|
||||
setupOpts = {};
|
||||
cmd = ["Cheatsheet" "CheatsheetEdit"];
|
||||
|
||||
vim.pluginRC.cheaetsheet-nvim = entryAnywhere ''
|
||||
require('cheatsheet').setup({})
|
||||
'';
|
||||
before = optionalString config.vim.lazy.enable "require('lz.n').trigger_load('telescope')";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -8,9 +8,14 @@
|
|||
cfg = config.vim.utility.diffview-nvim;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = [
|
||||
"diffview-nvim"
|
||||
"plenary-nvim"
|
||||
];
|
||||
vim = {
|
||||
startPlugins = ["plenary-nvim"];
|
||||
lazy.plugins.diffview-nvim = {
|
||||
package = "diffview-nvim";
|
||||
cmd = ["DiffviewClose" "DiffviewFileHistory" "DiffviewFocusFiles" "DiffviewLog" "DiffviewOpen" "DiffviewRefresh" "DiffviewToggleFiles"];
|
||||
setupModule = "diffview";
|
||||
inherit (cfg) setupOpts;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption;
|
||||
inherit (lib.nvim.types) mkPluginSetupOption;
|
||||
in {
|
||||
options.vim.utility.diffview-nvim = {
|
||||
enable = mkEnableOption "diffview-nvim: cycle through diffs for all modified files for any git rev";
|
||||
setupOpts = mkPluginSetupOption "Fidget" {};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -4,20 +4,20 @@
|
|||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
|
||||
cfg = config.vim.utility.icon-picker;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = [
|
||||
"icon-picker-nvim"
|
||||
"dressing-nvim"
|
||||
];
|
||||
vim.startPlugins = ["dressing-nvim"];
|
||||
|
||||
vim.pluginRC.icon-picker = entryAnywhere ''
|
||||
require("icon-picker").setup({
|
||||
disable_legacy_commands = true
|
||||
})
|
||||
'';
|
||||
vim.lazy.plugins.icon-picker-nvim = {
|
||||
package = "icon-picker-nvim";
|
||||
setupModule = "icon-picker";
|
||||
setupOpts = {
|
||||
disable_legacy_commands = true;
|
||||
};
|
||||
|
||||
cmd = ["IconPickerInsert" "IconPickerNormal" "IconPickerYank"];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -3,71 +3,59 @@
|
|||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.nvim.binds) mkBinding;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
inherit (lib.modules) mkIf mkDefault;
|
||||
inherit (lib.nvim.binds) mkLznBinding;
|
||||
|
||||
cfg = config.vim.utility.motion.leap;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = [
|
||||
"leap-nvim"
|
||||
"vim-repeat"
|
||||
];
|
||||
vim = {
|
||||
startPlugins = ["vim-repeat"];
|
||||
lazy.plugins.leap-nvim = {
|
||||
package = "leap-nvim";
|
||||
keys = [
|
||||
(mkLznBinding ["n" "o" "x"] cfg.mappings.leapForwardTo "<Plug>(leap-forward-to)" "Leap forward to")
|
||||
(mkLznBinding ["n" "o" "x"] cfg.mappings.leapBackwardTo "<Plug>(leap-backward-to)" "Leap backward to")
|
||||
(mkLznBinding ["n" "o" "x"] cfg.mappings.leapForwardTill "<Plug>(leap-forward-till)" "Leap forward till")
|
||||
(mkLznBinding ["n" "o" "x"] cfg.mappings.leapBackwardTill "<Plug>(leap-backward-till)" "Leap backward till")
|
||||
(mkLznBinding ["n" "o" "x"] cfg.mappings.leapFromWindow "<Plug>(leap-from-window)" "Leap from window")
|
||||
];
|
||||
|
||||
vim.maps.normal = mkMerge [
|
||||
(mkBinding cfg.mappings.leapForwardTo "<Plug>(leap-forward-to)" "Leap forward to")
|
||||
(mkBinding cfg.mappings.leapBackwardTo "<Plug>(leap-backward-to)" "Leap backward to")
|
||||
(mkBinding cfg.mappings.leapFromWindow "<Plug>(leap-from-window)" "Leap from window")
|
||||
];
|
||||
after = ''
|
||||
require('leap').opts = {
|
||||
max_phase_one_targets = nil,
|
||||
highlight_unlabeled_phase_one_targets = false,
|
||||
max_highlighted_traversal_targets = 10,
|
||||
case_sensitive = false,
|
||||
equivalence_classes = { ' \t\r\n', },
|
||||
substitute_chars = {},
|
||||
safe_labels = {
|
||||
"s", "f", "n", "u", "t", "/",
|
||||
"S", "F", "N", "L", "H", "M", "U", "G", "T", "?", "Z"
|
||||
},
|
||||
labels = {
|
||||
"s", "f", "n",
|
||||
"j", "k", "l", "h", "o", "d", "w", "e", "m", "b",
|
||||
"u", "y", "v", "r", "g", "t", "c", "x", "/", "z",
|
||||
"S", "F", "N",
|
||||
"J", "K", "L", "H", "O", "D", "W", "E", "M", "B",
|
||||
"U", "Y", "V", "R", "G", "T", "C", "X", "?", "Z"
|
||||
},
|
||||
special_keys = {
|
||||
repeat_search = '<enter>',
|
||||
next_phase_one_target = '<enter>',
|
||||
next_target = {'<enter>', ';'},
|
||||
prev_target = {'<tab>', ','},
|
||||
next_group = '<space>',
|
||||
prev_group = '<tab>',
|
||||
multi_accept = '<enter>',
|
||||
multi_revert = '<backspace>',
|
||||
},
|
||||
}
|
||||
'';
|
||||
};
|
||||
|
||||
vim.maps.operator = mkMerge [
|
||||
(mkBinding cfg.mappings.leapForwardTo "<Plug>(leap-forward-to)" "Leap forward to")
|
||||
(mkBinding cfg.mappings.leapBackwardTo "<Plug>(leap-backward-to)" "Leap backward to")
|
||||
(mkBinding cfg.mappings.leapForwardTill "<Plug>(leap-forward-till)" "Leap forward till")
|
||||
(mkBinding cfg.mappings.leapBackwardTill "<Plug>(leap-backward-till)" "Leap backward till")
|
||||
(mkBinding cfg.mappings.leapFromWindow "<Plug>(leap-from-window)" "Leap from window")
|
||||
];
|
||||
|
||||
vim.maps.visualOnly = mkMerge [
|
||||
(mkBinding cfg.mappings.leapForwardTo "<Plug>(leap-forward-to)" "Leap forward to")
|
||||
(mkBinding cfg.mappings.leapBackwardTo "<Plug>(leap-backward-to)" "Leap backward to")
|
||||
(mkBinding cfg.mappings.leapForwardTill "<Plug>(leap-forward-till)" "Leap forward till")
|
||||
(mkBinding cfg.mappings.leapBackwardTill "<Plug>(leap-backward-till)" "Leap backward till")
|
||||
(mkBinding cfg.mappings.leapFromWindow "<Plug>(leap-from-window)" "Leap from window")
|
||||
];
|
||||
|
||||
vim.pluginRC.leap-nvim = entryAnywhere ''
|
||||
require('leap').opts = {
|
||||
max_phase_one_targets = nil,
|
||||
highlight_unlabeled_phase_one_targets = false,
|
||||
max_highlighted_traversal_targets = 10,
|
||||
case_sensitive = false,
|
||||
equivalence_classes = { ' \t\r\n', },
|
||||
substitute_chars = {},
|
||||
safe_labels = {
|
||||
"s", "f", "n", "u", "t", "/",
|
||||
"S", "F", "N", "L", "H", "M", "U", "G", "T", "?", "Z"
|
||||
},
|
||||
labels = {
|
||||
"s", "f", "n",
|
||||
"j", "k", "l", "h", "o", "d", "w", "e", "m", "b",
|
||||
"u", "y", "v", "r", "g", "t", "c", "x", "/", "z",
|
||||
"S", "F", "N",
|
||||
"J", "K", "L", "H", "O", "D", "W", "E", "M", "B",
|
||||
"U", "Y", "V", "R", "G", "T", "C", "X", "?", "Z"
|
||||
},
|
||||
special_keys = {
|
||||
repeat_search = '<enter>',
|
||||
next_phase_one_target = '<enter>',
|
||||
next_target = {'<enter>', ';'},
|
||||
prev_target = {'<tab>', ','},
|
||||
next_group = '<space>',
|
||||
prev_group = '<tab>',
|
||||
multi_accept = '<enter>',
|
||||
multi_revert = '<backspace>',
|
||||
},
|
||||
}
|
||||
'';
|
||||
binds.whichKey.register."<leader>s" = mkDefault "+Leap";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -9,22 +9,22 @@ in {
|
|||
leapForwardTo = mkOption {
|
||||
type = nullOr str;
|
||||
description = "Leap forward to";
|
||||
default = "s";
|
||||
default = "<leader>ss";
|
||||
};
|
||||
leapBackwardTo = mkOption {
|
||||
type = nullOr str;
|
||||
description = "Leap backward to";
|
||||
default = "S";
|
||||
default = "<leader>sS";
|
||||
};
|
||||
leapForwardTill = mkOption {
|
||||
type = nullOr str;
|
||||
description = "Leap forward till";
|
||||
default = "x";
|
||||
default = "<leader>sx";
|
||||
};
|
||||
leapBackwardTill = mkOption {
|
||||
type = nullOr str;
|
||||
description = "Leap backward till";
|
||||
default = "X";
|
||||
default = "<leader>sX";
|
||||
};
|
||||
leapFromWindow = mkOption {
|
||||
type = nullOr str;
|
||||
|
|
|
@ -3,42 +3,52 @@
|
|||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetBinding;
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
|
||||
cfg = config.vim.utility.surround;
|
||||
self = import ./surround.nix {inherit lib config;};
|
||||
mappingDefinitions = self.options.vim.utility.surround.mappings;
|
||||
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
|
||||
mkLznKey = mode: key: {
|
||||
inherit key mode;
|
||||
};
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim = {
|
||||
startPlugins = [
|
||||
"nvim-surround"
|
||||
];
|
||||
startPlugins = ["nvim-surround"];
|
||||
pluginRC.surround = entryAnywhere "require('nvim-surround').setup(${toLuaObject cfg.setupOpts})";
|
||||
|
||||
pluginRC.surround = entryAnywhere ''
|
||||
require('nvim-surround').setup()
|
||||
'';
|
||||
lazy.plugins.nvim-surround = {
|
||||
package = "nvim-surround";
|
||||
setupModule = "nvim-surround";
|
||||
inherit (cfg) setupOpts;
|
||||
|
||||
maps = {
|
||||
insert = mkMerge [
|
||||
(mkIf (mappings.insert != null) (mkSetBinding mappings.insert "<Plug>(nvim-surround-insert)"))
|
||||
(mkIf (mappings.insertLine != null) (mkSetBinding mappings.insertLine "<Plug>(nvim-surround-insert-line)"))
|
||||
];
|
||||
normal = mkMerge [
|
||||
(mkIf (mappings.normal != null) (mkSetBinding mappings.normal "<Plug>(nvim-surround-normal)"))
|
||||
(mkIf (mappings.normalCur != null) (mkSetBinding mappings.normalCur "<Plug>(nvim-surround-normal-cur)"))
|
||||
(mkIf (mappings.normalLine != null) (mkSetBinding mappings.normalLine "<Plug>(nvim-surround-normal-line)"))
|
||||
(mkIf (mappings.normalCurLine != null) (mkSetBinding mappings.normalCurLine "<Plug>(nvim-surround-normal-cur-line)"))
|
||||
(mkIf (mappings.delete != null) (mkSetBinding mappings.delete "<Plug>(nvim-surround-delete)"))
|
||||
(mkIf (mappings.change != null) (mkSetBinding mappings.change "<Plug>(nvim-surround-change)"))
|
||||
];
|
||||
visualOnly = mkMerge [
|
||||
(mkIf (mappings.visual != null) (mkSetBinding mappings.visual "<Plug>(nvim-surround-visual)"))
|
||||
(mkIf (mappings.visualLine != null) (mkSetBinding mappings.visualLine "<Plug>(nvim-surround-visual-line)"))
|
||||
];
|
||||
keys =
|
||||
[
|
||||
(mkLznKey ["i"] cfg.setupOpts.keymaps.insert)
|
||||
(mkLznKey ["i"] cfg.setupOpts.keymaps.insert_line)
|
||||
(mkLznKey ["x"] cfg.setupOpts.keymaps.visual)
|
||||
(mkLznKey ["x"] cfg.setupOpts.keymaps.visual_line)
|
||||
(mkLznKey ["n"] cfg.setupOpts.keymaps.normal)
|
||||
(mkLznKey ["n"] cfg.setupOpts.keymaps.normal_cur)
|
||||
(mkLznKey ["n"] cfg.setupOpts.keymaps.normal_line)
|
||||
(mkLznKey ["n"] cfg.setupOpts.keymaps.normal_cur_line)
|
||||
(mkLznKey ["n"] cfg.setupOpts.keymaps.delete)
|
||||
(mkLznKey ["n"] cfg.setupOpts.keymaps.change)
|
||||
(mkLznKey ["n"] cfg.setupOpts.keymaps.change_line)
|
||||
]
|
||||
++ map (mkLznKey ["n" "i" "v"]) [
|
||||
"<Plug>(nvim-surround-insert)"
|
||||
"<Plug>(nvim-surround-insert-line)"
|
||||
"<Plug>(nvim-surround-normal)"
|
||||
"<Plug>(nvim-surround-normal-cur)"
|
||||
"<Plug>(nvim-surround-normal-line)"
|
||||
"<Plug>(nvim-surround-normal-cur-line)"
|
||||
"<Plug>(nvim-surround-visual)"
|
||||
"<Plug>(nvim-surround-visual-line)"
|
||||
"<Plug>(nvim-surround-delete)"
|
||||
"<Plug>(nvim-surround-change)"
|
||||
"<Plug>(nvim-surround-change-line)"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -3,88 +3,65 @@
|
|||
config,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf mkDefault;
|
||||
inherit (lib.options) mkOption;
|
||||
inherit (lib.types) bool nullOr str;
|
||||
inherit (lib.types) bool str;
|
||||
inherit (lib.nvim.types) mkPluginSetupOption;
|
||||
|
||||
cfg = config.vim.utility.surround;
|
||||
vendoredKeybinds = {
|
||||
insert = "<C-g>z";
|
||||
insert_line = "<C-g>Z";
|
||||
normal = "gz";
|
||||
normal_cur = "gZ";
|
||||
normal_line = "gzz";
|
||||
normal_cur_line = "gZZ";
|
||||
visual = "gz";
|
||||
visual_line = "gZ";
|
||||
delete = "gzd";
|
||||
change = "gzr";
|
||||
change_line = "gZR";
|
||||
};
|
||||
|
||||
mkKeymapOption = name: default:
|
||||
mkOption {
|
||||
description = "keymap for ${name}";
|
||||
type = str;
|
||||
default =
|
||||
if cfg.useVendoredKeybindings
|
||||
then vendoredKeybinds.${name}
|
||||
else default;
|
||||
};
|
||||
in {
|
||||
options.vim.utility.surround = {
|
||||
enable = mkOption {
|
||||
type = bool;
|
||||
default = false;
|
||||
description = "nvim-surround: add/change/delete surrounding delimiter pairs with ease. Note that the default mappings deviate from upstreeam to avoid conflicts with nvim-leap.";
|
||||
description = ''
|
||||
nvim-surround: add/change/delete surrounding delimiter pairs with ease.
|
||||
Note that the default mappings deviate from upstreeam to avoid conflicts
|
||||
with nvim-leap.
|
||||
'';
|
||||
};
|
||||
setupOpts = mkPluginSetupOption "nvim-surround" {
|
||||
keymaps = {
|
||||
insert = mkKeymapOption "insert" "<C-g>s";
|
||||
insert_line = mkKeymapOption "insert_line" "<C-g>S";
|
||||
normal = mkKeymapOption "normal" "ys";
|
||||
normal_cur = mkKeymapOption "normal_cur" "yss";
|
||||
normal_line = mkKeymapOption "normal_line" "yS";
|
||||
normal_cur_line = mkKeymapOption "normal_cur_line" "ySS";
|
||||
visual = mkKeymapOption "visual" "S";
|
||||
visual_line = mkKeymapOption "visual_line" "gS";
|
||||
delete = mkKeymapOption "delete" "ds";
|
||||
change = mkKeymapOption "change" "cs";
|
||||
change_line = mkKeymapOption "change_line" "cS";
|
||||
};
|
||||
};
|
||||
|
||||
useVendoredKeybindings = mkOption {
|
||||
type = bool;
|
||||
default = true;
|
||||
description = "Use alternative set of keybindings that avoids conflicts with other popular plugins, e.g. nvim-leap";
|
||||
};
|
||||
mappings = {
|
||||
insert = mkOption {
|
||||
type = nullOr str;
|
||||
default = "<C-g>z";
|
||||
description = "Add surround character around the cursor";
|
||||
};
|
||||
insertLine = mkOption {
|
||||
type = nullOr str;
|
||||
default = "<C-g>Z";
|
||||
description = "Add surround character around the cursor on new lines";
|
||||
};
|
||||
normal = mkOption {
|
||||
type = nullOr str;
|
||||
default = "gz";
|
||||
description = "Surround motion with character";
|
||||
};
|
||||
normalCur = mkOption {
|
||||
type = nullOr str;
|
||||
default = "gZ";
|
||||
description = "Surround motion with character on new lines";
|
||||
};
|
||||
normalLine = mkOption {
|
||||
type = nullOr str;
|
||||
default = "gzz";
|
||||
description = "Surround line with character";
|
||||
};
|
||||
normalCurLine = mkOption {
|
||||
type = nullOr str;
|
||||
default = "gZZ";
|
||||
description = "Surround line with character on new lines";
|
||||
};
|
||||
visual = mkOption {
|
||||
type = nullOr str;
|
||||
default = "gz";
|
||||
description = "Surround selection with character";
|
||||
};
|
||||
visualLine = mkOption {
|
||||
type = nullOr str;
|
||||
default = "gZ";
|
||||
description = "Surround selection with character on new lines";
|
||||
};
|
||||
delete = mkOption {
|
||||
type = nullOr str;
|
||||
default = "gzd";
|
||||
description = "Delete surrounding character";
|
||||
};
|
||||
change = mkOption {
|
||||
type = nullOr str;
|
||||
default = "gzr";
|
||||
description = "Change surrounding character";
|
||||
};
|
||||
};
|
||||
};
|
||||
config.vim.utility.surround = let
|
||||
cfg = config.vim.utility.surround;
|
||||
in {
|
||||
mappings = mkIf (! cfg.useVendoredKeybindings) (mkDefault {
|
||||
insert = null;
|
||||
insertLine = null;
|
||||
normal = null;
|
||||
normalCur = null;
|
||||
normalLine = null;
|
||||
normalCurLine = null;
|
||||
visual = null;
|
||||
visualLine = null;
|
||||
delete = null;
|
||||
change = null;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,63 +1,72 @@
|
|||
{
|
||||
options,
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetBinding;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
inherit (lib.nvim.binds) pushDownDefault;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.nvim.binds) addDescriptionsToMappings;
|
||||
inherit (lib.strings) optionalString;
|
||||
inherit (lib.lists) optionals;
|
||||
inherit (lib.nvim.binds) pushDownDefault mkSetLznBinding;
|
||||
|
||||
cfg = config.vim.telescope;
|
||||
self = import ./telescope.nix {inherit pkgs lib;};
|
||||
mappingDefinitions = self.options.vim.telescope.mappings;
|
||||
mappingDefinitions = options.vim.telescope.mappings;
|
||||
|
||||
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim = {
|
||||
startPlugins = [
|
||||
"telescope"
|
||||
"plenary-nvim"
|
||||
];
|
||||
startPlugins = ["plenary-nvim"];
|
||||
|
||||
maps.normal = mkMerge [
|
||||
(mkSetBinding mappings.findFiles "<cmd> Telescope find_files<CR>")
|
||||
(mkSetBinding mappings.liveGrep "<cmd> Telescope live_grep<CR>")
|
||||
(mkSetBinding mappings.buffers "<cmd> Telescope buffers<CR>")
|
||||
(mkSetBinding mappings.helpTags "<cmd> Telescope help_tags<CR>")
|
||||
(mkSetBinding mappings.open "<cmd> Telescope<CR>")
|
||||
(mkSetBinding mappings.resume "<cmd> Telescope resume<CR>")
|
||||
lazy.plugins.telescope = {
|
||||
package = "telescope";
|
||||
setupModule = "telescope";
|
||||
inherit (cfg) setupOpts;
|
||||
after = ''
|
||||
local telescope = require("telescope")
|
||||
${optionalString config.vim.ui.noice.enable "telescope.load_extension('noice')"}
|
||||
${optionalString config.vim.notify.nvim-notify.enable "telescope.load_extension('notify')"}
|
||||
${optionalString config.vim.projects.project-nvim.enable "telescope.load_extension('projects')"}
|
||||
'';
|
||||
|
||||
(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>")
|
||||
cmd = ["Telescope"];
|
||||
|
||||
(mkIf config.vim.lsp.enable (mkMerge [
|
||||
(mkSetBinding mappings.lspDocumentSymbols "<cmd> Telescope lsp_document_symbols<CR>")
|
||||
(mkSetBinding mappings.lspWorkspaceSymbols "<cmd> Telescope lsp_workspace_symbols<CR>")
|
||||
keys =
|
||||
[
|
||||
(mkSetLznBinding mappings.findFiles "<cmd> Telescope find_files<CR>")
|
||||
(mkSetLznBinding mappings.liveGrep "<cmd> Telescope live_grep<CR>")
|
||||
(mkSetLznBinding mappings.buffers "<cmd> Telescope buffers<CR>")
|
||||
(mkSetLznBinding mappings.helpTags "<cmd> Telescope help_tags<CR>")
|
||||
(mkSetLznBinding mappings.open "<cmd> Telescope<CR>")
|
||||
|
||||
(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>")
|
||||
]))
|
||||
(mkSetLznBinding mappings.gitCommits "<cmd> Telescope git_commits<CR>")
|
||||
(mkSetLznBinding mappings.gitBufferCommits "<cmd> Telescope git_bcommits<CR>")
|
||||
(mkSetLznBinding mappings.gitBranches "<cmd> Telescope git_branches<CR>")
|
||||
(mkSetLznBinding mappings.gitStatus "<cmd> Telescope git_status<CR>")
|
||||
(mkSetLznBinding mappings.gitStash "<cmd> Telescope git_stash<CR>")
|
||||
]
|
||||
++ (optionals config.vim.lsp.enable [
|
||||
(mkSetLznBinding mappings.lspDocumentSymbols "<cmd> Telescope lsp_document_symbols<CR>")
|
||||
(mkSetLznBinding mappings.lspWorkspaceSymbols "<cmd> Telescope lsp_workspace_symbols<CR>")
|
||||
|
||||
(
|
||||
mkIf config.vim.treesitter.enable
|
||||
(mkSetBinding mappings.treesitter "<cmd> Telescope treesitter<CR>")
|
||||
)
|
||||
|
||||
(
|
||||
mkIf config.vim.projects.project-nvim.enable
|
||||
(mkSetBinding mappings.findProjects "<cmd> Telescope projects<CR>")
|
||||
)
|
||||
];
|
||||
(mkSetLznBinding mappings.lspReferences "<cmd> Telescope lsp_references<CR>")
|
||||
(mkSetLznBinding mappings.lspImplementations "<cmd> Telescope lsp_implementations<CR>")
|
||||
(mkSetLznBinding mappings.lspDefinitions "<cmd> Telescope lsp_definitions<CR>")
|
||||
(mkSetLznBinding mappings.lspTypeDefinitions "<cmd> Telescope lsp_type_definitions<CR>")
|
||||
(mkSetLznBinding mappings.diagnostics "<cmd> Telescope diagnostics<CR>")
|
||||
])
|
||||
++ (
|
||||
optionals config.vim.treesitter.enable [
|
||||
(mkSetLznBinding mappings.treesitter "<cmd> Telescope treesitter<CR>")
|
||||
]
|
||||
)
|
||||
++ (
|
||||
optionals config.vim.projects.project-nvim.enable [
|
||||
(mkSetLznBinding mappings.findProjects "<cmd Telescope projects<CR>")
|
||||
]
|
||||
);
|
||||
};
|
||||
|
||||
binds.whichKey.register = pushDownDefault {
|
||||
"<leader>f" = "+Telescope";
|
||||
|
@ -66,29 +75,6 @@ in {
|
|||
"<leader>fv" = "Telescope Git";
|
||||
"<leader>fvc" = "Commits";
|
||||
};
|
||||
|
||||
pluginRC.telescope = entryAnywhere ''
|
||||
local telescope = require('telescope')
|
||||
telescope.setup(${toLuaObject cfg.setupOpts})
|
||||
|
||||
${
|
||||
if config.vim.ui.noice.enable
|
||||
then "telescope.load_extension('noice')"
|
||||
else ""
|
||||
}
|
||||
|
||||
${
|
||||
if config.vim.notify.nvim-notify.enable
|
||||
then "telescope.load_extension('notify')"
|
||||
else ""
|
||||
}
|
||||
|
||||
${
|
||||
if config.vim.projects.project-nvim.enable
|
||||
then "telescope.load_extension('projects')"
|
||||
else ""
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -4,16 +4,15 @@
|
|||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
|
||||
cfg = config.vim.visuals.fidget-nvim;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = ["fidget-nvim"];
|
||||
|
||||
vim.pluginRC.fidget-nvim = entryAnywhere ''
|
||||
require'fidget'.setup(${toLuaObject cfg.setupOpts})
|
||||
'';
|
||||
vim.lazy.plugins.fidget-nvim = {
|
||||
package = "fidget-nvim";
|
||||
setupModule = "fidget";
|
||||
event = "LspAttach";
|
||||
inherit (cfg) setupOpts;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
108
modules/wrapper/lazy/config.nix
Normal file
108
modules/wrapper/lazy/config.nix
Normal file
|
@ -0,0 +1,108 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) toJSON typeOf head length filter concatLists concatStringsSep;
|
||||
inherit (lib.attrsets) mapAttrsToList;
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.generators) mkLuaInline;
|
||||
inherit (lib.strings) optionalString;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
inherit (lib.nvim.dag) entryBefore entryAfter;
|
||||
cfg = config.vim.lazy;
|
||||
|
||||
toLuaLznKeySpec = keySpec:
|
||||
(removeAttrs keySpec ["key" "lua" "action"])
|
||||
// {
|
||||
"@1" = keySpec.key;
|
||||
"@2" =
|
||||
if keySpec.lua
|
||||
then mkLuaInline keySpec.action
|
||||
else keySpec.action;
|
||||
};
|
||||
|
||||
toLuaLznSpec = name: spec:
|
||||
(removeAttrs spec ["package" "setupModule" "setupOpts" "keys"])
|
||||
// {
|
||||
"@1" = name;
|
||||
before =
|
||||
if spec.before != null
|
||||
then
|
||||
mkLuaInline ''
|
||||
function()
|
||||
${spec.before}
|
||||
end
|
||||
''
|
||||
else null;
|
||||
|
||||
after =
|
||||
if spec.setupModule == null && spec.after == null
|
||||
then null
|
||||
else
|
||||
mkLuaInline ''
|
||||
function()
|
||||
${
|
||||
optionalString (spec.setupModule != null)
|
||||
"require(${toJSON spec.setupModule}).setup(${toLuaObject spec.setupOpts})"
|
||||
}
|
||||
${optionalString (spec.after != null) spec.after}
|
||||
end
|
||||
'';
|
||||
|
||||
keys =
|
||||
if typeOf spec.keys == "list" && length spec.keys > 0 && typeOf (head spec.keys) == "set"
|
||||
then map toLuaLznKeySpec (filter (keySpec: keySpec.key != null) spec.keys)
|
||||
# empty list or str or (listOf str)
|
||||
else spec.keys;
|
||||
};
|
||||
lznSpecs = mapAttrsToList toLuaLznSpec cfg.plugins;
|
||||
|
||||
pluginPackages = mapAttrsToList (_: plugin: plugin.package) cfg.plugins;
|
||||
|
||||
specToNotLazyConfig = _: spec: ''
|
||||
do
|
||||
${optionalString (spec.before != null) spec.before}
|
||||
${optionalString (spec.setupModule != null)
|
||||
"require(${toJSON spec.setupModule}).setup(${toLuaObject spec.setupOpts})"}
|
||||
${optionalString (spec.after != null) spec.after}
|
||||
end
|
||||
'';
|
||||
|
||||
specToKeymaps = _: spec:
|
||||
if typeOf spec.keys == "list"
|
||||
then map (x: removeAttrs x ["ft"]) (filter (lznKey: lznKey.action != null && lznKey.ft == null) spec.keys)
|
||||
else if spec.keys == null || typeOf spec.keys == "string"
|
||||
then []
|
||||
else [spec.keys];
|
||||
|
||||
notLazyConfig =
|
||||
concatStringsSep "\n"
|
||||
(mapAttrsToList specToNotLazyConfig cfg.plugins);
|
||||
|
||||
beforeAllJoined =
|
||||
concatStringsSep "\n"
|
||||
(filter (x: x != null) (mapAttrsToList (_: spec: spec.beforeAll) cfg.plugins));
|
||||
in {
|
||||
config.vim = mkMerge [
|
||||
(mkIf cfg.enable {
|
||||
startPlugins = ["lz-n" "lzn-auto-require"];
|
||||
|
||||
optPlugins = pluginPackages;
|
||||
|
||||
lazy.builtLazyConfig = ''
|
||||
require('lz.n').load(${toLuaObject lznSpecs})
|
||||
${optionalString cfg.enableLznAutoRequire "require('lzn-auto-require').enable()"}
|
||||
'';
|
||||
})
|
||||
|
||||
(mkIf (!cfg.enable) {
|
||||
startPlugins = pluginPackages;
|
||||
lazy.builtLazyConfig = ''
|
||||
${beforeAllJoined}
|
||||
${notLazyConfig}
|
||||
'';
|
||||
keymaps = concatLists (mapAttrsToList specToKeymaps cfg.plugins);
|
||||
})
|
||||
];
|
||||
}
|
6
modules/wrapper/lazy/default.nix
Normal file
6
modules/wrapper/lazy/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./lazy.nix
|
||||
./config.nix
|
||||
];
|
||||
}
|
237
modules/wrapper/lazy/lazy.nix
Normal file
237
modules/wrapper/lazy/lazy.nix
Normal file
|
@ -0,0 +1,237 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkOption mkEnableOption;
|
||||
inherit (lib.types) enum listOf submodule nullOr str bool int attrsOf anything either oneOf lines;
|
||||
inherit (lib.nvim.types) pluginType;
|
||||
inherit (lib.nvim.config) mkBool;
|
||||
|
||||
lznKeysSpec = submodule {
|
||||
options = {
|
||||
key = mkOption {
|
||||
type = nullOr str;
|
||||
description = "Key to bind to. If key is null this entry is ignored.";
|
||||
};
|
||||
|
||||
action = mkOption {
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
description = "Action to trigger.";
|
||||
};
|
||||
lua = mkBool false ''
|
||||
If true, `action` is considered to be lua code.
|
||||
Thus, it will not be wrapped in `""`.
|
||||
'';
|
||||
|
||||
desc = mkOption {
|
||||
description = "Description of the key map";
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
};
|
||||
|
||||
ft = mkOption {
|
||||
description = "TBD";
|
||||
type = nullOr (listOf str);
|
||||
default = null;
|
||||
};
|
||||
|
||||
mode = mkOption {
|
||||
description = "Modes to bind in";
|
||||
type = either str (listOf str);
|
||||
default = ["n" "x" "s" "o"];
|
||||
};
|
||||
|
||||
silent = mkBool true "Whether this mapping should be silent. Equivalent to adding <silent> to a map.";
|
||||
nowait = mkBool false "Whether to wait for extra input on ambiguous mappings. Equivalent to adding <nowait> to a map.";
|
||||
script = mkBool false "Equivalent to adding <script> to a map.";
|
||||
expr = mkBool false "Means that the action is actually an expression. Equivalent to adding <expr> to a map.";
|
||||
unique = mkBool false "Whether to fail if the map is already defined. Equivalent to adding <unique> to a map.";
|
||||
noremap = mkBool true "Whether to use the 'noremap' variant of the command, ignoring any custom mappings on the defined action. It is highly advised to keep this on, which is the default.";
|
||||
};
|
||||
};
|
||||
|
||||
lznPluginType = submodule {
|
||||
options = {
|
||||
package = mkOption {
|
||||
type = pluginType;
|
||||
description = "Plugin package";
|
||||
};
|
||||
|
||||
setupModule = mkOption {
|
||||
type = nullOr str;
|
||||
description = "Lua module to run setup function on.";
|
||||
default = null;
|
||||
};
|
||||
|
||||
setupOpts = mkOption {
|
||||
type = submodule {freeformType = attrsOf anything;};
|
||||
description = "Options to pass to the setup function";
|
||||
default = {};
|
||||
};
|
||||
|
||||
# lz.n options
|
||||
|
||||
enabled = mkOption {
|
||||
type = nullOr (either bool str);
|
||||
description = "When false, or if the lua function returns false, this plugin will not be included in the spec";
|
||||
default = null;
|
||||
};
|
||||
|
||||
beforeAll = mkOption {
|
||||
type = nullOr lines;
|
||||
description = "Lua code to run before any plugins are loaded. This will be wrapped in a function.";
|
||||
default = null;
|
||||
};
|
||||
|
||||
before = mkOption {
|
||||
type = nullOr lines;
|
||||
description = "Lua code to run before plugin is loaded. This will be wrapped in a function.";
|
||||
default = null;
|
||||
};
|
||||
|
||||
after = mkOption {
|
||||
type = nullOr lines;
|
||||
description = ''
|
||||
Lua code to run after plugin is loaded. This will be wrapped in a function.
|
||||
|
||||
If [](#opt-vim.lazy.plugins._name_.setupModule) is provided, the setup will be ran before `after`.
|
||||
'';
|
||||
default = null;
|
||||
};
|
||||
|
||||
event = mkOption {
|
||||
description = "Lazy-load on event";
|
||||
default = null;
|
||||
type = let
|
||||
event = submodule {
|
||||
options = {
|
||||
event = mkOption {
|
||||
type = nullOr (either str (listOf str));
|
||||
description = "Exact event name";
|
||||
example = "BufEnter";
|
||||
};
|
||||
pattern = mkOption {
|
||||
type = nullOr (either str (listOf str));
|
||||
description = "Event pattern";
|
||||
example = "BufEnter *.lua";
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
nullOr (oneOf [str (listOf str) event]);
|
||||
};
|
||||
|
||||
cmd = mkOption {
|
||||
description = "Lazy-load on command";
|
||||
default = null;
|
||||
type = nullOr (either str (listOf str));
|
||||
};
|
||||
|
||||
ft = mkOption {
|
||||
description = "Lazy-load on filetype";
|
||||
default = null;
|
||||
type = nullOr (either str (listOf str));
|
||||
};
|
||||
|
||||
keys = mkOption {
|
||||
description = "Lazy-load on key mapping";
|
||||
default = null;
|
||||
type = nullOr (oneOf [str (listOf lznKeysSpec) (listOf str)]);
|
||||
example = ''
|
||||
keys = [
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>s";
|
||||
action = ":DapStepOver<cr>";
|
||||
desc = "DAP Step Over";
|
||||
}
|
||||
{
|
||||
mode = ["n", "x"];
|
||||
key = "<leader>dc";
|
||||
action = "function() require('dap').continue() end";
|
||||
lua = true;
|
||||
desc = "DAP Continue";
|
||||
}
|
||||
]
|
||||
'';
|
||||
};
|
||||
|
||||
colorscheme = mkOption {
|
||||
description = "Lazy-load on colorscheme.";
|
||||
type = nullOr (either str (listOf str));
|
||||
default = null;
|
||||
};
|
||||
|
||||
lazy = mkBool false "Lazy-load manually, e.g. using `trigger_load`.";
|
||||
|
||||
priority = mkOption {
|
||||
type = nullOr int;
|
||||
description = "Only useful for stat plugins (not lazy-loaded) to force loading certain plugins first.";
|
||||
default = null;
|
||||
};
|
||||
|
||||
load = mkOption {
|
||||
type = nullOr lines;
|
||||
default = null;
|
||||
description = ''
|
||||
Lua code to override the `vim.g.lz_n.load()` function for a single plugin.
|
||||
|
||||
This will be wrapped in a function.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
in {
|
||||
options.vim.lazy = {
|
||||
enable = mkEnableOption "plugin lazy-loading via lz.n and lzn-auto-require" // {default = true;};
|
||||
loader = mkOption {
|
||||
description = "Lazy loader to use";
|
||||
type = enum ["lz.n"];
|
||||
default = "lz.n";
|
||||
};
|
||||
|
||||
plugins = mkOption {
|
||||
default = [];
|
||||
type = attrsOf lznPluginType;
|
||||
description = ''
|
||||
Plugins to lazy load.
|
||||
|
||||
The attribute key is used as the plugin name: for the default `vim.g.lz_n.load`
|
||||
function this should be either the `package.pname` or `package.name`.
|
||||
'';
|
||||
example = ''
|
||||
{
|
||||
toggleterm-nvim = {
|
||||
package = "toggleterm-nvim";
|
||||
setupModule = "toggleterm";
|
||||
setupOpts = cfg.setupOpts;
|
||||
|
||||
after = "require('toggleterm').do_something()";
|
||||
cmd = ["ToggleTerm"];
|
||||
};
|
||||
|
||||
$${pkgs.vimPlugins.vim-bbye.pname} = {
|
||||
package = pkgs.vimPlugins.vim-bbye;
|
||||
cmd = ["Bdelete" "Bwipeout"];
|
||||
};
|
||||
}
|
||||
'';
|
||||
};
|
||||
|
||||
enableLznAutoRequire = mkOption {
|
||||
description = ''
|
||||
Enable lzn-auto-require. Since builtin plugins rely on this, only turn
|
||||
off for debugging.
|
||||
'';
|
||||
type = bool;
|
||||
default = true;
|
||||
};
|
||||
|
||||
builtLazyConfig = mkOption {
|
||||
internal = true;
|
||||
type = lines;
|
||||
description = ''
|
||||
The built config for lz.n, or if `vim.lazy.enable` is false, the
|
||||
individual plugin configs.
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
|
@ -4,80 +4,14 @@
|
|||
...
|
||||
}: let
|
||||
inherit (builtins) map mapAttrs filter;
|
||||
inherit (lib.options) mkOption;
|
||||
inherit (lib.attrsets) mapAttrsToList filterAttrs getAttrs attrValues attrNames;
|
||||
inherit (lib.strings) concatLines concatMapStringsSep;
|
||||
inherit (lib.attrsets) mapAttrsToList;
|
||||
inherit (lib.strings) concatLines concatMapStringsSep optionalString;
|
||||
inherit (lib.trivial) showWarnings;
|
||||
inherit (lib.types) str nullOr;
|
||||
inherit (lib.generators) mkLuaInline;
|
||||
inherit (lib.nvim.dag) entryAfter mkLuarcSection resolveDag entryAnywhere;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
inherit (lib.nvim.config) mkBool;
|
||||
|
||||
cfg = config.vim;
|
||||
|
||||
# Most of the keybindings code is highly inspired by pta2002/nixvim.
|
||||
# Thank you!
|
||||
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 {
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
description = "A description of this keybind, to be shown in which-key, if you have it enabled.";
|
||||
};
|
||||
};
|
||||
|
||||
genMaps = mode: maps: let
|
||||
/*
|
||||
Take a user-defined action (string or attrs) and return the following attribute set:
|
||||
{
|
||||
action = (string) the actual action to map to this key
|
||||
config = (attrs) the configuration options for this mapping (noremap, silent...)
|
||||
}
|
||||
*/
|
||||
normalizeAction = action: {
|
||||
# Extract the values of the config options that have been explicitly set by the user
|
||||
config =
|
||||
filterAttrs (_: v: v != null)
|
||||
(getAttrs (attrNames mapConfigOptions) action);
|
||||
action =
|
||||
if action.lua
|
||||
then mkLuaInline action.action
|
||||
else action.action;
|
||||
};
|
||||
in
|
||||
attrValues (mapAttrs
|
||||
(key: action: let
|
||||
normalizedAction = normalizeAction action;
|
||||
in {
|
||||
inherit (normalizedAction) action config;
|
||||
inherit key;
|
||||
inherit mode;
|
||||
})
|
||||
maps);
|
||||
in {
|
||||
config = let
|
||||
globalsScript =
|
||||
|
@ -98,38 +32,18 @@ in {
|
|||
mapResult = result: concatLines (map mkLuarcSection result);
|
||||
};
|
||||
|
||||
toLuaBindings = mode: maps:
|
||||
map (value: ''
|
||||
vim.keymap.set(${toLuaObject mode}, ${toLuaObject value.key}, ${toLuaObject value.action}, ${toLuaObject value.config})
|
||||
'') (genMaps mode maps);
|
||||
getAction = keymap:
|
||||
if keymap.lua
|
||||
then mkLuaInline keymap.action
|
||||
else keymap.action;
|
||||
|
||||
# I'm not sure if every one of these will work.
|
||||
allmap = toLuaBindings "" config.vim.maps.normalVisualOp;
|
||||
nmap = toLuaBindings "n" config.vim.maps.normal;
|
||||
vmap = toLuaBindings "v" config.vim.maps.visual;
|
||||
xmap = toLuaBindings "x" config.vim.maps.visualOnly;
|
||||
smap = toLuaBindings "s" config.vim.maps.select;
|
||||
imap = toLuaBindings "i" config.vim.maps.insert;
|
||||
cmap = toLuaBindings "c" config.vim.maps.command;
|
||||
tmap = toLuaBindings "t" config.vim.maps.terminal;
|
||||
lmap = toLuaBindings "l" config.vim.maps.lang;
|
||||
omap = toLuaBindings "o" config.vim.maps.operator;
|
||||
icmap = toLuaBindings "ic" config.vim.maps.insertCommand;
|
||||
getOpts = keymap: {
|
||||
inherit (keymap) desc silent nowait script expr unique noremap;
|
||||
};
|
||||
|
||||
maps = [
|
||||
nmap
|
||||
imap
|
||||
vmap
|
||||
xmap
|
||||
smap
|
||||
cmap
|
||||
omap
|
||||
tmap
|
||||
lmap
|
||||
icmap
|
||||
allmap
|
||||
];
|
||||
mappings = concatLines (map concatLines maps);
|
||||
toLuaKeymap = bind: "vim.keymap.set(${toLuaObject bind.mode}, ${toLuaObject bind.key}, ${toLuaObject (getAction bind)}, ${toLuaObject (getOpts bind)})";
|
||||
|
||||
keymaps = concatLines (map toLuaKeymap cfg.keymaps);
|
||||
in {
|
||||
vim = {
|
||||
luaConfigRC = {
|
||||
|
@ -138,9 +52,10 @@ in {
|
|||
optionsScript = entryAfter ["basic"] (concatLines optionsScript);
|
||||
|
||||
# Basic
|
||||
pluginConfigs = entryAfter ["optionsScript"] pluginConfigs;
|
||||
lazyConfigs = entryAfter ["optionsScript"] cfg.lazy.builtLazyConfig;
|
||||
pluginConfigs = entryAfter ["lazyConfigs"] pluginConfigs;
|
||||
extraPluginConfigs = entryAfter ["pluginConfigs"] extraPluginConfigs;
|
||||
mappings = entryAfter ["extraPluginConfigs"] mappings;
|
||||
mappings = entryAfter ["extraPluginConfigs"] keymaps;
|
||||
};
|
||||
|
||||
builtLuaConfigRC = let
|
||||
|
|
|
@ -3,27 +3,18 @@
|
|||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkRemovedOptionModule;
|
||||
inherit (lib.options) mkOption mkEnableOption literalMD literalExpression;
|
||||
inherit (lib.strings) optionalString;
|
||||
inherit (lib.types) str attrs lines listOf either path bool;
|
||||
inherit (lib.types) str attrs lines listOf either path;
|
||||
inherit (lib.nvim.types) dagOf;
|
||||
inherit (lib.nvim.lua) listToLuaTable;
|
||||
|
||||
cfg = config.vim;
|
||||
in {
|
||||
imports = [
|
||||
(mkRemovedOptionModule ["vim" "configRC"] ''
|
||||
Please migrate your configRC sections to Neovim's Lua format, and
|
||||
add them to luaConfigRC.
|
||||
|
||||
See the v0.7 release notes for more information on how to migrate
|
||||
your existing configurations.
|
||||
'')
|
||||
];
|
||||
|
||||
options.vim = {
|
||||
enableLuaLoader = mkEnableOption ''
|
||||
[{option}`official documentation`]: https://neovim.io/doc/user/lua.html#vim.loader.enable()
|
||||
|
||||
the experimental Lua module loader to speed up the start up process
|
||||
|
||||
If `true`, this will enable the experimental Lua module loader which:
|
||||
|
@ -32,30 +23,12 @@ in {
|
|||
- adds the libs loader
|
||||
- removes the default Neovim loader
|
||||
|
||||
::: {.note}
|
||||
This is disabled by default. Before setting this option, please
|
||||
take a look at the [{option}`official documentation`](https://neovim.io/doc/user/lua.html#vim.loader.enable()).
|
||||
take a look at the [{option}`official documentation`].
|
||||
:::
|
||||
'';
|
||||
|
||||
disableDefaultRuntimePaths = mkOption {
|
||||
type = bool;
|
||||
default = true;
|
||||
example = false;
|
||||
description = ''
|
||||
Disables the default runtime paths that are set by Neovim
|
||||
when it starts up. This is useful when you want to have
|
||||
full control over the runtime paths that are set by Neovim.
|
||||
|
||||
::: {.note}
|
||||
To avoid leaking imperative user configuration into your
|
||||
configuration, this is enabled by default. If you wish
|
||||
to load configuration from user configuration directories
|
||||
(e.g. {file}`$HOME/.config/nvim`, {file}`$HOME/.config/nvim/after`
|
||||
and {file}`$HOME/.local/share/nvim/site`) you may set this
|
||||
option to true.
|
||||
:::
|
||||
'';
|
||||
};
|
||||
|
||||
additionalRuntimePaths = mkOption {
|
||||
type = listOf (either path str);
|
||||
default = [];
|
||||
|
@ -180,21 +153,6 @@ in {
|
|||
vim.opt.runtimepath:append(${listToLuaTable cfg.additionalRuntimePaths})
|
||||
''}
|
||||
|
||||
${optionalString cfg.disableDefaultRuntimePaths ''
|
||||
-- Remove default user runtime paths from the
|
||||
-- `runtimepath` option to avoid leaking user configuration
|
||||
-- into the final neovim wrapper
|
||||
local defaultRuntimePaths = {
|
||||
vim.fn.stdpath('config'), -- $HOME/.config/nvim
|
||||
vim.fn.stdpath('config') .. "/after", -- $HOME/.config/nvim/after
|
||||
vim.fn.stdpath('data') .. "/site", -- $HOME/.local/share/nvim/site
|
||||
}
|
||||
|
||||
for _, path in ipairs(defaultRuntimePaths) do
|
||||
vim.opt.runtimepath:remove(path)
|
||||
end
|
||||
''}
|
||||
|
||||
${optionalString cfg.enableLuaLoader "vim.loader.enable()"}
|
||||
'';
|
||||
|
||||
|
|
Loading…
Reference in a new issue