リビジョン | b9c4628cc7c95c556f9f44a6add68dff6c54d361 (tree) |
---|---|
日時 | 2023-01-19 18:47:59 |
作者 | badcoff33 <none@none> |
コミッター | badcoff33 |
merged
@@ -47,26 +47,34 @@ end | ||
47 | 47 | -- default to ON |
48 | 48 | toggle_blinky() |
49 | 49 | |
50 | - | |
51 | 50 | function hl_word_toggle() |
52 | 51 | if hl_word_timer == nil or #vim.fn.timer_info(hl_word_timer) == 0 then |
53 | - hl_word_timer = vim.fn.timer_start(500, cb_hl_word) | |
52 | + cb_new_color_scheme() | |
53 | + hl_word_timer = vim.fn.timer_start(1000, cb_hl_word) | |
54 | + print("ON") | |
54 | 55 | else |
55 | 56 | vim.fn.timer_stop(hl_word_timer) |
56 | 57 | local save_winid = vim.fn.winnr() |
57 | 58 | vim.cmd('windo match NONE') |
58 | 59 | vim.cmd(save_winid .. ' wincmd w') |
60 | + print("OFF") | |
59 | 61 | end |
60 | 62 | end |
61 | 63 | |
64 | +local hl_word_curpos = {} | |
65 | + | |
62 | 66 | function cb_hl_word() |
63 | 67 | local cword = vim.fn.expand("<cword>") |
64 | 68 | if string.match(cword, "[a-zA-Z0-9_]") ~= nil then |
65 | - vim.cmd('match HlWordUnderline "\\<' .. cword .. '\\>"') | |
69 | + if vim.fn.getcurpos() ~= hl_word_curpos then | |
70 | + vim.cmd('match HlWordUnderline "\\<' .. cword .. '\\>"') | |
71 | + else | |
72 | + hl_word_curpos = vim.fn.getcurpos() | |
73 | + end | |
66 | 74 | else |
67 | 75 | vim.cmd('match NONE') |
68 | 76 | end |
69 | - hl_word_timer = vim.fn.timer_start(500, cb_hl_word) | |
77 | + hl_word_timer = vim.fn.timer_start(1000, cb_hl_word) | |
70 | 78 | end |
71 | 79 | |
72 | 80 | -- Description: Print highlighting information at current cursor position. |
@@ -84,8 +92,6 @@ vim.api.nvim_create_autocmd( | ||
84 | 92 | { group = gid_visuals, pattern = { "*" }, callback = cb_new_color_scheme } |
85 | 93 | ) |
86 | 94 | |
87 | -cb_new_color_scheme() -- set it up when Neovim starts | |
88 | - | |
89 | 95 | vim.api.nvim_create_user_command( |
90 | 96 | "ToggleHlWord", |
91 | 97 | "lua hl_word_toggle()", |