summaryrefslogtreecommitdiff
path: root/server/src/method/textDocument/codeAction.lua
blob: 4c4e85a3a9cf4a1936f1cf2547892aa00867a2da (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
return function (lsp, params)
    log.debug(table.dump(params))
    local uri = params.textDocument.uri
    local result = {}

    for _, data in ipairs(params.context.diagnostics) do
        if data.code then
            result[#result+1] = {
                title = ('禁用诊断(%s)'):format(data.code),
                kind = 'quickfix',
                diagnostics = {data},
                command = {
                    title = '测试',
                    command = 'config',
                    arguments = {
                        key = {'diagnostics', 'disable'},
                        action = 'add',
                        value = data.code,
                    }
                }
            }
        end
    end

    log.debug(table.dump(result))

    if #result == 0 then
        return nil
    end

    return result
end