Skip to content

Commit

Permalink
added hop fork and better hover
Browse files Browse the repository at this point in the history
  • Loading branch information
quantumfate committed Jul 1, 2023
1 parent ad3a739 commit 23059d3
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 17 deletions.
11 changes: 6 additions & 5 deletions lazy-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
"dressing": { "branch": "master", "commit": "e6eff7a5a950a853c3903d906dbcea03f778db5f" },
"friendly-snippets": { "branch": "main", "commit": "1723ae01d83f3b3ac1530f1ae22b7b9d5da7749b" },
"gitsigns": { "branch": "main", "commit": "a36bc3360d584d39b4fb076d855c4180842d4444" },
"hop": { "branch": "v2", "commit": "90db1b2c61b820e230599a04fedcd2679e64bd07" },
"hop": { "branch": "master", "commit": "31e0e42e629bf16affea747132d9c54f55fb17c8" },
"hover": { "branch": "main", "commit": "b33e1f725a9bb181061425632672fa5ecc557e06" },
"indent-blankline": { "branch": "master", "commit": "7075d7861f7a6bbf0de0298c83f8a13195e6ec01" },
"lazy.nvim": { "branch": "main", "commit": "d65d5441d997c98be8c261ca8537694c5f4642be" },
"lazy.nvim": { "branch": "main", "commit": "f8611632d0f9c6818e8eb54f9bcd1dad122b5a7f" },
"lualine": { "branch": "master", "commit": "05d78e9fd0cdfb4545974a5aa14b1be95a86e9c9" },
"luasnip": { "branch": "master", "commit": "105b5f7f72c13e682a3aa5d29eac2408ae513b22" },
"mason": { "branch": "main", "commit": "b68d3be4b664671002221d43c82e74a0f1006b26" },
Expand All @@ -40,16 +41,16 @@
"nvim-lspconfig": { "branch": "master", "commit": "0011c435282f043a018e23393cae06ed926c3f4a" },
"nvim-navic": { "branch": "master", "commit": "32cff45f1c84bec5e2a7bf15c0f3c6739b64c85d" },
"nvim-notify": { "branch": "master", "commit": "ea9c8ce7a37f2238f934e087c255758659948e0f" },
"nvim-tree": { "branch": "master", "commit": "3cc698b35b0a67792c61e1726830bb9ecfc4c9f4" },
"nvim-treesitter": { "branch": "master", "commit": "393bc5bec591caeedb0a4c696d15946c5d6c2de8" },
"nvim-tree": { "branch": "master", "commit": "1fe32286db79719dd6e52236f82c5b52df3ccaa9" },
"nvim-treesitter": { "branch": "master", "commit": "3fde1587d0850d46b5a1473e5d1e59254e947496" },
"nvim-web-devicons": { "branch": "master", "commit": "9ab9b0b894b2388a9dbcdee5f00ce72e25d85bf9" },
"plenary": { "branch": "master", "commit": "102c02903c74b93c705406bf362049383abc87c8" },
"plenary.nvim": { "branch": "master", "commit": "102c02903c74b93c705406bf362049383abc87c8" },
"project": { "branch": "main", "commit": "8c6bad7d22eef1b71144b401c9f74ed01526a4fb" },
"schemastore": { "branch": "main", "commit": "0ba3914a03a4689441170d6b6796500a09b5c189" },
"structlog": { "branch": "main", "commit": "45b26a2b1036bb93c0e83f4225e85ab3cee8f476" },
"swenv": { "branch": "main", "commit": "08aea3e8809ab00dfcab3cebb466dcb8001ad162" },
"telescope": { "branch": "master", "commit": "c5b11f4fe780f4acd6ed0d58575d3cb7af3e893a" },
"telescope": { "branch": "master", "commit": "b14de80d1cdf66f988f6550ca8577c43bb3797cd" },
"telescope-dap.nvim": { "branch": "master", "commit": "313d2ea12ae59a1ca51b62bf01fc941a983d9c9c" },
"telescope-file-browser.nvim": { "branch": "master", "commit": "721f716f7392284ded78b4867fa67cf4b0605945" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "9bc8237565ded606e6c366a71c64c0af25cd7a50" },
Expand Down
1 change: 1 addition & 0 deletions lua/qvim/config/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ return {
"vimtex",
"whichkey",
"catppuccin",
"hover",
},
languages = {
-- https://github.com/nvim-treesitter/nvim-treesitter#supported-languages
Expand Down
31 changes: 22 additions & 9 deletions lua/qvim/integrations/hop.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ local M = {}

local utils = require("qvim.utils")
local Log = require("qvim.log")
local directions = require("hop.hint").HintDirection
local hint_position = require("hop.hint").HintPosition
---Registers the global configuration scope for hop
function M:init()
local hop = {
Expand All @@ -15,41 +15,54 @@ function M:init()
name = "+Hop",
bindings = {
h = {
desc = "Jump anywhere after the selected cursor.",
desc = "Jump before any char.",
callback = function()
local hop = require("hop")
hop.hint_char1({ direction = directions.AFTER_CURSOR, current_line_only = false })
hop.hint_char1({
current_line_only = false,
hint_offset = -1,
})
end,
},
H = {
desc = "Jump anywhere before the selected cursor.",
desc = "Jump after any char.",
callback = function()
local hop = require("hop")
hop.hint_char1({ direction = directions.BEFORE_CURSOR, current_line_only = false })
hop.hint_char1({
current_line_only = false,
hint_offset = 1,
})
end,
},
t = {
desc = "Jump after the selected cursor on the current line only.",
desc = "Jump before any char on the current line.",
callback = function()
local hop = require("hop")
hop.hint_char1({
direction = directions.AFTER_CURSOR,
current_line_only = true,
hint_offset = -1,
})
end,
},
T = {
desc = "Jump before the selected cursor on the current line only.",
desc = "Jump after any char on the current line.",
callback = function()
local hop = require("hop")
hop.hint_char1({
direction = directions.BEFORE_CURSOR,
current_line_only = true,
hint_offset = 1,
})
end,
},
["/"] = {
desc = "Jump to search pattern.",
callback = function()
local hop = require("hop")
hop.hint_patterns({
current_line_only = false,
})
end,
},
},
options = {
prefix = "<leader>",
Expand Down
53 changes: 53 additions & 0 deletions lua/qvim/integrations/hover.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---The hover configuration file
local M = {}

local Log = require("qvim.log")

---Registers the global configuration scope for hover
function M:init()
local hover = {
active = true,
on_config_done = nil,
keymaps = {},
options = {
-- hover option configuration
init = function()
-- Require providers
require("hover.providers.lsp")
require("hover.providers.gh")
-- require('hover.providers.gh_user')
-- require('hover.providers.jira')
-- require('hover.providers.man')
-- require('hover.providers.dictionary')
end,
preview_opts = {
border = "single",
},
-- Whether the contents of a currently open hover window should be moved
-- to a :h preview-window when pressing the hover keymap.
preview_window = false,
title = true,
},
}
return hover
end

---The hover setup function. The module will be required by
---this function and it will call the respective setup function.
---A on_config_done function will be called if the plugin implements it.
function M:setup()
local status_ok, hover = pcall(reload, "hover")
if not status_ok then
Log:warn(string.format("The plugin '%s' could not be loaded.", hover))
return
end

local _hover = qvim.integrations.hover
hover.setup(_hover.options)

if _hover.on_config_done then
_hover.on_config_done()
end
end

return M
1 change: 0 additions & 1 deletion lua/qvim/integrations/loader/spec/config/hop.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
local hop = {
lazy = true,
branch = "v2",
}

return hop
5 changes: 5 additions & 0 deletions lua/qvim/integrations/loader/spec/config/hover.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
local hover = {
lazy = false,
}

return hover
3 changes: 2 additions & 1 deletion lua/qvim/integrations/loader/spec/config/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ M.qvim_integrations = {
"nvim-telescope/telescope.nvim",
"nvim-lua/plenary.nvim",
tree = "kyazdani42/nvim-tree.lua",
"phaazon/hop.nvim",
"ahmedkhalf/project.nvim",
"folke/neodev.nvim",
notify = "rcarriga/nvim-notify",
Expand All @@ -50,7 +49,9 @@ M.qvim_integrations = {
"stevearc/dressing.nvim",
"AckslD/swenv.nvim",
"p00f/clangd_extensions.nvim",
"lewis6991/hover.nvim",
"AlexvZyl/nordic.nvim",
"smoka7/hop.nvim",
catppuccin = "catppuccin/nvim",
"utilyre/barbecue.nvim",
}
Expand Down
3 changes: 2 additions & 1 deletion lua/qvim/lang/lsp/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ return {
skipped_filetypes = skipped_filetypes,
},
buffer_mappings = {
["K"] = { "<cmd>lua vim.lsp.buf.hover()<cr>", "Show hover" },
["K"] = { callback = require("hover").hover, desc = "Show hover" },
["gK"] = { callback = require("hover").hover_select, desc = "Select hover and show" },
{
binding_group = "l",
name = "+LSP",
Expand Down

0 comments on commit 23059d3

Please sign in to comment.