Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lsp implementation #50

Merged
merged 2 commits into from
Jun 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ A pretty list for showing diagnostics, references, telescope results, quickfix a
* pretty list of:
- LSP Diagnostics
- LSP references
- LSP implementations
- LSP definitions
- quickfix list
- location list
- [Telescope](https://github.com/nvim-telescope/telescope.nvim) search results
Expand Down
1 change: 1 addition & 0 deletions lua/trouble/providers/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ M.providers = {
lsp_workspace_diagnostics = lsp.diagnostics,
lsp_document_diagnostics = lsp.diagnostics,
lsp_references = lsp.references,
lsp_implementations = lsp.implementations,
lsp_definitions = lsp.definitions,
quickfix = qf.qflist,
loclist = qf.loclist,
Expand Down
18 changes: 18 additions & 0 deletions lua/trouble/providers/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,24 @@ function M.references(win, buf, cb, _options)
end)
end

---@return Item[]
function M.implementations(win, buf, cb, _options)
local method = "textDocument/implementation"
local params = util.make_position_params(win, buf)
params.context = { includeDeclaration = true }
lsp.buf_request(buf, method, params, function(err, _method, result, _client_id, _bufnr, _config)
if err then
util.error("an error happened getting implementation: " .. err)
return cb({})
end
if result == nil or #result == 0 then
return cb({})
end
local ret = util.locations_to_items({ result }, 0)
cb(ret)
end)
end

---@return Item[]
function M.definitions(win, buf, cb, _options)
local method = "textDocument/definition"
Expand Down