Skip to content

KortanZ/cmp-nvim-tags

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 

Repository files navigation

cmp-nvim-tags

tags completion source for nvim-cmp

-- Installation
use { 
  'hrsh7th/nvim-cmp',
  requires = {
    {
      'quangnguyen30192/cmp-nvim-tags',
      -- if you want the sources is available for some file types
      ft = {
        'kotlin',
        'java'
      }
    }
  },
  config = function ()
    require'cmp'.setup {
    sources = {
      {
        name = 'tags',
        option = {
          -- this is the default options, change them if you want.
          -- Delayed time after user input, in milliseconds.
          complete_defer = 100,
          -- Max items when searching `taglist`.
          max_items = 10,
          -- The number of characters that need to be typed to trigger
          -- auto-completion.
          keyword_length = 3,
          -- Use exact word match when searching `taglist`, for better searching
          -- performance.
          exact_match = false,
          -- Prioritize searching result for current buffer.
          current_buffer_only = false,
        },
      },
      -- more sources
    }
  }
  end
}

Troubleshooting

If you are using cmp-nvim-lsp with cmp-nvim-tags, you may face a weird error method workspace/symbol is not supported by any of the servers registered for the current buffer.

This is because neovim will register tagfunc as vim.lsp.tagfunc when lsp is attached, and there's no attached lsps supports workspace/symbol method. To prevent this behavior, add the following code in your config file:

Besides, vim.lsp.tagfunc may also have performance issue since it is calling the lsp workspace/symbol method firstly and fallback to the default when the former one returns no result.

If you feel that use cmp-nvim-tags is laggy, then you can consider to set tagfunc to nil.

on_attach = function(bufnr, client)
    vim.bo.tagfunc = nil
end

-- sqls is an example lsp that does not support workspace/symbol
-- change sqls to the lsp where the error happens
require('lspconfig').sqls.setup {
    on_attach = on_attach
}

Credit

Compe source for tags

About

tags sources for nvim-cmp

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Lua 100.0%