1
0
mirror of https://github.com/dcarrillo/dotfiles.git synced 2025-02-21 17:37:59 +00:00

[neovim] Replace lsp-cmp by blink

This commit is contained in:
Daniel Carrillo 2025-02-02 19:28:41 +01:00
parent b40fa30e54
commit 302db332f9
Signed by: dcarrillo
GPG Key ID: E4CD5C09DAED6E16
10 changed files with 97 additions and 121 deletions

View File

@ -1,7 +1,7 @@
-- Highlight Yanked Text
vim.api.nvim_create_autocmd({ "TextYankPost" }, {
vim.api.nvim_create_autocmd("TextYankPost", {
callback = function()
vim.highlight.on_yank({ higroup = "Visual", timeout = 250 })
(vim.hl or vim.highlight).on_yank()
end,
})

View File

@ -140,12 +140,10 @@ require("lazy").setup({
-- cmp plugins
{
"hrsh7th/nvim-cmp",
event = "InsertEnter",
"saghen/blink.cmp",
version = "*",
dependencies = {
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"hrsh7th/cmp-nvim-lsp",
"fang2hou/blink-copilot",
},
},
@ -282,7 +280,6 @@ require("lazy").setup({
cmd = "Copilot",
event = "InsertEnter",
},
{ "zbirenbaum/copilot-cmp" },
{ "AndreM222/copilot-lualine" },
{
"copilotc-nvim/copilotchat.nvim",

View File

@ -16,6 +16,3 @@ require("nvim-autopairs").setup({
highlight_grey = "LineNr",
},
})
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
require("cmp").event:on("confirm_done", cmp_autopairs.on_confirm_done({}))

View File

@ -0,0 +1,45 @@
require("blink.cmp").setup({
appearance = {
use_nvim_cmp_as_default = false,
},
completion = {
accept = {
auto_brackets = {
enabled = false,
},
},
menu = {
border = "single",
draw = {
treesitter = { "lsp" },
columns = {
{ "label", "label_description", gap = 1 },
{ "kind_icon", "kind", gap = 1 },
},
},
},
},
signature = { window = { border = "single" } },
sources = {
default = { "lsp", "path", "buffer", "copilot" },
providers = {
copilot = {
name = "copilot",
module = "blink-copilot",
score_offset = 100,
async = true,
opts = {
kind = "IA",
max_completions = 3,
},
},
},
},
keymap = {
preset = "enter",
["<C-q>"] = { "hide", "fallback" },
["<S-Tab>"] = { "select_prev", "fallback" },
["<Tab>"] = { "select_next", "fallback" },
},
})

View File

@ -1,102 +0,0 @@
local cmp = require("cmp")
local kind_icons = {
Array = "",
Boolean = "",
Class = "",
Codeium = "",
Color = "",
Constant = "",
Constructor = "",
Copilot = "",
Enum = "",
EnumMember = "",
Event = "",
Field = "",
File = "",
Folder = "",
Function = "",
Interface = "",
Key = "",
Keyword = "",
Method = "",
Module = "",
Namespace = "",
Null = "",
Number = "",
Object = "",
Operator = "",
Package = "",
Property = "",
Reference = "",
String = "",
Struct = "",
Text = "",
TypeParameter = "",
Unit = "",
Value = "",
Variable = "",
}
cmp.setup({
mapping = {
["<C-p>"] = cmp.mapping.select_prev_item(),
["<C-n>"] = cmp.mapping.select_next_item(),
["<C-k>"] = cmp.mapping.scroll_docs(-1),
["<C-j>"] = cmp.mapping.scroll_docs(1),
["<C-Space>"] = cmp.mapping.complete(),
["<C-q>"] = cmp.mapping.close(),
["<CR>"] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Insert,
select = true,
}),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
else
fallback()
end
end, { "i", "s" }),
},
formatting = {
fields = { "kind", "abbr", "menu" },
format = function(entry, vim_item)
vim_item.kind = kind_icons[vim_item.kind]
vim_item.menu = ({
nvim_lsp = "[lsp]",
buffer = "[local]",
copilot = "[AI]",
path = "",
emoji = "",
})[entry.source.name]
return vim_item
end,
},
sources = {
{ name = "nvim_lsp" },
{ name = "buffer" },
{ name = "path" },
{ name = "copilot" },
},
confirm_opts = {
behavior = cmp.ConfirmBehavior.Replace,
select = false,
},
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
experimental = {
ghost_text = { enabled = true },
},
})

View File

@ -26,7 +26,6 @@ local prompts = {
},
}
require("copilot_cmp").setup()
require("CopilotChat").setup({
highlight_headers = false,
separator = "———",

View File

@ -1,12 +1,13 @@
require("illuminate").configure({
delay = 200,
filetypes_denylist = {
"neo-tree",
"packer",
"Trouble",
"TelescopePrompt",
"Trouble",
"avante",
"lspsagafinder",
"mason",
"neo-tree",
"packer",
"starter",
},
})

View File

@ -1,4 +1,4 @@
require("plugins.cmp")
require("plugins.blink")
require("plugins.copilot")
require("plugins.telescope")
require("plugins.starter")

View File

@ -1,8 +1,48 @@
require("plugins.lsp.mason")
require("plugins.lsp.handlers").setup()
require("plugins.lsp.none-ls")
require("plugins.lsp.conform")
require("plugins.lsp.lsp-saga")
local win = require("lspconfig.ui.windows")
win.default_options.border = "rounded"
local signs = {
{ name = "DiagnosticSignError", text = "" },
{ name = "DiagnosticSignWarn", text = "" },
{ name = "DiagnosticSignHint", text = "" },
{ name = "DiagnosticSignInfo", text = "" },
}
for _, sign in ipairs(signs) do
vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = "" })
end
local config = {
virtual_text = false,
signs = {
active = signs,
},
update_in_insert = true,
underline = true,
severity_sort = true,
float = {
focusable = true,
style = "minimal",
border = "rounded",
source = "always",
header = "",
prefix = "",
},
}
vim.diagnostic.config(config)
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {
border = "rounded",
})
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {
border = "rounded",
})
vim.diagnostic.config(config)

View File

@ -38,8 +38,7 @@ local lspconfig = require("lspconfig")
for _, server in pairs(servers) do
if server ~= "yamlls" then
local opts = {
on_attach = require("plugins.lsp.handlers").on_attach,
capabilities = require("plugins.lsp.handlers").capabilities,
capabilities = require("blink.cmp").get_lsp_capabilities(),
}
server = vim.split(server, "@")[1]