Code Monkey home page Code Monkey logo

cmp-nvim-tags's Introduction

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

cmp-nvim-tags's People

Contributors

linrongbin16 avatar quangnguyen30192 avatar quangbanhatnguyen avatar milanglacier avatar kortanz avatar kristijanhusak avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.