kevinhwang91 / nvim-fFHighlight

Highlight f and F in Neovim

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

nvim-fFHighlight

Highlight the chars and words searched by f and F.

fFHighlight-demo.mp4

Table of contents

Features

  • Highlight the chars searched by f and F
  • Highlight the words including the searched chars
  • Overlap the chars as numbers to jump faster

Quickstart

Requirements

Installation

Install nvim-fFHighlight with Packer.nvim:

use {'kevinhwang91/nvim-fFHighlight'}

Minimal configuration

require('fFHighlight').setup()

Usage

After using Minimal configuration:

The built-in f and F have been improved, enjoy!

Documentation

Setup and description

{
    disable_keymap = {
        description = [[Disable keymaps, users should map them manually]],
        default = false
    },
    disable_words_hl = {
        description = [[Disable the feature of highlighting words]],
        default = false
    },
    number_hint_threshold = {
        description = [[If the count of repeating latest `f` or `F` to the char is equal or greater
                        than this value, use number to overlap char. minimal value is 2]],
        default = 3
    },
    prompt_sign_define = {
        description = [[The optional dict argument for sign_define(), `:h sign_define()` for
                        more details. If this value is `{}`, will disable sign for prompt]],
        default = {text = '->', text_hl = 'fFPromptSign', culhl = 'fFPromptSign'}
    }
}

Highlight

hi default fFHintChar ctermfg=yellow cterm=bold guifg=yellow gui=bold
hi default fFHintNumber ctermfg=yellow cterm=bold guifg=yellow gui=bold
hi default fFHintWords cterm=underline gui=underline
hi default link fFHintCurrentWord fFHintWords
hi default fFPromptSign ctermfg=yellow cterm=bold guifg=yellow gui=bold
  1. fFHintChar: highlight the hint of chars
  2. fFHintNumber: highlight the hint of number
  3. fFHintWords: highlight the hint of words
  4. fFHintCurrentWord: highlight the hint of current word
  5. fFPromptSign: highlight the prompt sign before searching a char

API

-- All API under this module
local m = require('fFHighlight')

--- Find the character to be typed on the current line
---@param backward? boolean the direction of finding character. true is backward, otherwise is forward
m.findChar(backward)

Customize configuration

use {
    'kevinhwang91/nvim-fFHighlight',
    config = function()
        vim.cmd([[
            hi fFHintChar ctermfg=yellow cterm=bold,undercurl guifg=yellow gui=bold,undercurl
            hi fFHintWords cterm=undercurl gui=undercurl guisp=yellow
            hi fFPromptSign ctermfg=yellow cterm=bold guifg=yellow gui=bold
        ]])
        require('fFHighlight').setup({
            disable_keymap = false,
            disable_words_hl = false,
            number_hint_threshold = 3,
            prompt_sign_define = {text = ''}
        })
    end,
    keys = {{'n', 'f'}, {'x', 'f'}, {'n', 'F'}, {'x', 'F'}}
}

Feedback

  • If you get an issue or come up with an awesome idea, don't hesitate to open an issue in github.
  • If you think this plugin is useful or cool, consider rewarding it a star.

License

The project is licensed under a BSD-3-clause license. See LICENSE file for details.

About

Highlight f and F in Neovim

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Lua 100.0%