cmp is back baby

This commit is contained in:
Zacharias-Brohn
2026-02-25 11:30:39 +01:00
parent 00c2714194
commit db2b2d364f
18 changed files with 760 additions and 200 deletions
+4 -4
View File
@@ -1,9 +1,9 @@
---@diagnostic disable: redundant-parameter
require("catppuccin").setup({
flavour = "auto",
require("catppuccin").setup {
flavour = "latte",
background = {
light = "latte",
dark = "mocha",
dark = "latte",
},
transparent_background = false,
float = {
@@ -68,4 +68,4 @@ require("catppuccin").setup({
indentscope_color = "",
},
},
})
}
+18
View File
@@ -0,0 +1,18 @@
local M = {}
M = {
keymaps = {
toggle = "<C-S-q>",
quit = nil,
},
border = "rounded",
width = "0.8",
height = "0.8",
model = "gpt-5.2",
autoinstall = false,
panel = false,
use_buffer = false,
}
return M
+2
View File
@@ -0,0 +1,2 @@
vim.cmd.colorscheme "tokyodark"
vim.o.background = "dark"
+79 -6
View File
@@ -1,3 +1,7 @@
local cmp = require "cmp"
local cmp_lsp = require "cmp_nvim_lsp"
local cmp_kinds = require("assets.icons").icons.kinds
local function flatten_to_array(t)
local res = {}
local function _flatten(tbl)
@@ -17,7 +21,7 @@ local capabilities = vim.tbl_deep_extend(
"force",
{},
vim.lsp.protocol.make_client_capabilities(),
require("blink.cmp").get_lsp_capabilities()
cmp_lsp.default_capabilities()
)
require("fidget").setup {}
@@ -94,6 +98,74 @@ require("mason-lspconfig").setup {
},
}
cmp.setup {
preselect = "None",
formatting = {
fields = { "kind", "abbr" },
format = function(entry, vim_item)
vim_item.kind = cmp_kinds[vim_item.kind] or ""
if entry.completion_item.detail then
vim_item.menu = entry.completion_item.detail
end
return vim_item
end,
},
completion = { completeopt = "menu,menuone" },
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
view = {
entries = "custom",
},
mapping = {
["<C-p>"] = cmp.mapping.select_prev_item(),
["<C-n>"] = cmp.mapping.select_next_item(),
["<C-d>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = 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()
elseif require("luasnip").expand_or_jumpable() then
require("luasnip").expand_or_jump()
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif require("luasnip").jumpable(-1) then
require("luasnip").jump(-1)
else
fallback()
end
end, { "i", "s" }),
},
sources = cmp.config.sources {
{ name = "path" },
{ name = "nvim_lsp" },
{ name = "luasnip" },
{ name = "buffer" },
{ name = "nvim_lua" },
},
}
vim.diagnostic.config {
virtual_text = false,
virtual_lines = false,
@@ -165,6 +237,12 @@ lspconfig("texlab", {
lspconfig("qmlls", {
cmd = { "qmlls6" },
filetypes = { "qml" },
single_file_support = true,
root_dir = function(bufnr, on_dir)
local root = vim.fs.root(bufnr, ".git")
on_dir(root)
end,
})
lspconfig("jsonls", {
@@ -210,11 +288,6 @@ for _, server in ipairs(flat_servers) do
if client.name == "typos_lsp" then
return
end
require("workspace-diagnostics").populate_workspace_diagnostics(
client,
bufnr
)
end,
capabilities = capabilities,
})
+56 -89
View File
@@ -1,7 +1,7 @@
vim.notify = require('notify')
local dap = require('dap')
vim.notify = require "notify"
local dap = require "dap"
require('notify').setup({
require("notify").setup {
render = "wrapped-default",
timeout = 6000,
max_width = 50,
@@ -17,9 +17,9 @@ require('notify').setup({
},
on_open = function(win)
-- vim.api.nvim_win_set_option(win, 'wrap', true)
vim.api.nvim_win_set_option(win, 'breakat', ' ')
vim.api.nvim_win_set_option(win, "breakat", " ")
end,
})
}
-- Utility functions shared between progress reports for LSP and DAP
@@ -37,8 +37,8 @@ local function get_notif_data(client_id, token)
return client_notifs[client_id][token]
end
local spinner_frames = { "", "", "", "", "", "", "", "" }
local spinner_frames =
{ "", "", "", "", "", "", "", "" }
local function update_spinner(client_id, token)
local notif_data = get_notif_data(client_id, token)
@@ -67,85 +67,52 @@ local function format_message(message, percentage)
return (percentage and percentage .. "%\t" or "") .. (message or "")
end
-- vim.lsp.handlers["$/progress"] = function(_, result, ctx)
-- local client_id = ctx.client_id
--
-- local val = result.value
--
-- if not val.kind then
-- return
-- end
--
-- local notif_data = get_notif_data(client_id, result.token)
--
-- if val.kind == "begin" then
-- local message = format_message(val.message, val.percentage)
--
-- notif_data.notification = vim.notify(message, "info", {
-- title = format_title(val.title, vim.lsp.get_client_by_id(client_id).name),
-- icon = spinner_frames[1],
-- timeout = false,
-- hide_from_history = false,
-- })
--
-- notif_data.spinner = 1
-- update_spinner(client_id, result.token)
-- elseif val.kind == "report" and notif_data then
-- notif_data.notification = vim.notify(format_message(val.message, val.percentage), "info", {
-- replace = notif_data.notification,
-- hide_from_history = false,
-- })
-- elseif val.kind == "end" and notif_data then
-- notif_data.notification =
-- vim.notify(val.message and format_message(val.message) or "Complete", "info", {
-- icon = "",
-- replace = notif_data.notification,
-- timeout = 6000,
-- })
--
-- notif_data.spinner = nil
-- end
-- end
--
-- local severity = {
-- "error",
-- "warn",
-- "info",
-- "info", -- map both hint and info to info?
-- }
-- vim.lsp.handlers["window/showMessage"] = function(err, method, params, client_id)
-- vim.notify(method.message, severity[params.type])
-- end
--
-- dap.listeners.before['event_progressStart']['progress-notifications'] = function(session, body)
-- local notif_data = get_notif_data("dap", body.progressId)
--
-- local message = format_message(body.message, body.percentage)
-- notif_data.notification = vim.notify(message, "info", {
-- title = format_title(body.title, session.config.type),
-- icon = spinner_frames[1],
-- timeout = false,
-- hide_from_history = false,
-- })
--
-- notif_data.notification.spinner = 1,
-- update_spinner("dap", body.progressId)
-- end
--
-- dap.listeners.before['event_progressUpdate']['progress-notifications'] = function(session, body)
-- local notif_data = get_notif_data("dap", body.progressId)
-- notif_data.notification = vim.notify(format_message(body.message, body.percentage), "info", {
-- replace = notif_data.notification,
-- hide_from_history = false,
-- })
-- end
--
-- dap.listeners.before['event_progressEnd']['progress-notifications'] = function(session, body)
-- local notif_data = client_notifs["dap"][body.progressId]
-- notif_data.notification = vim.notify(body.message and format_message(body.message) or "Complete", "info", {
-- icon = "",
-- replace = notif_data.notification,
-- timeout = 6000
-- })
-- notif_data.spinner = nil
-- end
-- LSP integration
-- Make sure to also have the snippet with the common helper functions in your config!
vim.lsp.handlers["$/progress"] = function(_, result, ctx)
local client_id = ctx.client_id
local val = result.value
if not val.kind then
return
end
local notif_data = get_notif_data(client_id, result.token)
if val.kind == "begin" then
local message = format_message(val.message, val.percentage)
notif_data.notification = vim.notify(message, "info", {
title = format_title(
val.title,
vim.lsp.get_client_by_id(client_id).name
),
icon = spinner_frames[1],
timeout = false,
hide_from_history = false,
})
notif_data.spinner = 1
update_spinner(client_id, result.token)
elseif val.kind == "report" and notif_data then
notif_data.notification =
vim.notify(format_message(val.message, val.percentage), "info", {
replace = notif_data.notification,
hide_from_history = false,
})
elseif val.kind == "end" and notif_data then
notif_data.notification = vim.notify(
val.message and format_message(val.message) or "Complete",
"info",
{
icon = "",
replace = notif_data.notification,
timeout = 3000,
}
)
notif_data.spinner = nil
end
end
+55
View File
@@ -0,0 +1,55 @@
local opts = {}
opts = {
file_types = { "markdown" },
completions = {
lsp = {
enabled = true,
},
},
render_modes = true,
anti_conceal = {
enabled = true,
above = 1,
below = 1,
},
code = {
enabled = true,
render_modes = false,
sign = true,
conceal_delimiters = true,
language = true,
position = "left",
language_icon = true,
language_name = true,
language_info = true,
language_pad = 0,
width = "full",
left_margin = 0,
left_pad = 2,
right_pad = 0,
min_width = 40,
border = "thick",
language_border = "",
language_left = "",
language_right = "",
above = "",
below = "",
inline = true,
inline_left = "",
inline_right = "",
inline_pad = 0,
priority = 140,
highlight = "RenderMarkdownCode",
highlight_info = "RenderMarkdownCodeInfo",
highlight_language = nil,
highlight_border = "RenderMarkdownCodeBorder",
highlight_fallback = "RenderMarkdownCodeFallback",
highlight_inline = "RenderMarkdownCodeInline",
style = "full",
},
}
return opts
+22
View File
@@ -0,0 +1,22 @@
require("smart-splits").setup {
ignored_buftypes = {
"nofile",
"quickfix",
"prompt",
},
ignored_filetypes = { "NvimTree" },
default_amount = 3,
at_edge = "wrap",
float_win_behavior = "previous",
move_cursor_same_row = false,
cursor_follows_swapped_bufs = false,
ignored_events = {
"BufEnter",
"WinEnter",
},
multiplexer_integration = nil,
disable_multiplexer_nav_when_zoomed = true,
kitty_password = nil,
zellij_move_focus_or_tab = false,
log_level = "error",
}
+56 -5
View File
@@ -57,7 +57,33 @@ return {
max_height = 80,
},
},
notifier = { enabled = true },
notifier = {
timeout = 3000,
width = { min = 40, max = 0.4 },
height = { min = 1, max = 0.6 },
margin = { top = 0, right = 1, bottom = 0 },
padding = true,
gap = 0,
sort = { "level", "added" },
level = vim.log.levels.TRACE,
icons = {
error = "",
warn = "",
info = "",
debug = "",
trace = "",
},
keep = function(notif)
return vim.fn.getcmdpos() > 0
end,
---@type snacks.notifier.style
style = "fancy",
top_down = true,
date_format = "%R",
---@type string|boolean
more_format = " ↓ %d lines ",
refresh = 50,
},
quickfile = { enabled = true },
scope = { enabled = true },
scroll = { enabled = false },
@@ -75,10 +101,35 @@ return {
function()
Snacks.terminal.toggle()
end,
mode = "t"
}
}
}
mode = "t",
},
},
},
notification = {
border = true,
zindex = 100,
ft = "markdown",
wo = {
winblend = 0,
wrap = true,
conceallevel = 2,
colorcolumn = "",
},
bo = { filetype = "snacks_notif" },
},
notification_history = {
border = true,
zindex = 100,
minimal = false,
title = " Notifications ",
title_pos = "center",
ft = "markdown",
bo = { filetype = "snacks_notif_history", modifiable = false },
wo = { winhighlight = "Normal:SnacksNotifierHistory" },
keys = { q = "close" },
},
},
gitbrowse = {
enabled = true,