summaryrefslogtreecommitdiff
path: root/test/tclient/tests/single-mode.lua
blob: 0a7f85ff63d5f2a7170280784a5bc50f9aad3979 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
local lclient   = require 'tclient.lclient'
local ws        = require 'workspace'
local util      = require 'utility'

---@async
lclient():start(function (client)
    client:registerFakers()
    client:initialize()

    client:notify('textDocument/didOpen', {
        textDocument = {
            uri = 'test://single-file.lua',
            languageId = 'lua',
            version = 0,
            text = [[
local x
print(x)
]]
        }
    })

    ws.awaitReady()

    local locations = client:awaitRequest('textDocument/definition', {
        textDocument = { uri = 'test://single-file.lua' },
        position = { line = 1, character = 7 },
    })

    assert(util.equal(locations, {
        {
            uri = 'test://single-file.lua',
            range = {
                start   = { line = 0, character = 6 },
                ['end'] = { line = 0, character = 7 },
            }
        }
    }))
end)