Giter Site home page Giter Site logo

jceb / highlight-current-n.nvim Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rktjmp/highlight-current-n.nvim

0.0 1.0 0.0 83 KB

Highlights the current /, ? or * match under your cursor when pressing n or N and gets out of the way afterwards.

License: MIT License

Fennel 95.01% Vim Script 4.99%

highlight-current-n.nvim's Introduction

highlight-current-n

See demo configuration.

highlight-current-n highlights the current /, ? or * match under your cursor when pressing n or N and gets out of the way afterwards.

Installation

Requirements

  • Neovim 0.5
your_package_manager "rktjmp/highlight-current-n.nvim"

Setup & Usage

Configuration

Default options are shown, calling setup is not required unless you are changing an option.

require("highlight_current_n").setup({
  highlight_group = "IncSearch" -- highlight group name to use for highlight
})

See also demo configuration for important information regarding highlighting / and ? searches.

Maps

highlight-current-n provides 2 <Plug> keymaps for your use.

Note: You want to use nmap, not nnoremap for <Plug> mappings.

<Plug>(highlight-current-n-n) should be mapped to n.

nmap n <Plug>(highlight-current-n-n)

<Plug>(highlight-current-n-N) should be mapped to N.

nmap N <Plug>(highlight-current-n-N)

Functions

highlight-current-n provides 3 functions, but probably only 1 is useful.

require("highlight_current_n").n()

Executes feedkeys(n) and applies highlight when appropriate. Normally best run via the provided <Plug> mapping.

require("highlight_current_n").N()

Executes feedkeys(N) and applies highlight when appropriate. Normally best run via the provided <Plug> mapping.

require("highlight_current_n")["/,?"]()

Applies highlight at cursor, most useful when used in combination with the following autocommand, be careful when escaping \? in lua configurations.

autocmd CmdlineLeave /,\? lua require('highlight_current_n')['/,?']()

Demo Configuration

highlight-current-n only provides two maps to show highlights, but the following configuration may be preferred in real world use, especially the last CmdlineLeave autocommand.

" Map keys
nmap n <Plug>(highlight-current-n-n)
nmap N <Plug>(highlight-current-n-N)

" If you want the highlighting to take effect in other maps they must
" also be nmaps (or rather, not "nore").
"
" * will search <cword> ahead, but it can be more ergonomic to have *
" simply fill the / register with the current <cword>, which makes future
" commands like cgn "feel better". This effectively does that by performing
" "search ahead <cword> (*), go back to last match (N)".
nmap * *N

" Some QOL autocommands
augroup ClearSearchHL
  autocmd!
  " You may only want to see hlsearch /while/ searching, you can automatically
  " toggle hlsearch with the following autocommands
  autocmd CmdlineEnter /,\? set hlsearch
  autocmd CmdlineLeave /,\? set nohlsearch
  " this will apply similar n|N highlighting to the first search result
  " careful with escaping ? in lua, you may need \\?
  autocmd CmdlineLeave /,\? lua require('highlight_current_n')['/,?']()
augroup END

highlight-current-n.nvim's People

Contributors

rktjmp avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.