added illuminate and some fixes

This commit is contained in:
Adam Poniatowski 2025-04-30 14:58:34 +02:00
parent 2e0d6e1637
commit f6a19a3a75
No known key found for this signature in database
GPG Key ID: E08510DAEC63C586
2 changed files with 80 additions and 0 deletions

View File

@ -0,0 +1,35 @@
---@diagnostic disable: undefined-global
return {
'RRethy/vim-illuminate',
event = { "BufReadPost", "BufNewFile" },
opts = {
delay = 200,
large_file_cutoff = 2000,
large_file_overrides = {
providers = { "lsp" }
},
providers = {
'lsp',
'treesitter',
'regex',
},
min_count_to_highlight = 2, -- minimum number of matches required to perform highlighting
},
config = function(_, opts)
require('illuminate').configure(opts)
-- Set highlight style (using colors that match with gruvbox theme)
vim.api.nvim_set_hl(0, 'IlluminatedWordText', { bg = '#3c3836', bold = true })
vim.api.nvim_set_hl(0, 'IlluminatedWordRead', { bg = '#3c3836', bold = true })
vim.api.nvim_set_hl(0, 'IlluminatedWordWrite', { bg = '#3c3836', bold = true })
-- Map keys to navigate between highlighted words
vim.keymap.set('n', '<leader>hn', function()
require('illuminate').goto_next_reference()
end, { desc = 'Go to next reference' })
vim.keymap.set('n', '<leader>hp', function()
require('illuminate').goto_prev_reference()
end, { desc = 'Go to previous reference' })
end,
}

View File

@ -0,0 +1,45 @@
---@diagnostic disable: undefined-global
-- Override internal LSP functions to ensure position_encoding is always set
local M = {}
function M.setup()
-- Create a wrapper that ensures position_encoding is added to all calls
local function with_encoding(fn)
return function(params, ...)
params = params or {}
if not params.position_encoding then
params.position_encoding = 'utf-16'
end
return fn(params, ...)
end
end
-- Override standard LSP buffer functions that may be missing position_encoding
vim.lsp.buf.code_action = with_encoding(vim.lsp.buf.code_action)
vim.lsp.buf.rename = with_encoding(vim.lsp.buf.rename)
vim.lsp.buf.hover = with_encoding(vim.lsp.buf.hover)
vim.lsp.buf.formatting = with_encoding(vim.lsp.buf.formatting)
vim.lsp.buf.range_formatting = with_encoding(vim.lsp.buf.range_formatting)
vim.lsp.buf.format = with_encoding(vim.lsp.buf.format)
-- Patch util functions as well
local orig_make_position_params = vim.lsp.util.make_position_params
vim.lsp.util.make_position_params = function(window, client, position_encoding)
if not position_encoding then
position_encoding = 'utf-16'
end
return orig_make_position_params(window, client, position_encoding)
end
-- Override symbols_to_items to ensure position_encoding is set
local orig_symbols_to_items = vim.lsp.util.symbols_to_items
vim.lsp.util.symbols_to_items = function(symbols, bufnr, position_encoding)
if not position_encoding then
position_encoding = 'utf-16'
end
return orig_symbols_to_items(symbols, bufnr, position_encoding)
end
end
return M