From 7afdcaf81adf9eea66d099729dcc74c2069c8783 Mon Sep 17 00:00:00 2001 From: Natty Date: Sat, 20 Jan 2024 01:58:39 +0100 Subject: [PATCH] Heirline separators, leap.nvim, better binds --- init.lua | 37 +++++++++++++--------- mappings.lua | 7 ++++- options.lua | 10 ++++++ plugins.lua | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 127 insertions(+), 16 deletions(-) diff --git a/init.lua b/init.lua index 5f6f173..8417ee6 100644 --- a/init.lua +++ b/init.lua @@ -1,19 +1,26 @@ local config = { - updater = { - remote = "origin", - channel = "stable", - version = "latest", - branch = "nightly", - commit = nil, - pin_plugins = nil, - skip_prompts = false, - show_changelog = true, - auto_quit = false, - remotes = {} - }, - colorscheme = "catppuccin", - polish = function() - end + updater = { + remote = "origin", + channel = "stable", + version = "latest", + branch = "nightly", + commit = nil, + pin_plugins = nil, + skip_prompts = false, + show_changelog = true, + auto_quit = false, + remotes = {} + }, + colorscheme = "catppuccin", + heirline = { + separators = { + left = { "", " " }, -- separator for the left side of the statusline + right = { " ", " " }, -- separator for the right side of the statusline + tab = { "", "" }, + } + }, + polish = function() + end } return config diff --git a/mappings.lua b/mappings.lua index 4329955..34d655b 100644 --- a/mappings.lua +++ b/mappings.lua @@ -1,15 +1,20 @@ return { n = { [""] = {"db", desc = "Ctrl+Backspace to delete a word backwards"}, + [""] = {"db", desc = "Ctrl+Backspace to delete a word backwards (Neovide)"}, [""] = {"dw", desc = "Ctrl+Delete to delete a word forwards"}, [""] = {":Neotree close:UndotreeToggle", desc = "Toggle undo tree"}, [""] = {"h", desc = "Go to the window left"}, [""] = {"l", desc = "Go to the window right"}, [""] = {"k", desc = "Go to the window up"}, - [""] = {"j", desc = "Go to the window down"} + [""] = {"j", desc = "Go to the window down"}, + ["K"] = {require("hover").hover, desc = "Show hover.nvim popup"}, + [""] = {":Telescope buffers", desc = "Show Telescope for open buffers"}, + [""] = {":Telescope registers", desc = "Show Telescope for register paste"} }, i = { ["\b"] = {"db", desc = "Ctrl+Backspace to delete a word backwards"}, + [""] = {"db", desc = "Ctrl+Backspace to delete a word backwards (Neovide)"}, [""] = {"dw", desc = "Ctrl+Delete to delete a word forwards"} } } diff --git a/options.lua b/options.lua index 17615af..6b1700f 100644 --- a/options.lua +++ b/options.lua @@ -5,6 +5,16 @@ local options = function(local_vim) local_vim.expandtab = {} local_vim.smartindent = {} local_vim.autoindent = {} + -- Neovide + local_vim.opt.guifont = "Monaspace Radon:h11" + local_vim.g.neovide_cursor_vfx_mode = "pixiedust" + local_vim.g.neovide_cursor_vfx_particle_density = 14.0 + + -- Currently buggy, needs an edit to trigger + local_vim.g.inlay_hints_enabled = true + + -- Grey out the search area for leap.nvim + vim.api.nvim_set_hl(0, 'LeapBackdrop', { fg = "#888888" }) return local_vim end diff --git a/plugins.lua b/plugins.lua index b5b6c73..fc2470c 100644 --- a/plugins.lua +++ b/plugins.lua @@ -185,4 +185,93 @@ return {{ -- return the new table to be used return opts end, +}, { + "lewis6991/hover.nvim", + name = "hover", + config = function() + require("hover").setup { + 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, + mouse_providers = { + 'LSP' + }, + mouse_delay = 1000 + } + end +}, { + "ggandor/leap.nvim", + name = "leap", + lazy = false, + config = function() + local leap = require('leap') + leap.setup { + highlight_unlabeled_phase_one_targets = true + } + leap.create_default_mappings() + + -- Magic trick from https://github.com/ggandor/leap.nvim/issues/65#issuecomment-1637749795 + -- to highlight already matched parts + local function highlight_unlabeled_phase_one_targets(targets, first_idx, last_idx) + local hl = require('leap.highlight') + for i = first_idx or 1, last_idx or #targets do + local target = targets[i] + if target.chars then + local bufnr = target.wininfo.bufnr + local id = vim.api.nvim_buf_set_extmark( + bufnr, hl.ns, target.pos[1] - 1, target.pos[2] - 1, + { + virt_text = { { table.concat(target.chars), "LeapMatch" } }, + virt_text_pos = "overlay", + hl_mode = "combine", + priority = hl.priority.label, + } + ) + -- This way Leap automatically cleans up your stuff together with its own. + table.insert(hl.extmarks, { bufnr, id }) + end + end + -- Continue with Leap's native function body. + return true + end + + leap.opts.on_beacons = highlight_unlabeled_phase_one_targets + end +}, { + "rebelot/heirline.nvim", + opts = function(_, opts) + -- Config override from: https://docs.astronvim.com/recipes/status#default-statusline-with-mode-text + local status = require("astronvim.utils.status") + opts.statusline = { -- statusline + hl = { fg = "fg", bg = "bg" }, + status.component.mode { mode_text = { padding = { left = 1, right = 1 } } }, -- add the mode text + status.component.git_branch(), + status.component.file_info { filetype = {}, filename = false, file_modified = false }, + status.component.git_diff(), + status.component.diagnostics(), + status.component.fill(), + status.component.cmd_info(), + status.component.fill(), + status.component.lsp(), + status.component.treesitter(), + status.component.nav(), + -- remove the 2nd mode indicator on the right + } + + -- return the final configuration table + return opts + end, }}