plugin/ux: add hop (easy motion) plugin

This commit is contained in:
Dmitriy Pleshevskiy 2022-09-18 16:10:03 +03:00
parent 252f3cf2a6
commit 3d704b32d0
Signed by: pleshevskiy
GPG key ID: 1B59187B161C0215
4 changed files with 50 additions and 2 deletions

View file

@ -22,6 +22,7 @@ let
})
./plugins/lsp
./plugins/formatter
./plugins/ux
];
basicConfigs = builtins.map builtins.readFile [ ./config/basic.lua ];

View file

@ -7,5 +7,5 @@ vim.g.loaded_netrwPlugin = 1
-- empty setup using defaults
require("nvim-tree").setup()
vim.keymap.set("n", "<leader>nt", ":NvimTreeToggle<CR>")
vim.keymap.set("n", "<leader>nf", ":NvimTreeFindFile<CR>")
vim.keymap.set("n", "<leader>nt", "<Cmd>NvimTreeToggle<CR>")
vim.keymap.set("n", "<leader>nf", "<Cmd>NvimTreeFindFile<CR>")

7
plugins/ux/default.nix Normal file
View file

@ -0,0 +1,7 @@
{ hop-nvim, ... }:
{
luaConfig = builtins.readFile ./hop-nvim.lua;
plugins = [ hop-nvim ];
}

40
plugins/ux/hop-nvim.lua Normal file
View file

@ -0,0 +1,40 @@
-- See: https://github.com/phaazon/hop.nvim/wiki/Configuration
local hop = require("hop")
require("hop").setup({})
-------------------------------------------------------------------------------
-- Keybindings
local hint = require("hop.hint")
vim.keymap.set("", "f", function()
hop.hint_char1({
direction = hint.HintDirection.AFTER_CURSOR,
current_line_only = true,
})
end)
vim.keymap.set("", "F", function()
hop.hint_char1({
direction = hint.HintDirection.BEFORE_CURSOR,
current_line_only = true,
})
end)
vim.keymap.set("", "t", function()
hop.hint_char1({
direction = hint.HintDirection.AFTER_CURSOR,
current_line_only = true,
hint_offset = -1,
})
end)
vim.keymap.set("", "T", function()
hop.hint_char1({
direction = hint.HintDirection.BEFORE_CURSOR,
current_line_only = true,
hint_offset = 1,
})
end)
vim.keymap.set("n", "<leader>hw", "<Cmd>HopWord<CR>")
vim.keymap.set("n", "<leader>hp", "<Cmd>HopPattern<CR>")
vim.keymap.set("n", "<leader>hl", "<Cmd>HopLine<CR>")
vim.keymap.set("n", "<leader>hv", "<Cmd>HopVertical<CR>")