Skip to content

Commit

Permalink
feat(nvim): bring copilot back, improve icons
Browse files Browse the repository at this point in the history
- now on blink-cmp, seems to work better
- also refactors the icons part
  • Loading branch information
caarlos0 committed Dec 30, 2024
1 parent 7ac3612 commit f6fb3f8
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 60 deletions.
68 changes: 58 additions & 10 deletions modules/neovim/config/lua/user/cmp.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
---@diagnostic disable: missing-fields
require("copilot").setup({
suggestion = { enabled = false },
panel = { enabled = false },
})

require("blink.cmp").setup({
fuzzy = {
prebuilt_binaries = {
Expand All @@ -11,10 +16,47 @@ require("blink.cmp").setup({
appearance = {
use_nvim_cmp_as_default = true,
nerd_font_variant = "mono",
kind_icons = {
Array = "",
Boolean = "",
Class = "",
Color = "",
Constant = "",
Constructor = "",
Copilot = "",
Enum = "",
EnumMember = "",
Event = "",
Field = "",
File = "",
Folder = "󰉋",
Function = "",
Interface = "",
Key = "",
Keyword = "",
Method = "",
Module = "",
Namespace = "",
Null = "󰟢",
Number = "",
Object = "",
Operator = "",
Package = "",
Property = "",
Reference = "",
Snippet = "",
String = "",
Struct = "",
Text = "",
TypeParameter = "",
Unit = "",
Value = "",
Variable = "",
},
},
signature = { enabled = true },
sources = {
default = { "lsp", "path", "snippets", "buffer" },
default = { "lsp", "path", "snippets", "buffer", "copilot" },
cmdline = function()
local type = vim.fn.getcmdtype()
if type == "/" or type == "?" then
Expand All @@ -40,6 +82,21 @@ require("blink.cmp").setup({
min_keyword_length = 5,
max_items = 5,
},
copilot = {
name = "copilot",
module = "blink-cmp-copilot",
score_offset = 100,
async = true,
transform_items = function(_, items)
local CompletionItemKind = require("blink.cmp.types").CompletionItemKind
local kind_idx = #CompletionItemKind + 1
CompletionItemKind[kind_idx] = "Copilot"
for _, item in ipairs(items) do
item.kind = kind_idx
end
return items
end,
},
},
},
completion = {
Expand All @@ -57,15 +114,6 @@ require("blink.cmp").setup({
{ "kind_icon", "label", gap = 1 },
{ "kind" },
},
components = {
kind_icon = {
text = function(item)
local icons = require("user.icons").kinds
local kind = icons[item.kind] or ""
return kind .. " "
end,
},
},
},
},
},
Expand Down
49 changes: 0 additions & 49 deletions modules/neovim/config/lua/user/icons.lua

This file was deleted.

11 changes: 10 additions & 1 deletion modules/neovim/config/lua/user/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,16 @@ vim.lsp.handlers[ms.textDocument_signatureHelp] = vim.lsp.with(vim.lsp.handlers.
vim.highlight.priorities.semantic_tokens = 95

-- set up diagnostic signs
for name, icon in pairs(require("user.icons").diagnostics) do
local icons = {
Error = "",
Warn = "",
Info = "",
Question = "",
Hint = "󰌶",
Debug = "",
Trace = "",
}
for name, icon in pairs(icons) do
name = "DiagnosticSign" .. name
vim.fn.sign_define(name, { text = icon, texthl = name, numhl = "" })
end
2 changes: 2 additions & 0 deletions modules/neovim/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ in
nvim-lspconfig
conform-nvim
blink-cmp
blink-cmp-copilot
copilot-lua
nvim-autopairs
nvim-ts-autotag
friendly-snippets
Expand Down

0 comments on commit f6fb3f8

Please sign in to comment.