Skip to content
This repository has been archived by the owner on Oct 13, 2021. It is now read-only.

Customizing LSP label

haorenW1025 edited this page Jun 8, 2020 · 1 revision

Customizing symbolKind or CompletionItemKind

  • NOTE This is not a feature in completion-nvim, it also work for the default omnifunc.
  • You can customize your kind and symbol labels in completion menus with on_attach, even in a server basis.
  • See the default labels in runtime/lua/vim/lsp/protocol.lua of neovim's source code.
  • Here is an example of customizing labels in texlab provided by Clason.
local lsp = require'nvim_lsp'
local protocol = require'vim.lsp.protocol'

local function texlab_attach()
    require'completion'.on_attach()
    protocol.SymbolKind = {
        'file';
        'sec';
        'fold';
        '';
        'class';
        'float';
        'lib';
        'field';
        'label';
        'enum';
        'misc';
        'cmd';
        'thm';
        'equ';
        'strg';
        'arg';
        '';
        '';
        'PhD';
        '';
        '';
        'item';
        'book';
        'artl';
        'part';
        'coll';
    }
    protocol.CompletionItemKind = {
        'string';
        '';
        '';
        '';
        'field';
        '';
        'class';
        'misc';
        '';
        'library';
        'thesis';
        'argument';
        '';
        '';
        'snippet';
        'color';
        'file';
        '';
        'folder';
        '';
        '';
        'book';
        'article';
        'part';
        'collect';
    }
end

lsp.texlab.setup{
    cmd = {vim.fn.stdpath("cache")..'/nvim_lsp/texlab'},
    on_attach=texlab_attach
}
Clone this wiki locally