feat: migrate to blink.cmp

also remove lsp-zero
This commit is contained in:
Seymur Bagirov 2025-02-24 16:49:36 +04:00
parent 3f162cefdc
commit cf1e4aae1c
6 changed files with 69 additions and 135 deletions

View File

@ -2,12 +2,8 @@
"Ionide-vim": { "branch": "master", "commit": "c7e8973426431839e9d888a4aa8d6a41251ba16f" },
"LuaSnip": { "branch": "master", "commit": "c9b9a22904c97d0eb69ccb9bab76037838326817" },
"barbecue": { "branch": "main", "commit": "cd7e7da622d68136e13721865b4d919efd6325ed" },
"blink.cmp": { "branch": "main", "commit": "18b352d12b35bca148427b607098df14b75a218f" },
"cloak.nvim": { "branch": "main", "commit": "648aca6d33ec011dc3166e7af3b38820d01a71e4" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
"cmp-nvim-lsp": { "branch": "main", "commit": "99290b3ec1322070bcfb9e846450a46f6efa50f0" },
"cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" },
"codesnap.nvim": { "branch": "main", "commit": "6400480aa6cc366cbd931146c429aaa64680dab9" },
"conform.nvim": { "branch": "master", "commit": "a6f5bdb78caa305496357d17e962bbc4c0b392e2" },
"copilot.vim": { "branch": "release", "commit": "782461159655b259cff10ecff05efa761e3d4764" },
@ -35,7 +31,6 @@
"noice.nvim": { "branch": "main", "commit": "0427460c2d7f673ad60eb02b35f5e9926cf67c59" },
"nui.nvim": { "branch": "main", "commit": "53e907ffe5eedebdca1cd503b00aa8692068ca46" },
"nvim-autopairs": { "branch": "master", "commit": "68f0e5c3dab23261a945272032ee6700af86227a" },
"nvim-cmp": { "branch": "main", "commit": "12509903a5723a876abd65953109f926f4634c30" },
"nvim-dap": { "branch": "master", "commit": "52302f02fea3a490e55475de52fa4deb8af2eb11" },
"nvim-dap-ui": { "branch": "master", "commit": "bc81f8d3440aede116f821114547a476b082b319" },
"nvim-lightbulb": { "branch": "master", "commit": "f7f61c47af5bf701b1f4af127bc565ab6491acbf" },

View File

@ -0,0 +1,50 @@
return {
'saghen/blink.cmp',
dependencies = { 'rafamadriz/friendly-snippets' },
version = '*',
---@module 'blink.cmp'
---@type blink.cmp.Config
opts = {
-- 'default' for mappings similar to built-in completion
-- 'super-tab' for mappings similar to vscode (tab to accept, arrow keys to navigate)
-- 'enter' for mappings similar to 'super-tab' but with 'enter' to accept
-- See the full "keymap" documentation for information on defining your own keymap.
keymap = { preset = 'super-tab' },
completion = {
menu = { border = 'single' },
documentation = { window = { border = 'single' } },
},
signature = { window = { border = 'single' } },
appearance = {
-- Sets the fallback highlight groups to nvim-cmp's highlight groups
-- Useful for when your theme doesn't support blink.cmp
-- Will be removed in a future release
use_nvim_cmp_as_default = true,
-- Set to 'mono' for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
-- Adjusts spacing to ensure icons are aligned
nerd_font_variant = 'mono',
},
-- Default list of enabled providers defined so that you can extend it
-- elsewhere in your config, without redefining it, due to `opts_extend`
sources = {
default = { 'lsp', 'path', 'snippets', 'buffer' },
per_filetype = {
sql = { 'snippets', 'dadbod', 'buffer' },
},
-- add vim-dadbod-completion to your completion providers
providers = {
dadbod = { name = "Dadbod", module = "vim_dadbod_completion.blink" },
lazydev = {
name = "LazyDev",
module = "lazydev.integrations.blink",
-- make lazydev completions top priority (see `:h blink.cmp`)
score_offset = 100,
}
},
},
},
opts_extend = { "sources.default" }
}

View File

