Skip to content
jinzhongjia edited this page Feb 20, 2024 · 7 revisions

Inlay Hint filter

you can choose the filetypes which enable inlay_hint,like this:

local LspUI = require("LspUI")

LspUI.setup({
    inlay_hint = {
        filter = {
            blacklist = { "zig" },
            -- you also can use white list
            -- whitelist = { "lua" }, 
        },
    },
})

Use signature in lualine with git-blame.nvim

local lualine = require("lualin")
local LspUI = require("LspUI")
local git_blame = require("gitblame")

local is_insert = false
local is_blame = false

lualine.setup({
    sections = {
        lualine_c = {
            {
                function()
                    if is_insert then
                        local signature = LspUI.api.signature()
                        if not signature then
                            return ""
                        end
                        if not signature.hint then
                            return signature.label
                        end

                        return signature.parameters[signature.hint].label
                        -- or you can use below code, it will format all parameters
                        -- local res = ""
                        -- for i, parameter in ipairs(signature.parameters) do
                        --     res = string.format("%s%s%s", res, parameter.label, i == #signature.parameters and "" or ", ")
                        -- end
                        --
                        -- return res
                    elseif is_blame then
                        return git_blame.get_current_blame_text()
                    end
                end,
                cond = function()
                    local mode_info = vim.api.nvim_get_mode()
                    local mode = mode_info["mode"]
                    is_insert = mode:find("i") ~= nil or mode:find("ic") ~= nil

                    local text = git_blame.get_current_blame_text()
                    if text then
                        is_blame = text ~= ""
                    else
                        is_blame = false
                    end

                    return is_insert or is_blame
                end,
            },
        },
    },
})

Filetypes

  • For code action: LspUI-code_action
  • For rename: LspUI-rename
  • For diagnostic: LspUI-diagnostic
  • For definition: LspUI-definition
  • For type definition: LspUI-type_definition
  • For declaration: LspUI-declaration
  • For reference: LspUI-reference
  • For implementation: LspUI-implementation
Clone this wiki locally