summaryrefslogtreecommitdiff
path: root/server/src/method/initialized.lua
blob: f79d035d5103dc7d1c1e8f9f8476d19314ef6682 (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
local rpc = require 'rpc'
local workspace = require 'workspace'

return function (lsp)
    rpc:request('workspace/workspaceFolders', nil, function (folders)
        if folders then
            local folder = folders[1]
            if folder then
                lsp.workspace = workspace(lsp, folder.name, folder.uri)
            end
        end
    end)
    -- 必须动态注册的事件:
    rpc:request('client/registerCapability', {
        registrations = {
            -- 监视文件变化
            {
                id = '0',
                method = 'workspace/didChangeWatchedFiles',
                registerOptions = {
                    watchers = {
                        {
                            globPattern = '**/*.lua',
                            kind = 1 | 4, -- Create | Change | Delete
                        },
                    },
                },
            },
        }
    }, function ()
        log.debug('client/registerCapability Success!')
    end)
    return true
end