Skip to content

Commit 85d6935

Browse files
authored
Merge pull request #92 from NotAShelf/release/v0.4
release/v0.4
2 parents 37a3f5b + ef3a132 commit 85d6935

File tree

136 files changed

+3403
-1226
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+3403
-1226
lines changed

.github/CONTRIBUTING.md

Lines changed: 217 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,224 @@ If you have any questions regarding those files, feel free to open an issue or [
1818

1919
The contribution process is mostly documented in the [pull request template](.github/pull_request_template.md). You will find a checklist of items to complete before submitting a pull request. Please make sure you complete it before submitting a pull request. If you are unsure about any of the items, please ask.
2020

21-
## Code of Conduct
21+
### Code of Conduct
2222

2323
This project does not quite have a code of conduct yet. And to be honest, I'm not sure if I want one. I'm not expecting this project to be a hotbed of activity, but I do want to make sure that everyone who does contribute feels welcome and safe. As such, I will do my best to make sure that those who distrupt the project are dealt with swiftly and appropriately.
2424

2525
If you feel that you are not being treated with respect, please contact me directly.
26+
27+
### Guidelines
28+
29+
Here are the overall boundaries I would like you to follow while contributing to neovim-flake.
30+
31+
#### Documentation
32+
33+
If you are making a pull request to add a
34+
35+
36+
#### Style
37+
38+
**Nix**
39+
We use Alejandra for formatting nix code, which can be invoked directly with `nix fmt` in the repository.
40+
41+
While Alejandra is mostly opinionated on how code looks after formatting, certain formattings are done at the user's discretion.
42+
43+
Please use one line code for attribute sets that contain only one subset.
44+
For example:
45+
46+
```nix
47+
# parent modules should always be unfolded
48+
module = {
49+
value = mkEnableOption "some description" // { default = true; };
50+
# same as parent modules, unfold submodules
51+
subModule = {
52+
# this is an option that contains more than one nested value
53+
someOtherValue = mkOption {
54+
type = lib.types.bool;
55+
description = "Some other description"
56+
default = true;
57+
};
58+
};
59+
}
60+
```
61+
62+
If you move a line down after the merge operator, Alejandra will automatically unfold the whole merged attrset for you, which we do not want.
63+
64+
```nix
65+
module = {
66+
key = mkEnableOption "some description" // {
67+
default = true; # we want this to be inline
68+
};
69+
# ...
70+
}
71+
```
72+
73+
For lists, it's up mostly to your discretion but please try to avoid unfolded lists if there is only one item in the list.
74+
```nix
75+
76+
# ok
77+
acceptableList = [
78+
item1
79+
item2
80+
item3
81+
item4
82+
];
83+
84+
# not ok
85+
listToBeAvoided = [item1 item2 item3 item4];
86+
```
87+
88+
*This will be moved elsewhere, disregard unless you are adding a new plugin with keybinds*
89+
#### Keybinds
90+
91+
##### Custom key mappings support for a plugin
92+
93+
To add custom keymappings to a plugin, a couple of helper functions are available in the project.
94+
95+
To set a mapping, you should define it on `vim.maps.<mode>`.
96+
The available modes are:
97+
98+
- normal
99+
- insert
100+
- select
101+
- visual
102+
- terminal
103+
- normalVisualOp
104+
- visualOnly
105+
- operator
106+
- insertCommand
107+
- lang
108+
- command
109+
110+
An example, simple keybinding, can look like this:
111+
112+
```nix
113+
114+
{
115+
vim.maps.normal = {
116+
"<leader>wq" = {
117+
action = ":wq<CR>";
118+
silent = true;
119+
desc = "Save file and quit";
120+
};
121+
};
122+
}
123+
```
124+
125+
There are many settings available in the options. Please refer to [the documentation](https://notashelf.github.io/neovim-flake/options.html#opt-vim.maps.command._name_.action) to see a list of them.
126+
127+
neovim-flake provides a list of helper commands, so that you don't have to write the mapping attribute sets every time:
128+
129+
`mkBinding = key: action: desc:` - makes a basic binding, with `silent` set to true.
130+
`mkExprBinding = key: action: desc:` - makes an expression binding, with `lua`, `silent`, and `expr` set to true.
131+
`mkLuaBinding = key: action: desc:` - makes an expression binding, with `lua`, and `silent` set to true.
132+
Note - the lua in these bindings is _actual_ lua, not pasted into a `:lua`.
133+
Therefore, you either pass in a function like `require('someplugin').some_function`, without actually calling it,
134+
or you define your own function, like `function() require('someplugin').some_function() end`.
135+
136+
Additionally, to not have to repeat the descriptions, there's another utility function with its own set of functions:
137+
138+
```nix
139+
# Utility function that takes two attrsets:
140+
# { someKey = "some_value" } and
141+
# { someKey = { description = "Some Description"; }; }
142+
# and merges them into
143+
# { someKey = { value = "some_value"; description = "Some Description"; }; }
144+
145+
addDescriptionsToMappings = actualMappings: mappingDefinitions:
146+
```
147+
148+
This function can be used in combination with the same mkBinding functions as above, except they only take two arguments - `binding` and `action`, and have different names.
149+
`mkSetBinding = binding: action:` - makes a basic binding, with `silent` set to true.
150+
`mkSetExprBinding = binding: action:` - makes an expression binding, with `lua`, `silent`, and `expr` set to true.
151+
`mkSetLuaBinding = binding: action:` - makes an expression binding, with `lua`, and `silent` set to true.
152+
153+
You can read the source code of some modules to see them in action, but their usage should look something like this:
154+
155+
```nix
156+
# plugindefinition.nix
157+
{lib, ...}:
158+
with lib; {
159+
options.vim.plugin = {
160+
enable = mkEnableOption "Enable plugin";
161+
162+
# Mappings should always be inside an attrset called mappings
163+
mappings = {
164+
# mkMappingOption is a helper function from lib,
165+
# that takes a description (which will also appear in which-key),
166+
# and a default mapping (which can be null)
167+
toggleCurrentLine = mkMappingOption "Toggle current line comment" "gcc";
168+
toggleCurrentBlock = mkMappingOption "Toggle current block comment" "gbc";
169+
170+
toggleOpLeaderLine = mkMappingOption "Toggle line comment" "gc";
171+
toggleOpLeaderBlock = mkMappingOption "Toggle block comment" "gb";
172+
173+
toggleSelectedLine = mkMappingOption "Toggle selected comment" "gc";
174+
toggleSelectedBlock = mkMappingOption "Toggle selected block" "gb";
175+
};
176+
};
177+
}
178+
```
179+
180+
```nix
181+
# config.nix
182+
{
183+
pkgs,
184+
config,
185+
lib,
186+
...
187+
}:
188+
with lib;
189+
with builtins; let
190+
cfg = config.vim.plugin;
191+
self = import ./plugindefinition.nix {inherit lib;};
192+
mappingDefinitions = self.options.vim.plugin;
193+
194+
# addDescriptionsToMappings is a helper function from lib,
195+
# that merges mapping values and their descriptions
196+
# into one nice attribute set
197+
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
198+
in {
199+
config = mkIf (cfg.enable) {
200+
# ...
201+
202+
vim.maps.normal = mkMerge [
203+
# mkSetBinding is another helper function from lib,
204+
# that actually adds the mapping with a description.
205+
(mkSetBinding mappings.findFiles "<cmd> Telescope find_files<CR>")
206+
(mkSetBinding mappings.liveGrep "<cmd> Telescope live_grep<CR>")
207+
(mkSetBinding mappings.buffers "<cmd> Telescope buffers<CR>")
208+
(mkSetBinding mappings.helpTags "<cmd> Telescope help_tags<CR>")
209+
(mkSetBinding mappings.open "<cmd> Telescope<CR>")
210+
211+
(mkSetBinding mappings.gitCommits "<cmd> Telescope git_commits<CR>")
212+
(mkSetBinding mappings.gitBufferCommits "<cmd> Telescope git_bcommits<CR>")
213+
(mkSetBinding mappings.gitBranches "<cmd> Telescope git_branches<CR>")
214+
(mkSetBinding mappings.gitStatus "<cmd> Telescope git_status<CR>")
215+
(mkSetBinding mappings.gitStash "<cmd> Telescope git_stash<CR>")
216+
217+
(mkIf config.vim.lsp.enable (mkMerge [
218+
(mkSetBinding mappings.lspDocumentSymbols "<cmd> Telescope lsp_document_symbols<CR>")
219+
(mkSetBinding mappings.lspWorkspaceSymbols "<cmd> Telescope lsp_workspace_symbols<CR>")
220+
221+
(mkSetBinding mappings.lspReferences "<cmd> Telescope lsp_references<CR>")
222+
(mkSetBinding mappings.lspImplementations "<cmd> Telescope lsp_implementations<CR>")
223+
(mkSetBinding mappings.lspDefinitions "<cmd> Telescope lsp_definitions<CR>")
224+
(mkSetBinding mappings.lspTypeDefinitions "<cmd> Telescope lsp_type_definitions<CR>")
225+
(mkSetBinding mappings.diagnostics "<cmd> Telescope diagnostics<CR>")
226+
]))
227+
228+
(
229+
mkIf config.vim.treesitter.enable
230+
(mkSetBinding mappings.treesitter "<cmd> Telescope treesitter<CR>")
231+
)
232+
];
233+
234+
# ...
235+
};
236+
}
237+
```
238+
239+
If you have come across a plugin that has an API that doesn't seem to easily allow custom keybindings, don't be scared to implement a draft PR. We'll help you get it done.
240+
241+

.github/README.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@
4141
<div align="center"><p>
4242

4343
**[<kbd> <br> Get Started <br> </kbd>][Get Started]**
44-
**[<kbd> <br> Documentation <br> </kbd>][Documentation]**
45-
**[<kbd> <br> Help <br> </kbd>][Help]**
46-
**[<kbd> <br> Contribute <br> </kbd>][Contribute]**
47-
**[<kbd> <br> FAQ <br> </kbd>][Faq]**
44+
**[<kbd> <br> Documentation <br> </kbd>][Documentation]**
45+
**[<kbd> <br> Help <br> </kbd>][Help]**
46+
**[<kbd> <br> Contribute <br> </kbd>][Contribute]**
47+
**[<kbd> <br> FAQ <br> </kbd>][Faq]**
4848
**[<kbd> <br> Credits <br> </kbd>][Credits]**
4949

5050
</p></div>
@@ -78,7 +78,7 @@ nix run github:notashelf/neovim-flake#tidal
7878

7979
Similar instructions will apply for `nix profile install`.
8080

81-
P.S. The `maximal` configuration is *massive* and will take a while to build. To get a feel for the configuration, use the default `nix` or `tidal` configurations.
81+
P.S. The `maximal` configuration is _massive_ and will take a while to build. To get a feel for the configuration, use the default `nix` or `tidal` configurations.
8282

8383
## Documentation
8484

@@ -103,8 +103,8 @@ I am always looking for new ways to help improve this flake. If you would like t
103103
## Philosophy
104104

105105
The philosophy behind this flake configuration is to create an easily configurable and reproducible Neovim environment. While it does sacrifice in size
106-
(which I know some users will find *disagreeable*), it offers a lot of flexibility and customizability in exchange for the large size of the flake inputs.
107-
The KISS (Keep it simple, stupid) principle has been abandoned here, however, you *can* ultimately leverage the flexibility of this flake to declare a configuration that follows KISS principles, it is very easy to bring your own plugins and configurations from non-nix. What this flake is meant to be does eventually fall into your hands. Whether you are a developer, writer, or live coder (see tidal cycles below!), you can quickly craft a config that suits every project's need. Think of it like a distribution of Neovim that takes advantage of pinning vim plugins and
106+
(which I know some users will find _disagreeable_), it offers a lot of flexibility and customizability in exchange for the large size of the flake inputs.
107+
The KISS (Keep it simple, stupid) principle has been abandoned here, however, you _can_ ultimately leverage the flexibility of this flake to declare a configuration that follows KISS principles, it is very easy to bring your own plugins and configurations from non-nix. What this flake is meant to be does eventually fall into your hands. Whether you are a developer, writer, or live coder, you can quickly craft a config that suits every project's need. Think of it like a distribution of Neovim that takes advantage of pinning vim plugins and
108108
third party dependencies (such as tree-sitter grammars, language servers, and more).
109109

110110
One should never get a broken config when setting options. If setting multiple options results in a broken Neovim, file an issue! Each plugin knows when another plugin which allows for smart configuration of keybindings and automatic setup of things like completion sources and languages.
@@ -128,9 +128,9 @@ instead of the `maximal` output. This will reduce size by a lot, but you will lo
128128
**A**: No. If you feel the need to ask that question, then you have missed the whole point of using nix and ultimately this flake. The whole reason we use nix is to be able to handle EVERYTHING declaratively, well including the LSP and plugin installations.
129129
<br/><br/>
130130

131-
**Q**: Can you add *X*?
131+
**Q**: Can you add _X_?
132132
<br/>
133-
**A**: Maybe. Open an issue using the appropriate template and I will consider it. I do not intend to add *every plugin that is in existence*, but I will consider it, should it offer something useful to the flake.
133+
**A**: Maybe. Open an issue using the appropriate template and I will consider it. I do not intend to add _every plugin that is in existence_, but I will consider it, should it offer something useful to the flake.
134134

135135
## Credits
136136

@@ -139,17 +139,19 @@ instead of the `maximal` output. This will reduce size by a lot, but you will lo
139139
Special thanks to
140140

141141
- [@fufexan](https://github.com/fufexan) - For the transition to flake-parts
142-
- [@FlafyDev](https://github.com/FlafyDev) - For getting the home-manager to work
142+
- [@FlafyDev](https://github.com/FlafyDev) - For getting the home-manager to work
143+
- [@n3oney](https://github.com/n3oney) - For making custom keybinds finally possible
144+
- [@horriblename](https://github.com/horriblename) - For actively implementing planned features and quality of life updates
143145

144146
and everyone who has submitted issues or pull requests!
145147

146148
### Inspiration
147149

148150
This configuration borrows from and is based on a few other configurations, including:
149151

152+
- [@jordanisaacs's](https://github.com/jordanisaacs) [neovim-flake](https://github.com/jordanisaacs/neovim-flake)
150153
- [@sioodmy's](https://github.com/sioodmy) [dotfiles](https://github.com/sioodmy/dotfiles)
151154
- [@wiltaylor's](https://github.com/wiltaylor) [neovim-flake](https://github.com/wiltaylor/neovim-flake)
152-
- [@jordanisaacs's](https://github.com/jordanisaacs) [neovim-flake](https://github.com/jordanisaacs/neovim-flake)
153155
- [@gvolpe's](https://github.com/gvolpe) [neovim-flake](https://github.com/gvolpe/neovim-flake)
154156

155157
I am grateful for their previous work and inspiration.

.github/workflows/check-docs.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,10 @@ jobs:
4040
run: nix flake check
4141
- name: Build neovim-flake with default settings
4242
run: nix build .#${{ matrix.package }} --print-build-logs
43+
- name: Upload doc artifacts
44+
uses: actions/upload-artifact@v3
45+
with:
46+
name: doc
47+
path: result/share/doc/neovim-flake/
4348

4449

0 commit comments

Comments
 (0)