replace cmp with blink-cmp
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
return {
|
||||
'windwp/nvim-autopairs',
|
||||
event = "InsertEnter",
|
||||
config = true
|
||||
-- 'windwp/nvim-autopairs',
|
||||
-- event = "InsertEnter",
|
||||
-- config = true
|
||||
}
|
||||
|
||||
|
||||
39
lua/crentist/lazy/completion.lua
Normal file
39
lua/crentist/lazy/completion.lua
Normal file
@@ -0,0 +1,39 @@
|
||||
return {
|
||||
'saghen/blink.cmp',
|
||||
-- optional: provides snippets for the snippet source
|
||||
dependencies = {
|
||||
'rafamadriz/friendly-snippets',
|
||||
{ 'L3MON4D3/LuaSnip', version = 'v2.*' }
|
||||
},
|
||||
-- use a release tag to download pre-built binaries
|
||||
-- version = 'v0.*',
|
||||
build = 'cargo build --release',
|
||||
|
||||
opts = {
|
||||
snippets = {
|
||||
expand = function(snippet) require('luasnip').lsp_expand(snippet) end,
|
||||
active = function(filter)
|
||||
if filter and filter.direction then
|
||||
return require('luasnip').jumpable(filter.direction)
|
||||
end
|
||||
return require('luasnip').in_snippet()
|
||||
end,
|
||||
jump = function(direction) require('luasnip').jump(direction) end,
|
||||
},
|
||||
|
||||
keymap = { preset = 'enter' },
|
||||
|
||||
appearance = {
|
||||
use_nvim_cmp_as_default = true,
|
||||
nerd_font_variant = 'mono'
|
||||
},
|
||||
|
||||
sources = {
|
||||
default = { 'lsp', 'luasnip', 'path', 'buffer' },
|
||||
cmdline = {},
|
||||
},
|
||||
|
||||
signature = { enabled = true }
|
||||
},
|
||||
}
|
||||
|
||||
@@ -4,13 +4,7 @@ return {
|
||||
dependencies = {
|
||||
'williamboman/mason.nvim',
|
||||
'williamboman/mason-lspconfig.nvim',
|
||||
'hrsh7th/nvim-cmp',
|
||||
'hrsh7th/cmp-nvim-lsp',
|
||||
'hrsh7th/cmp-buffer',
|
||||
'hrsh7th/cmp-path',
|
||||
'SergioRibera/cmp-dotenv',
|
||||
'hrsh7th/cmp-cmdline',
|
||||
'saadparwaiz1/cmp_luasnip',
|
||||
'saghen/blink.cmp',
|
||||
'L3MON4D3/LuaSnip',
|
||||
'j-hui/fidget.nvim',
|
||||
'rafamadriz/friendly-snippets',
|
||||
@@ -31,7 +25,6 @@ return {
|
||||
config = function()
|
||||
local lspconfig = require('lspconfig')
|
||||
|
||||
local cmp = require('cmp')
|
||||
local luasnip = require('luasnip')
|
||||
|
||||
-- load snippets from friendly-snippets
|
||||
@@ -56,69 +49,13 @@ return {
|
||||
},
|
||||
handlers = {
|
||||
function(server_name)
|
||||
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||
local capabilities = require('blink.cmp').get_lsp_capabilities()
|
||||
require('lspconfig')[server_name].setup({
|
||||
capabilities = capabilities
|
||||
})
|
||||
end,
|
||||
}
|
||||
})
|
||||
cmp.setup({
|
||||
sources = {
|
||||
{ name = 'path' },
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'luasnip', keyword_length = 2 },
|
||||
{ name = 'buffer', keyword_length = 3 },
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
-- `Enter` key to confirm completion
|
||||
['<CR>'] = cmp.mapping({
|
||||
i = function(fallback)
|
||||
if cmp.visible() and cmp.get_active_entry() then
|
||||
cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true })
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end,
|
||||
s = cmp.mapping.confirm({ select = true }),
|
||||
c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }),
|
||||
}),
|
||||
['<Tab>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.locally_jumpable(1) then
|
||||
luasnip.jump(1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { 'i', 's' }),
|
||||
|
||||
['<S-Tab>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.locally_jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { 'i', 's' }),
|
||||
|
||||
-- Ctrl+Space to trigger completion menu
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
|
||||
-- Scroll up and down in the completion documentation
|
||||
['<C-u>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-d>'] = cmp.mapping.scroll_docs(4),
|
||||
}),
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
require('luasnip').lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
|
||||
})
|
||||
|
||||
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||
local pythonLineLength = 95
|
||||
lspconfig.pylsp.setup {
|
||||
settings = {
|
||||
@@ -146,9 +83,7 @@ return {
|
||||
}
|
||||
}
|
||||
|
||||
lspconfig.yamlls.setup {
|
||||
capabilities = capabilities,
|
||||
}
|
||||
lspconfig.yamlls.setup { }
|
||||
|
||||
lspconfig.terraformls.setup {
|
||||
filetypes = { 'terraform', 'terraform-vars', 'tf' }
|
||||
|
||||
Reference in New Issue
Block a user