mirror of
				https://github.com/NotAShelf/nvf.git
				synced 2025-11-04 12:42:21 +00:00 
			
		
		
		
	docs: rename all instances of neovim-flake to nvf
		
	This commit is contained in:
		
					parent
					
						
							
								ebe0d6c960
							
						
					
				
			
			
				commit
				
					
						227f80ac9d
					
				
			
		
					 36 changed files with 430 additions and 278 deletions
				
			
		| 
						 | 
				
			
			@ -1,8 +1,9 @@
 | 
			
		|||
# Keybinds {#sec-keybinds}
 | 
			
		||||
 | 
			
		||||
As of 0.4, there exists an API for writing your own keybinds and a couple of useful utility functions are available in
 | 
			
		||||
the [extended standard library](https://github.com/NotAShelf/neovim-flake/tree/main/lib). The following section contains
 | 
			
		||||
a general overview to how you may utilize said functions.
 | 
			
		||||
As of 0.4, there exists an API for writing your own keybinds and a couple of
 | 
			
		||||
useful utility functions are available in the [extended standard
 | 
			
		||||
library](https://github.com/NotAShelf/nvf/tree/main/lib). The following
 | 
			
		||||
section contains a general overview to how you may utilize said functions.
 | 
			
		||||
 | 
			
		||||
## Custom Key Mappings Support for a Plugin {#sec-custom-key-mappings}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -36,44 +37,58 @@ An example, simple keybinding, can look like this:
 | 
			
		|||
```
 | 
			
		||||
 | 
			
		||||
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)
 | 
			
		||||
[documentation](https://notashelf.github.io/nvf/options.html#opt-vim.maps.command._name_.action)
 | 
			
		||||
to see a list of them.
 | 
			
		||||
 | 
			
		||||
`neovim-flake` provides a list of helper commands, so that you don't have to write the mapping attribute sets every
 | 
			
		||||
time:
 | 
			
		||||
**nvf** provides a list of helper commands, so that you don't have to write the
 | 
			
		||||
mapping attribute sets every time:
 | 
			
		||||
 | 
			
		||||
- `mkBinding = key: action: desc:` - makes a basic binding, with `silent` set to true.
 | 
			
		||||
- `mkExprBinding = key: action: desc:` - makes an expression binding, with `lua`, `silent`, and `expr` set to true.
 | 
			
		||||
- `mkLuaBinding = key: action: desc:` - makes an expression binding, with `lua`, and `silent` set to true.
 | 
			
		||||
- `mkBinding = key: action: desc:` - makes a basic binding, with `silent` set
 | 
			
		||||
  to true.
 | 
			
		||||
- `mkExprBinding = key: action: desc:` - makes an expression binding, with
 | 
			
		||||
  `lua`, `silent`, and `expr` set to true.
 | 
			
		||||
- `mkLuaBinding = key: action: desc:` - makes an expression binding, with
 | 
			
		||||
  `lua`, and `silent` set to true.
 | 
			
		||||
 | 
			
		||||
Note that the Lua in these bindings is actual Lua, not pasted into a `:lua` command.
 | 
			
		||||
Therefore, you either pass in a function like `require('someplugin').some_function`, without actually calling it,
 | 
			
		||||
or you define your own function, like `function() require('someplugin').some_function() end`.
 | 
			
		||||
Do note that the Lua in these bindings is actual Lua, and not pasted into a
 | 
			
		||||
`:lua` command. Therefore, you should either pass in a function like
 | 
			
		||||
`require('someplugin').some_function`, without actually calling it, or you
 | 
			
		||||
should define your own functions, for example
 | 
			
		||||
 | 
			
		||||
Additionally, to not have to repeat the descriptions, there's another utility function with its own set of functions:
 | 
			
		||||
```lua
 | 
			
		||||
function()
 | 
			
		||||
  require('someplugin').some_function()
 | 
			
		||||
end
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
Utility function that takes two attrsets:
 | 
			
		||||
Additionally, to not have to repeat the descriptions, there's another utility
 | 
			
		||||
function with its own set of functions: Utility function that takes two
 | 
			
		||||
attribute sets:
 | 
			
		||||
 | 
			
		||||
- `{ someKey = "some_value" }`
 | 
			
		||||
- `{ someKey = { description = "Some Description"; }; }`
 | 
			
		||||
 | 
			
		||||
and merges them into `{ someKey = { value = "some_value"; description = "Some Description"; }; }`
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
```nix
 | 
			
		||||
addDescriptionsToMappings = actualMappings: mappingDefinitions:
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
This function can be used in combination with the same `mkBinding` functions as above, except they only take two
 | 
			
		||||
arguments - `binding` and `action`, and have different names:
 | 
			
		||||
This function can be used in combination with the same `mkBinding` functions as
 | 
			
		||||
above, except they only take two arguments - `binding` and `action`, and have
 | 
			
		||||
different names:
 | 
			
		||||
 | 
			
		||||
- `mkSetBinding = binding: action:` - makes a basic binding, with `silent` set to true.
 | 
			
		||||
- `mkSetExprBinding = binding: action:` - makes an expression binding, with `lua`, `silent`, and `expr` set to true.
 | 
			
		||||
- `mkSetLuaBinding = binding: action:` - makes an expression binding, with `lua`, and `silent` set to true.
 | 
			
		||||
- `mkSetBinding = binding: action:` - makes a basic binding, with `silent`
 | 
			
		||||
  set to true.
 | 
			
		||||
- `mkSetExprBinding = binding: action:` - makes an expression binding, with
 | 
			
		||||
  `lua`, `silent`, and `expr` set to true.
 | 
			
		||||
- `mkSetLuaBinding = binding: action:` - makes an expression binding, with
 | 
			
		||||
  `lua`, and `silent` set to true.
 | 
			
		||||
 | 
			
		||||
You can read the source code of some modules to see them in action, but their usage should look something like this:
 | 
			
		||||
You can read the source code of some modules to see them in action, but their
 | 
			
		||||
usage should look something like this:
 | 
			
		||||
 | 
			
		||||
```nix
 | 
			
		||||
 | 
			
		||||
# plugindefinition.nix
 | 
			
		||||
{lib, ...}: with lib; {
 | 
			
		||||
  options.vim.plugin = {
 | 
			
		||||
| 
						 | 
				
			
			@ -96,15 +111,13 @@ You can read the source code of some modules to see them in action, but their us
 | 
			
		|||
 | 
			
		||||
  };
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
```nix
 | 
			
		||||
 | 
			
		||||
# config.nix
 | 
			
		||||
{
 | 
			
		||||
  pkgs,
 | 
			
		||||
  config,
 | 
			
		||||
  pkgs,
 | 
			
		||||
  lib,
 | 
			
		||||
  ...
 | 
			
		||||
}:
 | 
			
		||||
| 
						 | 
				
			
			@ -158,9 +171,8 @@ in {
 | 
			
		|||
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
:::{.note}
 | 
			
		||||
 | 
			
		||||
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.
 | 
			
		||||
 | 
			
		||||
::: {.note}
 | 
			
		||||
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.
 | 
			
		||||
:::
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue