Skip to content

Register code action

影翼 edited this page Aug 23, 2023 · 2 revisions

This is for plugin developer!

LspUI.nvim provides an interface for plug-in developers to register code action by themselves

The registration parameters are name and callback, callback will be called when request code action and lightbulb, callback should return a array of {title:string,action:function}

local LspUI_register = require("LspUI.code_action.register")

-- register code action
LspUI_register.register(
    "demo",
    --- @param uri lsp.URI
    --- @param range lsp.Range
    function(uri, range)
        --- @type {title:string,action:function}[]
        local res

        -- do something

        return res
    end
)

-- unregister code action
LspUI_register.unregister("demo")
Clone this wiki locally