summaryrefslogtreecommitdiff
path: root/server/src/method/textDocument/codeAction.lua
blob: 04a07e3bb0f8ec767df55afca5749915fafddc2c (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
return function (lsp, 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

    if #result == 0 then
        return nil
    end

    return result
end