Skip to content

Commit

Permalink
Update to new handler signatures (#22)
Browse files Browse the repository at this point in the history
* Update handler signatures

Closes #20

* Make changes compatible with Neovim < 0.5.1
  • Loading branch information
ojroques authored Sep 11, 2021
1 parent 3aef90e commit 0874c04
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
9 changes: 1 addition & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,11 @@ It works by redefining LSP handlers so that they call FZF. Therefore you don't
need to change any of your exising LSP mappings. It's also small and written
entirely in Lua.

The plugin is compatible only with Neovim 0.5+. **If you're using Neovim master,
please check out the `dev` branch** (due to
[breaking changes](https://github.com/neovim/neovim/pull/15504) to LSP
handlers).
The plugin is compatible only with Neovim 0.5+.

![demo](./demo.gif)

## Installation
**If you're using Neovim master, please check out the `dev` branch** (due to
[breaking changes](https://github.com/neovim/neovim/pull/15504) to LSP
handlers).

With [packer.nvim](https://github.com/wbthomason/packer.nvim):
```lua
use {
Expand Down
18 changes: 14 additions & 4 deletions lua/lspfuzzy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ local function fzf(source, sink, label, preview, multi)
end

-------------------- LSP HANDLERS --------------------------
local function symbol_handler(label, result, _, bufnr)
local items = lsp.util.symbols_to_items(result, bufnr)
local function symbol_handler(label, result, ctx)
local items = lsp.util.symbols_to_items(result, ctx.bufnr)
local source = vim.tbl_map(lsp_to_fzf, items)
fzf(source, jump, label, true, true)
end
Expand Down Expand Up @@ -234,7 +234,7 @@ local handlers = {
}

local function wrap_handler(handler)
return function(err, method, result, client_id, bufnr, config)
local wrapper = function(err, result, ctx, config)
if err then
return echo('ErrorMsg', err.message)
end
Expand All @@ -243,8 +243,18 @@ local function wrap_handler(handler)
return echo('None', fmt('No %s found', string.lower(handler.label)))
end

return handler.target(handler.label, result, client_id, bufnr, config)
return handler.target(handler.label, result, ctx, config)
end

-- See neovim#15504
if not fn.has('nvim-0.5.1') then
return function(err, method, result, client_id, bufnr, config)
local ctx = {method = method, client_id = client_id, bufnr = bufnr}
return wrapper(err, result, ctx, config)
end
end

return wrapper
end

local function load_fzf_opts()
Expand Down

0 comments on commit 0874c04

Please sign in to comment.