Skip to content

Commit

Permalink
Merge pull request #33 from ttak0422/doc
Browse files Browse the repository at this point in the history
`doc`
  • Loading branch information
ttak0422 authored Jan 20, 2024
2 parents c9b330c + 95e1fca commit 0414f4e
Show file tree
Hide file tree
Showing 13 changed files with 349 additions and 61 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@
<p>Vim/Neovim package manager for Nix.</p>
</div>

## Features
Nix flake module. This module provides a package of Vim environments from minimal to full configuration.

## License
This project is licensed under the MIT license.
7 changes: 2 additions & 5 deletions docs/SUMMARY.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
# Summary

[Introduction](./introduction.md)
[Introduction](./../README.md)
[Quick Start](./quick-start.md)

---
# Configuration

- [Common Configuration](./common-configuration.md)
- [Neovim Configuration](./neovim-configuration.md)
- [pluginConfigDetail.args example](./neovim-configuration-example-args.md)
- [Vim Configuration](./vim-configuration.md)

---
# Usage


1 change: 0 additions & 1 deletion docs/common-configuration.md

This file was deleted.

1 change: 0 additions & 1 deletion docs/getting-started.md

This file was deleted.

4 changes: 1 addition & 3 deletions docs/introduction.md
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# bundler

Vim / Neovim package manager for Nix.
# Introduction
25 changes: 25 additions & 0 deletions docs/neovim-configuration-example-args.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# example `pluginConfigDetail.args`

```nix
# access args in viml
{
language = "vim";
code = ''
s:args['foo'] " bar
'';
args = {
foo = "bar";
};
}
# access args in lua
{
language = "lua";
code = ''
args.foo -- bar
'';
args = {
foo = "bar"
};
}
```
85 changes: 85 additions & 0 deletions docs/neovim-configuration.md
Original file line number Diff line number Diff line change
@@ -1 +1,86 @@
# Neovim Configuration

Configurations defined in bundler-nvim are available as packages and apps.
This module assumes that you will use that package as you wish, as follows.

```nix
environment.systemPackages = [
(pkgs.runCommand "nvim" { } ''
mkdir -p $out/bin
ln -s ${
self.packages.${system}.bundler-nvim
}/bin/nvim $out/bin/nvim
'')
];
```

## flakeModule schemes

| name | type | default | description |
| :-: | :-: | :- | :- |
| packageNamePrefix | `types.str` | `"bundler-nvim"` | package name prefix provided by this module |
| appNamePrefix | `types.str` | `"bundler-nvim"` | app name prefix provided by this module |
| package | `types.package` | `pkgs.neovim-unwrapped` | neovim package |
| extraPackages | `with types; listOf package` | `[]` | e.g. lua-language-server |
| extraConfig | `types.lines` | `""` | viml code executed at startup |
| extraLuaConfig | `types.lines` | `""` | lua code executed at startup |
| after.ftPlugin | `with types; attrsOf lines` | `{}` | `after/ftplugin` (viml only) |
| withNodeJs | `types.bool` | `false` | alias for `neovim.withNodeJs` |
| withPython3 | `types.bool` | `false` | alias for `neovim.withPython3` |
| withRuby | `types.bool` | `false` | alias for `neovim.withRuby` |
| eagerPlugins | `with types; listOf (either package eagerPluginConfig)` | `[]` | plugins loaded at startup |
| lazyPlugins | `with types; listOf (either package lazyPluginConfig)` | `[]` | plugins lazy loaded |
| lazyGroups | `types.listOf lazyGroupConfig` | `[]` | plugin groups lazy loaded |
| timer | `types.int` | `100` | time used for loading plugin (msec) |
| logLevel | `types.enum [ "debug" "info" "warn" "error" ]` | `"warn"` |

### pluginConfigDetail

| name | type | default | description |
| :-: | :-: | :-: | :- |
| language | `types.enum [ "vim" "lua" ]` | `vim` | - |
| code | `types.lines` | `""` | setup code |
| args | `types.attrs` | `{}` | bring the values of nix into the code . see [example](./neovim-configuration-example-args.md). |

### eagerPluginConfig

| name | type | default | description |
| :-: | :-: | :-: | :- |
| startupConfig | `with types; either lines pluginConfigDetail` | `""` | setup code executed at startup |
| extraPackages | `with types; listOf package` | `[]` | nix packages |

### lazyPluginConfig

| name | type | default | description |
| :-: | :-: | :-: | :- |
| startupConfig | `with types; either lines pluginConfigDetail` | `""` | setup code executed at startup |
| extraPackages | `with types; listOf package` | `[]` | nix packages |
| preConfig | `with types; either lines pluginConfigDetail` | `""` | setup code executed before load plugin |
| postConfig | `with types; either lines pluginConfigDetail` | `""` | setup code executed after load plugin |
| dependPlugins | `with types; listOf (either package lazyPluginConfig)` | `[]` | plugins on which this plugin depends |
| dependGroups | `with types; listOf str` | `[]` | groups on which this plugin depends |
| onModules | `with types; listOf str` | `[]` | load plugin when configured modules is called |
| onEvents | `with types; listOf str` | `[]` | load plugin when configured events fires |
| onFiletypes | `with types; listOf str` | `[]` | load plugin when configured filetype is read |
| onCommands | `with types; listOf str` | `[]` | load plugin when configured commands execute |
| useTimer | `types.bool` | `false` | set `true` to load the plugin using timer |
| useDenops | `types.bool` | `false` | must be explicitly set to `true` in the denops plugin |

