mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-11-04 20:52:21 +00:00
Compare commits
No commits in common. "0115325759fca0d5991d06cd7ba3b6f141eca36e" and "da1fed218b2dda294190e004da4d5bec7d43ec34" have entirely different histories.
0115325759
...
da1fed218b
11 changed files with 110 additions and 273 deletions
|
|
@ -43,7 +43,7 @@ isMaximal: {
|
||||||
# This section does not include a comprehensive list of available language modules.
|
# This section does not include a comprehensive list of available language modules.
|
||||||
# To list all available language module options, please visit the nvf manual.
|
# To list all available language module options, please visit the nvf manual.
|
||||||
languages = {
|
languages = {
|
||||||
enableFormat = true;
|
enableFormat = true; #
|
||||||
enableTreesitter = true;
|
enableTreesitter = true;
|
||||||
enableExtraDiagnostics = true;
|
enableExtraDiagnostics = true;
|
||||||
|
|
||||||
|
|
@ -194,7 +194,7 @@ isMaximal: {
|
||||||
leetcode-nvim.enable = isMaximal;
|
leetcode-nvim.enable = isMaximal;
|
||||||
multicursors.enable = isMaximal;
|
multicursors.enable = isMaximal;
|
||||||
smart-splits.enable = isMaximal;
|
smart-splits.enable = isMaximal;
|
||||||
undotree.enable = isMaximal;
|
|
||||||
motion = {
|
motion = {
|
||||||
hop.enable = true;
|
hop.enable = true;
|
||||||
leap.enable = true;
|
leap.enable = true;
|
||||||
|
|
|
||||||
|
|
@ -1,92 +1,25 @@
|
||||||
# Adding Plugins {#sec-additional-plugins}
|
# Adding Plugins {#sec-additional-plugins}
|
||||||
|
|
||||||
There are two methods for adding new Neovim plugins to **nvf**. npins is the
|
To add a new Neovim plugin, use `npins`
|
||||||
faster option that should be preferred if the plugin consists of pure Lua or
|
|
||||||
Vimscript code. In which case there is no building required, and we can easily
|
|
||||||
handle the copying of plugin files. Alternative method, which is required when
|
|
||||||
plugins try to build their own libraries (e.g., in Rust or C) that need to be
|
|
||||||
built with Nix to function correctly.
|
|
||||||
|
|
||||||
## With npins {#sec-npins-for-plugins}
|
Use:
|
||||||
|
|
||||||
npins is the standard method of adding new plugins to **nvf**. You simply need
|
`nix-shell -p npins` or `nix shell nixpkgs#npins`
|
||||||
the repository URL for the plugin, and can add it as a source to be built
|
|
||||||
automatically with one command. To add a new Neovim plugin, use `npins`. For
|
|
||||||
example:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
nix-shell -p npins # or nix shell nixpkgs#npins if using flakes
|
|
||||||
```
|
|
||||||
|
|
||||||
Then run:
|
Then run:
|
||||||
|
|
||||||
```bash
|
`npins add --name <plugin name> github <owner> <repo> -b <branch>`
|
||||||
npins add --name <plugin name> github <owner> <repo> -b <branch>
|
|
||||||
```
|
|
||||||
|
|
||||||
::: {.note}
|
Be sure to replace any non-alphanumeric characters with `-` for `--name`
|
||||||
|
|
||||||
Be sure to replace any non-alphanumeric characters with `-` for `--name`. For
|
For example
|
||||||
example
|
|
||||||
|
|
||||||
```bash
|
`npins add --name lazydev-nvim github folke lazydev.nvim -b main`
|
||||||
npins add --name lazydev-nvim github folke lazydev.nvim -b main
|
|
||||||
```
|
|
||||||
|
|
||||||
:::
|
You can now reference this plugin as a **string**.
|
||||||
|
|
||||||
Once the `npins` command is done, you can start referencing the plugin as a
|
|
||||||
**string**.
|
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
|
||||||
config.vim.startPlugins = ["lazydev-nvim"];
|
config.vim.startPlugins = ["lazydev-nvim"];
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Packaging Complex Plugins {#sec-pkgs-for-plugins}
|
|
||||||
|
|
||||||
[blink.cmp]: https://github.com/Saghen/blink.cmp
|
|
||||||
|
|
||||||
Some plugins require additional packages to be built and substituted to function
|
|
||||||
correctly. For example [blink.cmp] requires its own fuzzy matcher library, built
|
|
||||||
with Rust, to be installed or else defaults to a much slower Lua implementation.
|
|
||||||
In the Blink documentation, you are advised to build with `cargo` but that is
|
|
||||||
not ideal since we are leveraging the power of Nix. In this case the ideal
|
|
||||||
solution is to write a derivation for the plugin.
|
|
||||||
|
|
||||||
We use `buildRustPackage` to build the library from the repository root, and
|
|
||||||
copy everything in the `postInstall` phase.
|
|
||||||
|
|
||||||
```nix
|
|
||||||
postInstall = ''
|
|
||||||
cp -r {lua,plugin} "$out"
|
|
||||||
|
|
||||||
mkdir -p "$out/doc"
|
|
||||||
cp 'doc/'*'.txt' "$out/doc/"
|
|
||||||
|
|
||||||
mkdir -p "$out/target"
|
|
||||||
mv "$out/lib" "$out/target/release"
|
|
||||||
'';
|
|
||||||
```
|
|
||||||
|
|
||||||
In a similar fashion, you may utilize `stdenv.mkDerivation` and other Nixpkgs
|
|
||||||
builders to build your library from source, and copy the relevant files and Lua
|
|
||||||
plugin files in the `postInstall` phase. Do note, however, that you still need
|
|
||||||
to fetch the plugin sources somehow. npins is, once again, the recommended
|
|
||||||
option to fetch the plugin sources. Refer to the previous section on how to use
|
|
||||||
npins to add a new plugin.
|
|
||||||
|
|
||||||
Plugins built from source must go into the `flake/pkgs/by-name` overlay. It will
|
|
||||||
automatically create flake outputs for individual packages. Lastly, you must add
|
|
||||||
your package to the plugin builder (`pluginBuilders`) function manually in
|
|
||||||
`modules/wrapper/build/config.nix`. Once done, you may refer to your plugin as a
|
|
||||||
**string**.
|
|
||||||
|
|
||||||
```nix
|
|
||||||
{
|
|
||||||
config.vim.startPlugins = ["blink-cmp"];
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Modular setup options {#sec-modular-setup-options}
|
## Modular setup options {#sec-modular-setup-options}
|
||||||
|
|
@ -137,7 +70,7 @@ in {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
This above config will result in this Lua script:
|
This above config will result in this lua script:
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
require('plugin-name').setup({
|
require('plugin-name').setup({
|
||||||
|
|
@ -168,39 +101,21 @@ own fields!
|
||||||
As you've seen above, `toLuaObject` is used to convert our nix attrSet
|
As you've seen above, `toLuaObject` is used to convert our nix attrSet
|
||||||
`cfg.setupOpts`, into a lua table. Here are some rules of the conversion:
|
`cfg.setupOpts`, into a lua table. Here are some rules of the conversion:
|
||||||
|
|
||||||
1. Nix `null` converts to lua `nil`
|
1. nix `null` converts to lua `nil`
|
||||||
2. Number and strings convert to their lua counterparts
|
2. number and strings convert to their lua counterparts
|
||||||
3. Nix attribute sets (`{}`) and lists (`[]`) convert into Lua dictionaries and
|
3. nix attrSet/list convert into lua tables
|
||||||
tables respectively. Here is an example of Nix -> Lua conversion.
|
4. you can write raw lua code using `lib.generators.mkLuaInline`. This function
|
||||||
- `{foo = "bar"}` -> `{["foo"] = "bar"}`
|
is part of nixpkgs.
|
||||||
- `["foo" "bar"]` -> `{"foo", "bar"}`
|
|
||||||
4. You can write raw Lua code using `lib.generators.mkLuaInline`. This function
|
Example:
|
||||||
is part of nixpkgs, and is accessible without relying on **nvf**'s extended
|
|
||||||
library.
|
|
||||||
- `mkLuaInline "function add(a, b) return a + b end"` will yield the
|
|
||||||
following result:
|
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
{
|
|
||||||
_type = "lua-inline";
|
|
||||||
expr = "function add(a, b) return a + b end";
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
The above expression will be interpreted as a Lua expression in the final
|
|
||||||
config. Without the `mkLuaInline` function, you will only receive a string
|
|
||||||
literal. You can use it to feed plugin configuration tables Lua functions
|
|
||||||
that return specific values as expected by the plugins.
|
|
||||||
|
|
||||||
```nix
|
|
||||||
{
|
|
||||||
vim.your-plugin.setupOpts = {
|
vim.your-plugin.setupOpts = {
|
||||||
on_init = lib.generators.mkLuaInline ''
|
on_init = lib.generators.mkLuaInline ''
|
||||||
function()
|
function()
|
||||||
print('we can write lua!')
|
print('we can write lua!')
|
||||||
end
|
end
|
||||||
'';
|
'';
|
||||||
};
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -211,24 +126,25 @@ Lazy plugins are managed by `lz.n`.
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
# in modules/.../your-plugin/config.nix
|
# in modules/.../your-plugin/config.nix
|
||||||
{config, ...}: let
|
{lib, config, ...}:
|
||||||
|
let
|
||||||
cfg = config.vim.your-plugin;
|
cfg = config.vim.your-plugin;
|
||||||
in {
|
in {
|
||||||
vim.lazy.plugins.your-plugin = {
|
vim.lazy.plugins.your-plugin = {
|
||||||
# Instead of vim.startPlugins, use this:
|
# instead of vim.startPlugins, use this:
|
||||||
package = "your-plugin";
|
package = "your-plugin";
|
||||||
|
|
||||||
# ıf your plugin uses the `require('your-plugin').setup{...}` pattern
|
# if your plugin uses the `require('your-plugin').setup{...}` pattern
|
||||||
setupModule = "your-plugin";
|
setupModule = "your-plugin";
|
||||||
inherit (cfg) setupOpts;
|
inherit (cfg) setupOpts;
|
||||||
|
|
||||||
# Events that trigger this plugin to be loaded
|
# events that trigger this plugin to be loaded
|
||||||
event = ["DirChanged"];
|
event = ["DirChanged"];
|
||||||
cmd = ["YourPluginCommand"];
|
cmd = ["YourPluginCommand"];
|
||||||
|
|
||||||
# Plugin Keymaps
|
# keymaps
|
||||||
keys = [
|
keys = [
|
||||||
# We'll cover this in detail in the 'keybinds' section
|
# we'll cover this in detail in the keymaps section
|
||||||
{
|
{
|
||||||
key = "<leader>d";
|
key = "<leader>d";
|
||||||
mode = "n";
|
mode = "n";
|
||||||
|
|
@ -236,6 +152,7 @@ in {
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -246,9 +163,7 @@ require('lz.n').load({
|
||||||
{
|
{
|
||||||
"name-of-your-plugin",
|
"name-of-your-plugin",
|
||||||
after = function()
|
after = function()
|
||||||
require('your-plugin').setup({
|
require('your-plugin').setup({--[[ your setupOpts ]]})
|
||||||
--[[ your setupOpts ]]--
|
|
||||||
})
|
|
||||||
end,
|
end,
|
||||||
|
|
||||||
event = {"DirChanged"},
|
event = {"DirChanged"},
|
||||||
|
|
@ -260,7 +175,5 @@ require('lz.n').load({
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
[`vim.lazy.plugins` spec]: https://notashelf.github.io/nvf/options.html#opt-vim.lazy.plugins
|
A full list of options can be found
|
||||||
|
[here](https://notashelf.github.io/nvf/options.html#opt-vim.lazy.plugins
|
||||||
A full list of options can be found in the [`vim.lazy.plugins` spec] on the
|
|
||||||
rendered manual.
|
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,6 @@
|
||||||
[snacks.nvim]: https://github.com/folke/snacks.nvim
|
[snacks.nvim]: https://github.com/folke/snacks.nvim
|
||||||
[oil.nvim]: https://github.com/stevearc/oil.nvim
|
[oil.nvim]: https://github.com/stevearc/oil.nvim
|
||||||
[hunk.nvim]: https://github.com/julienvincent/hunk.nvim
|
[hunk.nvim]: https://github.com/julienvincent/hunk.nvim
|
||||||
[undotree]: https://github.com/mbbill/undotree
|
|
||||||
|
|
||||||
- Add [typst-preview.nvim] under
|
- Add [typst-preview.nvim] under
|
||||||
`languages.typst.extensions.typst-preview-nvim`.
|
`languages.typst.extensions.typst-preview-nvim`.
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
{
|
{
|
||||||
pins,
|
|
||||||
openssl,
|
openssl,
|
||||||
pkg-config,
|
pkg-config,
|
||||||
rustPlatform,
|
rustPlatform,
|
||||||
|
|
@ -7,17 +6,11 @@
|
||||||
vimUtils,
|
vimUtils,
|
||||||
makeWrapper,
|
makeWrapper,
|
||||||
pkgs,
|
pkgs,
|
||||||
|
version,
|
||||||
|
src,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
# From npins
|
inherit version src;
|
||||||
pin = pins.avante-nvim;
|
|
||||||
version = pin.branch;
|
|
||||||
src = pkgs.fetchFromGitHub {
|
|
||||||
inherit (pin.repository) owner repo;
|
|
||||||
rev = pin.revision;
|
|
||||||
sha256 = pin.hash;
|
|
||||||
};
|
|
||||||
|
|
||||||
avante-nvim-lib = rustPlatform.buildRustPackage {
|
avante-nvim-lib = rustPlatform.buildRustPackage {
|
||||||
pname = "avante-nvim-lib";
|
pname = "avante-nvim-lib";
|
||||||
inherit version src;
|
inherit version src;
|
||||||
|
|
@ -55,9 +48,10 @@ in
|
||||||
ext = stdenv.hostPlatform.extensions.sharedLibrary;
|
ext = stdenv.hostPlatform.extensions.sharedLibrary;
|
||||||
in ''
|
in ''
|
||||||
mkdir -p $out/build
|
mkdir -p $out/build
|
||||||
for lib in avante_repo_map avante_templates avante_tokenizers avante_html2md; do
|
ln -s ${avante-nvim-lib}/lib/libavante_repo_map${ext} $out/build/avante_repo_map${ext}
|
||||||
ln -s ${avante-nvim-lib}/lib/lib$lib${ext} $out/build/$$lib${ext}
|
ln -s ${avante-nvim-lib}/lib/libavante_templates${ext} $out/build/avante_templates${ext}
|
||||||
done
|
ln -s ${avante-nvim-lib}/lib/libavante_tokenizers${ext} $out/build/avante_tokenizers${ext}
|
||||||
|
ln -s ${avante-nvim-lib}/lib/libavante_html2md${ext} $out/build/avante_html2md${ext}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
nvimSkipModules = [
|
nvimSkipModules = [
|
||||||
|
|
@ -9,59 +9,29 @@
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib.customisation) makeScope;
|
|
||||||
inherit (lib.attrsets) isDerivation isAttrs concatMapAttrs;
|
|
||||||
inherit (lib.strings) concatStringsSep;
|
|
||||||
inherit (lib.filesystem) packagesFromDirectoryRecursive;
|
|
||||||
|
|
||||||
# Entrypoint for nvf documentation and relevant packages.
|
|
||||||
docs = import ../docs {inherit pkgs inputs lib;};
|
docs = import ../docs {inherit pkgs inputs lib;};
|
||||||
|
|
||||||
# Helper function for creating demo configurations for nvf
|
|
||||||
# TODO: make this more generic.
|
|
||||||
buildPkg = maximal:
|
buildPkg = maximal:
|
||||||
(args.config.flake.lib.nvim.neovimConfiguration {
|
(args.config.flake.lib.nvim.neovimConfiguration {
|
||||||
inherit pkgs;
|
inherit pkgs;
|
||||||
modules = [(import ../configuration.nix maximal)];
|
modules = [(import ../configuration.nix maximal)];
|
||||||
}).neovim;
|
}).neovim;
|
||||||
|
in {
|
||||||
# This constructs a by-name overlay similar to the one found in Nixpkgs.
|
packages = {
|
||||||
# The goal is to automatically discover and packages found in pkgs/by-name
|
blink-cmp = pkgs.callPackage ./blink {};
|
||||||
# as long as they have a 'package.nix' in the package directory. We also
|
avante-nvim = let
|
||||||
# pass 'inputs' and 'pins' to all packages in the 'callPackage' scope, therefore
|
pin = self.pins.avante-nvim;
|
||||||
# they are always available in the relevant 'package.nix' files.
|
in
|
||||||
# ---
|
pkgs.callPackage ./avante-nvim {
|
||||||
# The logic is borrowed from drupol/pkgs-by-name-for-flake-parts, available
|
version = pin.branch;
|
||||||
# under the MIT license.
|
src = pkgs.fetchFromGitHub {
|
||||||
flattenPkgs = separator: path: value:
|
inherit (pin.repository) owner repo;
|
||||||
if isDerivation value
|
rev = pin.revision;
|
||||||
then {
|
sha256 = pin.hash;
|
||||||
${concatStringsSep separator path} = value;
|
};
|
||||||
}
|
pins = self.pins;
|
||||||
else if isAttrs value
|
|
||||||
then concatMapAttrs (name: flattenPkgs separator (path ++ [name])) value
|
|
||||||
else
|
|
||||||
# Ignore the functions which makeScope returns
|
|
||||||
{};
|
|
||||||
|
|
||||||
inputsScope = makeScope pkgs.newScope (_: {
|
|
||||||
inherit inputs;
|
|
||||||
inherit (self) pins;
|
|
||||||
});
|
|
||||||
|
|
||||||
scopeFromDirectory = directory:
|
|
||||||
packagesFromDirectoryRecursive {
|
|
||||||
inherit directory;
|
|
||||||
inherit (inputsScope) newScope callPackage;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
legacyPackages = scopeFromDirectory ./pkgs/by-name;
|
|
||||||
in {
|
|
||||||
packages =
|
|
||||||
(flattenPkgs "/" [] legacyPackages)
|
|
||||||
// {
|
|
||||||
inherit (docs.manual) htmlOpenTool;
|
inherit (docs.manual) htmlOpenTool;
|
||||||
|
|
||||||
# Documentation
|
# Documentation
|
||||||
docs = docs.manual.html;
|
docs = docs.manual.html;
|
||||||
docs-html = docs.manual.html;
|
docs-html = docs.manual.html;
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,5 @@
|
||||||
./wakatime
|
./wakatime
|
||||||
./yanky-nvim
|
./yanky-nvim
|
||||||
./yazi-nvim
|
./yazi-nvim
|
||||||
./undotree
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
{
|
|
||||||
vim.lazy.plugins.undotree = {
|
|
||||||
package = "undotree";
|
|
||||||
cmd = [
|
|
||||||
"UndotreeToggle"
|
|
||||||
"UndotreeShow"
|
|
||||||
"UndotreeHide"
|
|
||||||
"UndotreePersistUndo"
|
|
||||||
"UndotreeFocus"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
{
|
|
||||||
imports = [
|
|
||||||
./undotree.nix
|
|
||||||
./config.nix
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
{lib, ...}: let
|
|
||||||
inherit (lib.options) mkEnableOption;
|
|
||||||
in {
|
|
||||||
options.vim.utility.undotree = {
|
|
||||||
enable = mkEnableOption "undo history visualizer for Vim [undotree]";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -2497,19 +2497,6 @@
|
||||||
"url": "https://github.com/chomosuke/typst-preview.nvim/archive/dea4525d5420b7c32eebda7de15a6beb9d6574fa.tar.gz",
|
"url": "https://github.com/chomosuke/typst-preview.nvim/archive/dea4525d5420b7c32eebda7de15a6beb9d6574fa.tar.gz",
|
||||||
"hash": "0y658l2ibq0x4cwa4rl3lab7aw4ba68xcrdnxp81p2rsk0d60qq4"
|
"hash": "0y658l2ibq0x4cwa4rl3lab7aw4ba68xcrdnxp81p2rsk0d60qq4"
|
||||||
},
|
},
|
||||||
"undotree": {
|
|
||||||
"type": "Git",
|
|
||||||
"repository": {
|
|
||||||
"type": "GitHub",
|
|
||||||
"owner": "mbbill",
|
|
||||||
"repo": "undotree"
|
|
||||||
},
|
|
||||||
"branch": "master",
|
|
||||||
"submodules": false,
|
|
||||||
"revision": "28f2f54a34baff90ea6f4a735ef1813ad875c743",
|
|
||||||
"url": "https://github.com/mbbill/undotree/archive/28f2f54a34baff90ea6f4a735ef1813ad875c743.tar.gz",
|
|
||||||
"hash": "0k9qfp64rbwy1lc62x0vkwfl3qlx8633lfbhqxkf64yqwi81ysp5"
|
|
||||||
},
|
|
||||||
"vim-dirtytalk": {
|
"vim-dirtytalk": {
|
||||||
"type": "Git",
|
"type": "Git",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue