diff options
author | Mathias Fußenegger <mfussenegger@users.noreply.github.com> | 2020-06-30 17:48:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-30 11:48:04 -0400 |
commit | 554b21261ec0ad1eaac7afc21d9a1ba7fb7cabf1 (patch) | |
tree | 312ee1d63d6914e5fd4b1f974fa157b6088acf19 /test/functional/plugin/lsp_spec.lua | |
parent | 1920ba4b5597a872973de0a5d558cbbf23063fb6 (diff) | |
download | rneovim-554b21261ec0ad1eaac7afc21d9a1ba7fb7cabf1.tar.gz rneovim-554b21261ec0ad1eaac7afc21d9a1ba7fb7cabf1.tar.bz2 rneovim-554b21261ec0ad1eaac7afc21d9a1ba7fb7cabf1.zip |
lsp: Use nvim_buf_get_lines in locations_to_items and add more tests (#12357)
* LSP: Add tests & use nvim_buf_get_lines in locations_to_items
This is to add support for cases where the server returns a URI in the
locations that does not have a file scheme but needs to be loaded via a
BufReadCmd event.
* LSP: Don't iterate through all lines in locations_to_items
* fixup! LSP: Don't iterate through all lines in locations_to_items
* fixup! fixup! LSP: Don't iterate through all lines in locations_to_items
* fixup! fixup! fixup! LSP: Don't iterate through all lines in locations_to_items
Diffstat (limited to 'test/functional/plugin/lsp_spec.lua')
-rw-r--r-- | test/functional/plugin/lsp_spec.lua | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua index 4b12ea2557..1b022f50df 100644 --- a/test/functional/plugin/lsp_spec.lua +++ b/test/functional/plugin/lsp_spec.lua @@ -1070,6 +1070,64 @@ describe('LSP', function() ]]) end) end) + describe('lsp.util.locations_to_items', function() + it('Convert Location[] to items', function() + local expected = { + { + filename = 'fake/uri', + lnum = 1, + col = 3, + text = 'testing' + }, + } + local actual = exec_lua [[ + local bufnr = vim.uri_to_bufnr("file://fake/uri") + local lines = {"testing", "123"} + vim.api.nvim_buf_set_lines(bufnr, 0, 1, false, lines) + local locations = { + { + uri = 'file://fake/uri', + range = { + start = { line = 0, character = 2 }, + ['end'] = { line = 0, character = 3 }, + } + }, + } + return vim.lsp.util.locations_to_items(locations) + ]] + eq(expected, actual) + end) + it('Convert LocationLink[] to items', function() + local expected = { + { + filename = 'fake/uri', + lnum = 1, + col = 3, + text = 'testing' + }, + } + local actual = exec_lua [[ + local bufnr = vim.uri_to_bufnr("file://fake/uri") + local lines = {"testing", "123"} + vim.api.nvim_buf_set_lines(bufnr, 0, 1, false, lines) + local locations = { + { + targetUri = vim.uri_from_bufnr(bufnr), + targetRange = { + start = { line = 0, character = 2 }, + ['end'] = { line = 0, character = 3 }, + }, + targetSelectionRange = { + start = { line = 0, character = 2 }, + ['end'] = { line = 0, character = 3 }, + } + }, + } + return vim.lsp.util.locations_to_items(locations) + ]] + eq(expected, actual) + end) + end) describe('lsp.util.symbols_to_items', function() describe('convert DocumentSymbol[] to items', function() it('DocumentSymbol has children', function() |