feat(nvim): fix completion with blink

This commit is contained in:
2025-10-24 07:02:36 +02:00
parent 653f44935a
commit 692c87e1ba
4 changed files with 79 additions and 109 deletions

View File

@@ -17,3 +17,8 @@ vim.keymap.set("n", "N", "Nzzzv")
-- Move block on visual mode
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
-- Diagnostic (erreurs LSP)
vim.keymap.set('n', 'gl', vim.diagnostic.open_float, { desc = 'Show diagnostic' })
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Previous diagnostic' })
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Next diagnostic' })

View File

@@ -1,77 +1,22 @@
-- return {
-- 'hrsh7th/nvim-cmp',
-- dependencies = {
-- 'neovim/nvim-lspconfig',
-- 'hrsh7th/cmp-nvim-lsp',
-- 'hrsh7th/cmp-buffer',
-- 'hrsh7th/cmp-path',
-- 'hrsh7th/cmp-cmdline',
-- 'hrsh7th/cmp-vsnip',
-- 'hrsh7th/vim-vsnip',
-- },
-- config = function ()
-- local cmp = require'cmp'
-- cmp.setup({
-- snippet = {
-- expand = function(args)
-- vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
-- end,
-- },
-- window = {
-- completion = cmp.config.window.bordered(),
-- documentation = cmp.config.window.bordered(),
-- },
-- sources = cmp.config.sources({
-- { name = 'nvim_lsp' },
-- { name = 'vsnip' }, -- For vsnip users.
-- { name = 'path' },
-- {
-- name = 'buffer',
-- option = {
-- keyword_length = 3,
-- get_bufnrs = function()
-- return vim.api.nvim_list_bufs()
-- end
-- }
-- },
-- }, {
-- { name = 'buffer' },
-- })
-- })
--
-- -- Set configuration for specific filetype.
-- cmp.setup.filetype('gitcommit', {
-- sources = cmp.config.sources({
-- { name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git).
-- }, {
-- { name = 'buffer' },
-- })
-- })
--
-- -- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
-- cmp.setup.cmdline({ '/', '?' }, {
-- mapping = cmp.mapping.preset.cmdline(),
-- sources = {
-- { name = 'buffer' }
-- }
-- })
--
-- -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
-- cmp.setup.cmdline(':', {
-- mapping = cmp.mapping.preset.cmdline(),
-- sources = cmp.config.sources({
-- { name = 'path' }
-- }, {
-- { name = 'cmdline' }
-- })
-- })
-- end
-- }
return {
"saghen/blink.cmp",
-- optional: provides snippets for the snippet source
dependencies = { "rafamadriz/friendly-snippets" },
dependencies = {
"rafamadriz/friendly-snippets",
{
"L3MON4D3/LuaSnip",
build = "make install_jsregexp",
config = function()
require("luasnip").setup({
store_selection_keys = "<Tab>",
})
require("luasnip.loaders.from_vscode").lazy_load()
require("luasnip.loaders.from_lua").lazy_load({
paths = { "~/.config/nvim/snippets" },
})
end,
},
},
-- use a release tag to download pre-built binaries
version = "1.*",
@@ -106,15 +51,28 @@ return {
-- (Default) Only show the documentation popup when manually triggered
completion = {
documentation = {
auto_show = false,
auto_show = true,
auto_show_delay_ms = 200,
},
ghost_text = {
enabled = true,
},
},
-- 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" },
providers = {
buffer = {
min_keyword_length = 3,
score_offset = -10,
},
},
},
snippets = {
preset = "luasnip",
},
-- (Default) Rust fuzzy matcher for typo resistance and significantly better performance

View File

@@ -1,29 +0,0 @@
{
"Begin/End environment": {
"prefix": "beg",
"body": [
"\\begin{${1:environment}}",
"\t$0",
"\\end{$1}"
],
"description": "Begin/End environment"
},
"Multicols": {
"prefix": "multicols",
"body": [
"\\begin{multicols}{${1:2}}",
"\t$0",
"\\end{multicols}"
],
"description": "Multicols environment"
},
"Minipage": {
"prefix": "minipage",
"body": [
"\\begin{minipage}{${1:0.5}\\textwidth}",
"\t$0",
"\\end{minipage}"
],
"description": "Minipage environment"
}
}

View File

@@ -1,21 +1,57 @@
local ls = require("luasnip")
local s = ls.snippet
local sn = ls.snippet_node
local t = ls.text_node
local i = ls.insert_node
local f = ls.function_node
local d = ls.dynamic_node
return {
-- Auto-expand: tape "beg" + TAB
s({ trig = "beg", dscr = "Begin/End environment" }, {
t("\\begin{"),
i(1, "environment"),
-- Minipage avec texte sélectionné
s({ trig = "minipage", dscr = "Minipage environment" }, {
t("\\begin{minipage}{"),
i(1, "0.5"),
t("\\textwidth}"),
t({ "", "\t" }),
d(2, function(_, snip)
return sn(nil, i(1, snip.env.LS_SELECT_RAW or ""))
end),
t({ "", "\\end{minipage}" }),
}),
-- Multicols avec texte sélectionné
s({ trig = "multicols", dscr = "Multicols environment" }, {
t("\\begin{multicols}{"),
i(1, "2"),
t("}"),
t({ "", "\t" }),
i(0),
t({ "", "\\end{" }),
d(2, function(_, snip)
return sn(nil, i(1, snip.env.LS_SELECT_RAW or ""))
end),
t({ "", "\\end{multicols}" }),
}),
-- Deux minipages côte à côte
s({ trig = "minipage2", dscr = "Two minipages side by side" }, {
t("\\begin{minipage}{"),
i(1, "0.48"),
t("\\textwidth}"),
t({ "", "\t" }),
i(2),
t({ "", "\\end{minipage}" }),
t({ "", "\\hfill" }),
t({ "", "\\begin{minipage}{" }),
f(function(args)
return args[1][1]
local width = tonumber(args[1][1])
if width then
return tostring(1 - width)
else
return "0.48"
end
end, { 1 }),
t("}"),
t("\\textwidth}"),
t({ "", "\t" }),
i(0),
t({ "", "\\end{minipage}" }),
}),
}