Giter Club home page Giter Club logo

Comments (5)

VonHeikemen avatar VonHeikemen commented on May 25, 2024 1

@starptr sure. When using the preset lsp-compe you can configure nvim-cmp anywhere you like.

About the mappings... You can technically "delete" a mapping before it gets to the setup function.

local cmp_config = lsp.defaults.cmp_config({
  window = {
    completion = cmp.config.window.bordered()
  }
})

cmp_config.mapping['<Tab>'] = nil
cmp_config.mapping['<S-Tab>'] = nil

cmp.setup(cmp_config)

If you want to override it, you can do it right inside .defaults.cmp_config. This has the advantage of keeping the other defaults.

local cmp_config = lsp.defaults.cmp_config({
  window = {
    completion = cmp.config.window.bordered()
  },
  mapping = {
    ['<C-e>'] = cmp.mapping.abort(),
  }
})

If you want to delete all default keybindings and make your own, override the mapping option outside .defaults.cmp_config.

local cmp_config = lsp.defaults.cmp_config({
  window = {
    completion = cmp.config.window.bordered()
  },
})

cmp_config.mapping = {
  ---
  -- add your own mappings here...
  ---
}

from lsp-zero.nvim.

VonHeikemen avatar VonHeikemen commented on May 25, 2024 1

@kiryl I mention the avaible options of .setup_nvim_cmp on the readme (also the help page). I also try to explain how to customize nvim-cmp in the Advance usage page. And there is also Under the hood section of the wiki, which shows everything lsp-zero configures with the recommended preset.

from lsp-zero.nvim.

VonHeikemen avatar VonHeikemen commented on May 25, 2024

The window.completion option didn't exists when lsp-zero was created, that's why it isnt part of the defaults. So now the role of setup_nvim_cmp is just to allow the user to change some defaults, instead of being a mirror of the setup function for nvim-cmp.

If you want to extend your config for nvim-cmp use the lsp-compe preset. You can use the function .defaults.cmp_config to expose the default config and then extend it however you like.

local lsp = require('lsp-zero')
lsp.preset('lsp-compe')

lsp.setup()

vim.opt.completeopt = {'menu', 'menuone', 'noselect'}

local cmp = require('cmp')
local cmp_config = lsp.defaults.cmp_config({
  window = {
    completion = cmp.config.window.bordered()
  }
})

cmp.setup(cmp_config)

from lsp-zero.nvim.

starptr avatar starptr commented on May 25, 2024

Is it possible to remove a default mapping (added by lsp-zero) using this strategy? I'd like to customize <C-e> but in a different configuration file

from lsp-zero.nvim.

kiryl avatar kiryl commented on May 25, 2024

@VonHeikemen , okay it works. Looks like setup_nvim_cmp() doesn't not mix with the proposed fix. Any configuration that is done with setup_nvim_cmp() will be ignored.

It is okay with me. But maybe expose somewhere what config lsp-zero constructed and passed to cmp.setup(), including changes made with setup_nvim_cmp()?

from lsp-zero.nvim.

Related Issues (20)

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.