neovim breaking changes: offset_encoding

neovim_0.6
ray-x 2 years ago
parent 3bc154bbb3
commit da9448a88c

@ -19,15 +19,17 @@ local definition_hdlr = util.mk_handler(function(err, locations, ctx, _)
vim.notify('Definition not found')
return
end
local client = vim.lsp.get_client_by_id(ctx.client_id)
if vim.tbl_islist(locations) then
if #locations > 1 then
local items = locations_to_items(locations)
gui.new_list_view({ items = items, api = 'Definition' })
else
vim.lsp.util.jump_to_location(locations[1])
vim.lsp.util.jump_to_location(locations[1], client.offset_encoding)
end
else
vim.lsp.util.jump_to_location(locations)
vim.lsp.util.jump_to_location(locations, client.offset_encoding)
end
end)

@ -152,8 +152,9 @@ local handle_document_highlight = mk_handler(function(_, result, ctx)
return before(a.range, b.range)
end)
references[ctx.bufnr] = result
vim.lsp.util.buf_highlight_references(ctx.bufnr, result, ctx.client_id)
local client_id = ctx.client_id
local client = vim.lsp.get_client_by_id(client_id)
vim.lsp.util.buf_highlight_references(ctx.bufnr, result, client.offset_encoding)
end)
-- modify from vim-illuminate
local function goto_adjent_reference(opt)
@ -244,8 +245,10 @@ local function documentHighlight()
vim.lsp.util.buf_clear_references(bufnr)
return
end
local client_id = ctx.client_id
local client = vim.lsp.get_client_by_id(client_id)
vim.lsp.util.buf_clear_references(bufnr)
vim.lsp.util.buf_highlight_references(bufnr, result)
vim.lsp.util.buf_highlight_references(bufnr, result, client.offset_encoding)
table.sort(result, function(a, b)
return before(a.range, b.range)
end)

@ -1,26 +1,26 @@
-- https://github.com/wention/dotfiles/blob/master/.config/nvim/lua/config/lsp.lua
-- https://github.com/lukas-reineke/dotfiles/blob/master/vim/lua/lsp/handlers.lua
local mk_handler = require"navigator.util".mk_handler
local mk_handler = require('navigator.util').mk_handler
return {
format_hdl = mk_handler(function(err, result, ctx, cfg) -- FIXME: bufnr is nil
if err ~= nil or result == nil then
return
end
local util = require "navigator.util"
local util = require('navigator.util')
local log = util.log
local offset_encoding = vim.lsp.get_client_by_id(ctx.client_id).offset_encoding
-- If the buffer hasn't been modified before the formatting has finished,
-- update the buffer
-- if not vim.api.nvim_buf_get_option(ctx.bufnr, 'modified') then
vim.defer_fn(function()
log('fmt callback')
if ctx.bufnr == vim.api.nvim_get_current_buf()
or not vim.api.nvim_buf_get_option(ctx.bufnr, 'modified') then
if ctx.bufnr == vim.api.nvim_get_current_buf() or not vim.api.nvim_buf_get_option(ctx.bufnr, 'modified') then
local view = vim.fn.winsaveview()
vim.lsp.util.apply_text_edits(result, ctx.bufnr)
vim.lsp.util.apply_text_edits(result, ctx.bufnr, offset_encoding)
vim.fn.winrestview(view)
-- FIXME: commented out as a workaround
-- if bufnr == vim.api.nvim_get_current_buf() then
@ -30,7 +30,6 @@ return {
vim.api.nvim_command('silent doautocmd <nomodeline> User FormatterPost')
-- end
end
end, 100)
end)
end),
}

Loading…
Cancel
Save