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

per server setup by lua

haorenW1025 edited this page Jul 10, 2020 · 2 revisions

Set up completion-nvim by lua

This section give a guide with setting up neovim by lua, also allow each option to be server independent by using the on_attach function.

  • Simply do this by adding a table to pass in in your on_attach function. Here's a simple demonstration using lua.
-- define an chain complete list
local chain_complete_list = {
  default = {
    {complete_items = {'lsp', 'snippet'}},
    {complete_items = {'path'}, triggered_only = {'/'}},
    {complete_items = {'buffers'}},
  },
  string = {
    {complete_items = {'path'}, triggered_only = {'/'}},
  },
  comment = {},
}

local on_attach = function()
  require'diagnostic'.on_attach()
  -- passing in a table with on_attach function
  require'completion'.on_attach({
      sorting = 'alphabet',
      matching_strategy_list = {'exact', 'fuzzy'},
      chain_complete_list = chain_complete_list,
    })
  • Every option can be of completion-nvim can be pass into the table, for example, g:completion_enable_auto_signature can be pass by enable_auto_signature = 1 in the table. Every option passed in will overwrite your global option and option not passed in will fall back in using global option instead. So you can have different table to pass in for each lsp and have a completely different setup for every server! Also if your love using lua, this will help porting your config to lua and also the chain completion will be cleaner in this way.
Clone this wiki locally