mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-26 15:06:45 +00: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.
|
||||
|
||||
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
|
||||
mkNvimLib = import ./.;
|
||||
in
|
||||
nixpkgsLib.extend (self: super: {
|
||||
nixpkgsLib.extend (self: super: rec {
|
||||
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.
|
||||
literalExpression = super.literalExpression or super.literalExample;
|
||||
literalDocBook = super.literalDocBook or super.literalExample;
|
||||
|
|
|
@ -7,6 +7,18 @@
|
|||
with lib;
|
||||
with builtins; let
|
||||
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 {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = [
|
||||
|
@ -18,7 +30,50 @@ in {
|
|||
require("copilot").setup({
|
||||
-- available options: https://github.com/zbirenbaum/copilot.lua
|
||||
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 = {
|
||||
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 {
|
||||
type = types.str;
|
||||
default = "${lib.getExe pkgs.nodejs-slim-16_x}";
|
||||
|
|
|
@ -10,13 +10,43 @@ in {
|
|||
config = mkIf cfg.enable {
|
||||
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 ''
|
||||
require('tabnine').setup({
|
||||
disable_auto_comment = ${boolToString cfg.disable_auto_comment},
|
||||
accept_keymap = ${cfg.accept_keymap},
|
||||
dismiss_keymap = ${cfg.dismiss_keymap},
|
||||
accept_keymap = null,
|
||||
dismiss_keymap = null,
|
||||
debounce_ms = ${cfg.debounce_ms},
|
||||
execlude_filetypes = ${cfg.execlude_filetypes},
|
||||
exclude_filetypes = ${cfg.exclude_filetypes},
|
||||
})
|
||||
'';
|
||||
};
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{lib, ...}:
|
||||
with lib;
|
||||
with builtins; {
|
||||
options.vim.assistant.tabnine = {
|
||||
|
@ -14,16 +10,9 @@ with builtins; {
|
|||
description = "Disable auto comment";
|
||||
};
|
||||
|
||||
accept_keymap = mkOption {
|
||||
type = types.str;
|
||||
default = "<Tab>";
|
||||
description = "Accept keymap";
|
||||
};
|
||||
|
||||
dismiss_keymap = mkOption {
|
||||
type = types.str;
|
||||
default = "<C-]>";
|
||||
description = "Dismiss keymap";
|
||||
mappings = {
|
||||
accept = mkMappingOption "Accept [Tabnine]" "<Tab>";
|
||||
dismiss = mkMappingOption "Dismiss [Tabnine]" "<C-]>";
|
||||
};
|
||||
|
||||
debounce_ms = mkOption {
|
||||
|
@ -32,10 +21,10 @@ with builtins; {
|
|||
description = "Debounce ms";
|
||||
};
|
||||
|
||||
execlude_filetypes = mkOption {
|
||||
exclude_filetypes = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = ["TelescopePrompt" "NvimTree" "alpha"];
|
||||
description = "Execlude filetypes";
|
||||
description = "Exclude filetypes";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -10,21 +10,51 @@ in {
|
|||
config = {
|
||||
vim.startPlugins = ["plenary-nvim"];
|
||||
|
||||
vim.nmap = mkIf cfg.disableArrows {
|
||||
"<up>" = "<nop>";
|
||||
"<down>" = "<nop>";
|
||||
"<left>" = "<nop>";
|
||||
"<right>" = "<nop>";
|
||||
vim.maps.normal =
|
||||
mkIf cfg.disableArrows {
|
||||
"<up>" = {
|
||||
action = "<nop>";
|
||||
|
||||
noremap = false;
|
||||
};
|
||||
"<down>" = {
|
||||
action = "<nop>";
|
||||
|
||||
noremap = false;
|
||||
};
|
||||
"<left>" = {
|
||||
action = "<nop>";
|
||||
noremap = false;
|
||||
};
|
||||
"<right>" = {
|
||||
action = "<nop>";
|
||||
noremap = false;
|
||||
};
|
||||
}
|
||||
// mkIf cfg.mapLeaderSpace {
|
||||
"<space>" = {
|
||||
action = "<nop>";
|
||||
};
|
||||
};
|
||||
|
||||
vim.imap = mkIf cfg.disableArrows {
|
||||
"<up>" = "<nop>";
|
||||
"<down>" = "<nop>";
|
||||
"<left>" = "<nop>";
|
||||
"<right>" = "<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.nnoremap = mkIf cfg.mapLeaderSpace {"<space>" = "<nop>";};
|
||||
|
||||
vim.configRC.basic = nvim.dag.entryAfter ["globalsScript"] ''
|
||||
" Debug mode settings
|
||||
|
|
|
@ -1,11 +1,18 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{lib, ...}:
|
||||
with lib;
|
||||
with builtins; {
|
||||
options.vim.comments.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 builtins; let
|
||||
cfg = config.vim.comments.comment-nvim;
|
||||
self = import ./comment-nvim.nix {
|
||||
inherit lib;
|
||||
};
|
||||
mappings = self.options.vim.comments.comment-nvim.mappings;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = [
|
||||
"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 ''
|
||||
require('Comment').setup()
|
||||
require('Comment').setup({
|
||||
mappings = { basic = false, extra = false, },
|
||||
})
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
{
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
|
@ -8,6 +7,12 @@ with lib;
|
|||
with builtins; let
|
||||
cfg = config.vim.autocomplete;
|
||||
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 =
|
||||
concatMapStringsSep
|
||||
"\n"
|
||||
|
@ -46,6 +51,133 @@ in {
|
|||
"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 ''
|
||||
local nvim_cmp_menu_map = function(entry, vim_item)
|
||||
-- name for each source
|
||||
|
@ -59,16 +191,6 @@ in {
|
|||
${optionalString lspkindEnabled ''
|
||||
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'
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
|
@ -79,37 +201,6 @@ in {
|
|||
sources = {
|
||||
${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 = {
|
||||
completeopt = 'menu,menuone,noinsert',
|
||||
},
|
||||
|
|
|
@ -1,34 +1,6 @@
|
|||
{
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
{lib, ...}:
|
||||
with lib;
|
||||
with builtins; let
|
||||
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 {
|
||||
with builtins; {
|
||||
options.vim = {
|
||||
autocomplete = {
|
||||
enable = mkOption {
|
||||
|
@ -37,6 +9,16 @@ in {
|
|||
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 = types.enum ["nvim-cmp"];
|
||||
default = "nvim-cmp";
|
||||
|
|
|
@ -13,12 +13,106 @@ with builtins; let
|
|||
EOF
|
||||
'';
|
||||
|
||||
mkMappingOption = it:
|
||||
mkOption ({
|
||||
default = {};
|
||||
type = with types; attrsOf (nullOr str);
|
||||
mkBool = value: description:
|
||||
mkOption {
|
||||
type = types.bool;
|
||||
default = value;
|
||||
description = description;
|
||||
};
|
||||
|
||||
# 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...)
|
||||
}
|
||||
// it);
|
||||
*/
|
||||
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 {
|
||||
options.vim = {
|
||||
viAlias = mkOption {
|
||||
|
@ -67,64 +161,38 @@ in {
|
|||
type = types.attrs;
|
||||
};
|
||||
|
||||
nnoremap =
|
||||
mkMappingOption {description = "Defines 'Normal mode' mappings";};
|
||||
maps = mkOption {
|
||||
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 {
|
||||
description = "Defines 'Insert and Replace mode' mappings";
|
||||
visualOnly = mapOptions "visual only";
|
||||
operator = mapOptions "operator-pending";
|
||||
insertCommand = mapOptions "insert and command-line";
|
||||
lang = mapOptions "insert, command-line and lang-arg";
|
||||
command = mapOptions "command-line";
|
||||
};
|
||||
|
||||
vnoremap = mkMappingOption {
|
||||
description = "Defines 'Visual and Select mode' mappings";
|
||||
};
|
||||
default = {};
|
||||
description = ''
|
||||
Custom keybindings for any mode.
|
||||
|
||||
xnoremap =
|
||||
mkMappingOption {description = "Defines 'Visual mode' mappings";};
|
||||
For plain maps (e.g. just 'map' or 'remap') use maps.normalVisualOp.
|
||||
'';
|
||||
|
||||
snoremap =
|
||||
mkMappingOption {description = "Defines 'Select mode' mappings";};
|
||||
|
||||
cnoremap =
|
||||
mkMappingOption {description = "Defines 'Command-line mode' mappings";};
|
||||
|
||||
onoremap = mkMappingOption {
|
||||
description = "Defines 'Operator pending mode' mappings";
|
||||
example = ''
|
||||
maps = {
|
||||
normal."<leader>m" = {
|
||||
silent = true;
|
||||
action = "<cmd>make<CR>";
|
||||
}; # Same as nnoremap <leader>m <silent> <cmd>make<CR>
|
||||
};
|
||||
|
||||
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}")
|
||||
(filterNonNull cfg.globals);
|
||||
|
||||
matchCtrl = it: match "Ctrl-(.)(.*)" it;
|
||||
mapKeyBinding = it: let
|
||||
groups = matchCtrl it;
|
||||
in
|
||||
if groups == null
|
||||
then it
|
||||
else "<C-${toUpper (head groups)}>${head (tail groups)}";
|
||||
mapVimBinding = prefix: mappings:
|
||||
mapAttrsFlatten (name: value: "${prefix} ${mapKeyBinding name} ${value}")
|
||||
(filterNonNull mappings);
|
||||
toLuaObject = args:
|
||||
if builtins.isAttrs args
|
||||
then
|
||||
if hasAttr "__raw" args
|
||||
then args.__raw
|
||||
else if hasAttr "__empty" args
|
||||
then "{ }"
|
||||
else
|
||||
"{"
|
||||
+ (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;
|
||||
imap = mapVimBinding "imap" config.vim.imap;
|
||||
vmap = mapVimBinding "vmap" config.vim.vmap;
|
||||
xmap = mapVimBinding "xmap" config.vim.xmap;
|
||||
smap = mapVimBinding "smap" config.vim.smap;
|
||||
cmap = mapVimBinding "cmap" config.vim.cmap;
|
||||
omap = mapVimBinding "omap" config.vim.omap;
|
||||
tmap = mapVimBinding "tmap" config.vim.tmap;
|
||||
toLuaBindings = mode: maps:
|
||||
builtins.map (value: ''
|
||||
vim.keymap.set(${toLuaObject mode}, ${toLuaObject value.key}, ${toLuaObject value.action}, ${toLuaObject value.config})
|
||||
'') (genMaps mode maps);
|
||||
|
||||
nnoremap = mapVimBinding "nnoremap" config.vim.nnoremap;
|
||||
inoremap = mapVimBinding "inoremap" config.vim.inoremap;
|
||||
vnoremap = mapVimBinding "vnoremap" config.vim.vnoremap;
|
||||
xnoremap = mapVimBinding "xnoremap" config.vim.xnoremap;
|
||||
snoremap = mapVimBinding "snoremap" config.vim.snoremap;
|
||||
cnoremap = mapVimBinding "cnoremap" config.vim.cnoremap;
|
||||
onoremap = mapVimBinding "onoremap" config.vim.onoremap;
|
||||
tnoremap = mapVimBinding "tnoremap" config.vim.tnoremap;
|
||||
# I'm not sure if every one of these will work.
|
||||
allmap = toLuaBindings "" config.vim.maps.normalVisualOp;
|
||||
nmap = toLuaBindings "n" config.vim.maps.normal;
|
||||
vmap = toLuaBindings "v" config.vim.maps.visual;
|
||||
xmap = toLuaBindings "x" config.vim.maps.visualOnly;
|
||||
smap = toLuaBindings "s" config.vim.maps.select;
|
||||
imap = toLuaBindings "i" config.vim.maps.insert;
|
||||
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 = {
|
||||
name,
|
||||
|
@ -208,9 +305,22 @@ in {
|
|||
in
|
||||
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
|
||||
maps = [nmap imap vmap xmap smap cmap omap tmap nnoremap inoremap vnoremap xnoremap snoremap cnoremap onoremap tnoremap];
|
||||
mapConfig = concatStringsSep "\n" (map (v: concatStringsSep "\n" v) maps);
|
||||
maps = [
|
||||
nmap
|
||||
imap
|
||||
vmap
|
||||
xmap
|
||||
smap
|
||||
cmap
|
||||
omap
|
||||
tmap
|
||||
lmap
|
||||
icmap
|
||||
allmap
|
||||
];
|
||||
mapConfig = wrapLuaConfig (concatStringsSep "\n" (map (v: concatStringsSep "\n" v) maps));
|
||||
in
|
||||
nvim.dag.entryAfter ["globalsScript"] mapConfig;
|
||||
};
|
||||
|
|
|
@ -1,30 +1,29 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
with builtins; let
|
||||
cfg = config.vim.filetree.nvimTreeLua;
|
||||
self = import ./nvimtree-lua.nix {
|
||||
inherit pkgs;
|
||||
lib = lib;
|
||||
};
|
||||
mappings = self.options.vim.filetree.nvimTreeLua.mappings;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = ["nvim-tree-lua"];
|
||||
|
||||
# vim.nnoremap = {
|
||||
# "<C-n>" = ":NvimTreeToggle<CR>";
|
||||
# "<leader>tr" = ":NvimTreeRefresh<CR>";
|
||||
# "<leader>tg" = ":NvimTreeFindFile<CR>";
|
||||
# "<leader>tf" = ":NvimTreeFocus<CR>";
|
||||
# };
|
||||
vim.maps.normal = mkMerge [
|
||||
(mkBinding cfg.mappings.toggle ":NvimTreeToggle<cr>" mappings.toggle.description)
|
||||
(mkBinding cfg.mappings.refresh ":NvimTreeRefresh<cr>" mappings.refresh.description)
|
||||
(mkBinding cfg.mappings.findFile ":NvimTreeFindFile<cr>" mappings.findFile.description)
|
||||
(mkBinding cfg.mappings.focus ":NvimTreeFocus<cr>" mappings.focus.description)
|
||||
];
|
||||
|
||||
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 IGNORED_FT = {
|
||||
"markdown",
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
|
@ -13,6 +12,29 @@ with builtins; {
|
|||
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 {
|
||||
default = "name";
|
||||
description = "Sort by name or extension";
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
|
@ -7,40 +6,62 @@
|
|||
with lib;
|
||||
with builtins; let
|
||||
cfg = config.vim.git;
|
||||
|
||||
self = import ./git.nix {inherit lib;};
|
||||
gsMappingDefinitions = self.options.vim.git.gitsigns.mappings;
|
||||
|
||||
gsMappings = addDescriptionsToMappings cfg.gitsigns.mappings gsMappingDefinitions;
|
||||
in {
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
(mkIf cfg.gitsigns.enable (mkMerge [
|
||||
{
|
||||
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 ''
|
||||
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>'
|
||||
},
|
||||
}
|
||||
require('gitsigns').setup{}
|
||||
'';
|
||||
}
|
||||
|
||||
|
|
|
@ -1,19 +1,34 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{lib, ...}:
|
||||
with lib;
|
||||
with builtins; let
|
||||
cfg = config.vim.git;
|
||||
in {
|
||||
with builtins; {
|
||||
options.vim.git = {
|
||||
enable = mkEnableOption "Git support";
|
||||
|
||||
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";
|
||||
};
|
||||
};
|
||||
|
|
|
@ -6,41 +6,35 @@
|
|||
with lib;
|
||||
with builtins; let
|
||||
cfg = config.vim.lsp;
|
||||
self = import ./lspsaga.nix {inherit lib;};
|
||||
|
||||
mappingDefinitions = self.options.vim.lsp.lspsaga.mappings;
|
||||
mappings = addDescriptionsToMappings cfg.lspsaga.mappings mappingDefinitions;
|
||||
in {
|
||||
config = mkIf (cfg.enable && cfg.lspsaga.enable) {
|
||||
vim.startPlugins = ["lspsaga"];
|
||||
|
||||
vim.vnoremap = {
|
||||
"<silent><leader>ca" = ":<C-U>lua require('lspsaga.codeaction').range_code_action()<CR>";
|
||||
};
|
||||
vim.maps.visual = mkSetLuaBinding mappings.codeAction "require('lspsaga.codeaction').range_code_action";
|
||||
|
||||
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.maps.normal = mkMerge [
|
||||
(mkSetLuaBinding mappings.lspFinder "require('lspsaga.provider').lsp_finder")
|
||||
(mkSetLuaBinding mappings.renderHoveredDoc "require('lspsaga.hover').render_hover_doc")
|
||||
|
||||
(mkSetLuaBinding mappings.smartScrollUp "function() require('lspsaga.action').smart_scroll_with_saga(-1) end")
|
||||
(mkSetLuaBinding mappings.smartScrollDown "function() require('lspsaga.action').smart_scroll_with_saga(1) end")
|
||||
|
||||
(mkSetLuaBinding mappings.rename "require('lspsaga.rename').rename")
|
||||
(mkSetLuaBinding mappings.previewDefinition "require('lspsaga.provider').preview_definition")
|
||||
|
||||
(mkSetLuaBinding mappings.showLineDiagnostics "require('lspsaga.diagnostic').show_line_diagnostics")
|
||||
(mkSetLuaBinding mappings.showCursorDiagnostics "require('lspsaga.diagnostic').show_cursor_diagnostics")
|
||||
|
||||
(mkSetLuaBinding mappings.nextDiagnostic "require('lspsaga.diagnostic').navigate('next')")
|
||||
(mkSetLuaBinding mappings.previousDiagnostic "require('lspsaga.diagnostic').navigate('prev')")
|
||||
|
||||
(mkIf (!cfg.nvimCodeActionMenu.enable) (mkSetLuaBinding mappings.codeAction "require('lspsaga.codeaction').code_action"))
|
||||
(mkIf (!cfg.lspSignature.enable) (mkSetLuaBinding mappings.signatureHelp "require('lspsaga.signaturehelp').signature_help"))
|
||||
];
|
||||
|
||||
vim.luaConfigRC.lspsage = nvim.dag.entryAnywhere ''
|
||||
-- Enable lspsaga
|
||||
|
|
|
@ -1,53 +1,28 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{lib, ...}:
|
||||
with lib;
|
||||
with builtins; let
|
||||
cfg = config.vim.lsp;
|
||||
in {
|
||||
options.vim.lsp = {lspsaga = {enable = mkEnableOption "LSP Saga";};};
|
||||
with builtins; {
|
||||
options.vim.lsp.lspsaga = {
|
||||
enable = mkEnableOption "LSP Saga";
|
||||
|
||||
config = mkIf (cfg.enable && cfg.lspsaga.enable) {
|
||||
vim.startPlugins = ["lspsaga"];
|
||||
mappings = {
|
||||
lspFinder = mkMappingOption "LSP Finder [LSPSaga]" "<leader>lf";
|
||||
renderHoveredDoc = mkMappingOption "Rendered hovered docs [LSPSaga]" "<leader>lh";
|
||||
|
||||
vim.vnoremap = {
|
||||
"<silent><leader>ca" = ":<C-U>lua require('lspsaga.codeaction').range_code_action()<CR>";
|
||||
smartScrollUp = mkMappingOption "Smart scroll up [LSPSaga]" "<C-f>";
|
||||
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 builtins; let
|
||||
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 {
|
||||
config = mkIf (cfg.enable && cfg.nvimCodeActionMenu.enable) {
|
||||
vim.startPlugins = ["nvim-code-action-menu"];
|
||||
|
||||
vim.nnoremap = {
|
||||
"<silent><leader>ca" = ":CodeActionMenu<CR>";
|
||||
};
|
||||
vim.maps.normal = mkSetBinding mappings.open ":CodeActionMenu<CR>";
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
with builtins; {
|
||||
{lib, ...}:
|
||||
with lib; {
|
||||
options.vim.lsp = {
|
||||
nvimCodeActionMenu = {
|
||||
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 builtins; let
|
||||
cfg = config.vim.lsp;
|
||||
|
||||
self = import ./trouble.nix {inherit lib;};
|
||||
|
||||
mappingDefinitions = self.options.vim.lsp.trouble.mappings;
|
||||
mappings = addDescriptionsToMappings cfg.trouble.mappings mappingDefinitions;
|
||||
in {
|
||||
config = mkIf (cfg.enable && cfg.trouble.enable) {
|
||||
vim.startPlugins = ["trouble"];
|
||||
|
||||
vim.nnoremap = {
|
||||
"<leader>xx" = "<cmd>TroubleToggle<CR>";
|
||||
"<leader>lwd" = "<cmd>TroubleToggle workspace_diagnostics<CR>";
|
||||
"<leader>ld" = "<cmd>TroubleToggle document_diagnostics<CR>";
|
||||
"<leader>lr" = "<cmd>TroubleToggle lsp_references<CR>";
|
||||
"<leader>xq" = "<cmd>TroubleToggle quickfix<CR>";
|
||||
"<leader>xl" = "<cmd>TroubleToggle loclist<CR>";
|
||||
};
|
||||
vim.maps.normal = mkMerge [
|
||||
(mkSetBinding mappings.toggle "<cmd>TroubleToggle<CR>")
|
||||
(mkSetBinding mappings.workspaceDiagnostics "<cmd>TroubleToggle workspace_diagnostics<CR>")
|
||||
(mkSetBinding mappings.documentDiagnostics "<cmd>TroubleToggle document_diagnostics<CR>")
|
||||
(mkSetBinding mappings.lspReferences "<cmd>TroubleToggle lsp_references<CR>")
|
||||
(mkSetBinding mappings.quickfix "<cmd>TroubleToggle quickfix<CR>")
|
||||
(mkSetBinding mappings.locList "<cmd>TroubleToggle loclist<CR>")
|
||||
];
|
||||
|
||||
vim.luaConfigRC.trouble = nvim.dag.entryAnywhere ''
|
||||
-- Enable trouble diagnostics viewer
|
||||
|
|
|
@ -1,13 +1,17 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
with builtins; {
|
||||
{lib, ...}:
|
||||
with lib; {
|
||||
options.vim.lsp = {
|
||||
trouble = {
|
||||
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 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
with builtins; {
|
||||
{lib, ...}:
|
||||
with lib; {
|
||||
options.vim.minimap.codewindow = {
|
||||
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 builtins; let
|
||||
cfg = config.vim.minimap.codewindow;
|
||||
|
||||
self = import ./codewindow.nix {inherit lib;};
|
||||
|
||||
mappingDefinitions = self.options.vim.minimap.codewindow.mappings;
|
||||
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = [
|
||||
"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 ''
|
||||
local codewindow = require('codewindow')
|
||||
codewindow.setup({
|
||||
exclude_filetypes = { 'NvimTree', 'orgagenda'},
|
||||
}
|
||||
)
|
||||
codewindow.apply_default_keybinds()
|
||||
})
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
@ -12,10 +12,10 @@ in {
|
|||
"mind-nvim"
|
||||
];
|
||||
|
||||
vim.nnoremap = {
|
||||
"<leader>om" = ":MindOpenMain<CR>";
|
||||
"<leader>op" = ":MindOpenProject<CR>";
|
||||
"<leader>oc" = ":MindClose<CR>";
|
||||
vim.maps.normal = {
|
||||
"<leader>om" = {action = ":MindOpenMain<CR>";};
|
||||
"<leader>op" = {action = ":MindOpenProject<CR>";};
|
||||
"<leader>oc" = {action = ":MindClose<CR>";};
|
||||
};
|
||||
|
||||
vim.luaConfigRC.mind-nvim = nvim.dag.entryAnywhere ''
|
||||
|
|
|
@ -7,17 +7,19 @@
|
|||
with lib;
|
||||
with builtins; let
|
||||
cfg = config.vim.notes.todo-comments;
|
||||
self = import ./todo-comments.nix {inherit lib;};
|
||||
mappings = self.options.vim.notes.todo-comments.mappings;
|
||||
in {
|
||||
config = mkIf (cfg.enable) {
|
||||
vim.startPlugins = [
|
||||
"todo-comments"
|
||||
];
|
||||
|
||||
vim.nnoremap = {
|
||||
"<leader>tdq" = ":TodoQuickFix<CR>";
|
||||
"<leader>tds" = ":TodoTelescope<CR>";
|
||||
"<leader>tdt" = ":TodoTrouble<CR>";
|
||||
};
|
||||
vim.maps.normal = mkMerge [
|
||||
(mkBinding cfg.mappings.quickFix ":TodoQuickFix<CR>" mappings.quickFix.description)
|
||||
(mkIf config.vim.telescope.enable (mkBinding cfg.mappings.telescope ":TodoTelescope<CR>" mappings.telescope.description))
|
||||
(mkIf config.vim.lsp.trouble.enable (mkBinding cfg.mappings.trouble ":TodoTrouble<CR>" mappings.trouble.description))
|
||||
];
|
||||
|
||||
vim.luaConfigRC.todo-comments = ''
|
||||
require('todo-comments').setup {
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{lib, ...}:
|
||||
with lib;
|
||||
with builtins; {
|
||||
options.vim.notes.todo-comments = {
|
||||
|
@ -21,5 +17,11 @@ with builtins; {
|
|||
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"];
|
||||
|
||||
vim.nnoremap = {
|
||||
"<leader>sl" = ":SessionManager load_session<CR>";
|
||||
"<leader>sd" = ":SessionManager delete_session<CR>";
|
||||
"<leader>sc" = ":SessionManager save_current_session<CR>";
|
||||
"<leader>slt" = ":SessionManager load_last_session<CR>";
|
||||
vim.maps.normal = mkMerge [
|
||||
(mkBinding cfg.mappings.loadSession ":SessionManager load_session<CR>" "Load session")
|
||||
(mkBinding cfg.mappings.deleteSession ":SessionManager delete_session<CR>" "Delete session")
|
||||
(mkBinding cfg.mappings.saveCurrentSession ":SessionManager save_current_session<CR>" "Save current session")
|
||||
(mkBinding cfg.mappings.loadLastSession ":SessionManager load_last_session<CR>" "Load last session")
|
||||
# TODO: load_current_dir_session
|
||||
};
|
||||
];
|
||||
|
||||
vim.luaConfigRC.nvim-session-manager = nvim.dag.entryAnywhere ''
|
||||
local Path = require('plenary.path')
|
||||
|
|
|
@ -8,6 +8,29 @@ with builtins; {
|
|||
options.vim.session.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 {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
|
|
|
@ -6,6 +6,10 @@
|
|||
with lib;
|
||||
with builtins; let
|
||||
cfg = config.vim.tabline.nvimBufferline;
|
||||
self = import ./nvim-bufferline.nix {
|
||||
inherit lib;
|
||||
};
|
||||
mappings = self.options.vim.tabline.nvimBufferline.mappings;
|
||||
in {
|
||||
config = mkIf cfg.enable (
|
||||
let
|
||||
|
@ -23,25 +27,18 @@ in {
|
|||
"bufdelete-nvim"
|
||||
];
|
||||
|
||||
vim.nnoremap = {
|
||||
"<silent><leader>bn" = ":BufferLineCycleNext<CR>";
|
||||
"<silent><leader>bp" = ":BufferLineCyclePrev<CR>";
|
||||
"<silent><leader>bc" = ":BufferLinePick<CR>";
|
||||
"<silent><leader>bse" = ":BufferLineSortByExtension<CR>";
|
||||
"<silent><leader>bsd" = ":BufferLineSortByDirectory<CR>";
|
||||
"<silent><leader>bsi" = ":lua require'bufferline'.sort_buffers_by(function (buf_a, buf_b) return buf_a.id < buf_b.id end)<CR>";
|
||||
"<silent><leader>bmn" = ":BufferLineMoveNext<CR>";
|
||||
"<silent><leader>bmp" = ":BufferLineMovePrev<CR>";
|
||||
"<silent><leader>b1" = "<Cmd>BufferLineGoToBuffer 1<CR>";
|
||||
"<silent><leader>b2" = "<Cmd>BufferLineGoToBuffer 2<CR>";
|
||||
"<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.maps.normal = mkMerge [
|
||||
(mkLuaBinding cfg.mappings.closeCurrent "require(\"bufdelete\").bufdelete" mappings.closeCurrent.description)
|
||||
(mkBinding cfg.mappings.cycleNext ":BufferLineCycleNext<CR>" mappings.cycleNext.description)
|
||||
(mkBinding cfg.mappings.cycleNext ":BufferLineCycleNext<CR>" mappings.cycleNext.description)
|
||||
(mkBinding cfg.mappings.cyclePrevious ":BufferLineCyclePrev<CR>" mappings.cyclePrevious.description)
|
||||
(mkBinding cfg.mappings.pick ":BufferLinePick<CR>" mappings.pick.description)
|
||||
(mkBinding cfg.mappings.sortByExtension ":BufferLineSortByExtension<CR>" mappings.sortByExtension.description)
|
||||
(mkBinding cfg.mappings.sortByDirectory ":BufferLineSortByDirectory<CR>" mappings.sortByDirectory.description)
|
||||
(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)
|
||||
(mkBinding cfg.mappings.moveNext ":BufferLineMoveNext<CR>" mappings.moveNext.description)
|
||||
(mkBinding cfg.mappings.movePrevious ":BufferLineMovePrev<CR>" mappings.movePrevious.description)
|
||||
];
|
||||
|
||||
vim.luaConfigRC.nvimBufferline = nvim.dag.entryAnywhere ''
|
||||
require("bufferline").setup{
|
||||
|
@ -51,8 +48,8 @@ in {
|
|||
close_command = ${mouse.close},
|
||||
right_mouse_command = ${mouse.right},
|
||||
indicator = {
|
||||
style = 'underline',
|
||||
-- indicator_icon = '▎',
|
||||
style = 'icon',
|
||||
indicator_icon = '▎',
|
||||
},
|
||||
buffer_close_icon = '',
|
||||
modified_icon = '●',
|
||||
|
|
|
@ -1,11 +1,19 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{lib, ...}:
|
||||
with lib;
|
||||
with builtins; {
|
||||
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";
|
||||
};
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
with lib;
|
||||
with builtins; let
|
||||
cfg = config.vim.terminal.toggleterm;
|
||||
toggleKey = "<c-t>";
|
||||
in {
|
||||
config = mkMerge [
|
||||
(
|
||||
|
@ -15,9 +14,11 @@ in {
|
|||
"toggleterm-nvim"
|
||||
];
|
||||
|
||||
vim.maps.normal = mkBinding cfg.mappings.open "<Cmd>execute v:count . \"ToggleTerm\"<CR>" "Toggle terminal";
|
||||
|
||||
vim.luaConfigRC.toggleterm = nvim.dag.entryAnywhere ''
|
||||
require("toggleterm").setup({
|
||||
open_mapping = [[${toggleKey}]],
|
||||
open_mapping = null,
|
||||
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
|
||||
size = function(term)
|
||||
|
@ -55,11 +56,10 @@ in {
|
|||
hidden = true,
|
||||
on_open = function(term)
|
||||
vim.cmd("startinsert!")
|
||||
vim.keymap.set( 't', [[${toggleKey}]], function() term:toggle() end, {silent = true, noremap = true, buffer = term.bufnr})
|
||||
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; {
|
||||
options.vim.terminal.toggleterm = {
|
||||
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 {
|
||||
type = types.enum ["horizontal" "vertical" "tab" "float"];
|
||||
default = "horizontal";
|
||||
|
@ -30,6 +37,10 @@ with builtins; {
|
|||
default = pkgs.lazygit;
|
||||
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,
|
||||
lib,
|
||||
...
|
||||
|
@ -8,6 +7,11 @@ with lib;
|
|||
with builtins; let
|
||||
cfg = config.vim.treesitter;
|
||||
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 {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins =
|
||||
|
@ -16,6 +20,16 @@ in {
|
|||
|
||||
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
|
||||
vim.configRC.treesitter-fold = mkIf cfg.fold (nvim.dag.entryBefore ["basic"] ''
|
||||
set foldmethod=expr
|
||||
|
@ -36,10 +50,10 @@ in {
|
|||
incremental_selection = {
|
||||
enable = true,
|
||||
keymaps = {
|
||||
init_selection = "gnn",
|
||||
node_incremental = "grn",
|
||||
scope_incremental = "grc",
|
||||
node_decremental = "grm",
|
||||
init_selection = false,
|
||||
node_incremental = false,
|
||||
scope_incremental = false,
|
||||
node_decremental = false,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -1,14 +1,5 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
with builtins; let
|
||||
cfg = config.vim.treesitter;
|
||||
usingNvimCmp = config.vim.autocomplete.enable && config.vim.autocomplete.type == "nvim-cmp";
|
||||
in {
|
||||
{lib, ...}:
|
||||
with lib; {
|
||||
options.vim.treesitter = {
|
||||
enable = mkEnableOption "treesitter, also enabled automatically through language options";
|
||||
|
||||
|
@ -16,13 +7,21 @@ in {
|
|||
|
||||
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 {
|
||||
type = with types; listOf package;
|
||||
default = [];
|
||||
description = nvim.nmd.asciiDoc ''
|
||||
List of treesitter grammars to install. For supported languages
|
||||
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
|
||||
then ''
|
||||
-- NvimTree
|
||||
|
|
|
@ -6,21 +6,26 @@
|
|||
with lib;
|
||||
with builtins; let
|
||||
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 {
|
||||
config = mkIf cfg.enable {
|
||||
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.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")
|
||||
gesture.register({
|
||||
name = "scroll to bottom",
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
with builtins; {
|
||||
{lib, ...}:
|
||||
with lib; {
|
||||
options.vim.gestures.gesture-nvim = {
|
||||
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
|
||||
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 {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = ["hop-nvim"];
|
||||
|
||||
vim.nnoremap = {
|
||||
"<leader>h" = "<cmd> HopPattern<CR>";
|
||||
};
|
||||
vim.maps.normal = mkSetBinding mappings.hop "<cmd> HopPattern<CR>";
|
||||
|
||||
vim.luaConfigRC.hop-nvim = nvim.dag.entryAnywhere ''
|
||||
require('hop').setup()
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.vim.utility.motion.hop;
|
||||
in {
|
||||
{lib, ...}:
|
||||
with lib; {
|
||||
options.vim.utility.motion.hop = {
|
||||
mappings = {
|
||||
hop = mkMappingOption "Jump to occurences [hop.nvim]" "<leader>h";
|
||||
};
|
||||
|
||||
enable = mkEnableOption "Enable Hop.nvim plugin (easy motion)";
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
|
@ -13,18 +12,59 @@ in {
|
|||
"vim-repeat"
|
||||
];
|
||||
|
||||
vim.nnoremap = {
|
||||
"<leader>h" = "<cmd> HopPattern<CR>";
|
||||
};
|
||||
vim.maps.normal = 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.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 ''
|
||||
require('leap').add_default_mappings()
|
||||
-- TODO: register custom keybinds
|
||||
-- require('leap').leap {
|
||||
-- opts = {
|
||||
-- labels = {}
|
||||
-- }
|
||||
-- }
|
||||
require('leap').opts = {
|
||||
max_phase_one_targets = nil,
|
||||
highlight_unlabeled_phase_one_targets = false,
|
||||
max_highlighted_traversal_targets = 10,
|
||||
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 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.vim.utility.motion.leap;
|
||||
in {
|
||||
{lib, ...}:
|
||||
with lib;
|
||||
with builtins; {
|
||||
options.vim.utility.motion.leap = {
|
||||
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 builtins; let
|
||||
cfg = config.vim.telescope;
|
||||
self = import ./telescope.nix {inherit lib;};
|
||||
mappingDefinitions = self.options.vim.telescope.mappings;
|
||||
|
||||
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
|
||||
in {
|
||||
config = mkIf (cfg.enable) {
|
||||
vim.startPlugins = [
|
||||
"telescope"
|
||||
];
|
||||
|
||||
vim.nnoremap =
|
||||
{
|
||||
"<leader>ff" = "<cmd> Telescope find_files<CR>";
|
||||
"<leader>fg" = "<cmd> Telescope live_grep<CR>";
|
||||
"<leader>fb" = "<cmd> Telescope buffers<CR>";
|
||||
"<leader>fh" = "<cmd> Telescope help_tags<CR>";
|
||||
"<leader>ft" = "<cmd> Telescope<CR>";
|
||||
vim.maps.normal = mkMerge [
|
||||
(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>")
|
||||
|
||||
"<leader>fvcw" = "<cmd> Telescope git_commits<CR>";
|
||||
"<leader>fvcb" = "<cmd> Telescope git_bcommits<CR>";
|
||||
"<leader>fvb" = "<cmd> Telescope git_branches<CR>";
|
||||
"<leader>fvs" = "<cmd> Telescope git_status<CR>";
|
||||
"<leader>fvx" = "<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>";
|
||||
(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>")
|
||||
|
||||
"<leader>flr" = "<cmd> Telescope lsp_references<CR>";
|
||||
"<leader>fli" = "<cmd> Telescope lsp_implementations<CR>";
|
||||
"<leader>flD" = "<cmd> Telescope lsp_definitions<CR>";
|
||||
"<leader>flt" = "<cmd> Telescope lsp_type_definitions<CR>";
|
||||
"<leader>fld" = "<cmd> Telescope diagnostics<CR>";
|
||||
}
|
||||
else {}
|
||||
(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 config.vim.treesitter.enable
|
||||
then {
|
||||
"<leader>fs" = "<cmd> Telescope treesitter<CR>";
|
||||
}
|
||||
else {}
|
||||
);
|
||||
];
|
||||
|
||||
vim.luaConfigRC.telescope = nvim.dag.entryAnywhere ''
|
||||
local telescope = require('telescope')
|
||||
|
|
|
@ -1,11 +1,31 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{lib, ...}:
|
||||
with lib;
|
||||
with builtins; {
|
||||
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";
|
||||
};
|
||||
}
|
||||
|
|
|
@ -67,6 +67,9 @@ in {
|
|||
|
||||
(mkIf cfg.cellularAutomaton.enable {
|
||||
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 ''
|
||||
local config = {
|
||||
fps = 50,
|
||||
|
@ -90,8 +93,6 @@ in {
|
|||
end
|
||||
|
||||
require("cellular-automaton").register_animation(config)
|
||||
|
||||
vim.keymap.set("n", "<leader>fml", "<cmd>CellularAutomaton make_it_rain<CR>")
|
||||
'';
|
||||
})
|
||||
|
||||
|
|
|
@ -24,12 +24,18 @@ in {
|
|||
default = false;
|
||||
};
|
||||
|
||||
cellularAutomaton.enable = mkOption {
|
||||
cellularAutomaton = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
description = "Enable cellular automaton [cellular-automaton]";
|
||||
default = false;
|
||||
};
|
||||
|
||||
mappings = {
|
||||
makeItRain = mkMappingOption "Make it rain [cellular-automaton]" "<leader>fml";
|
||||
};
|
||||
};
|
||||
|
||||
fidget-nvim = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
|
|
Loading…
Reference in a new issue