Update 2024-12-15 14:45 OpenBSD/amd64-t14
This commit is contained in:
21
.vim/pack/plugins/start/vim-cursorword/LICENSE
Normal file
21
.vim/pack/plugins/start/vim-cursorword/LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015-2022 itchyny
|
||||
|
||||
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.
|
||||
12
.vim/pack/plugins/start/vim-cursorword/README.md
Normal file
12
.vim/pack/plugins/start/vim-cursorword/README.md
Normal file
@@ -0,0 +1,12 @@
|
||||
# vim-cursorword
|
||||
## Underlines the word under the cursor
|
||||

|
||||
|
||||
## Installation
|
||||
Install with your favorite plugin manager.
|
||||
|
||||
## Author
|
||||
itchyny (https://github.com/itchyny)
|
||||
|
||||
## License
|
||||
This software is released under the MIT License, see LICENSE.
|
||||
@@ -0,0 +1,58 @@
|
||||
" =============================================================================
|
||||
" Filename: autoload/cursorword.vim
|
||||
" Author: itchyny
|
||||
" License: MIT License
|
||||
" Last Change: 2022/11/17 08:57:47.
|
||||
" =============================================================================
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
function! cursorword#highlight() abort
|
||||
if !get(g:, 'cursorword_highlight', 1) | return | endif
|
||||
highlight default CursorWord term=underline cterm=underline gui=underline
|
||||
endfunction
|
||||
|
||||
let s:alphabets = '^[\x00-\x7f\xb5\xc0-\xd6\xd8-\xf6\xf8-\u01bf\u01c4-\u02af\u0370-\u0373\u0376\u0377\u0386-\u0481\u048a-\u052f]\+$'
|
||||
|
||||
function! cursorword#matchadd(...) abort
|
||||
let enable = get(b:, 'cursorword', get(g:, 'cursorword', 1)) && !has('vim_starting')
|
||||
if !enable && !get(w:, 'cursorword_match') | return | endif
|
||||
let i = (a:0 ? a:1 : mode() ==# 'i' || mode() ==# 'R') && col('.') > 1
|
||||
let line = getline('.')
|
||||
let word = matchstr(line[:(col('.')-i-1)], '\k*$') . matchstr(line[(col('.')-i-1):], '^\k*')[1:]
|
||||
if get(w:, 'cursorword_state', []) ==# [ word, enable ] | return | endif
|
||||
let w:cursorword_state = [ word, enable ]
|
||||
if get(w:, 'cursorword_match')
|
||||
silent! call matchdelete(w:cursorword_id)
|
||||
endif
|
||||
let w:cursorword_match = 0
|
||||
if !enable || word ==# '' || len(word) !=# strchars(word) && word !~# s:alphabets || len(word) > 1000 | return | endif
|
||||
let pattern = '\<' . escape(word, '~"\.^$[]*') . '\>'
|
||||
let w:cursorword_id = matchadd('CursorWord', pattern, -100)
|
||||
let w:cursorword_match = 1
|
||||
endfunction
|
||||
|
||||
let s:delay = get(g:, 'cursorword_delay', 50)
|
||||
if has('timers') && s:delay > 0
|
||||
let s:timer = 0
|
||||
function! cursorword#cursormoved() abort
|
||||
if get(w:, 'cursorword_match')
|
||||
silent! call matchdelete(w:cursorword_id)
|
||||
let w:cursorword_match = 0
|
||||
let w:cursorword_state = []
|
||||
endif
|
||||
call timer_stop(s:timer)
|
||||
let s:timer = timer_start(s:delay, 'cursorword#timer_callback')
|
||||
endfunction
|
||||
function! cursorword#timer_callback(...) abort
|
||||
call cursorword#matchadd()
|
||||
endfunction
|
||||
else
|
||||
function! cursorword#cursormoved() abort
|
||||
call cursorword#matchadd()
|
||||
endfunction
|
||||
endif
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
72
.vim/pack/plugins/start/vim-cursorword/doc/cursorword.txt
Normal file
72
.vim/pack/plugins/start/vim-cursorword/doc/cursorword.txt
Normal file
@@ -0,0 +1,72 @@
|
||||
*cursorword.txt* Underlines the word under the cursor
|
||||
|
||||
Author: itchyny (https://github.com/itchyny)
|
||||
License: MIT License
|
||||
Repository: https://github.com/itchyny/vim-cursorword
|
||||
Last Change: 2022/11/17 18:55:06.
|
||||
|
||||
CONTENTS *cursorword-contents*
|
||||
|
||||
Introduction |cursorword-introduction|
|
||||
Options |cursorword-options|
|
||||
Changelog |cursorword-changelog|
|
||||
|
||||
==============================================================================
|
||||
INTRODUCTION *cursorword-introduction*
|
||||
This *cursorword* plugin underlines the word under the cursor. That's it.
|
||||
|
||||
While we are coding, we always pay attention to the variable under the cursor.
|
||||
Where did we define the variable? In which statement do we use the variable?
|
||||
Searching the variable using |star| or |#| is a simple solution to highlight all
|
||||
the places the variable is used. However, it costs too much time to highlight
|
||||
a word, move around to check the places and clear the highlight. This plugin
|
||||
|cursorword| provides you the modest underlines for the variables under the
|
||||
cursor to let you know all the places the variable is used at a glance without
|
||||
stopping coding.
|
||||
|
||||
The brightest plugin (https://github.com/osyo-manga/vim-brightest) is a nice
|
||||
plugin to fulfill highlights of the word under the cursor. However, it uses
|
||||
too long codes and is too slow. I had been using the plugin for a while but I
|
||||
could not bear the slowness caused by brightest on the cursor motions. This is
|
||||
why I created |cursorword|. I think that a plugin which is running all the time
|
||||
should be coded with the performance efficiency in mind. When we publish a
|
||||
plugin which stays running in all buffers, we should be aware that it will use
|
||||
much resource of all the users.
|
||||
|
||||
The code of |cursorword| is very tiny. It's very tiny that |cursorword| runs ten
|
||||
times faster than brightest. Instead of its efficiency, |cursorword| is totally
|
||||
unconfigurable. But you will find this plugin just comfortable; the modest
|
||||
underlines are enough for us. A good configurable plugin would have many
|
||||
options that users can configure almost all the features. But be relaxed and
|
||||
imagine, do we need such a lot of options for a plugin to highlight the word
|
||||
under the cursor? Most people would never need such a lot of options. We
|
||||
should not implement features for a few power users at the sacrifice of the
|
||||
performance of the software. Keep your software small for the happiness of
|
||||
most users. Too much configurability makes your software dirty and causes
|
||||
unwanted slowness on many users. We have to rethink what good configurability
|
||||
is and for what kind of software such configurability is required.
|
||||
|
||||
==============================================================================
|
||||
OPTIONS *cursorword-options*
|
||||
|
||||
g:cursorword *g:cursorword*
|
||||
Set this variable to 0 to disable this plugin globally.
|
||||
|
||||
b:cursorword *b:cursorword*
|
||||
If you set this variable to 0, the plugin stops highlighting
|
||||
the word under the cursor in the buffer. This variable has
|
||||
priority over |g:cursorword|.
|
||||
|
||||
g:cursorword_highlight *g:cursorword_highlight*
|
||||
Set this variable to 0 to disable the default highlighting
|
||||
style. If you set this variable to 0, you need to define your
|
||||
own style for the CursorWord |highlight-groups|.
|
||||
|
||||
g:cursorword_delay *g:cursorword_delay*
|
||||
The delay duration in milliseconds for setting the word
|
||||
highlight after cursor motions. When the value is set to 0, the
|
||||
plugin highlights the word synchronously, but there is a
|
||||
performance sacrifice. The default value is 50.
|
||||
|
||||
==============================================================================
|
||||
vim:tw=78:sw=4:ts=8:ft=help:norl:noet:
|
||||
32
.vim/pack/plugins/start/vim-cursorword/plugin/cursorword.vim
Normal file
32
.vim/pack/plugins/start/vim-cursorword/plugin/cursorword.vim
Normal file
@@ -0,0 +1,32 @@
|
||||
" =============================================================================
|
||||
" Filename: plugin/cursorword.vim
|
||||
" Author: itchyny
|
||||
" License: MIT License
|
||||
" Last Change: 2020/05/01 19:05:29.
|
||||
" =============================================================================
|
||||
|
||||
if exists('g:loaded_cursorword') || v:version < 703
|
||||
finish
|
||||
endif
|
||||
let g:loaded_cursorword = 1
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
augroup cursorword
|
||||
autocmd!
|
||||
if has('vim_starting')
|
||||
autocmd VimEnter * call cursorword#highlight() |
|
||||
\ autocmd cursorword WinEnter,BufEnter * call cursorword#matchadd()
|
||||
else
|
||||
call cursorword#highlight()
|
||||
autocmd WinEnter,BufEnter * call cursorword#matchadd()
|
||||
endif
|
||||
autocmd ColorScheme * call cursorword#highlight()
|
||||
autocmd CursorMoved,CursorMovedI * call cursorword#cursormoved()
|
||||
autocmd InsertEnter * call cursorword#matchadd(1)
|
||||
autocmd InsertLeave * call cursorword#matchadd(0)
|
||||
augroup END
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
Reference in New Issue
Block a user