Open phongvcao opened 1 year ago
Can you try set_highlights = true,
?
yeah that still doesn't work.
@petertriho ok I finally got it to work with the following config. However, when I press key <CR>
and then n
or N
of hlslens
to navigate to the next / prev search results, the entire ScrollbarSearchHandle
& ScrollbarSearch
disappear (screenshots attached below):
lua <<EOF
local ensure_packer = function()
local fn = vim.fn
local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim'
if fn.empty(fn.glob(install_path)) > 0 then
fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path})
vim.cmd [[packadd packer.nvim]]
return true
end
return false
end
local packer_bootstrap = ensure_packer()
-- Setup packer
local use = require('packer').use
require('packer').startup(function()
use 'wbthomason/packer.nvim' -- Package manager
use {
'kevinhwang91/nvim-hlslens',
config = function()
-- require('hlslens').setup() is not required
require("scrollbar.handlers.search").setup({
override_lens = function(render, posList, nearest, idx, relIdx)
local sfw = vim.v.searchforward == 1
local indicator, text, chunks
local absRelIdx = math.abs(relIdx)
if absRelIdx > 1 then
indicator = ('%d%s'):format(absRelIdx, sfw ~= (relIdx > 1) and ' N ▲' or ' n ▼')
elseif absRelIdx == 1 then
indicator = sfw ~= (relIdx == 1) and ' N ▲' or ' n ▼'
else
indicator = ''
end
local lnum, col = unpack(posList[idx])
if nearest then
local cnt = #posList
if indicator ~= '' then
text = (' %s %d / %d '):format(indicator, idx, cnt)
else
text = (' %d / %d '):format(idx, cnt)
end
chunks = {{' ', 'Ignore'}, {text, 'HlSearchLensNear'}}
else
local cnt = #posList
text = (' %s %d / %d '):format(indicator, idx, cnt)
chunks = {{' ', 'Ignore'}, {text, 'HlSearchLens'}}
end
render.setVirt(0, lnum - 1, col - 1, chunks, nearest)
end,
-- override_lens = function() end,
build_position_cb = function(plist, _, _, _)
require("scrollbar.handlers.search").handler.show(plist.start_pos)
end,
})
end,
}
use {
"petertriho/nvim-scrollbar",
requires = { "kevinhwang91/nvim-hlslens" },
config = function()
vim.cmd([[
augroup scrollbar_search_hide
autocmd!
autocmd CmdlineLeave : lua require('scrollbar.handlers.search').handler.hide()
autocmd BufEnter * :hi ScrollbarHandle ctermfg=1 guifg=#222222
autocmd BufEnter * :hi ScrollbarSearch ctermfg=1 guifg=#222222
autocmd BufEnter * :hi ScrollbarSearchHandle ctermfg=1 guifg=#222222
augroup END
]])
end,
}
-- Automatically set up your configuration after cloning packer.nvim
-- Put this at the end after all plugins
if packer_bootstrap then
require('packer').sync()
end
end)
local kopts = {noremap = true, silent = true}
vim.api.nvim_set_keymap('n', 'n',
[[<Cmd>execute('normal! ' . v:count1 . 'n')<CR><Cmd>lua require('hlslens').start()<CR>]],
kopts)
vim.api.nvim_set_keymap('n', 'N',
[[<Cmd>execute('normal! ' . v:count1 . 'N')<CR><Cmd>lua require('hlslens').start()<CR>]],
kopts)
vim.api.nvim_set_keymap('n', '*', [[*<Cmd>lua require('hlslens').start()<CR>]], kopts)
vim.api.nvim_set_keymap('n', '#', [[#<Cmd>lua require('hlslens').start()<CR>]], kopts)
vim.api.nvim_set_keymap('n', 'g*', [[g*<Cmd>lua require('hlslens').start()<CR>]], kopts)
vim.api.nvim_set_keymap('n', 'g#', [[g#<Cmd>lua require('hlslens').start()<CR>]], kopts)
vim.api.nvim_set_keymap('n', '<Leader>l', '<Cmd>noh<CR>', kopts)
-- nvim-scrollbar settings
require("scrollbar").setup({
set_highlights = true,
})
Screenshots:
Before Pressing <CR>
and then n
or N
:
After Pressing <CR>
and then n
or N
(it actually disappears sometimes right after <CR>
):
In this block
vim.cmd([[
augroup scrollbar_search_hide
autocmd!
autocmd CmdlineLeave : lua require('scrollbar.handlers.search').handler.hide()
autocmd BufEnter * :hi ScrollbarHandle ctermfg=1 guifg=#222222
autocmd BufEnter * :hi ScrollbarSearch ctermfg=1 guifg=#222222
autocmd BufEnter * :hi ScrollbarSearchHandle ctermfg=1 guifg=#222222
augroup END
]])
Remove autocmd CmdlineLeave : lua require('scrollbar.handlers.search').handler.hide()
Ok I might have found a hint. So if I disable dense-analysis/ale
it works. It looks like it only disappears when ALE
is on. I tried disabling coc.nvim
too but it didn't make a difference. I also tried disabling ale
's virtualtext
using let g:ale_virtualtext_cursor = 0
but it doesn't help. Here is my ale
settings in .vimrc
:
" ale settings
if exists('g:custom_ale_linters')
let g:ale_linters = g:custom_ale_linters
endif
let g:ale_virtualenv_dir_names = []
let g:ale_cache_executable_check_failures = 1
let g:ale_completion_enabled = 0
let g:ale_completion_delay = 300
let g:ale_completion_max_suggestions = 0
let g:ale_lint_delay = 300
let g:ale_lint_on_text_changed = 'always'
let g:ale_lint_on_insert_leave = 1
let g:ale_lint_on_filetype_changed = 1
let g:ale_lint_on_enter = 1
let g:ale_lint_on_save = 1
let g:ale_update_tagstack = 0
let g:ale_set_loclist = 0
let g:ale_set_quickfix = 0
let g:ale_set_highlights = 0
let g:ale_open_list = 0
if exists('g:custom_ale_sign_error')
let g:ale_sign_error = g:custom_ale_sign_error
endif
if exists('g:custom_ale_sign_warning')
let g:ale_sign_warning = g:custom_ale_sign_warning
endif
if exists('g:custom_ale_sign_info')
let g:ale_sign_info = g:custom_ale_sign_info
endif
if exists('g:custom_ale_sign_style_error')
let g:ale_sign_style_error = g:custom_ale_sign_style_error
endif
if exists('g:custom_ale_sign_style_warning')
let g:ale_sign_style_warning = g:custom_ale_sign_style_warning
endif
" Set this if you want to.
" This can be useful if you are combining ALE with
" some other plugin which sets quickfix errors, etc.
let g:ale_keep_list_window_open = 0
let g:ale_use_global_executables = 1
Since nvim-scrollbar
has ale
integration, I'm guessing lots of people using nvim-scrollbar
with ALE
enabled? Can you share your ALE
config here - I wonder what ALE
config I did wrong that led to this.
ok even if I disabled all of my ALE
configs, nvim-scrollbar
still disappears as above. I also disabled all other Vim plugins & my entire .vimrc
& init.lua
except nvim-scrollbar
and hlslens
. Hence it looks like nvim-scrollbar
's Search
doesn't play well with default config of ALE
?
It happens to me also, I'm not using ale (is that required?). lsp neovim + nvim-scrollbar + nvim-hlslens and search does not show.
Same here
@AndreaHasani @TxHawks
I had the same problem and figured out how to turn on search marks (with virtualtext at the same time like in the demo gif).
Add the option handlers = { search = true },
to the example configuration in the readme. I think this handler is false by default.
use {
"kevinhwang91/nvim-hlslens",
config = function()
-- require('hlslens').setup() is not required
require("scrollbar.handlers.search").setup({
handlers = { search = true },
})
end,
}
Describe the bug I cannot get
nvim-scrollbar
to show Search marks usinghlslens
no matter which way I configure it.To Reproduce Here is my entire configuration:
Expected behavior Search marks should have been shown.
Screenshots
Version Info (please complete the following information):