### lazyGroupConfig

| name | type | default | description |
| :-: | :-: | :-: | :- |
| name | `types.str` | **required** | group name |
| plugins | `with types; listOf` | `[]` | group name |
| startupConfig | `with types; either lines pluginConfigDetail` | `""` | setup code executed at startup |
| extraPackages | `with types; listOf package` | `[]` | nix packages |
| preConfig | `with types; either lines pluginConfigDetail` | `""` | setup code executed before load plugin |
| postConfig | `with types; either lines pluginConfigDetail` | `""` | setup code executed after load plugin |
| dependPlugins | `with types; listOf (either package lazyPluginConfig)` | `[]` | plugins on which this plugin depends |
| dependGroups | `with types; listOf str` | `[]` | groups on which this plugin depends |
| onModules | `with types; listOf str` | `[]` | load plugin when configured modules is called |
| onEvents | `with types; listOf str` | `[]` | load plugin when configured events fires |
| onFiletypes | `with types; listOf str` | `[]` | load plugin when configured filetype is read |
| onCommands | `with types; listOf str` | `[]` | load plugin when configured commands execute |
| useTimer | `types.bool` | `false` | set `true` to load the plugin using timer |

13 changes: 13 additions & 0 deletions docs/quick-start.md
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
# Quick Start

## `bundler-nvim` (for Neovim)

```bash
$ nix flake init --template github:ttak0422/bundler#neovim
$ nix run .#bundler-nvim
```

## `bundler-vim` (for Vim)

<div class="warning">
`bundler-vim` is under development.
</div>
4 changes: 4 additions & 0 deletions docs/vim-configuration.md
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
# Vim Configuration

<div class="warning">
`bundler-vim` is under development.
</div>
90 changes: 90 additions & 0 deletions examples/neovim/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{
description = "Neovim with bundler-nvim";

inputs = {
bundler.url = "github:ttak0422/bundler";
nixpkgs.follows = "bundler/nixpkgs";
flake-parts.follows = "bundler/flake-parts";
};

outputs = inputs@{ bundler, nixpkgs, flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [ bundler.flakeModules.neovim ];
systems = nixpkgs.lib.systems.flakeExposed;

perSystem = { pkgs, ... }: {

# Please see the documentation for more information.
bundler-nvim = {

# The configuration defined in `default` can be accessed as `bundler-nvim`.
default = {

# Define viml code to be executed at startup.
extraConfig = ''
set laststatus=3
'';

# Define lua code to be executed at startup.
extraLuaConfig = ''
vim.loader.enable()
'';

# Define plugins to be loaded at startup.
eagerPlugins = with pkgs.vimPlugins; [{
plugin = kanagawa-nvim;

# Define viml code to be executed at startup.
#
# following sample code is equivalent to
#
# ```nix
# startupConfig = {
# language = "vim";
# code = ''
# colorscheme kanagawa
# '';
# };
#
startupConfig = ''
colorscheme kanagawa
'';
}];

# define plugins to be lazy loaded.
lazyPlugins = with pkgs.vimPlugins; [{
plugin = telescope-nvim;

# `startupConfig` is executed at startup, regardless of whether the plugin is loaded or not.
startupConfig = ''
nnoremap <leader>ff <cmd>Telescope find_files<cr>
nnoremap <leader>fg <cmd>Telescope live_grep<cr>
nnoremap <leader>fb <cmd>Telescope buffers<cr>
nnoremap <leader>fh <cmd>Telescope help_tags<cr>
'';

# `preConfig` is executed before the plugin is loaded.
preConfig = "";

# `postConfig` is executed after the plugin is loaded.
postConfig = {
# Explicit language specification is required when use lua code.
language = "lua";
code = ''
require('telescope').setup()
'';
};

# Load the plugin when the following commands are executed.
onCommands = [ "Telescope" ];
}];
};

# The configuration defined in `foo` can be accessed as `bundler-nvim-foo`.
foo = {
# ...
};
};
};
};
}
28 changes: 28 additions & 0 deletions examples/vim/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
description = "Vim with bundler-vim";

inputs = {
bundler.url = "github:ttak0422/bundler";
nixpkgs.follows = "bundler/nixpkgs";
flake-parts.follows = "bundler/flake-parts";
};

outputs = inputs@{ bundler, nixpkgs, flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [ bundler.flakeModules.vim ];
systems = nixpkgs.lib.systems.flakeExposed;

perSystem = { pkgs, ... }: {
bundler-vim = {
default = {
eagerPlugins = with pkgs.vimPlugins; [{
plugin = iceberg-vim;
startupConfig = ''
colorscheme iceberg
'';
}];
};
};
};
};
}
16 changes: 16 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0414f4e

Please sign in to comment.