Skip to content

Commit 72eef5c

Browse files
committed
feat!: update to Neovim v0.11
If you're on an older version, pin the commit 3459d17.
1 parent 3459d17 commit 72eef5c

File tree

4 files changed

+17
-18
lines changed

4 files changed

+17
-18
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ https://github.com/user-attachments/assets/7109c1bc-1664-46eb-b16a-fa65c4f05f74
88

99
## Installation
1010

11+
Refjump targets Neovim v0.11+. If you're on an older version, pin the commit [3459d17](https://github.com/mawkler/refjump.nvim/commit/3459d17ad750d49458fec5b315e3181c525c6b27) with your plugin manager.
12+
1113
With [lazy.nvim](https://github.com/folke/lazy.nvim):
1214

1315
```lua

lua/refjump/highlight.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ function M.enable(references, bufnr)
2828
local start_col = ref.range.start.character
2929
local end_col = ref.range['end'].character
3030

31-
vim.api.nvim_buf_add_highlight(
31+
vim.hl.range(
3232
bufnr,
3333
highlight_namespace,
3434
reference_hl_name,
35-
line,
36-
start_col,
37-
end_col
35+
{ line, start_col },
36+
{ line, end_col },
37+
{ inclusive = false }
3838
)
3939
end
4040

lua/refjump/jump.lua

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
local M = {}
22

3+
-- NOTE: encoding is hard-coded here. It's apparently usually utf-16. But
4+
-- perhaps it should be calculated dynamically?
5+
local POSITION_ENCODING = 'utf-16'
6+
37
---@alias RefjumpReferencePosition { character: integer, line: integer }
48
---@alias RefjumpReferenceRange { start: RefjumpReferencePosition, end: RefjumpReferencePosition }
59
---@alias RefjumpReference { range: RefjumpReferenceRange, uri: string }
@@ -52,11 +56,8 @@ local function jump_to(next_reference)
5256
local bufnr = vim.api.nvim_get_current_buf()
5357
local uri = vim.uri_from_bufnr(bufnr)
5458
local next_location = { uri = uri, range = next_reference.range }
55-
-- NOTE: encoding is hard-coded here. It's apparently usually utf-16. But
56-
-- perhaps it should be calculated dynamically?
57-
local encoding = 'utf-16'
5859

59-
vim.lsp.util.jump_to_location(next_location, encoding)
60+
vim.lsp.util.show_document(next_location, POSITION_ENCODING)
6061

6162
-- Open folds if the reference is inside a fold
6263
vim.cmd('normal! zv')
@@ -111,13 +112,13 @@ function M.reference_jump_from(current_position, opts, count, references, with_r
111112
return
112113
end
113114

114-
local params = vim.lsp.util.make_position_params()
115-
116-
-- We call `textDocument/documentHighlight` here instead of
115+
-- NOTE: We call `textDocument/documentHighlight` here instead of
117116
-- `textDocument/references` for performance reasons. The latter searches the
118117
-- entire workspace, but `textDocument/documentHighlight` only searches the
119118
-- current buffer, which is what we want.
120-
vim.lsp.buf_request(0, 'textDocument/documentHighlight', params, function(err, refs, _, _)
119+
local document_highlight = 'textDocument/documentHighlight'
120+
local params = vim.lsp.util.make_position_params(0, POSITION_ENCODING)
121+
vim.lsp.buf_request(0, document_highlight, params, function(err, refs, _, _)
121122
if err then
122123
vim.notify('refjump.nvim: LSP Error: ' .. err.message, vim.log.levels.ERROR)
123124
return
@@ -152,10 +153,6 @@ end
152153
---@param references? RefjumpReference[]
153154
---@param with_references? function(RefjumpReference[]) Called if `references` is `nil` with LSP references for item at `current_position`
154155
function M.reference_jump(opts, references, with_references)
155-
local compatible_lsp_clients = vim.lsp.get_clients({
156-
method = 'textDocument/documentHighlight',
157-
})
158-
159156
local current_position = vim.api.nvim_win_get_cursor(0)
160157
local count = vim.v.count1
161158
M.reference_jump_from(current_position, opts, count, references, with_references)

lua/refjump/keymaps.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ function M.create_keymaps_autocmd(opts)
2626
---@param event { buf: number, data: { client_id: number } }
2727
callback = function(event)
2828
local client = vim.lsp.get_client_by_id(event.data.client_id)
29-
local supports_document_highlight = client and client.supports_method(
29+
local supports_document_highlight = client and client:supports_method(
3030
'textDocument/documentHighlight',
31-
{ bufnr = event.buf }
31+
event.buf
3232
)
3333
if not supports_document_highlight then
3434
return

0 commit comments

Comments
 (0)