diff --git a/lua/custom/plugins/ui.lua b/lua/custom/plugins/ui.lua index e7e9634..d55addc 100644 --- a/lua/custom/plugins/ui.lua +++ b/lua/custom/plugins/ui.lua @@ -260,8 +260,15 @@ return { lazy = false, event = { 'BufReadPost', 'BufNewFile' }, opts = { + -- providers: provider used to get references in the buffer, ordered by priority + providers = { + 'lsp', + 'treesitter', + 'regex', + }, + large_file_cutoff = 50000, delay = 200, - under_cursor = false, + under_cursor = true, modes_allowlist = { 'n', 'no', 'nt' }, filetypes_denylist = { 'DiffviewFileHistory', @@ -271,6 +278,8 @@ return { 'git', 'minifiles', 'neo-tree', + 'NvimTree_1', + 'dashboard', }, }, -- looks weird but is useful: put your cursor on a word and other occurences @@ -283,36 +292,22 @@ return { -- ############## word ###### -- #### word #### word word # -- - -- (It might not work with comments) + -- (Does only work if the regex source is currently active, otherwise the + -- references are those your language server or treesitter gives out, so + -- syntax aware) keys = { { ']]', desc = 'Next Reference' }, { '[[', desc = 'Prev Reference' }, }, config = function(_, opts) - require('illuminate').configure(opts) - - -- only magic follows - local function map(key, dir, buffer) - vim.keymap.set('n', key, function() - require('illuminate')['goto_' .. dir .. '_reference'](false) - end, { - desc = dir:sub(1, 1):upper() .. dir:sub(2) .. ' Reference', - buffer = buffer, - }) - end - - map(']]', 'next') - map('[[', 'prev') - - -- also set it after loading ftplugins, since a lot overwrite [[ and ]] - vim.api.nvim_create_autocmd('FileType', { - group = vim.api.nvim_create_augroup('plex_illuminate', {}), - callback = function() - local buffer = vim.api.nvim_get_current_buf() - map(']]', 'next', buffer) - map('[[', 'prev', buffer) - end, - }) + local illuminate = require 'illuminate' + illuminate.configure(opts) + vim.keymap.set('n', '[[', function() + illuminate.goto_prev_reference() -- try putting your cursor on `illuminate` + end, { desc = 'Goto last occurence of current word' }) + vim.keymap.set('n', ']]', function() + illuminate.goto_next_reference() + end, { desc = 'Goto next occurence of current word' }) end, }, {