mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-12-19 12:09:48 +01:00
Merge pull request #40 from n3oney/feature/custom-keybinds
feature/custom-keybinds
This commit is contained in:
commit
0a829bed0e
46 changed files with 1335 additions and 521 deletions
150
.github/CONTRIBUTING.md
vendored
150
.github/CONTRIBUTING.md
vendored
|
@ -23,3 +23,153 @@ The contribution process is mostly documented in the [pull request template](.gi
|
||||||
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.
|
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.
|
||||||
|
|
||||||
If you feel that you are not being treated with respect, please contact me directly.
|
If you feel that you are not being treated with respect, please contact me directly.
|
||||||
|
|
||||||
|
## Custom key mappings support for a plugin
|
||||||
|
|
||||||
|
To add custom keymappings to a plugin, a couple of helper functions are available in the project.
|
||||||
|
|
||||||
|
To set a mapping, you should define it on `vim.maps.<mode>`.
|
||||||
|
The available modes are:
|
||||||
|
|
||||||
|
- normal
|
||||||
|
- insert
|
||||||
|
- select
|
||||||
|
- visual
|
||||||
|
- terminal
|
||||||
|
- normalVisualOp
|
||||||
|
- visualOnly
|
||||||
|
- operator
|
||||||
|
- insertCommand
|
||||||
|
- lang
|
||||||
|
- command
|
||||||
|
|
||||||
|
An example, simple keybinding, can look like this:
|
||||||
|
|
||||||
|
```nix
|
||||||
|
|
||||||
|
{
|
||||||
|
vim.maps.normal = {
|
||||||
|
"<leader>wq" = {
|
||||||
|
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/neovim-flake/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:
|
||||||
|
|
||||||
|
`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 - the lua in these bindings is _actual_ lua, not pasted into a `:lua`.
|
||||||
|
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`.
|
||||||
|
|
||||||
|
Additionally, to not have to repeat the descriptions, there's another utility function with its own set of functions:
|
||||||
|
|
||||||
|
```nix
|
||||||
|
# Utility function that takes two attrsets:
|
||||||
|
# { someKey = "some_value" } and
|
||||||
|
# { someKey = { description = "Some Description"; }; }
|
||||||
|
# and merges them into
|
||||||
|
# { someKey = { value = "some_value"; description = "Some Description"; }; }
|
||||||
|
|
||||||
|
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.
|
||||||
|
`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:
|
||||||
|
|
||||||
|
```nix
|
||||||
|
# plugindefinition.nix
|
||||||
|
{lib, ...}:
|
||||||
|
with lib; {
|
||||||
|
options.vim.plugin = {
|
||||||
|
enable = mkEnableOption "Enable plugin";
|
||||||
|
|
||||||
|
# Mappings should always be inside an attrset called mappings
|
||||||
|
mappings = {
|
||||||
|
# mkMappingOption is a helper function from lib,
|
||||||
|
# that takes a description (which will also appear in which-key),
|
||||||
|
# and a default mapping (which can be null)
|
||||||
|
toggleCurrentLine = mkMappingOption "Toggle current line comment" "gcc";
|
||||||
|
toggleCurrentBlock = mkMappingOption "Toggle current block comment" "gbc";
|
||||||
|
|
||||||
|
toggleOpLeaderLine = mkMappingOption "Toggle line comment" "gc";
|
||||||
|
toggleOpLeaderBlock = mkMappingOption "Toggle block comment" "gb";
|
||||||
|
|
||||||
|
toggleSelectedLine = mkMappingOption "Toggle selected comment" "gc";
|
||||||
|
toggleSelectedBlock = mkMappingOption "Toggle selected block" "gb";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
```nix
|
||||||
|
# config.nix
|
||||||
|
{
|
||||||
|
pkgs,
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
with lib;
|
||||||
|
with builtins; let
|
||||||
|
cfg = config.vim.plugin;
|
||||||
|
self = import ./plugindefinition.nix {inherit lib;};
|
||||||
|
mappingDefinitions = self.options.vim.plugin;
|
||||||
|
|
||||||
|
# addDescriptionsToMappings is a helper function from lib,
|
||||||
|
# that merges mapping values and their descriptions
|
||||||
|
# into one nice attribute set
|
||||||
|
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
|
||||||
|
in {
|
||||||
|
config = mkIf (cfg.enable) {
|
||||||
|
# ...
|
||||||
|
|
||||||
|
vim.maps.normal = mkMerge [
|
||||||
|
# mkSetBinding is another helper function from lib,
|
||||||
|
# that actually adds the mapping with a description.
|
||||||
|
(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.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>")
|
||||||
|
|
||||||
|
(mkIf config.vim.lsp.enable (mkMerge [
|
||||||
|
(mkSetBinding mappings.lspDocumentSymbols "<cmd> Telescope lsp_document_symbols<CR>")
|
||||||
|
(mkSetBinding mappings.lspWorkspaceSymbols "<cmd> Telescope lsp_workspace_symbols<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>")
|
||||||
|
]))
|
||||||
|
|
||||||
|
(
|
||||||
|
mkIf config.vim.treesitter.enable
|
||||||
|
(mkSetBinding mappings.treesitter "<cmd> Telescope treesitter<CR>")
|
||||||
|
)
|
||||||
|
];
|
||||||
|
|
||||||
|
# ...
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
|
@ -4,9 +4,70 @@
|
||||||
nixpkgsLib: let
|
nixpkgsLib: let
|
||||||
mkNvimLib = import ./.;
|
mkNvimLib = import ./.;
|
||||||
in
|
in
|
||||||
nixpkgsLib.extend (self: super: {
|
nixpkgsLib.extend (self: super: rec {
|
||||||
nvim = mkNvimLib {lib = self;};
|
nvim = mkNvimLib {lib = self;};
|
||||||
|
|
||||||
|
mkLuaBinding = key: action: desc:
|
||||||
|
self.mkIf (key != null) {
|
||||||
|
"${key}" = {
|
||||||
|
inherit action desc;
|
||||||
|
lua = true;
|
||||||
|
silent = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
mkExprBinding = key: action: desc:
|
||||||
|
self.mkIf (key != null) {
|
||||||
|
"${key}" = {
|
||||||
|
inherit action desc;
|
||||||
|
lua = true;
|
||||||
|
silent = true;
|
||||||
|
expr = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
mkBinding = key: action: desc:
|
||||||
|
self.mkIf (key != null) {
|
||||||
|
"${key}" = {
|
||||||
|
inherit action desc;
|
||||||
|
silent = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
mkMappingOption = description: default:
|
||||||
|
self.mkOption {
|
||||||
|
type = self.types.nullOr self.types.str;
|
||||||
|
inherit default description;
|
||||||
|
};
|
||||||
|
|
||||||
|
# Utility function that takes two attrsets:
|
||||||
|
# { someKey = "some_value" } and
|
||||||
|
# { someKey = { description = "Some Description"; }; }
|
||||||
|
# and merges them into
|
||||||
|
# { someKey = { value = "some_value"; description = "Some Description"; }; }
|
||||||
|
addDescriptionsToMappings = actualMappings: mappingDefinitions:
|
||||||
|
self.attrsets.mapAttrs (name: value: let
|
||||||
|
isNested = self.isAttrs value;
|
||||||
|
returnedValue =
|
||||||
|
if isNested
|
||||||
|
then addDescriptionsToMappings actualMappings."${name}" mappingDefinitions."${name}"
|
||||||
|
else {
|
||||||
|
value = value;
|
||||||
|
description = mappingDefinitions."${name}".description;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
returnedValue)
|
||||||
|
actualMappings;
|
||||||
|
|
||||||
|
mkSetBinding = binding: action:
|
||||||
|
mkBinding binding.value action binding.description;
|
||||||
|
|
||||||
|
mkSetExprBinding = binding: action:
|
||||||
|
mkExprBinding binding.value action binding.description;
|
||||||
|
|
||||||
|
mkSetLuaBinding = binding: action:
|
||||||
|
mkLuaBinding binding.value action binding.description;
|
||||||
|
|
||||||
# For forward compatibility.
|
# For forward compatibility.
|
||||||
literalExpression = super.literalExpression or super.literalExample;
|
literalExpression = super.literalExpression or super.literalExample;
|
||||||
literalDocBook = super.literalDocBook or super.literalExample;
|
literalDocBook = super.literalDocBook or super.literalExample;
|
||||||
|
|
|
@ -7,6 +7,18 @@
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; let
|
with builtins; let
|
||||||
cfg = config.vim.assistant.copilot;
|
cfg = config.vim.assistant.copilot;
|
||||||
|
|
||||||
|
wrapPanelBinding = luaFunction: key: ''
|
||||||
|
function()
|
||||||
|
local s, _ = pcall(${luaFunction})
|
||||||
|
|
||||||
|
if not s then
|
||||||
|
local termcode = vim.api.nvim_replace_termcodes(${builtins.toJSON key}, true, false, true)
|
||||||
|
|
||||||
|
vim.fn.feedkeys(termcode, 'n')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
'';
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
vim.startPlugins = [
|
vim.startPlugins = [
|
||||||
|
@ -18,7 +30,50 @@ in {
|
||||||
require("copilot").setup({
|
require("copilot").setup({
|
||||||
-- available options: https://github.com/zbirenbaum/copilot.lua
|
-- available options: https://github.com/zbirenbaum/copilot.lua
|
||||||
copilot_node_command = "${cfg.copilot_node_command}",
|
copilot_node_command = "${cfg.copilot_node_command}",
|
||||||
|
panel = {
|
||||||
|
keymap = {
|
||||||
|
jump_prev = false,
|
||||||
|
jump_next = false,
|
||||||
|
accept = false,
|
||||||
|
refresh = false,
|
||||||
|
open = false,
|
||||||
|
},
|
||||||
|
layout = {
|
||||||
|
position = "${cfg.panel.position}",
|
||||||
|
ratio = ${toString cfg.panel.ratio},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
suggestion = {
|
||||||
|
keymap = {
|
||||||
|
accept = false,
|
||||||
|
accept_word = false,
|
||||||
|
accept_line = false,
|
||||||
|
next = false,
|
||||||
|
prev = false,
|
||||||
|
dismiss = 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.panel.position}", ratio = ${toString cfg.panel.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")
|
||||||
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,86 @@ with builtins; {
|
||||||
options.vim.assistant.copilot = {
|
options.vim.assistant.copilot = {
|
||||||
enable = mkEnableOption "Enable GitHub Copilot";
|
enable = mkEnableOption "Enable GitHub Copilot";
|
||||||
|
|
||||||
|
panel = {
|
||||||
|
position = mkOption {
|
||||||
|
type = types.enum [
|
||||||
|
"bottom"
|
||||||
|
"top"
|
||||||
|
"left"
|
||||||
|
"right"
|
||||||
|
];
|
||||||
|
default = "bottom";
|
||||||
|
description = "Panel position";
|
||||||
|
};
|
||||||
|
ratio = mkOption {
|
||||||
|
type = types.float;
|
||||||
|
default = 0.4;
|
||||||
|
description = "Panel size";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
mappings = {
|
||||||
|
panel = {
|
||||||
|
jumpPrev = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = "[[";
|
||||||
|
description = "Jump to previous suggestion";
|
||||||
|
};
|
||||||
|
jumpNext = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = "]]";
|
||||||
|
description = "Jump to next suggestion";
|
||||||
|
};
|
||||||
|
accept = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = "<CR>";
|
||||||
|
description = "Accept suggestion";
|
||||||
|
};
|
||||||
|
refresh = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = "gr";
|
||||||
|
description = "Refresh suggestions";
|
||||||
|
};
|
||||||
|
open = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = "<M-CR>";
|
||||||
|
description = "Open suggestions";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
suggestion = {
|
||||||
|
accept = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = "<M-l>";
|
||||||
|
description = "Accept suggetion";
|
||||||
|
};
|
||||||
|
acceptWord = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = null;
|
||||||
|
description = "Accept next word";
|
||||||
|
};
|
||||||
|
acceptLine = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = null;
|
||||||
|
description = "Accept next line";
|
||||||
|
};
|
||||||
|
prev = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = "<M-[>";
|
||||||
|
description = "Previous suggestion";
|
||||||
|
};
|
||||||
|
next = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = "<M-]>";
|
||||||
|
description = "Next suggestion";
|
||||||
|
};
|
||||||
|
dismiss = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = "<C-]>";
|
||||||
|
description = "Dismiss suggestion";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
copilot_node_command = mkOption {
|
copilot_node_command = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "${lib.getExe pkgs.nodejs-slim-16_x}";
|
default = "${lib.getExe pkgs.nodejs-slim-16_x}";
|
||||||
|
|
|
@ -10,13 +10,43 @@ in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
vim.startPlugins = ["tabnine-nvim"];
|
vim.startPlugins = ["tabnine-nvim"];
|
||||||
|
|
||||||
|
vim.maps.insert = mkMerge [
|
||||||
|
(mkExprBinding cfg.mappings.accept ''
|
||||||
|
function()
|
||||||
|
local state = require("tabnine.state")
|
||||||
|
local completion = require("tabnine.completion")
|
||||||
|
|
||||||
|
if not state.completions_cache then
|
||||||
|
return "${builtins.toJSON cfg.mappings.accept}"
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.schedule(completion.accept)
|
||||||
|
end
|
||||||
|
'' "orzel")
|
||||||
|
(mkExprBinding cfg.mappings.dismiss ''
|
||||||
|
function()
|
||||||
|
local state = require("tabnine.state")
|
||||||
|
local completion = require("tabnine.completion")
|
||||||
|
|
||||||
|
if not state.completions_cache then
|
||||||
|
return "${builtins.toJSON cfg.mappings.dismiss}"
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.schedule(function()
|
||||||
|
completion.clear()
|
||||||
|
state.completions_cache = nil
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
'' "orzel")
|
||||||
|
];
|
||||||
|
|
||||||
vim.luaConfigRC.tabnine-nvim = nvim.dag.entryAnywhere ''
|
vim.luaConfigRC.tabnine-nvim = nvim.dag.entryAnywhere ''
|
||||||
require('tabnine').setup({
|
require('tabnine').setup({
|
||||||
disable_auto_comment = ${boolToString cfg.disable_auto_comment},
|
disable_auto_comment = ${boolToString cfg.disable_auto_comment},
|
||||||
accept_keymap = ${cfg.accept_keymap},
|
accept_keymap = null,
|
||||||
dismiss_keymap = ${cfg.dismiss_keymap},
|
dismiss_keymap = null,
|
||||||
debounce_ms = ${cfg.debounce_ms},
|
debounce_ms = ${cfg.debounce_ms},
|
||||||
execlude_filetypes = ${cfg.execlude_filetypes},
|
exclude_filetypes = ${cfg.exclude_filetypes},
|
||||||
})
|
})
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,8 +1,4 @@
|
||||||
{
|
{lib, ...}:
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; {
|
with builtins; {
|
||||||
options.vim.assistant.tabnine = {
|
options.vim.assistant.tabnine = {
|
||||||
|
@ -14,16 +10,9 @@ with builtins; {
|
||||||
description = "Disable auto comment";
|
description = "Disable auto comment";
|
||||||
};
|
};
|
||||||
|
|
||||||
accept_keymap = mkOption {
|
mappings = {
|
||||||
type = types.str;
|
accept = mkMappingOption "Accept [Tabnine]" "<Tab>";
|
||||||
default = "<Tab>";
|
dismiss = mkMappingOption "Dismiss [Tabnine]" "<C-]>";
|
||||||
description = "Accept keymap";
|
|
||||||
};
|
|
||||||
|
|
||||||
dismiss_keymap = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
default = "<C-]>";
|
|
||||||
description = "Dismiss keymap";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
debounce_ms = mkOption {
|
debounce_ms = mkOption {
|
||||||
|
@ -32,10 +21,10 @@ with builtins; {
|
||||||
description = "Debounce ms";
|
description = "Debounce ms";
|
||||||
};
|
};
|
||||||
|
|
||||||
execlude_filetypes = mkOption {
|
exclude_filetypes = mkOption {
|
||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
default = ["TelescopePrompt" "NvimTree" "alpha"];
|
default = ["TelescopePrompt" "NvimTree" "alpha"];
|
||||||
description = "Execlude filetypes";
|
description = "Exclude filetypes";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,21 +10,51 @@ in {
|
||||||
config = {
|
config = {
|
||||||
vim.startPlugins = ["plenary-nvim"];
|
vim.startPlugins = ["plenary-nvim"];
|
||||||
|
|
||||||
vim.nmap = mkIf cfg.disableArrows {
|
vim.maps.normal =
|
||||||
"<up>" = "<nop>";
|
mkIf cfg.disableArrows {
|
||||||
"<down>" = "<nop>";
|
"<up>" = {
|
||||||
"<left>" = "<nop>";
|
action = "<nop>";
|
||||||
"<right>" = "<nop>";
|
|
||||||
};
|
|
||||||
|
|
||||||
vim.imap = mkIf cfg.disableArrows {
|
noremap = false;
|
||||||
"<up>" = "<nop>";
|
};
|
||||||
"<down>" = "<nop>";
|
"<down>" = {
|
||||||
"<left>" = "<nop>";
|
action = "<nop>";
|
||||||
"<right>" = "<nop>";
|
|
||||||
};
|
|
||||||
|
|
||||||
vim.nnoremap = mkIf cfg.mapLeaderSpace {"<space>" = "<nop>";};
|
noremap = false;
|
||||||
|
};
|
||||||
|
"<left>" = {
|
||||||
|
action = "<nop>";
|
||||||
|
noremap = false;
|
||||||
|
};
|
||||||
|
"<right>" = {
|
||||||
|
action = "<nop>";
|
||||||
|
noremap = false;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
// mkIf cfg.mapLeaderSpace {
|
||||||
|
"<space>" = {
|
||||||
|
action = "<nop>";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
vim.maps.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.configRC.basic = nvim.dag.entryAfter ["globalsScript"] ''
|
vim.configRC.basic = nvim.dag.entryAfter ["globalsScript"] ''
|
||||||
" Debug mode settings
|
" Debug mode settings
|
||||||
|
|
|
@ -1,11 +1,18 @@
|
||||||
{
|
{lib, ...}:
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; {
|
with builtins; {
|
||||||
options.vim.comments.comment-nvim = {
|
options.vim.comments.comment-nvim = {
|
||||||
enable = mkEnableOption "Enable comment-nvim";
|
enable = mkEnableOption "Enable comment-nvim";
|
||||||
|
|
||||||
|
mappings = {
|
||||||
|
toggleCurrentLine = mkMappingOption "Toggle current line comment" "gcc";
|
||||||
|
toggleCurrentBlock = mkMappingOption "Toggle current block comment" "gbc";
|
||||||
|
|
||||||
|
toggleOpLeaderLine = mkMappingOption "Toggle line comment" "gc";
|
||||||
|
toggleOpLeaderBlock = mkMappingOption "Toggle block comment" "gb";
|
||||||
|
|
||||||
|
toggleSelectedLine = mkMappingOption "Toggle selected comment" "gc";
|
||||||
|
toggleSelectedBlock = mkMappingOption "Toggle selected block" "gb";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,14 +6,45 @@
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; let
|
with builtins; let
|
||||||
cfg = config.vim.comments.comment-nvim;
|
cfg = config.vim.comments.comment-nvim;
|
||||||
|
self = import ./comment-nvim.nix {
|
||||||
|
inherit lib;
|
||||||
|
};
|
||||||
|
mappings = self.options.vim.comments.comment-nvim.mappings;
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
vim.startPlugins = [
|
vim.startPlugins = [
|
||||||
"comment-nvim"
|
"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.luaConfigRC.comment-nvim = nvim.dag.entryAnywhere ''
|
vim.luaConfigRC.comment-nvim = nvim.dag.entryAnywhere ''
|
||||||
require('Comment').setup()
|
require('Comment').setup({
|
||||||
|
mappings = { basic = false, extra = false, },
|
||||||
|
})
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
{
|
{
|
||||||
pkgs,
|
|
||||||
lib,
|
lib,
|
||||||
config,
|
config,
|
||||||
...
|
...
|
||||||
|
@ -8,6 +7,12 @@ with lib;
|
||||||
with builtins; let
|
with builtins; let
|
||||||
cfg = config.vim.autocomplete;
|
cfg = config.vim.autocomplete;
|
||||||
lspkindEnabled = config.vim.lsp.enable && config.vim.lsp.lspkind.enable;
|
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 =
|
builtSources =
|
||||||
concatMapStringsSep
|
concatMapStringsSep
|
||||||
"\n"
|
"\n"
|
||||||
|
@ -46,6 +51,133 @@ in {
|
||||||
"path" = "[Path]";
|
"path" = "[Path]";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
vim.maps.insert = mkMerge [
|
||||||
|
(mkSetLuaBinding mappings.complete ''
|
||||||
|
require('cmp').complete
|
||||||
|
'')
|
||||||
|
(mkSetLuaBinding mappings.confirm ''
|
||||||
|
function()
|
||||||
|
if not require('cmp').confirm({ select = true }) then
|
||||||
|
local termcode = vim.api.nvim_replace_termcodes(${builtins.toJSON mappings.confirm.value}, true, false, true)
|
||||||
|
|
||||||
|
vim.fn.feedkeys(termcode, '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
|
||||||
|
fallback()
|
||||||
|
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 ''
|
||||||
|
function()
|
||||||
|
require('cmp').mapping.scroll_docs(-4)
|
||||||
|
end
|
||||||
|
'')
|
||||||
|
(mkSetLuaBinding mappings.scrollDocsDown ''
|
||||||
|
function()
|
||||||
|
require('cmp').mapping.scroll_docs(4)
|
||||||
|
end
|
||||||
|
'')
|
||||||
|
];
|
||||||
|
|
||||||
|
vim.maps.command = mkMerge [
|
||||||
|
(mkSetLuaBinding mappings.complete ''
|
||||||
|
require('cmp').complete
|
||||||
|
'')
|
||||||
|
(mkSetLuaBinding mappings.close ''
|
||||||
|
require('cmp').mapping.close
|
||||||
|
'')
|
||||||
|
(mkSetLuaBinding mappings.scrollDocsUp ''
|
||||||
|
function()
|
||||||
|
require('cmp').mapping.scroll_docs(-4)
|
||||||
|
end
|
||||||
|
'')
|
||||||
|
(mkSetLuaBinding mappings.scrollDocsDown ''
|
||||||
|
function()
|
||||||
|
require('cmp').mapping.scroll_docs(4)
|
||||||
|
end
|
||||||
|
'')
|
||||||
|
];
|
||||||
|
|
||||||
|
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
|
||||||
|
fallback()
|
||||||
|
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
|
||||||
|
'')
|
||||||
|
];
|
||||||
|
|
||||||
vim.luaConfigRC.completion = mkIf (cfg.type == "nvim-cmp") (dagPlacement ''
|
vim.luaConfigRC.completion = mkIf (cfg.type == "nvim-cmp") (dagPlacement ''
|
||||||
local nvim_cmp_menu_map = function(entry, vim_item)
|
local nvim_cmp_menu_map = function(entry, vim_item)
|
||||||
-- name for each source
|
-- name for each source
|
||||||
|
@ -59,16 +191,6 @@ in {
|
||||||
${optionalString lspkindEnabled ''
|
${optionalString lspkindEnabled ''
|
||||||
lspkind_opts.before = ${cfg.formatting.format}
|
lspkind_opts.before = ${cfg.formatting.format}
|
||||||
''}
|
''}
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
local cmp = require'cmp'
|
local cmp = require'cmp'
|
||||||
cmp.setup({
|
cmp.setup({
|
||||||
snippet = {
|
snippet = {
|
||||||
|
@ -79,37 +201,6 @@ in {
|
||||||
sources = {
|
sources = {
|
||||||
${builtSources}
|
${builtSources}
|
||||||
},
|
},
|
||||||
mapping = {
|
|
||||||
['<C-d>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
|
|
||||||
['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c'}),
|
|
||||||
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c'}),
|
|
||||||
['<C-y>'] = cmp.config.disable,
|
|
||||||
['<C-e>'] = cmp.mapping({
|
|
||||||
i = cmp.mapping.abort(),
|
|
||||||
c = cmp.mapping.close(),
|
|
||||||
}),
|
|
||||||
['<CR>'] = cmp.mapping.confirm({
|
|
||||||
select = true,
|
|
||||||
}),
|
|
||||||
['<Tab>'] = cmp.mapping(function (fallback)
|
|
||||||
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
|
|
||||||
fallback()
|
|
||||||
end
|
|
||||||
end, { 'i', 's' }),
|
|
||||||
['<S-Tab>'] = cmp.mapping(function (fallback)
|
|
||||||
if cmp.visible() then
|
|
||||||
cmp.select_prev_item()
|
|
||||||
elseif vim.fn['vsnip#available'](-1) == 1 then
|
|
||||||
feedkeys("<Plug>(vsnip-jump-prev)", "")
|
|
||||||
end
|
|
||||||
end, { 'i', 's' })
|
|
||||||
},
|
|
||||||
completion = {
|
completion = {
|
||||||
completeopt = 'menu,menuone,noinsert',
|
completeopt = 'menu,menuone,noinsert',
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,34 +1,6 @@
|
||||||
{
|
{lib, ...}:
|
||||||
pkgs,
|
|
||||||
lib,
|
|
||||||
config,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; let
|
with builtins; {
|
||||||
cfg = config.vim.autocomplete;
|
|
||||||
lspkindEnabled = config.vim.lsp.enable && config.vim.lsp.lspkind.enable;
|
|
||||||
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 nvim.dag.entryAfter ["lspkind"]
|
|
||||||
else nvim.dag.entryAnywhere;
|
|
||||||
in {
|
|
||||||
options.vim = {
|
options.vim = {
|
||||||
autocomplete = {
|
autocomplete = {
|
||||||
enable = mkOption {
|
enable = mkOption {
|
||||||
|
@ -37,6 +9,16 @@ in {
|
||||||
description = "enable autocomplete";
|
description = "enable autocomplete";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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 = mkOption {
|
||||||
type = types.enum ["nvim-cmp"];
|
type = types.enum ["nvim-cmp"];
|
||||||
default = "nvim-cmp";
|
default = "nvim-cmp";
|
||||||
|
|
|
@ -13,12 +13,106 @@ with builtins; let
|
||||||
EOF
|
EOF
|
||||||
'';
|
'';
|
||||||
|
|
||||||
mkMappingOption = it:
|
mkBool = value: description:
|
||||||
mkOption ({
|
mkOption {
|
||||||
default = {};
|
type = types.bool;
|
||||||
type = with types; attrsOf (nullOr str);
|
default = value;
|
||||||
}
|
description = description;
|
||||||
// it);
|
};
|
||||||
|
|
||||||
|
# Most of the keybindings code is highly inspired by pta2002/nixvim. Thank you!
|
||||||
|
mapConfigOptions = {
|
||||||
|
silent =
|
||||||
|
mkBool false
|
||||||
|
(nvim.nmd.asciiDoc "Whether this mapping should be silent. Equivalent to adding <silent> to a map.");
|
||||||
|
|
||||||
|
nowait =
|
||||||
|
mkBool false
|
||||||
|
(nvim.nmd.asciiDoc "Whether to wait for extra input on ambiguous mappings. Equivalent to adding <nowait> to a map.");
|
||||||
|
|
||||||
|
script =
|
||||||
|
mkBool false
|
||||||
|
(nvim.nmd.asciiDoc "Equivalent to adding <script> to a map.");
|
||||||
|
|
||||||
|
expr =
|
||||||
|
mkBool false
|
||||||
|
(nvim.nmd.asciiDoc "Means that the action is actually an expression. Equivalent to adding <expr> to a map.");
|
||||||
|
|
||||||
|
unique =
|
||||||
|
mkBool false
|
||||||
|
(nvim.nmd.asciiDoc "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 = types.nullOr types.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: let
|
||||||
|
# Extract the values of the config options that have been explicitly set by the user
|
||||||
|
config =
|
||||||
|
filterAttrs (n: v: v != null)
|
||||||
|
(getAttrs (attrNames mapConfigOptions) action);
|
||||||
|
in {
|
||||||
|
config =
|
||||||
|
if config == {}
|
||||||
|
then {"__empty" = null;}
|
||||||
|
else config;
|
||||||
|
action =
|
||||||
|
if action.lua
|
||||||
|
then {"__raw" = action.action;}
|
||||||
|
else action.action;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
builtins.attrValues (builtins.mapAttrs
|
||||||
|
(key: action: let
|
||||||
|
normalizedAction = normalizeAction action;
|
||||||
|
in {
|
||||||
|
inherit (normalizedAction) action config;
|
||||||
|
key = key;
|
||||||
|
mode = mode;
|
||||||
|
})
|
||||||
|
maps);
|
||||||
|
|
||||||
|
mapOption = types.submodule {
|
||||||
|
options =
|
||||||
|
mapConfigOptions
|
||||||
|
// {
|
||||||
|
action = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
description = "The action to execute.";
|
||||||
|
};
|
||||||
|
|
||||||
|
lua = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
description = ''
|
||||||
|
If true, `action` is considered to be lua code.
|
||||||
|
Thus, it will not be wrapped in `""`.
|
||||||
|
'';
|
||||||
|
default = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
mapOptions = mode:
|
||||||
|
mkOption {
|
||||||
|
description = "Mappings for ${mode} mode";
|
||||||
|
type = types.attrsOf mapOption;
|
||||||
|
default = {};
|
||||||
|
};
|
||||||
in {
|
in {
|
||||||
options.vim = {
|
options.vim = {
|
||||||
viAlias = mkOption {
|
viAlias = mkOption {
|
||||||
|
@ -67,64 +161,38 @@ in {
|
||||||
type = types.attrs;
|
type = types.attrs;
|
||||||
};
|
};
|
||||||
|
|
||||||
nnoremap =
|
maps = mkOption {
|
||||||
mkMappingOption {description = "Defines 'Normal mode' mappings";};
|
type = types.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')";
|
||||||
|
|
||||||
inoremap = mkMappingOption {
|
visualOnly = mapOptions "visual only";
|
||||||
description = "Defines 'Insert and Replace mode' mappings";
|
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.
|
||||||
|
|
||||||
vnoremap = mkMappingOption {
|
For plain maps (e.g. just 'map' or 'remap') use maps.normalVisualOp.
|
||||||
description = "Defines 'Visual and Select mode' mappings";
|
'';
|
||||||
};
|
|
||||||
|
|
||||||
xnoremap =
|
example = ''
|
||||||
mkMappingOption {description = "Defines 'Visual mode' mappings";};
|
maps = {
|
||||||
|
normal."<leader>m" = {
|
||||||
snoremap =
|
silent = true;
|
||||||
mkMappingOption {description = "Defines 'Select mode' mappings";};
|
action = "<cmd>make<CR>";
|
||||||
|
}; # Same as nnoremap <leader>m <silent> <cmd>make<CR>
|
||||||
cnoremap =
|
};
|
||||||
mkMappingOption {description = "Defines 'Command-line mode' mappings";};
|
'';
|
||||||
|
|
||||||
onoremap = mkMappingOption {
|
|
||||||
description = "Defines 'Operator pending mode' mappings";
|
|
||||||
};
|
|
||||||
|
|
||||||
tnoremap = mkMappingOption {
|
|
||||||
description = "Defines 'Terminal mode' mappings";
|
|
||||||
};
|
|
||||||
|
|
||||||
nmap = mkMappingOption {
|
|
||||||
description = "Defines 'Normal mode' mappings";
|
|
||||||
};
|
|
||||||
|
|
||||||
imap = mkMappingOption {
|
|
||||||
description = "Defines 'Insert and Replace mode' mappings";
|
|
||||||
};
|
|
||||||
|
|
||||||
vmap = mkMappingOption {
|
|
||||||
description = "Defines 'Visual and Select mode' mappings";
|
|
||||||
};
|
|
||||||
|
|
||||||
xmap = mkMappingOption {
|
|
||||||
description = "Defines 'Visual mode' mappings";
|
|
||||||
};
|
|
||||||
|
|
||||||
smap = mkMappingOption {
|
|
||||||
description = "Defines 'Select mode' mappings";
|
|
||||||
};
|
|
||||||
|
|
||||||
cmap = mkMappingOption {
|
|
||||||
description = "Defines 'Command-line mode' mappings";
|
|
||||||
};
|
|
||||||
|
|
||||||
omap = mkMappingOption {
|
|
||||||
description = "Defines 'Operator pending mode' mappings";
|
|
||||||
};
|
|
||||||
|
|
||||||
tmap = mkMappingOption {
|
|
||||||
description = "Defines 'Terminal mode' mappings";
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -148,34 +216,63 @@ in {
|
||||||
mapAttrsFlatten (name: value: "let g:${name}=${valToVim value}")
|
mapAttrsFlatten (name: value: "let g:${name}=${valToVim value}")
|
||||||
(filterNonNull cfg.globals);
|
(filterNonNull cfg.globals);
|
||||||
|
|
||||||
matchCtrl = it: match "Ctrl-(.)(.*)" it;
|
toLuaObject = args:
|
||||||
mapKeyBinding = it: let
|
if builtins.isAttrs args
|
||||||
groups = matchCtrl it;
|
then
|
||||||
in
|
if hasAttr "__raw" args
|
||||||
if groups == null
|
then args.__raw
|
||||||
then it
|
else if hasAttr "__empty" args
|
||||||
else "<C-${toUpper (head groups)}>${head (tail groups)}";
|
then "{ }"
|
||||||
mapVimBinding = prefix: mappings:
|
else
|
||||||
mapAttrsFlatten (name: value: "${prefix} ${mapKeyBinding name} ${value}")
|
"{"
|
||||||
(filterNonNull mappings);
|
+ (concatStringsSep ","
|
||||||
|
(mapAttrsToList
|
||||||
|
(n: v:
|
||||||
|
if head (stringToCharacters n) == "@"
|
||||||
|
then toLuaObject v
|
||||||
|
else "[${toLuaObject n}] = " + (toLuaObject v))
|
||||||
|
(filterAttrs
|
||||||
|
(
|
||||||
|
n: v:
|
||||||
|
!isNull v && (toLuaObject v != "{}")
|
||||||
|
)
|
||||||
|
args)))
|
||||||
|
+ "}"
|
||||||
|
else if builtins.isList args
|
||||||
|
then "{" + concatMapStringsSep "," toLuaObject args + "}"
|
||||||
|
else if builtins.isString args
|
||||||
|
then
|
||||||
|
# This should be enough!
|
||||||
|
builtins.toJSON args
|
||||||
|
else if builtins.isPath args
|
||||||
|
then builtins.toJSON (toString args)
|
||||||
|
else if builtins.isBool args
|
||||||
|
then "${boolToString args}"
|
||||||
|
else if builtins.isFloat args
|
||||||
|
then "${toString args}"
|
||||||
|
else if builtins.isInt args
|
||||||
|
then "${toString args}"
|
||||||
|
else if isNull args
|
||||||
|
then "nil"
|
||||||
|
else "";
|
||||||
|
|
||||||
nmap = mapVimBinding "nmap" config.vim.nmap;
|
toLuaBindings = mode: maps:
|
||||||
imap = mapVimBinding "imap" config.vim.imap;
|
builtins.map (value: ''
|
||||||
vmap = mapVimBinding "vmap" config.vim.vmap;
|
vim.keymap.set(${toLuaObject mode}, ${toLuaObject value.key}, ${toLuaObject value.action}, ${toLuaObject value.config})
|
||||||
xmap = mapVimBinding "xmap" config.vim.xmap;
|
'') (genMaps mode maps);
|
||||||
smap = mapVimBinding "smap" config.vim.smap;
|
|
||||||
cmap = mapVimBinding "cmap" config.vim.cmap;
|
|
||||||
omap = mapVimBinding "omap" config.vim.omap;
|
|
||||||
tmap = mapVimBinding "tmap" config.vim.tmap;
|
|
||||||
|
|
||||||
nnoremap = mapVimBinding "nnoremap" config.vim.nnoremap;
|
# I'm not sure if every one of these will work.
|
||||||
inoremap = mapVimBinding "inoremap" config.vim.inoremap;
|
allmap = toLuaBindings "" config.vim.maps.normalVisualOp;
|
||||||
vnoremap = mapVimBinding "vnoremap" config.vim.vnoremap;
|
nmap = toLuaBindings "n" config.vim.maps.normal;
|
||||||
xnoremap = mapVimBinding "xnoremap" config.vim.xnoremap;
|
vmap = toLuaBindings "v" config.vim.maps.visual;
|
||||||
snoremap = mapVimBinding "snoremap" config.vim.snoremap;
|
xmap = toLuaBindings "x" config.vim.maps.visualOnly;
|
||||||
cnoremap = mapVimBinding "cnoremap" config.vim.cnoremap;
|
smap = toLuaBindings "s" config.vim.maps.select;
|
||||||
onoremap = mapVimBinding "onoremap" config.vim.onoremap;
|
imap = toLuaBindings "i" config.vim.maps.insert;
|
||||||
tnoremap = mapVimBinding "tnoremap" config.vim.tnoremap;
|
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;
|
||||||
|
|
||||||
resolveDag = {
|
resolveDag = {
|
||||||
name,
|
name,
|
||||||
|
@ -208,9 +305,22 @@ in {
|
||||||
in
|
in
|
||||||
nvim.dag.entryAfter ["globalsScript"] luaConfig;
|
nvim.dag.entryAfter ["globalsScript"] luaConfig;
|
||||||
|
|
||||||
|
# This is probably not the right way to set the config. I'm not sure how it should look like.
|
||||||
mappings = let
|
mappings = let
|
||||||
maps = [nmap imap vmap xmap smap cmap omap tmap nnoremap inoremap vnoremap xnoremap snoremap cnoremap onoremap tnoremap];
|
maps = [
|
||||||
mapConfig = concatStringsSep "\n" (map (v: concatStringsSep "\n" v) maps);
|
nmap
|
||||||
|
imap
|
||||||
|
vmap
|
||||||
|
xmap
|
||||||
|
smap
|
||||||
|
cmap
|
||||||
|
omap
|
||||||
|
tmap
|
||||||
|
lmap
|
||||||
|
icmap
|
||||||
|
allmap
|
||||||
|
];
|
||||||
|
mapConfig = wrapLuaConfig (concatStringsSep "\n" (map (v: concatStringsSep "\n" v) maps));
|
||||||
in
|
in
|
||||||
nvim.dag.entryAfter ["globalsScript"] mapConfig;
|
nvim.dag.entryAfter ["globalsScript"] mapConfig;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,30 +1,29 @@
|
||||||
{
|
{
|
||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
|
pkgs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; let
|
with builtins; let
|
||||||
cfg = config.vim.filetree.nvimTreeLua;
|
cfg = config.vim.filetree.nvimTreeLua;
|
||||||
|
self = import ./nvimtree-lua.nix {
|
||||||
|
inherit pkgs;
|
||||||
|
lib = lib;
|
||||||
|
};
|
||||||
|
mappings = self.options.vim.filetree.nvimTreeLua.mappings;
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
vim.startPlugins = ["nvim-tree-lua"];
|
vim.startPlugins = ["nvim-tree-lua"];
|
||||||
|
|
||||||
# vim.nnoremap = {
|
vim.maps.normal = mkMerge [
|
||||||
# "<C-n>" = ":NvimTreeToggle<CR>";
|
(mkBinding cfg.mappings.toggle ":NvimTreeToggle<cr>" mappings.toggle.description)
|
||||||
# "<leader>tr" = ":NvimTreeRefresh<CR>";
|
(mkBinding cfg.mappings.refresh ":NvimTreeRefresh<cr>" mappings.refresh.description)
|
||||||
# "<leader>tg" = ":NvimTreeFindFile<CR>";
|
(mkBinding cfg.mappings.findFile ":NvimTreeFindFile<cr>" mappings.findFile.description)
|
||||||
# "<leader>tf" = ":NvimTreeFocus<CR>";
|
(mkBinding cfg.mappings.focus ":NvimTreeFocus<cr>" mappings.focus.description)
|
||||||
# };
|
];
|
||||||
|
|
||||||
vim.luaConfigRC.nvimtreelua = nvim.dag.entryAnywhere ''
|
vim.luaConfigRC.nvimtreelua = nvim.dag.entryAnywhere ''
|
||||||
local opts = { silent = true, noremap = true }
|
|
||||||
|
|
||||||
vim.api.nvim_set_keymap("n", "<C-n>", ":NvimTreeToggle<cr>", opts)
|
|
||||||
vim.api.nvim_set_keymap("n", "<leader>tr", ":NvimTreeRefresh<cr>", opts)
|
|
||||||
vim.api.nvim_set_keymap("n", "<leader>tg", ":NvimTreeFindFile<cr>", opts)
|
|
||||||
vim.api.nvim_set_keymap("n", "<leader>tf", ":NvimTreeFocus<cr>", opts)
|
|
||||||
|
|
||||||
local function open_nvim_tree(data)
|
local function open_nvim_tree(data)
|
||||||
local IGNORED_FT = {
|
local IGNORED_FT = {
|
||||||
"markdown",
|
"markdown",
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
{
|
{
|
||||||
pkgs,
|
pkgs,
|
||||||
config,
|
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
@ -13,6 +12,29 @@ with builtins; {
|
||||||
description = "Enable nvim-tree-lua";
|
description = "Enable nvim-tree-lua";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
mappings = {
|
||||||
|
toggle = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = "<C-n>";
|
||||||
|
description = "Toggle NvimTree";
|
||||||
|
};
|
||||||
|
refresh = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = "<leader>tr";
|
||||||
|
description = "Refresh NvimTree";
|
||||||
|
};
|
||||||
|
findFile = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = "<leader>tg";
|
||||||
|
description = "Find file in NvimTree";
|
||||||
|
};
|
||||||
|
focus = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
default = "<leader>tf";
|
||||||
|
description = "Focus NvimTree";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
sortBy = mkOption {
|
sortBy = mkOption {
|
||||||
default = "name";
|
default = "name";
|
||||||
description = "Sort by name or extension";
|
description = "Sort by name or extension";
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
{
|
{
|
||||||
pkgs,
|
|
||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
|
@ -7,40 +6,62 @@
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; let
|
with builtins; let
|
||||||
cfg = config.vim.git;
|
cfg = config.vim.git;
|
||||||
|
|
||||||
|
self = import ./git.nix {inherit lib;};
|
||||||
|
gsMappingDefinitions = self.options.vim.git.gitsigns.mappings;
|
||||||
|
|
||||||
|
gsMappings = addDescriptionsToMappings cfg.gitsigns.mappings gsMappingDefinitions;
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable (mkMerge [
|
config = mkIf cfg.enable (mkMerge [
|
||||||
(mkIf cfg.gitsigns.enable (mkMerge [
|
(mkIf cfg.gitsigns.enable (mkMerge [
|
||||||
{
|
{
|
||||||
vim.startPlugins = ["gitsigns-nvim"];
|
vim.startPlugins = ["gitsigns-nvim"];
|
||||||
|
|
||||||
|
vim.maps.normal = mkMerge [
|
||||||
|
(mkSetExprBinding gsMappings.nextHunk ''
|
||||||
|
function()
|
||||||
|
if vim.wo.diff then return ${toJSON gsMappings.nextHunk.value} end
|
||||||
|
|
||||||
|
vim.schedule(function() package.loaded.gitsigns.next_hunk() end)
|
||||||
|
|
||||||
|
return '<Ignore>'
|
||||||
|
end
|
||||||
|
'')
|
||||||
|
(mkSetExprBinding gsMappings.previousHunk ''
|
||||||
|
function()
|
||||||
|
if vim.wo.diff then return ${toJSON gsMappings.previousHunk.value} end
|
||||||
|
|
||||||
|
vim.schedule(function() package.loaded.gitsigns.prev_hunk() end)
|
||||||
|
|
||||||
|
return '<Ignore>'
|
||||||
|
end
|
||||||
|
'')
|
||||||
|
|
||||||
|
(mkSetLuaBinding gsMappings.stageHunk "package.loaded.gitsigns.stage_hunk")
|
||||||
|
(mkSetLuaBinding gsMappings.resetHunk "package.loaded.gitsigns.reset_hunk")
|
||||||
|
(mkSetLuaBinding gsMappings.undoStageHunk "package.loaded.gitsigns.undo_stage_hunk")
|
||||||
|
|
||||||
|
(mkSetLuaBinding gsMappings.stageBuffer "package.loaded.gitsigns.stage_buffer")
|
||||||
|
(mkSetLuaBinding gsMappings.resetBuffer "package.loaded.gitsigns.reset_buffer")
|
||||||
|
|
||||||
|
(mkSetLuaBinding gsMappings.previewHunk "package.loaded.gitsigns.preview_hunk")
|
||||||
|
|
||||||
|
(mkSetLuaBinding gsMappings.blameLine "function() package.loaded.gitsigns.blame_line{full=true} end")
|
||||||
|
(mkSetLuaBinding gsMappings.toggleBlame "package.loaded.gitsigns.toggle_current_line_blame")
|
||||||
|
|
||||||
|
(mkSetLuaBinding gsMappings.diffThis "package.loaded.gitsigns.diffthis")
|
||||||
|
(mkSetLuaBinding gsMappings.diffProject "function() package.loaded.gitsigns.diffthis('~') end")
|
||||||
|
|
||||||
|
(mkSetLuaBinding gsMappings.toggleDeleted "package.loaded.gitsigns.toggle_deleted")
|
||||||
|
];
|
||||||
|
|
||||||
|
vim.maps.visual = mkMerge [
|
||||||
|
(mkSetLuaBinding gsMappings.stageHunk "function() package.loaded.gitsigns.stage_hunk {vim.fn.line('.'), vim.fn.line('v')} end")
|
||||||
|
(mkSetLuaBinding gsMappings.resetHunk "function() package.loaded.gitsigns.reset_hunk {vim.fn.line('.'), vim.fn.line('v')} end")
|
||||||
|
];
|
||||||
|
|
||||||
vim.luaConfigRC.gitsigns = nvim.dag.entryAnywhere ''
|
vim.luaConfigRC.gitsigns = nvim.dag.entryAnywhere ''
|
||||||
require('gitsigns').setup {
|
require('gitsigns').setup{}
|
||||||
keymaps = {
|
|
||||||
noremap = true,
|
|
||||||
|
|
||||||
['n <leader>gn'] = { expr = true, "&diff ? \'\' : '<cmd>Gitsigns next_hunk<CR>'"},
|
|
||||||
['n <leader>gp'] = { expr = true, "&diff ? \'\' : '<cmd>Gitsigns prev_hunk<CR>'"},
|
|
||||||
|
|
||||||
['n <leader>gs'] = '<cmd>Gitsigns stage_hunk<CR>',
|
|
||||||
['v <leader>gs'] = ':Gitsigns stage_hunk<CR>',
|
|
||||||
['n <leader>gu'] = '<cmd>Gitsigns undo_stage_hunk<CR>',
|
|
||||||
['n <leader>gr'] = '<cmd>Gitsigns reset_hunk<CR>',
|
|
||||||
['v <leader>gr'] = ':Gitsigns reset_hunk<CR>',
|
|
||||||
['n <leader>gR'] = '<cmd>Gitsigns reset_buffer<CR>',
|
|
||||||
['n <leader>gp'] = '<cmd>Gitsigns preview_hunk<CR>',
|
|
||||||
['n <leader>gb'] = '<cmd>lua require"gitsigns".blame_line{full=true}<CR>',
|
|
||||||
['n <leader>gS'] = '<cmd>Gitsigns stage_buffer<CR>',
|
|
||||||
['n <leader>gU'] = '<cmd>Gitsigns reset_buffer_index<CR>',
|
|
||||||
['n <leader>gts'] = ':Gitsigns toggle_signs<CR>',
|
|
||||||
['n <leader>gtn'] = ':Gitsigns toggle_numhl<CR>',
|
|
||||||
['n <leader>gtl'] = ':Gitsigns toggle_linehl<CR>',
|
|
||||||
['n <leader>gtw'] = ':Gitsigns toggle_word_diff<CR>',
|
|
||||||
|
|
||||||
-- Text objects
|
|
||||||
['o ih'] = ':<C-U>Gitsigns select_hunk<CR>',
|
|
||||||
['x ih'] = ':<C-U>Gitsigns select_hunk<CR>'
|
|
||||||
},
|
|
||||||
}
|
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,34 @@
|
||||||
{
|
{lib, ...}:
|
||||||
pkgs,
|
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; let
|
with builtins; {
|
||||||
cfg = config.vim.git;
|
|
||||||
in {
|
|
||||||
options.vim.git = {
|
options.vim.git = {
|
||||||
enable = mkEnableOption "Git support";
|
enable = mkEnableOption "Git support";
|
||||||
|
|
||||||
gitsigns = {
|
gitsigns = {
|
||||||
enable = mkEnableOption "gitsigns";
|
enable = mkEnableOption "gitsigns";
|
||||||
|
|
||||||
|
mappings = {
|
||||||
|
nextHunk = mkMappingOption "Next hunk [Gitsigns]" "]c";
|
||||||
|
previousHunk = mkMappingOption "Previous hunk [Gitsigns]" "[c";
|
||||||
|
|
||||||
|
stageHunk = mkMappingOption "Stage hunk [Gitsigns]" "<leader>hs";
|
||||||
|
undoStageHunk = mkMappingOption "Undo stage hunk [Gitsigns]" "<leader>hu";
|
||||||
|
resetHunk = mkMappingOption "Reset hunk [Gitsigns]" "<leader>hr";
|
||||||
|
|
||||||
|
stageBuffer = mkMappingOption "Stage buffer [Gitsigns]" "<leader>hS";
|
||||||
|
resetBuffer = mkMappingOption "Reset buffer [Gitsigns]" "<leader>hR";
|
||||||
|
|
||||||
|
previewHunk = mkMappingOption "Preview hunk [Gitsigns]" "<leader>hP";
|
||||||
|
|
||||||
|
blameLine = mkMappingOption "Blame line [Gitsigns]" "<leader>hb";
|
||||||
|
toggleBlame = mkMappingOption "Toggle blame [Gitsigns]" "<leader>tb";
|
||||||
|
|
||||||
|
diffThis = mkMappingOption "Diff this [Gitsigns]" "<leader>hd";
|
||||||
|
diffProject = mkMappingOption "Diff project [Gitsigns]" "<leader>hD";
|
||||||
|
|
||||||
|
toggleDeleted = mkMappingOption "Toggle deleted [Gitsigns]" "<leader>td";
|
||||||
|
};
|
||||||
|
|
||||||
codeActions = mkEnableOption "gitsigns codeactions through null-ls";
|
codeActions = mkEnableOption "gitsigns codeactions through null-ls";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,41 +6,35 @@
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; let
|
with builtins; let
|
||||||
cfg = config.vim.lsp;
|
cfg = config.vim.lsp;
|
||||||
|
self = import ./lspsaga.nix {inherit lib;};
|
||||||
|
|
||||||
|
mappingDefinitions = self.options.vim.lsp.lspsaga.mappings;
|
||||||
|
mappings = addDescriptionsToMappings cfg.lspsaga.mappings mappingDefinitions;
|
||||||
in {
|
in {
|
||||||
config = mkIf (cfg.enable && cfg.lspsaga.enable) {
|
config = mkIf (cfg.enable && cfg.lspsaga.enable) {
|
||||||
vim.startPlugins = ["lspsaga"];
|
vim.startPlugins = ["lspsaga"];
|
||||||
|
|
||||||
vim.vnoremap = {
|
vim.maps.visual = mkSetLuaBinding mappings.codeAction "require('lspsaga.codeaction').range_code_action";
|
||||||
"<silent><leader>ca" = ":<C-U>lua require('lspsaga.codeaction').range_code_action()<CR>";
|
|
||||||
};
|
|
||||||
|
|
||||||
vim.nnoremap =
|
vim.maps.normal = mkMerge [
|
||||||
{
|
(mkSetLuaBinding mappings.lspFinder "require('lspsaga.provider').lsp_finder")
|
||||||
"<silent><leader>lf" = "<cmd>lua require'lspsaga.provider'.lsp_finder()<CR>";
|
(mkSetLuaBinding mappings.renderHoveredDoc "require('lspsaga.hover').render_hover_doc")
|
||||||
"<silent><leader>lh" = "<cmd>lua require('lspsaga.hover').render_hover_doc()<CR>";
|
|
||||||
"<silent><C-f>" = "<cmd>lua require('lspsaga.action').smart_scroll_with_saga(1)<CR>";
|
(mkSetLuaBinding mappings.smartScrollUp "function() require('lspsaga.action').smart_scroll_with_saga(-1) end")
|
||||||
"<silent><C-b>" = "<cmd>lua require('lspsaga.action').smart_scroll_with_saga(-1)<CR>";
|
(mkSetLuaBinding mappings.smartScrollDown "function() require('lspsaga.action').smart_scroll_with_saga(1) end")
|
||||||
"<silent><leader>lr" = "<cmd>lua require'lspsaga.rename'.rename()<CR>";
|
|
||||||
"<silent><leader>ld" = "<cmd>lua require'lspsaga.provider'.preview_definition()<CR>";
|
(mkSetLuaBinding mappings.rename "require('lspsaga.rename').rename")
|
||||||
"<silent><leader>ll" = "<cmd>lua require'lspsaga.diagnostic'.show_line_diagnostics()<CR>";
|
(mkSetLuaBinding mappings.previewDefinition "require('lspsaga.provider').preview_definition")
|
||||||
"<silent><leader>lc" = "<cmd>lua require'lspsaga.diagnostic'.show_cursor_diagnostics()<CR>";
|
|
||||||
"<silent><leader>lp" = "<cmd>lua require'lspsaga.diagnostic'.lsp_jump_diagnostic_prev()<CR>";
|
(mkSetLuaBinding mappings.showLineDiagnostics "require('lspsaga.diagnostic').show_line_diagnostics")
|
||||||
"<silent><leader>ln" = "<cmd>lua require'lspsaga.diagnostic'.lsp_jump_diagnostic_next()<CR>";
|
(mkSetLuaBinding mappings.showCursorDiagnostics "require('lspsaga.diagnostic').show_cursor_diagnostics")
|
||||||
}
|
|
||||||
// (
|
(mkSetLuaBinding mappings.nextDiagnostic "require('lspsaga.diagnostic').navigate('next')")
|
||||||
if (!cfg.nvimCodeActionMenu.enable)
|
(mkSetLuaBinding mappings.previousDiagnostic "require('lspsaga.diagnostic').navigate('prev')")
|
||||||
then {
|
|
||||||
"<silent><leader>ca" = "<cmd>lua require('lspsaga.codeaction').code_action()<CR>";
|
(mkIf (!cfg.nvimCodeActionMenu.enable) (mkSetLuaBinding mappings.codeAction "require('lspsaga.codeaction').code_action"))
|
||||||
}
|
(mkIf (!cfg.lspSignature.enable) (mkSetLuaBinding mappings.signatureHelp "require('lspsaga.signaturehelp').signature_help"))
|
||||||
else {}
|
];
|
||||||
)
|
|
||||||
// (
|
|
||||||
if (!cfg.lspSignature.enable)
|
|
||||||
then {
|
|
||||||
"<silent><leader>ls" = "<cmd>lua require('lspsaga.signaturehelp').signature_help()<CR>";
|
|
||||||
}
|
|
||||||
else {}
|
|
||||||
);
|
|
||||||
|
|
||||||
vim.luaConfigRC.lspsage = nvim.dag.entryAnywhere ''
|
vim.luaConfigRC.lspsage = nvim.dag.entryAnywhere ''
|
||||||
-- Enable lspsaga
|
-- Enable lspsaga
|
||||||
|
|
|
@ -1,53 +1,28 @@
|
||||||
{
|
{lib, ...}:
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; let
|
with builtins; {
|
||||||
cfg = config.vim.lsp;
|
options.vim.lsp.lspsaga = {
|
||||||
in {
|
enable = mkEnableOption "LSP Saga";
|
||||||
options.vim.lsp = {lspsaga = {enable = mkEnableOption "LSP Saga";};};
|
|
||||||
|
|
||||||
config = mkIf (cfg.enable && cfg.lspsaga.enable) {
|
mappings = {
|
||||||
vim.startPlugins = ["lspsaga"];
|
lspFinder = mkMappingOption "LSP Finder [LSPSaga]" "<leader>lf";
|
||||||
|
renderHoveredDoc = mkMappingOption "Rendered hovered docs [LSPSaga]" "<leader>lh";
|
||||||
|
|
||||||
vim.vnoremap = {
|
smartScrollUp = mkMappingOption "Smart scroll up [LSPSaga]" "<C-f>";
|
||||||
"<silent><leader>ca" = ":<C-U>lua require('lspsaga.codeaction').range_code_action()<CR>";
|
smartScrollDown = mkMappingOption "Smart scroll up [LSPSaga]" "<C-b>";
|
||||||
|
|
||||||
|
rename = mkMappingOption "Rename [LSPSaga]" "<leader>lr";
|
||||||
|
previewDefinition = mkMappingOption "Preview definition [LSPSaga]" "<leader>ld";
|
||||||
|
|
||||||
|
showLineDiagnostics = mkMappingOption "Show line diagnostics [LSPSaga]" "<leader>ll";
|
||||||
|
showCursorDiagnostics = mkMappingOption "Show cursor diagnostics [LSPSaga]" "<leader>lc";
|
||||||
|
|
||||||
|
nextDiagnostic = mkMappingOption "Next diagnostic [LSPSaga]" "<leader>ln";
|
||||||
|
previousDiagnostic = mkMappingOption "Previous diagnostic [LSPSaga]" "<leader>lp";
|
||||||
|
|
||||||
|
codeAction = mkMappingOption "Code action [LSPSaga]" "<leader>ca";
|
||||||
|
|
||||||
|
signatureHelp = mkMappingOption "Signature help [LSPSaga]" "<ledaer>ls";
|
||||||
};
|
};
|
||||||
|
|
||||||
vim.nnoremap =
|
|
||||||
{
|
|
||||||
"<silent><leader>lf" = "<cmd>lua require'lspsaga.provider'.lsp_finder()<CR>";
|
|
||||||
"<silent><leader>lh" = "<cmd>lua require('lspsaga.hover').render_hover_doc()<CR>";
|
|
||||||
"<silent><C-f>" = "<cmd>lua require('lspsaga.action').smart_scroll_with_saga(1)<CR>";
|
|
||||||
"<silent><C-b>" = "<cmd>lua require('lspsaga.action').smart_scroll_with_saga(-1)<CR>";
|
|
||||||
"<silent><leader>lr" = "<cmd>lua require'lspsaga.rename'.rename()<CR>";
|
|
||||||
"<silent><leader>ld" = "<cmd>lua require'lspsaga.provider'.preview_definition()<CR>";
|
|
||||||
"<silent><leader>ll" = "<cmd>lua require'lspsaga.diagnostic'.show_line_diagnostics()<CR>";
|
|
||||||
"<silent><leader>lc" = "<cmd>lua require'lspsaga.diagnostic'.show_cursor_diagnostics()<CR>";
|
|
||||||
"<silent><leader>lp" = "<cmd>lua require'lspsaga.diagnostic'.lsp_jump_diagnostic_prev()<CR>";
|
|
||||||
"<silent><leader>ln" = "<cmd>lua require'lspsaga.diagnostic'.lsp_jump_diagnostic_next()<CR>";
|
|
||||||
}
|
|
||||||
// (
|
|
||||||
if (!cfg.nvimCodeActionMenu.enable)
|
|
||||||
then {
|
|
||||||
"<silent><leader>ca" = "<cmd>lua require('lspsaga.codeaction').code_action()<CR>";
|
|
||||||
}
|
|
||||||
else {}
|
|
||||||
)
|
|
||||||
// (
|
|
||||||
if (!cfg.lspSignature.enable)
|
|
||||||
then {
|
|
||||||
"<silent><leader>ls" = "<cmd>lua require('lspsaga.signaturehelp').signature_help()<CR>";
|
|
||||||
}
|
|
||||||
else {}
|
|
||||||
);
|
|
||||||
|
|
||||||
vim.luaConfigRC.lspsage = nvim.dag.entryAnywhere ''
|
|
||||||
-- Enable lspsaga
|
|
||||||
local saga = require 'lspsaga'
|
|
||||||
saga.init_lsp_saga()
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,12 +6,15 @@
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; let
|
with builtins; let
|
||||||
cfg = config.vim.lsp;
|
cfg = config.vim.lsp;
|
||||||
|
|
||||||
|
self = import ./nvim-code-action-menu.nix {inherit lib;};
|
||||||
|
|
||||||
|
mappingDefinitions = self.options.vim.lsp.nvimCodeActionMenu.mappings;
|
||||||
|
mappings = addDescriptionsToMappings cfg.nvimCodeActionMenu.mappings mappingDefinitions;
|
||||||
in {
|
in {
|
||||||
config = mkIf (cfg.enable && cfg.nvimCodeActionMenu.enable) {
|
config = mkIf (cfg.enable && cfg.nvimCodeActionMenu.enable) {
|
||||||
vim.startPlugins = ["nvim-code-action-menu"];
|
vim.startPlugins = ["nvim-code-action-menu"];
|
||||||
|
|
||||||
vim.nnoremap = {
|
vim.maps.normal = mkSetBinding mappings.open ":CodeActionMenu<CR>";
|
||||||
"<silent><leader>ca" = ":CodeActionMenu<CR>";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
{
|
{lib, ...}:
|
||||||
config,
|
with lib; {
|
||||||
lib,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
with lib;
|
|
||||||
with builtins; {
|
|
||||||
options.vim.lsp = {
|
options.vim.lsp = {
|
||||||
nvimCodeActionMenu = {
|
nvimCodeActionMenu = {
|
||||||
enable = mkEnableOption "Enable nvim code action menu";
|
enable = mkEnableOption "Enable nvim code action menu";
|
||||||
|
|
||||||
|
mappings = {
|
||||||
|
open = mkMappingOption "Open code action menu [nvim-code-action-menu]" "<leader>ca";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,18 +6,23 @@
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; let
|
with builtins; let
|
||||||
cfg = config.vim.lsp;
|
cfg = config.vim.lsp;
|
||||||
|
|
||||||
|
self = import ./trouble.nix {inherit lib;};
|
||||||
|
|
||||||
|
mappingDefinitions = self.options.vim.lsp.trouble.mappings;
|
||||||
|
mappings = addDescriptionsToMappings cfg.trouble.mappings mappingDefinitions;
|
||||||
in {
|
in {
|
||||||
config = mkIf (cfg.enable && cfg.trouble.enable) {
|
config = mkIf (cfg.enable && cfg.trouble.enable) {
|
||||||
vim.startPlugins = ["trouble"];
|
vim.startPlugins = ["trouble"];
|
||||||
|
|
||||||
vim.nnoremap = {
|
vim.maps.normal = mkMerge [
|
||||||
"<leader>xx" = "<cmd>TroubleToggle<CR>";
|
(mkSetBinding mappings.toggle "<cmd>TroubleToggle<CR>")
|
||||||
"<leader>lwd" = "<cmd>TroubleToggle workspace_diagnostics<CR>";
|
(mkSetBinding mappings.workspaceDiagnostics "<cmd>TroubleToggle workspace_diagnostics<CR>")
|
||||||
"<leader>ld" = "<cmd>TroubleToggle document_diagnostics<CR>";
|
(mkSetBinding mappings.documentDiagnostics "<cmd>TroubleToggle document_diagnostics<CR>")
|
||||||
"<leader>lr" = "<cmd>TroubleToggle lsp_references<CR>";
|
(mkSetBinding mappings.lspReferences "<cmd>TroubleToggle lsp_references<CR>")
|
||||||
"<leader>xq" = "<cmd>TroubleToggle quickfix<CR>";
|
(mkSetBinding mappings.quickfix "<cmd>TroubleToggle quickfix<CR>")
|
||||||
"<leader>xl" = "<cmd>TroubleToggle loclist<CR>";
|
(mkSetBinding mappings.locList "<cmd>TroubleToggle loclist<CR>")
|
||||||
};
|
];
|
||||||
|
|
||||||
vim.luaConfigRC.trouble = nvim.dag.entryAnywhere ''
|
vim.luaConfigRC.trouble = nvim.dag.entryAnywhere ''
|
||||||
-- Enable trouble diagnostics viewer
|
-- Enable trouble diagnostics viewer
|
||||||
|
|
|
@ -1,13 +1,17 @@
|
||||||
{
|
{lib, ...}:
|
||||||
config,
|
with lib; {
|
||||||
lib,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
with lib;
|
|
||||||
with builtins; {
|
|
||||||
options.vim.lsp = {
|
options.vim.lsp = {
|
||||||
trouble = {
|
trouble = {
|
||||||
enable = mkEnableOption "Enable trouble diagnostics viewer";
|
enable = mkEnableOption "Enable trouble diagnostics viewer";
|
||||||
|
|
||||||
|
mappings = {
|
||||||
|
toggle = mkMappingOption "Toggle trouble [trouble]" "<leader>xx";
|
||||||
|
workspaceDiagnostics = mkMappingOption "Workspace diagnostics [trouble]" "<leader>lwd";
|
||||||
|
documentDiagnostics = mkMappingOption "Document diagnostics [trouble]" "<leader>ld";
|
||||||
|
lspReferences = mkMappingOption "LSP References [trouble]" "<leader>lr";
|
||||||
|
quickfix = mkMappingOption "QuickFix [trouble]" "<leader>xq";
|
||||||
|
locList = mkMappingOption "LOCList [trouble]" "<leader>xl";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
{
|
{lib, ...}:
|
||||||
config,
|
with lib; {
|
||||||
lib,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
with lib;
|
|
||||||
with builtins; {
|
|
||||||
options.vim.minimap.codewindow = {
|
options.vim.minimap.codewindow = {
|
||||||
enable = mkEnableOption "Enable codewindow plugin for minimap view";
|
enable = mkEnableOption "Enable codewindow plugin for minimap view";
|
||||||
|
|
||||||
|
mappings = {
|
||||||
|
open = mkMappingOption "Open minimap [codewindow]" "<leader>mo";
|
||||||
|
close = mkMappingOption "Close minimap [codewindow]" "<leader>mc";
|
||||||
|
toggle = mkMappingOption "Toggle minimap [codewindow]" "<leader>mm";
|
||||||
|
toggleFocus = mkMappingOption "Toggle minimap focus [codewindow]" "<leader>mf";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,19 +6,29 @@
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; let
|
with builtins; let
|
||||||
cfg = config.vim.minimap.codewindow;
|
cfg = config.vim.minimap.codewindow;
|
||||||
|
|
||||||
|
self = import ./codewindow.nix {inherit lib;};
|
||||||
|
|
||||||
|
mappingDefinitions = self.options.vim.minimap.codewindow.mappings;
|
||||||
|
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
vim.startPlugins = [
|
vim.startPlugins = [
|
||||||
"codewindow-nvim"
|
"codewindow-nvim"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
vim.maps.normal = mkMerge [
|
||||||
|
(mkSetLuaBinding mappings.open "require('codewindow').open_minimap")
|
||||||
|
(mkSetLuaBinding mappings.close "require('codewindow').close_minimap")
|
||||||
|
(mkSetLuaBinding mappings.toggle "require('codewindow').toggle_minimap")
|
||||||
|
(mkSetLuaBinding mappings.toggleFocus "require('codewindow').toggle_focus")
|
||||||
|
];
|
||||||
|
|
||||||
vim.luaConfigRC.codewindow = nvim.dag.entryAnywhere ''
|
vim.luaConfigRC.codewindow = nvim.dag.entryAnywhere ''
|
||||||
local codewindow = require('codewindow')
|
local codewindow = require('codewindow')
|
||||||
codewindow.setup({
|
codewindow.setup({
|
||||||
exclude_filetypes = { 'NvimTree', 'orgagenda'},
|
exclude_filetypes = { 'NvimTree', 'orgagenda'},
|
||||||
}
|
})
|
||||||
)
|
|
||||||
codewindow.apply_default_keybinds()
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,10 +12,10 @@ in {
|
||||||
"mind-nvim"
|
"mind-nvim"
|
||||||
];
|
];
|
||||||
|
|
||||||
vim.nnoremap = {
|
vim.maps.normal = {
|
||||||
"<leader>om" = ":MindOpenMain<CR>";
|
"<leader>om" = {action = ":MindOpenMain<CR>";};
|
||||||
"<leader>op" = ":MindOpenProject<CR>";
|
"<leader>op" = {action = ":MindOpenProject<CR>";};
|
||||||
"<leader>oc" = ":MindClose<CR>";
|
"<leader>oc" = {action = ":MindClose<CR>";};
|
||||||
};
|
};
|
||||||
|
|
||||||
vim.luaConfigRC.mind-nvim = nvim.dag.entryAnywhere ''
|
vim.luaConfigRC.mind-nvim = nvim.dag.entryAnywhere ''
|
||||||
|
|
|
@ -7,17 +7,19 @@
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; let
|
with builtins; let
|
||||||
cfg = config.vim.notes.todo-comments;
|
cfg = config.vim.notes.todo-comments;
|
||||||
|
self = import ./todo-comments.nix {inherit lib;};
|
||||||
|
mappings = self.options.vim.notes.todo-comments.mappings;
|
||||||
in {
|
in {
|
||||||
config = mkIf (cfg.enable) {
|
config = mkIf (cfg.enable) {
|
||||||
vim.startPlugins = [
|
vim.startPlugins = [
|
||||||
"todo-comments"
|
"todo-comments"
|
||||||
];
|
];
|
||||||
|
|
||||||
vim.nnoremap = {
|
vim.maps.normal = mkMerge [
|
||||||
"<leader>tdq" = ":TodoQuickFix<CR>";
|
(mkBinding cfg.mappings.quickFix ":TodoQuickFix<CR>" mappings.quickFix.description)
|
||||||
"<leader>tds" = ":TodoTelescope<CR>";
|
(mkIf config.vim.telescope.enable (mkBinding cfg.mappings.telescope ":TodoTelescope<CR>" mappings.telescope.description))
|
||||||
"<leader>tdt" = ":TodoTrouble<CR>";
|
(mkIf config.vim.lsp.trouble.enable (mkBinding cfg.mappings.trouble ":TodoTrouble<CR>" mappings.trouble.description))
|
||||||
};
|
];
|
||||||
|
|
||||||
vim.luaConfigRC.todo-comments = ''
|
vim.luaConfigRC.todo-comments = ''
|
||||||
require('todo-comments').setup {
|
require('todo-comments').setup {
|
||||||
|
|
|
@ -1,8 +1,4 @@
|
||||||
{
|
{lib, ...}:
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; {
|
with builtins; {
|
||||||
options.vim.notes.todo-comments = {
|
options.vim.notes.todo-comments = {
|
||||||
|
@ -21,5 +17,11 @@ with builtins; {
|
||||||
description = "ripgrep regex pattern used for searching comments";
|
description = "ripgrep regex pattern used for searching comments";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
mappings = {
|
||||||
|
quickFix = mkMappingOption "Open Todo-s in a quickfix list" "<leader>tdq";
|
||||||
|
telescope = mkMappingOption "Open Todo-s in telescope" "<leader>tds";
|
||||||
|
trouble = mkMappingOption "Open Todo-s in Trouble" "<leader>tdt";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,13 +15,13 @@ in {
|
||||||
]
|
]
|
||||||
++ optionals (cfg.usePicker) ["dressing-nvim"];
|
++ optionals (cfg.usePicker) ["dressing-nvim"];
|
||||||
|
|
||||||
vim.nnoremap = {
|
vim.maps.normal = mkMerge [
|
||||||
"<leader>sl" = ":SessionManager load_session<CR>";
|
(mkBinding cfg.mappings.loadSession ":SessionManager load_session<CR>" "Load session")
|
||||||
"<leader>sd" = ":SessionManager delete_session<CR>";
|
(mkBinding cfg.mappings.deleteSession ":SessionManager delete_session<CR>" "Delete session")
|
||||||
"<leader>sc" = ":SessionManager save_current_session<CR>";
|
(mkBinding cfg.mappings.saveCurrentSession ":SessionManager save_current_session<CR>" "Save current session")
|
||||||
"<leader>slt" = ":SessionManager load_last_session<CR>";
|
(mkBinding cfg.mappings.loadLastSession ":SessionManager load_last_session<CR>" "Load last session")
|
||||||
# TODO: load_current_dir_session
|
# TODO: load_current_dir_session
|
||||||
};
|
];
|
||||||
|
|
||||||
vim.luaConfigRC.nvim-session-manager = nvim.dag.entryAnywhere ''
|
vim.luaConfigRC.nvim-session-manager = nvim.dag.entryAnywhere ''
|
||||||
local Path = require('plenary.path')
|
local Path = require('plenary.path')
|
||||||
|
|
|
@ -8,6 +8,29 @@ with builtins; {
|
||||||
options.vim.session.nvim-session-manager = {
|
options.vim.session.nvim-session-manager = {
|
||||||
enable = mkEnableOption "Enable nvim-session-manager";
|
enable = mkEnableOption "Enable nvim-session-manager";
|
||||||
|
|
||||||
|
mappings = {
|
||||||
|
loadSession = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
description = "Load session";
|
||||||
|
default = "<leader>sl";
|
||||||
|
};
|
||||||
|
deleteSession = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
description = "Delete session";
|
||||||
|
default = "<leader>sd";
|
||||||
|
};
|
||||||
|
saveCurrentSession = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
description = "Save current session";
|
||||||
|
default = "<leader>sc";
|
||||||
|
};
|
||||||
|
loadLastSession = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
description = "Load last session";
|
||||||
|
default = "<leader>slt";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
usePicker = mkOption {
|
usePicker = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = true;
|
default = true;
|
||||||
|
|
|
@ -6,6 +6,10 @@
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; let
|
with builtins; let
|
||||||
cfg = config.vim.tabline.nvimBufferline;
|
cfg = config.vim.tabline.nvimBufferline;
|
||||||
|
self = import ./nvim-bufferline.nix {
|
||||||
|
inherit lib;
|
||||||
|
};
|
||||||
|
mappings = self.options.vim.tabline.nvimBufferline.mappings;
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable (
|
config = mkIf cfg.enable (
|
||||||
let
|
let
|
||||||
|
@ -23,25 +27,18 @@ in {
|
||||||
"bufdelete-nvim"
|
"bufdelete-nvim"
|
||||||
];
|
];
|
||||||
|
|
||||||
vim.nnoremap = {
|
vim.maps.normal = mkMerge [
|
||||||
"<silent><leader>bn" = ":BufferLineCycleNext<CR>";
|
(mkLuaBinding cfg.mappings.closeCurrent "require(\"bufdelete\").bufdelete" mappings.closeCurrent.description)
|
||||||
"<silent><leader>bp" = ":BufferLineCyclePrev<CR>";
|
(mkBinding cfg.mappings.cycleNext ":BufferLineCycleNext<CR>" mappings.cycleNext.description)
|
||||||
"<silent><leader>bc" = ":BufferLinePick<CR>";
|
(mkBinding cfg.mappings.cycleNext ":BufferLineCycleNext<CR>" mappings.cycleNext.description)
|
||||||
"<silent><leader>bse" = ":BufferLineSortByExtension<CR>";
|
(mkBinding cfg.mappings.cyclePrevious ":BufferLineCyclePrev<CR>" mappings.cyclePrevious.description)
|
||||||
"<silent><leader>bsd" = ":BufferLineSortByDirectory<CR>";
|
(mkBinding cfg.mappings.pick ":BufferLinePick<CR>" mappings.pick.description)
|
||||||
"<silent><leader>bsi" = ":lua require'bufferline'.sort_buffers_by(function (buf_a, buf_b) return buf_a.id < buf_b.id end)<CR>";
|
(mkBinding cfg.mappings.sortByExtension ":BufferLineSortByExtension<CR>" mappings.sortByExtension.description)
|
||||||
"<silent><leader>bmn" = ":BufferLineMoveNext<CR>";
|
(mkBinding cfg.mappings.sortByDirectory ":BufferLineSortByDirectory<CR>" mappings.sortByDirectory.description)
|
||||||
"<silent><leader>bmp" = ":BufferLineMovePrev<CR>";
|
(mkLuaBinding cfg.mappings.sortById "function() require(\"bufferline\").sort_buffers_by(function (buf_a, buf_b) return buf_a.id < buf_b.id end) end" mappings.sortById.description)
|
||||||
"<silent><leader>b1" = "<Cmd>BufferLineGoToBuffer 1<CR>";
|
(mkBinding cfg.mappings.moveNext ":BufferLineMoveNext<CR>" mappings.moveNext.description)
|
||||||
"<silent><leader>b2" = "<Cmd>BufferLineGoToBuffer 2<CR>";
|
(mkBinding cfg.mappings.movePrevious ":BufferLineMovePrev<CR>" mappings.movePrevious.description)
|
||||||
"<silent><leader>b3" = "<Cmd>BufferLineGoToBuffer 3<CR>";
|
];
|
||||||
"<silent><leader>b4" = "<Cmd>BufferLineGoToBuffer 4<CR>";
|
|
||||||
"<silent><leader>b5" = "<Cmd>BufferLineGoToBuffer 5<CR>";
|
|
||||||
"<silent><leader>b6" = "<Cmd>BufferLineGoToBuffer 6<CR>";
|
|
||||||
"<silent><leader>b7" = "<Cmd>BufferLineGoToBuffer 7<CR>";
|
|
||||||
"<silent><leader>b8" = "<Cmd>BufferLineGoToBuffer 8<CR>";
|
|
||||||
"<silent><leader>b9" = "<Cmd>BufferLineGoToBuffer 9<CR>";
|
|
||||||
};
|
|
||||||
|
|
||||||
vim.luaConfigRC.nvimBufferline = nvim.dag.entryAnywhere ''
|
vim.luaConfigRC.nvimBufferline = nvim.dag.entryAnywhere ''
|
||||||
require("bufferline").setup{
|
require("bufferline").setup{
|
||||||
|
@ -51,8 +48,8 @@ in {
|
||||||
close_command = ${mouse.close},
|
close_command = ${mouse.close},
|
||||||
right_mouse_command = ${mouse.right},
|
right_mouse_command = ${mouse.right},
|
||||||
indicator = {
|
indicator = {
|
||||||
style = 'underline',
|
style = 'icon',
|
||||||
-- indicator_icon = '▎',
|
indicator_icon = '▎',
|
||||||
},
|
},
|
||||||
buffer_close_icon = '',
|
buffer_close_icon = '',
|
||||||
modified_icon = '●',
|
modified_icon = '●',
|
||||||
|
|
|
@ -1,11 +1,19 @@
|
||||||
{
|
{lib, ...}:
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; {
|
with builtins; {
|
||||||
options.vim.tabline.nvimBufferline = {
|
options.vim.tabline.nvimBufferline = {
|
||||||
|
mappings = {
|
||||||
|
closeCurrent = mkMappingOption "Close buffer" null;
|
||||||
|
cycleNext = mkMappingOption "Next buffer" "<leader>bn";
|
||||||
|
cyclePrevious = mkMappingOption "Previous buffer" "<leader>bp";
|
||||||
|
pick = mkMappingOption "Pick buffer" "<leader>bc";
|
||||||
|
sortByExtension = mkMappingOption "Sort buffers by extension" "<leader>bse";
|
||||||
|
sortByDirectory = mkMappingOption "Sort buffers by directory" "<leader>bsd";
|
||||||
|
sortById = mkMappingOption "Sort buffers by ID" "<leader>bsi";
|
||||||
|
moveNext = mkMappingOption "Move next buffer" "<leader>bmn";
|
||||||
|
movePrevious = mkMappingOption "Move previous buffer" "<leader>bmp";
|
||||||
|
};
|
||||||
|
|
||||||
enable = mkEnableOption "Enable nvim-bufferline-lua as a bufferline";
|
enable = mkEnableOption "Enable nvim-bufferline-lua as a bufferline";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; let
|
with builtins; let
|
||||||
cfg = config.vim.terminal.toggleterm;
|
cfg = config.vim.terminal.toggleterm;
|
||||||
toggleKey = "<c-t>";
|
|
||||||
in {
|
in {
|
||||||
config = mkMerge [
|
config = mkMerge [
|
||||||
(
|
(
|
||||||
|
@ -15,9 +14,11 @@ in {
|
||||||
"toggleterm-nvim"
|
"toggleterm-nvim"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
vim.maps.normal = mkBinding cfg.mappings.open "<Cmd>execute v:count . \"ToggleTerm\"<CR>" "Toggle terminal";
|
||||||
|
|
||||||
vim.luaConfigRC.toggleterm = nvim.dag.entryAnywhere ''
|
vim.luaConfigRC.toggleterm = nvim.dag.entryAnywhere ''
|
||||||
require("toggleterm").setup({
|
require("toggleterm").setup({
|
||||||
open_mapping = [[${toggleKey}]],
|
open_mapping = null,
|
||||||
direction = '${toString cfg.direction}',
|
direction = '${toString cfg.direction}',
|
||||||
-- TODO: this should probably be turned into a module that uses the lua function if and only if the user has not set it
|
-- TODO: this should probably be turned into a module that uses the lua function if and only if the user has not set it
|
||||||
size = function(term)
|
size = function(term)
|
||||||
|
@ -55,11 +56,10 @@ in {
|
||||||
hidden = true,
|
hidden = true,
|
||||||
on_open = function(term)
|
on_open = function(term)
|
||||||
vim.cmd("startinsert!")
|
vim.cmd("startinsert!")
|
||||||
vim.keymap.set( 't', [[${toggleKey}]], function() term:toggle() end, {silent = true, noremap = true, buffer = term.bufnr})
|
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
vim.keymap.set( 'n', [[<leader>gg]], function() lazygit:toggle() end, {silent = true, noremap = true})
|
vim.keymap.set('n', ${toJSON cfg.lazygit.mappings.open}, function() lazygit:toggle() end, {silent = true, noremap = true, desc = 'Open lazygit [toggleterm]'})
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -8,6 +8,13 @@ with lib;
|
||||||
with builtins; {
|
with builtins; {
|
||||||
options.vim.terminal.toggleterm = {
|
options.vim.terminal.toggleterm = {
|
||||||
enable = mkEnableOption "Enable toggleterm as a replacement to built-in terminal command";
|
enable = mkEnableOption "Enable toggleterm as a replacement to built-in terminal command";
|
||||||
|
mappings = {
|
||||||
|
open = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
description = "The keymapping to open toggleterm";
|
||||||
|
default = "<c-t>";
|
||||||
|
};
|
||||||
|
};
|
||||||
direction = mkOption {
|
direction = mkOption {
|
||||||
type = types.enum ["horizontal" "vertical" "tab" "float"];
|
type = types.enum ["horizontal" "vertical" "tab" "float"];
|
||||||
default = "horizontal";
|
default = "horizontal";
|
||||||
|
@ -30,6 +37,10 @@ with builtins; {
|
||||||
default = pkgs.lazygit;
|
default = pkgs.lazygit;
|
||||||
description = "The package that should be used for lazygit. Setting it to null will attempt to use lazygit from your PATH";
|
description = "The package that should be used for lazygit. Setting it to null will attempt to use lazygit from your PATH";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
mappings = {
|
||||||
|
open = mkMappingOption "Open lazygit [toggleterm]" "<leader>gg";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
{
|
{
|
||||||
pkgs,
|
|
||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
|
@ -8,6 +7,11 @@ with lib;
|
||||||
with builtins; let
|
with builtins; let
|
||||||
cfg = config.vim.treesitter;
|
cfg = config.vim.treesitter;
|
||||||
usingNvimCmp = config.vim.autocomplete.enable && config.vim.autocomplete.type == "nvim-cmp";
|
usingNvimCmp = config.vim.autocomplete.enable && config.vim.autocomplete.type == "nvim-cmp";
|
||||||
|
|
||||||
|
self = import ./treesitter.nix {inherit lib;};
|
||||||
|
|
||||||
|
mappingDefinitions = self.options.vim.treesitter.mappings;
|
||||||
|
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
vim.startPlugins =
|
vim.startPlugins =
|
||||||
|
@ -16,6 +20,16 @@ in {
|
||||||
|
|
||||||
vim.autocomplete.sources = {"treesitter" = "[Treesitter]";};
|
vim.autocomplete.sources = {"treesitter" = "[Treesitter]";};
|
||||||
|
|
||||||
|
# For some reason, using mkSetLuaBinding and putting the lua code does not work. It just selects the whole file.
|
||||||
|
# This works though, and if it ain't broke, don't fix it.
|
||||||
|
vim.maps.normal = mkSetBinding mappings.incrementalSelection.init ":lua require('nvim-treesitter.incremental_selection').init_selection()<CR>";
|
||||||
|
|
||||||
|
vim.maps.visualOnly = mkMerge [
|
||||||
|
(mkSetBinding mappings.incrementalSelection.incrementByNode ":lua require('nvim-treesitter.incremental_selection').node_incremental()<CR>")
|
||||||
|
(mkSetBinding mappings.incrementalSelection.incrementByScope ":lua require('nvim-treesitter.incremental_selection').scope_incremental()<CR>")
|
||||||
|
(mkSetBinding mappings.incrementalSelection.decrementByNode ":lua require('nvim-treesitter.incremental_selection').node_decremental()<CR>")
|
||||||
|
];
|
||||||
|
|
||||||
# For some reason treesitter highlighting does not work on start if this is set before syntax on
|
# For some reason treesitter highlighting does not work on start if this is set before syntax on
|
||||||
vim.configRC.treesitter-fold = mkIf cfg.fold (nvim.dag.entryBefore ["basic"] ''
|
vim.configRC.treesitter-fold = mkIf cfg.fold (nvim.dag.entryBefore ["basic"] ''
|
||||||
set foldmethod=expr
|
set foldmethod=expr
|
||||||
|
@ -36,10 +50,10 @@ in {
|
||||||
incremental_selection = {
|
incremental_selection = {
|
||||||
enable = true,
|
enable = true,
|
||||||
keymaps = {
|
keymaps = {
|
||||||
init_selection = "gnn",
|
init_selection = false,
|
||||||
node_incremental = "grn",
|
node_incremental = false,
|
||||||
scope_incremental = "grc",
|
scope_incremental = false,
|
||||||
node_decremental = "grm",
|
node_decremental = false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,5 @@
|
||||||
{
|
{lib, ...}:
|
||||||
pkgs,
|
with lib; {
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
with lib;
|
|
||||||
with builtins; let
|
|
||||||
cfg = config.vim.treesitter;
|
|
||||||
usingNvimCmp = config.vim.autocomplete.enable && config.vim.autocomplete.type == "nvim-cmp";
|
|
||||||
in {
|
|
||||||
options.vim.treesitter = {
|
options.vim.treesitter = {
|
||||||
enable = mkEnableOption "treesitter, also enabled automatically through language options";
|
enable = mkEnableOption "treesitter, also enabled automatically through language options";
|
||||||
|
|
||||||
|
@ -16,13 +7,21 @@ in {
|
||||||
|
|
||||||
autotagHtml = mkEnableOption "autoclose and rename html tag";
|
autotagHtml = mkEnableOption "autoclose and rename html tag";
|
||||||
|
|
||||||
|
mappings = {
|
||||||
|
incrementalSelection = {
|
||||||
|
init = mkMappingOption "Init selection [treesitter]" "gnn";
|
||||||
|
incrementByNode = mkMappingOption "Increment selection by node [treesitter]" "grn";
|
||||||
|
incrementByScope = mkMappingOption "Increment selection by scope [treesitter]" "grc";
|
||||||
|
decrementByNode = mkMappingOption "Decrement selection by node [treesitter]" "grm";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
grammars = mkOption {
|
grammars = mkOption {
|
||||||
type = with types; listOf package;
|
type = with types; listOf package;
|
||||||
default = [];
|
default = [];
|
||||||
description = nvim.nmd.asciiDoc ''
|
description = nvim.nmd.asciiDoc ''
|
||||||
List of treesitter grammars to install. For supported languages
|
List of treesitter grammars to install. For supported languages
|
||||||
use the `vim.language.<lang>.treesitter` option
|
use the `vim.language.<lang>.treesitter` option
|
||||||
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -88,6 +88,7 @@ in {
|
||||||
}
|
}
|
||||||
|
|
||||||
${
|
${
|
||||||
|
# TODO: This probably will need to be reworked for custom-keybinds
|
||||||
if config.vim.filetree.nvimTreeLua.enable
|
if config.vim.filetree.nvimTreeLua.enable
|
||||||
then ''
|
then ''
|
||||||
-- NvimTree
|
-- NvimTree
|
||||||
|
|
|
@ -6,21 +6,26 @@
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; let
|
with builtins; let
|
||||||
cfg = config.vim.gestures.gesture-nvim;
|
cfg = config.vim.gestures.gesture-nvim;
|
||||||
|
|
||||||
|
self = import ./gesture-nvim.nix {inherit lib;};
|
||||||
|
|
||||||
|
mappingDefinitions = self.options.vim.gestures.gesture-nvim.mappings;
|
||||||
|
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
vim.startPlugins = ["gesture-nvim"];
|
vim.startPlugins = ["gesture-nvim"];
|
||||||
|
|
||||||
|
vim.maps.normal = mkMerge [
|
||||||
|
(mkSetLuaBinding mappings.draw "require('gesture').draw")
|
||||||
|
(mkSetLuaBinding mappings.finish "require('gesture').finish")
|
||||||
|
(mkIf (mappings.draw.value == "<RightDrag>") {
|
||||||
|
"<RightMouse>" = {action = "<Nop>";};
|
||||||
|
})
|
||||||
|
];
|
||||||
|
|
||||||
vim.luaConfigRC.gesture-nvim = nvim.dag.entryAnywhere ''
|
vim.luaConfigRC.gesture-nvim = nvim.dag.entryAnywhere ''
|
||||||
vim.opt.mouse = "a"
|
vim.opt.mouse = "a"
|
||||||
|
|
||||||
vim.keymap.set("n", "<LeftDrag>", [[<Cmd>lua require("gesture").draw()<CR>]], { silent = true })
|
|
||||||
vim.keymap.set("n", "<LeftRelease>", [[<Cmd>lua require("gesture").finish()<CR>]], { silent = true })
|
|
||||||
|
|
||||||
-- or if you would like to use right click
|
|
||||||
-- vim.keymap.set("n", "<RightMouse>", [[<Nop>]])
|
|
||||||
-- vim.keymap.set("n", "<RightDrag>", [[<Cmd>lua require("gesture").draw()<CR>]], { silent = true })
|
|
||||||
-- vim.keymap.set("n", "<RightRelease>", [[<Cmd>lua require("gesture").finish()<CR>]], { silent = true })
|
|
||||||
|
|
||||||
local gesture = require("gesture")
|
local gesture = require("gesture")
|
||||||
gesture.register({
|
gesture.register({
|
||||||
name = "scroll to bottom",
|
name = "scroll to bottom",
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
{
|
{lib, ...}:
|
||||||
config,
|
with lib; {
|
||||||
lib,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
with lib;
|
|
||||||
with builtins; {
|
|
||||||
options.vim.gestures.gesture-nvim = {
|
options.vim.gestures.gesture-nvim = {
|
||||||
enable = mkEnableOption "Enable gesture-nvim plugin";
|
enable = mkEnableOption "Enable gesture-nvim plugin";
|
||||||
|
|
||||||
|
mappings = {
|
||||||
|
draw = mkMappingOption "Start drawing [gesture.nvim]" "<LeftDrag>";
|
||||||
|
finish = mkMappingOption "Finish drawing [gesture.nvim]" "<LeftRelease>";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,13 +5,16 @@
|
||||||
}:
|
}:
|
||||||
with lib; let
|
with lib; let
|
||||||
cfg = config.vim.utility.motion.hop;
|
cfg = config.vim.utility.motion.hop;
|
||||||
|
|
||||||
|
self = import ./hop.nix {inherit lib;};
|
||||||
|
|
||||||
|
mappingDefinitions = self.options.vim.utility.motion.hop.mappings;
|
||||||
|
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
vim.startPlugins = ["hop-nvim"];
|
vim.startPlugins = ["hop-nvim"];
|
||||||
|
|
||||||
vim.nnoremap = {
|
vim.maps.normal = mkSetBinding mappings.hop "<cmd> HopPattern<CR>";
|
||||||
"<leader>h" = "<cmd> HopPattern<CR>";
|
|
||||||
};
|
|
||||||
|
|
||||||
vim.luaConfigRC.hop-nvim = nvim.dag.entryAnywhere ''
|
vim.luaConfigRC.hop-nvim = nvim.dag.entryAnywhere ''
|
||||||
require('hop').setup()
|
require('hop').setup()
|
||||||
|
|
|
@ -1,13 +1,10 @@
|
||||||
{
|
{lib, ...}:
|
||||||
config,
|
with lib; {
|
||||||
lib,
|
|
||||||
pkgs,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
with lib; let
|
|
||||||
cfg = config.vim.utility.motion.hop;
|
|
||||||
in {
|
|
||||||
options.vim.utility.motion.hop = {
|
options.vim.utility.motion.hop = {
|
||||||
|
mappings = {
|
||||||
|
hop = mkMappingOption "Jump to occurences [hop.nvim]" "<leader>h";
|
||||||
|
};
|
||||||
|
|
||||||
enable = mkEnableOption "Enable Hop.nvim plugin (easy motion)";
|
enable = mkEnableOption "Enable Hop.nvim plugin (easy motion)";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
{
|
{
|
||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
pkgs,
|
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
with lib; let
|
with lib; let
|
||||||
|
@ -13,18 +12,59 @@ in {
|
||||||
"vim-repeat"
|
"vim-repeat"
|
||||||
];
|
];
|
||||||
|
|
||||||
vim.nnoremap = {
|
vim.maps.normal = mkMerge [
|
||||||
"<leader>h" = "<cmd> HopPattern<CR>";
|
(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")
|
||||||
|
];
|
||||||
|
|
||||||
|
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.luaConfigRC.leap-nvim = nvim.dag.entryAnywhere ''
|
vim.luaConfigRC.leap-nvim = nvim.dag.entryAnywhere ''
|
||||||
require('leap').add_default_mappings()
|
require('leap').opts = {
|
||||||
-- TODO: register custom keybinds
|
max_phase_one_targets = nil,
|
||||||
-- require('leap').leap {
|
highlight_unlabeled_phase_one_targets = false,
|
||||||
-- opts = {
|
max_highlighted_traversal_targets = 10,
|
||||||
-- labels = {}
|
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>',
|
||||||
|
},
|
||||||
|
}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,35 @@
|
||||||
{
|
{lib, ...}:
|
||||||
config,
|
with lib;
|
||||||
lib,
|
with builtins; {
|
||||||
pkgs,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
with lib; let
|
|
||||||
cfg = config.vim.utility.motion.leap;
|
|
||||||
in {
|
|
||||||
options.vim.utility.motion.leap = {
|
options.vim.utility.motion.leap = {
|
||||||
enable = mkEnableOption "Enable leap.nvim plugin (easy motion)";
|
enable = mkEnableOption "Enable leap.nvim plugin (easy motion)";
|
||||||
|
|
||||||
|
mappings = {
|
||||||
|
leapForwardTo = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
description = "Leap forward to";
|
||||||
|
default = "s";
|
||||||
|
};
|
||||||
|
leapBackwardTo = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
description = "Leap backward to";
|
||||||
|
default = "S";
|
||||||
|
};
|
||||||
|
leapForwardTill = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
description = "Leap forward till";
|
||||||
|
default = "x";
|
||||||
|
};
|
||||||
|
leapBackwardTill = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
description = "Leap backward till";
|
||||||
|
default = "X";
|
||||||
|
};
|
||||||
|
leapFromWindow = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
description = "Leap from window";
|
||||||
|
default = "gs";
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,47 +7,45 @@
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; let
|
with builtins; let
|
||||||
cfg = config.vim.telescope;
|
cfg = config.vim.telescope;
|
||||||
|
self = import ./telescope.nix {inherit lib;};
|
||||||
|
mappingDefinitions = self.options.vim.telescope.mappings;
|
||||||
|
|
||||||
|
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
|
||||||
in {
|
in {
|
||||||
config = mkIf (cfg.enable) {
|
config = mkIf (cfg.enable) {
|
||||||
vim.startPlugins = [
|
vim.startPlugins = [
|
||||||
"telescope"
|
"telescope"
|
||||||
];
|
];
|
||||||
|
|
||||||
vim.nnoremap =
|
vim.maps.normal = mkMerge [
|
||||||
{
|
(mkSetBinding mappings.findFiles "<cmd> Telescope find_files<CR>")
|
||||||
"<leader>ff" = "<cmd> Telescope find_files<CR>";
|
(mkSetBinding mappings.liveGrep "<cmd> Telescope live_grep<CR>")
|
||||||
"<leader>fg" = "<cmd> Telescope live_grep<CR>";
|
(mkSetBinding mappings.buffers "<cmd> Telescope buffers<CR>")
|
||||||
"<leader>fb" = "<cmd> Telescope buffers<CR>";
|
(mkSetBinding mappings.helpTags "<cmd> Telescope help_tags<CR>")
|
||||||
"<leader>fh" = "<cmd> Telescope help_tags<CR>";
|
(mkSetBinding mappings.open "<cmd> Telescope<CR>")
|
||||||
"<leader>ft" = "<cmd> Telescope<CR>";
|
|
||||||
|
|
||||||
"<leader>fvcw" = "<cmd> Telescope git_commits<CR>";
|
(mkSetBinding mappings.gitCommits "<cmd> Telescope git_commits<CR>")
|
||||||
"<leader>fvcb" = "<cmd> Telescope git_bcommits<CR>";
|
(mkSetBinding mappings.gitBufferCommits "<cmd> Telescope git_bcommits<CR>")
|
||||||
"<leader>fvb" = "<cmd> Telescope git_branches<CR>";
|
(mkSetBinding mappings.gitBranches "<cmd> Telescope git_branches<CR>")
|
||||||
"<leader>fvs" = "<cmd> Telescope git_status<CR>";
|
(mkSetBinding mappings.gitStatus "<cmd> Telescope git_status<CR>")
|
||||||
"<leader>fvx" = "<cmd> Telescope git_stash<CR>";
|
(mkSetBinding mappings.gitStash "<cmd> Telescope git_stash<CR>")
|
||||||
}
|
|
||||||
// (
|
|
||||||
if config.vim.lsp.enable
|
|
||||||
then {
|
|
||||||
"<leader>flsb" = "<cmd> Telescope lsp_document_symbols<CR>";
|
|
||||||
"<leader>flsw" = "<cmd> Telescope lsp_workspace_symbols<CR>";
|
|
||||||
|
|
||||||
"<leader>flr" = "<cmd> Telescope lsp_references<CR>";
|
(mkIf config.vim.lsp.enable (mkMerge [
|
||||||
"<leader>fli" = "<cmd> Telescope lsp_implementations<CR>";
|
(mkSetBinding mappings.lspDocumentSymbols "<cmd> Telescope lsp_document_symbols<CR>")
|
||||||
"<leader>flD" = "<cmd> Telescope lsp_definitions<CR>";
|
(mkSetBinding mappings.lspWorkspaceSymbols "<cmd> Telescope lsp_workspace_symbols<CR>")
|
||||||
"<leader>flt" = "<cmd> Telescope lsp_type_definitions<CR>";
|
|
||||||
"<leader>fld" = "<cmd> Telescope diagnostics<CR>";
|
(mkSetBinding mappings.lspReferences "<cmd> Telescope lsp_references<CR>")
|
||||||
}
|
(mkSetBinding mappings.lspImplementations "<cmd> Telescope lsp_implementations<CR>")
|
||||||
else {}
|
(mkSetBinding mappings.lspDefinitions "<cmd> Telescope lsp_definitions<CR>")
|
||||||
|
(mkSetBinding mappings.lspTypeDefinitions "<cmd> Telescope lsp_type_definitions<CR>")
|
||||||
|
(mkSetBinding mappings.diagnostics "<cmd> Telescope diagnostics<CR>")
|
||||||
|
]))
|
||||||
|
|
||||||
|
(
|
||||||
|
mkIf config.vim.treesitter.enable
|
||||||
|
(mkSetBinding mappings.treesitter "<cmd> Telescope treesitter<CR>")
|
||||||
)
|
)
|
||||||
// (
|
];
|
||||||
if config.vim.treesitter.enable
|
|
||||||
then {
|
|
||||||
"<leader>fs" = "<cmd> Telescope treesitter<CR>";
|
|
||||||
}
|
|
||||||
else {}
|
|
||||||
);
|
|
||||||
|
|
||||||
vim.luaConfigRC.telescope = nvim.dag.entryAnywhere ''
|
vim.luaConfigRC.telescope = nvim.dag.entryAnywhere ''
|
||||||
local telescope = require('telescope')
|
local telescope = require('telescope')
|
||||||
|
|
|
@ -1,11 +1,31 @@
|
||||||
{
|
{lib, ...}:
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
with lib;
|
with lib;
|
||||||
with builtins; {
|
with builtins; {
|
||||||
options.vim.telescope = {
|
options.vim.telescope = {
|
||||||
|
mappings = {
|
||||||
|
findFiles = mkMappingOption "Find files [Telescope]" "<leader>ff";
|
||||||
|
liveGrep = mkMappingOption "Live grep [Telescope]" "<leader>fg";
|
||||||
|
buffers = mkMappingOption "Buffers [Telescope]" "<leader>fb";
|
||||||
|
helpTags = mkMappingOption "Help tags [Telescope]" "<leader>fh";
|
||||||
|
open = mkMappingOption "Open [Telescope]" "<leader>ft";
|
||||||
|
|
||||||
|
gitCommits = mkMappingOption "Git commits [Telescope]" "<leader>fvcw";
|
||||||
|
gitBufferCommits = mkMappingOption "Git buffer commits [Telescope]" "<leader>fvcb";
|
||||||
|
gitBranches = mkMappingOption "Git branches [Telescope]" "<leader>fvb";
|
||||||
|
gitStatus = mkMappingOption "Git status [Telescope]" "<leader>fvs";
|
||||||
|
gitStash = mkMappingOption "Git stash [Telescope]" "<leader>fvx";
|
||||||
|
|
||||||
|
lspDocumentSymbols = mkMappingOption "LSP Document Symbols [Telescope]" "<leader>flsb";
|
||||||
|
lspWorkspaceSymbols = mkMappingOption "LSP Workspace Symbols [Telescope]" "<leader>flsw";
|
||||||
|
lspReferences = mkMappingOption "LSP References [Telescope]" "<leader>flr";
|
||||||
|
lspImplementations = mkMappingOption "LSP Implementations [Telescope]" "<leader>fli";
|
||||||
|
lspDefinitions = mkMappingOption "LSP Definitions [Telescope]" "<leader>flD";
|
||||||
|
lspTypeDefinitions = mkMappingOption "LSP Type Definitions [Telescope]" "<leader>flt";
|
||||||
|
diagnostics = mkMappingOption "Diagnostics [Telescope]" "<leader>fld";
|
||||||
|
|
||||||
|
treesitter = mkMappingOption "Treesitter [Telescope]" "<leader>fs";
|
||||||
|
};
|
||||||
|
|
||||||
enable = mkEnableOption "Enable multi-purpose telescope utility";
|
enable = mkEnableOption "Enable multi-purpose telescope utility";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,9 @@ in {
|
||||||
|
|
||||||
(mkIf cfg.cellularAutomaton.enable {
|
(mkIf cfg.cellularAutomaton.enable {
|
||||||
vim.startPlugins = ["cellular-automaton"];
|
vim.startPlugins = ["cellular-automaton"];
|
||||||
|
|
||||||
|
vim.maps.normal = mkBinding cfg.cellularAutomaton.mappings.makeItRain "<cmd>CellularAutomaton make_it_rain<CR>" "Make it rain";
|
||||||
|
|
||||||
vim.luaConfigRC.cellularAUtomaton = nvim.dag.entryAnywhere ''
|
vim.luaConfigRC.cellularAUtomaton = nvim.dag.entryAnywhere ''
|
||||||
local config = {
|
local config = {
|
||||||
fps = 50,
|
fps = 50,
|
||||||
|
@ -90,8 +93,6 @@ in {
|
||||||
end
|
end
|
||||||
|
|
||||||
require("cellular-automaton").register_animation(config)
|
require("cellular-automaton").register_animation(config)
|
||||||
|
|
||||||
vim.keymap.set("n", "<leader>fml", "<cmd>CellularAutomaton make_it_rain<CR>")
|
|
||||||
'';
|
'';
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -24,10 +24,16 @@ in {
|
||||||
default = false;
|
default = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
cellularAutomaton.enable = mkOption {
|
cellularAutomaton = {
|
||||||
type = types.bool;
|
enable = mkOption {
|
||||||
description = "Enable cellular automaton [cellular-automaton]";
|
type = types.bool;
|
||||||
default = false;
|
description = "Enable cellular automaton [cellular-automaton]";
|
||||||
|
default = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
mappings = {
|
||||||
|
makeItRain = mkMappingOption "Make it rain [cellular-automaton]" "<leader>fml";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
fidget-nvim = {
|
fidget-nvim = {
|
||||||
|
|
Loading…
Reference in a new issue