@ -53,25 +53,14 @@ return {
}
},
{
'VonHeikemen/lsp-zero.nvim',
branch = 'v3.x',
'neovim/nvim-lspconfig',
dependencies = {
-- LSP Support
'neovim/nvim-lspconfig',
-- Mason
'williamboman/mason.nvim',
'williamboman/mason-lspconfig.nvim',
-- Autocompletion
'hrsh7th/nvim-cmp',
'hrsh7th/cmp-buffer',
'hrsh7th/cmp-path',
'saadparwaiz1/cmp_luasnip',
'hrsh7th/cmp-nvim-lsp',
'hrsh7th/cmp-nvim-lua',
-- Snippets
'L3MON4D3/LuaSnip',
'rafamadriz/friendly-snippets',
'saghen/blink.cmp',
-- extras
"SmiteshP/nvim-navic",
@ -94,83 +83,14 @@ return {
}
local lsp = require("lsp-zero")
local cmp = require('cmp')
local cmp_action = lsp.cmp_action()
require('luasnip.loaders.from_vscode').lazy_load()
local tailwindcss_colors = require('tailwindcss-colorizer-cmp')
local cmp_formatter = function(entry, vim_item)
-- vim_item as processed by tailwindcss-colorizer-cmp
vim_item = tailwindcss_colors.formatter(entry, vim_item)
-- change menu (name of source)
vim_item.menu = ({
nvim_lsp = "[LSP]",
buffer = "[Buffer]",
path = "[Path]",
emoji = "[Emoji]",
luasnip = "[LuaSnip]",
vsnip = "[VSCode Snippet]",
calc = "[Calc]",
spell = "[Spell]",
})[entry.source.name]
return vim_item
end
vim.opt.completeopt = { 'menu', 'menuone', 'noselect' }
cmp.setup({
formatting = {
fields = { "abbr", "menu", "kind" },
format = cmp_formatter,
},
preselect = 'item',
completion = {
completeopt = 'menu,menuone,noinsert'
},
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
sources = {
{ name = 'path' },
{ name = 'nvim_lsp' },
{ name = 'nvim_lua' },
{ name = 'buffer', keyword_length = 3 },
{ name = 'luasnip', keyword_length = 2 },
{ name = 'lazydev', group_index = 0 }
},
mapping = cmp.mapping.preset.insert({
-- confirm completion item
['<CR>'] = cmp.mapping.confirm({ select = false, behavior = cmp.ConfirmBehavior.Insert }),
['<Tab>'] = cmp.mapping.confirm({ select = false, behavior = cmp.ConfirmBehavior.Replace }),
-- toggle completion menu
['<C-e>'] = cmp_action.toggle_completion(),
-- tab complete
-- ['<Tab>'] = cmp_action.tab_complete(),
['<S-Tab>'] = cmp.mapping.select_prev_item(),
-- navigate between snippet placeholder
['<C-d>'] = cmp_action.luasnip_jump_forward(),
['<C-b>'] = cmp_action.luasnip_jump_backward(),
-- scroll documentation window
['<C-f>'] = cmp.mapping.scroll_docs(5),
['<C-u>'] = cmp.mapping.scroll_docs(-5),
}),
})
local lspconfig_defaults = require('lspconfig').util.default_config
lspconfig_defaults.capabilities = vim.tbl_deep_extend(
'force',
lspconfig_defaults.capabilities,
require('cmp_nvim_lsp').default_capabilities()
require('blink.cmp').get_lsp_capabilities()
)
@ -218,10 +138,6 @@ return {
function(server_name)
require("lspconfig")[server_name].setup {}
end,
-- lua_ls = function()
-- local lua_opts = lsp.nvim_lua_ls()
-- require('lspconfig').lua_ls.setup(lua_opts)
-- end,
rust_analyzer = noop,
fsautocomplete = noop,
gopls = function()

View File

@ -5,33 +5,6 @@ return {
ft = sql_ft,
dependencies = { 'tpope/vim-dadbod', lazy = true },
lazy = true,
init = function()
-- taken from here https://github.com/kristijanhusak/vim-dadbod-completion/issues/53#issuecomment-1902659351
local autocomplete_group = vim.api.nvim_create_augroup("vimrc_autocompletion", { clear = true })
vim.api.nvim_create_autocmd("FileType", {
pattern = sql_ft,
callback = function()
local cmp = require("cmp")
local global_sources = cmp.get_config().sources
local buffer_sources = {}
-- add globally defined sources (see separate nvim-cmp config)
-- this makes e.g. luasnip snippets available since luasnip is configured globally
if global_sources then
for _, source in ipairs(global_sources) do
table.insert(buffer_sources, { name = source.name })
end
end
-- add vim-dadbod-completion source
table.insert(buffer_sources, { name = "vim-dadbod-completion" })
-- update sources for the current buffer
cmp.setup.buffer({ sources = buffer_sources })
end,
group = autocomplete_group,
})
end
},
{
'kristijanhusak/vim-dadbod-ui',

View File

@ -17,17 +17,24 @@ return {
vim.keymap.set('n', 'zr', require('ufo').openFoldsExceptKinds)
vim.keymap.set('n', 'zm', require('ufo').closeFoldsWith) -- closeAllFolds == closeFoldsWith(0)
local lsp = require('lsp-zero')
lsp.set_server_config({
capabilities = {
local lsp_capabilities = vim.tbl_deep_extend(
'force',
require('blink.cmp').get_lsp_capabilities(),
{
textDocument = {
foldingRange = {
dynamicRegistration = false,
lineFoldingOnly = true
}
}
},
},
}
})
)
local lspconfig_defaults = require('lspconfig').util.default_config
lspconfig_defaults.capabilities = vim.tbl_deep_extend(
'force',
lspconfig_defaults.capabilities,
lsp_capabilities
)
end
}

View File

@ -8,7 +8,6 @@ fi
# Created by newuser for 5.9
# zsh settigns
# my alliases are in ~/.profile so this just sources it
@ -26,8 +25,6 @@ source <(copilot completion zsh)
export HISTSIZE=10000
export SAVEHIST=10000
_dotnet_zsh_complete()
{
local completions=("$(dotnet complete "$words")")
@ -43,7 +40,6 @@ _dotnet_zsh_complete()
_values = "${(ps:\n:)completions}"
}
# useful plugins
source ~/.zsh/zsh-autocomplete/zsh-autocomplete.plugin.zsh
source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh
@ -86,6 +82,3 @@ export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"
export FP='fzf --preview="bat --style=numbers --color=always --line-range :500 {}"'