Skip to content

Latest commit

 

History

History
127 lines (92 loc) · 3.13 KB

README.md

File metadata and controls

127 lines (92 loc) · 3.13 KB

README

INTRODUCTION

lsp_extra_dim is a neovim plugin written 100% in lua. Aims to provide dimmed styles for some unused variables, functions, parameters and disable Lsp Diagnostic Style

example

He is inspired by neodim and dim. But with some cool features.

USE

From lazy.nvim:

{
    "askfiy/lsp_extra_dim",
    event = { "LspAttach" },
    config = function ()
        require("lsp_extra_dim").setup()
    end
}

CONFIG

The configurations that can be passed in setup are:

return {
    hooks = {
        -- see: README/CONCEPT
        -- after the default filter function runs, the following hook function will be executed
        lsp_filter = function(diagnostics)
            -- get all used diagnostics
            return diagnostics
        end,
    },

    -- disable diagnostic styling while dimming the colors?
    --------------------------------------
    -- {}    : do not disable any diagnostic styles
    -- "all" : disable all diagnostic styles
    -- { "parameter", "function", "keyword.function"} : only disable diagnostic styles for specific captures
    --------------------------------------
    -- see `https://github.com/nvim-treesitter/nvim-treesitter/blob/master/CONTRIBUTING.md`
    disable_diagnostic_style = "all",
    -- customize different files for different file types disable_diagnostic_style
    filetype_options = {
        -- python = {
        --     disable_diagnostic_style = {
        --         "parameter",
        --         "type"
        --     }
        -- }
    },
}

CONCEPT

This is a plugin to disable unused extra style in LSP The implementation method is very simple:

    1. Customize the vim.diagnostic.handlers[signs|virtual_text].show method
    1. Override the show method of handlers other than underline, Filtering out unused resources
    1. Underline's show method will still dim them, but other handler's show methods will disable hints such as dummy text

So, he has 1 filtering steps:

    1. Screening on lsp diagnostic level

Filtering at lsp diagnostic level will remove all diagnostics containing unused (but some diagnostics that qualify in disable_diagnostic_style will be kept)

In the configuration of setup, lsp_filter are the hook functions defined after the default filter function runs.

CASE

Disable all diagnostic styles:

all

--snippet--
config = function ()
    require("lsp_extra_dim").setup({
        disable_diagnostic_style = "all"
    })

Do not disable any diagnostic styles:

empty

--snippet--
config = function ()
    require("lsp_extra_dim").setup({
        disable_diagnostic_style = {}
    })

Disable diagnostic style for function arguments only:

params

--snippet--
config = function ()
    require("lsp_extra_dim").setup({
        disable_diagnostic_style = {
            "parameter"
        }
    })