Update 2024-01-31 08:01 OpenBSD/amd64-x13
This commit is contained in:
parent
96029351a1
commit
3f999f0902
@ -1,22 +0,0 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Romain Lafourcade
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
@ -1,64 +0,0 @@
|
||||
# vim-cool
|
||||
|
||||
Vim-cool disables search highlighting when you are done searching and re-enables it when you search again. That's it. No more `:noh<CR>`, no more `/sytdstdrsid<CR>`, and no more dodgy `<C-l>` mappings.
|
||||
|
||||
Vim-cool is cool.
|
||||
|
||||
Vim-cool is *experimental*.
|
||||
|
||||
![cool](https://user-images.githubusercontent.com/344335/226825463-4ff5e352-ac2e-4f4d-94c7-a8109da7b6db.gif)
|
||||
|
||||
## Requirements
|
||||
|
||||
Vim-cool is intended to be used with Vim, **and only Vim**, 7.4.2008 or later. It may or may not work in other editors but they are not and will not be officially supported.
|
||||
|
||||
## Installation
|
||||
|
||||
Follow your favorite plugin/runtimepath manager's instructions.
|
||||
|
||||
If you choose manual installation, just put `plugin/cool.vim` where it belongs:
|
||||
|
||||
$HOME/.vim/plugin/cool.vim on Unix-like systems
|
||||
$HOME\vimfiles\plugin\cool.vim on Windows
|
||||
|
||||
In Vim 8.0 and above, see `:help package`.
|
||||
|
||||
## Setup
|
||||
|
||||
The whole assumption behind Vim-cool is that the user enabled search highlighting but they don't want the highlighting to linger on when they are done searching. This implies that the user has the following line in their `vimrc`:
|
||||
|
||||
set hlsearch
|
||||
|
||||
That's it. Nothing else to do.
|
||||
|
||||
## Experimental features
|
||||
|
||||
* Show number of matches in the command-line:
|
||||
|
||||
let g:cool_total_matches = 1
|
||||
|
||||
![demo](https://user-images.githubusercontent.com/344335/226825418-12931cf3-5f89-4375-89be-c98a57e177df.png)
|
||||
|
||||
* Do something when we are doing `nnnNNnn`, do something else or do nothing when we are not:
|
||||
|
||||
set statusline+=%{get(g:,'cool_is_searching',0)?'Yep':''}
|
||||
|
||||
## Background
|
||||
|
||||
I wrote the first iteration of vim-cool in about twenty minutes, mostly to test a few ideas I had after a short discussion about `'hlsearch'` and `:nohlsearch` on #vim.
|
||||
|
||||
Because it relied almost exclusively on mappings, that first iteration was way too brittle to be of any use and actually messed with a bunch of my own mappings.
|
||||
|
||||
Then came [@purpleP](https://github.com/purpleP) and [the game-changing approach](https://github.com/romainl/vim-cool/issues/9) he put together with the help of [@chrisbra](https://github.com/chrisbra), [@justinmk](https://github.com/justinmk), [@jamessan](https://github.com/jamessan), and [@ZyX-I](https://github.com/ZyX-I).
|
||||
|
||||
The current version, essentially a weaponized version of @purpleP's code, doesn't rely on mappings anymore and thus should be devoid of nasty side-effects.
|
||||
|
||||
Many thanks to [@bounceme](https://github.com/bounceme) for his help.
|
||||
|
||||
## What they say about vim-cool
|
||||
|
||||
- **puremourning**, in #vim:
|
||||
|
||||
> vim-cool is by far my favourite plugin
|
||||
>
|
||||
> it's just so... cool.
|
@ -1,136 +0,0 @@
|
||||
" vim-cool - Disable hlsearch when you are done searching.
|
||||
" Maintainer: romainl <romainlafourcade@gmail.com>
|
||||
" Version: 0.0.2
|
||||
" License: MIT License
|
||||
" Location: plugin/cool.vim
|
||||
" Website: https://github.com/romainl/vim-cool
|
||||
|
||||
if exists("g:loaded_cool") || v:version < 704 || &compatible
|
||||
finish
|
||||
endif
|
||||
let g:loaded_cool = 1
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
augroup Cool
|
||||
autocmd!
|
||||
augroup END
|
||||
|
||||
if exists('##OptionSet')
|
||||
if !exists('*execute')
|
||||
autocmd Cool OptionSet highlight let <SID>saveh = &highlight
|
||||
endif
|
||||
" toggle coolness when hlsearch is toggled
|
||||
autocmd Cool OptionSet hlsearch call <SID>PlayItCool(v:option_old, v:option_new)
|
||||
endif
|
||||
|
||||
function! s:StartHL()
|
||||
if !v:hlsearch || mode() isnot 'n'
|
||||
return
|
||||
endif
|
||||
let g:cool_is_searching = 1
|
||||
let [pos, rpos] = [winsaveview(), getpos('.')]
|
||||
silent! exe "keepjumps go".(line2byte('.')+col('.')-(v:searchforward ? 2 : 0))
|
||||
try
|
||||
silent keepjumps norm! n
|
||||
if getpos('.') != rpos
|
||||
throw 0
|
||||
endif
|
||||
catch /^\%(0$\|Vim\%(\w\|:Interrupt$\)\@!\)/
|
||||
call <SID>StopHL()
|
||||
return
|
||||
finally
|
||||
call winrestview(pos)
|
||||
endtry
|
||||
if !get(g:,'cool_total_matches') || !exists('*reltimestr')
|
||||
return
|
||||
endif
|
||||
exe "silent! norm! :let g:cool_char=nr2char(screenchar(screenrow(),1))\<cr>"
|
||||
let cool_char = remove(g:,'cool_char')
|
||||
if cool_char !~ '[/?]'
|
||||
return
|
||||
endif
|
||||
let [f, ws, now, noOf] = [0, &wrapscan, reltime(), [0,0]]
|
||||
set nowrapscan
|
||||
try
|
||||
while f < 2
|
||||
if reltimestr(reltime(now))[:-6] =~ '[1-9]'
|
||||
" time >= 100ms
|
||||
return
|
||||
endif
|
||||
let noOf[v:searchforward ? f : !f] += 1
|
||||
try
|
||||
silent exe "keepjumps norm! ".(f ? 'n' : 'N')
|
||||
catch /^Vim[^)]\+):E38[45]\D/
|
||||
call setpos('.',rpos)
|
||||
let f += 1
|
||||
endtry
|
||||
endwhile
|
||||
finally
|
||||
call winrestview(pos)
|
||||
let &wrapscan = ws
|
||||
endtry
|
||||
redraw|echo cool_char.@/ 'match' noOf[0] 'of' noOf[0] + noOf[1] - 1
|
||||
endfunction
|
||||
|
||||
function! s:StopHL()
|
||||
if !v:hlsearch || mode() isnot 'n'
|
||||
return
|
||||
else
|
||||
let g:cool_is_searching = 0
|
||||
silent call feedkeys("\<Plug>(StopHL)", 'm')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
if !exists('*execute')
|
||||
let s:saveh = &highlight
|
||||
" toggle highlighting, a workaround for :nohlsearch in autocmds
|
||||
function! s:AuNohlsearch()
|
||||
noautocmd set highlight+=l:-
|
||||
autocmd Cool Insertleave *
|
||||
\ noautocmd let &highlight = s:saveh | autocmd! Cool InsertLeave *
|
||||
return ''
|
||||
endfunction
|
||||
endif
|
||||
|
||||
function! s:PlayItCool(old, new)
|
||||
if a:old == 0 && a:new == 1
|
||||
" nohls --> hls
|
||||
" set up coolness
|
||||
noremap <silent> <Plug>(StopHL) :<C-U>nohlsearch<cr>
|
||||
if !exists('*execute')
|
||||
noremap! <expr> <Plug>(StopHL) <SID>AuNohlsearch()
|
||||
|
||||
" If no "execute()", ":tnoremap" isn't probably implemented too.
|
||||
else
|
||||
noremap! <expr> <Plug>(StopHL) execute('nohlsearch')[-1]
|
||||
if exists(':tnoremap')
|
||||
tnoremap <expr> <Plug>(StopHL) execute('nohlsearch')[-1]
|
||||
endif
|
||||
endif
|
||||
|
||||
autocmd Cool CursorMoved * call <SID>StartHL()
|
||||
autocmd Cool InsertEnter * call <SID>StopHL()
|
||||
elseif a:old == 1 && a:new == 0
|
||||
" hls --> nohls
|
||||
" tear down coolness
|
||||
nunmap <Plug>(StopHL)
|
||||
unmap! <expr> <Plug>(StopHL)
|
||||
if exists(':tunmap')
|
||||
tunmap <Plug>(StopHL)
|
||||
endif
|
||||
|
||||
autocmd! Cool CursorMoved
|
||||
autocmd! Cool InsertEnter
|
||||
else
|
||||
" nohls --> nohls
|
||||
" do nothing
|
||||
return
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" play it cool
|
||||
call <SID>PlayItCool(0, &hlsearch)
|
||||
|
||||
let &cpo = s:save_cpo
|
16
.vim/vimrc
16
.vim/vimrc
@ -116,8 +116,6 @@ let g:fzf_tags_prompt = "Gd "
|
||||
noreabbrev <expr> ts getcmdtype() == ":" && getcmdline() == 'ts' ? 'FZFTselect' : 'ts'
|
||||
nmap gt <Plug>(fzf_tags)
|
||||
|
||||
|
||||
|
||||
let g:autotagTagsFile = ".tags"
|
||||
let g:autotagCtagsCmd = "ectags"
|
||||
|
||||
@ -130,6 +128,20 @@ match ErrorMsg '\(TODO:\|FIXME\|XXX\|workaround\|WTF\|: error:.*\|\s\+$\| \+\ze\
|
||||
" DIFF
|
||||
set formatoptions=crolj
|
||||
|
||||
" VIMDIFF COLORS
|
||||
hi DiffAdd ctermbg=22 ctermfg=NONE cterm=NONE
|
||||
hi DiffDelete ctermbg=234 ctermfg=NONE cterm=NONE
|
||||
hi DiffChange ctermbg=236 ctermfg=NONE cterm=NONE
|
||||
hi DiffText ctermbg=red ctermfg=NONE cterm=NONE
|
||||
|
||||
" SPLIT AND FOLD COLORS
|
||||
hi VertSplit ctermbg=NONE ctermfg=246 cterm=NONE
|
||||
hi FoldColumn ctermbg=NONE ctermfg=251 cterm=NONE
|
||||
hi Folded ctermbg=233 ctermfg=251 cterm=NONE
|
||||
|
||||
" SPELL COLOR
|
||||
hi SpellBad ctermbg=NONE ctermfg=124
|
||||
|
||||
" TEMPORARY FILES
|
||||
set undofile
|
||||
set undodir=~/.local/vim/undo//
|
||||
|
Loading…
Reference in New Issue
Block a user