2024-02-15 09:53:19 +01:00
return {
2024-02-16 15:27:16 +01:00
{{- if eq .chezmoi.os "openbsd" }}
2024-04-26 14:31:04 +02:00
-- auto completion
2024-02-16 14:17:59 +01:00
{
"hrsh7th/nvim-cmp",
2024-05-07 07:18:37 +02:00
version = false, -- last release is way too old
2024-04-26 14:31:04 +02:00
event = "InsertEnter",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
2024-09-16 06:01:11 +02:00
{
"garymjr/nvim-snippets",
opts = {
friendly_snippets = true,
},
dependencies = { "rafamadriz/friendly-snippets" },
},
2024-04-26 14:31:04 +02:00
},
opts = function()
vim.api.nvim_set_hl(0, "CmpGhostText", { link = "Comment", default = true })
local kind_icons = {
Text = " ",
Method = " ",
Function = " ",
Constructor = " ",
Field = " ",
Variable = " ",
Class = " ",
Interface = " ",
Module = " ",
Property = " ",
Unit = "",
Value = " ",
Enum = " ",
Keyword = " ",
Snippet = " ",
Color = " ",
File = " ",
Reference = " ",
Folder = " ",
EnumMember = " ",
Constant = " ",
Struct = " ",
Event = " ",
Operator = " ",
TypeParameter = "",
}
2024-02-16 14:17:59 +01:00
local cmp = require("cmp")
2024-04-26 14:31:04 +02:00
local defaults = require("cmp.config.default")()
return {
completion = {
completeopt = "menu,menuone,noinsert",
},
snippet = {
expand = function(args)
2024-09-16 06:01:11 +02:00
vim.snippet.expand(args.body)
2024-04-26 14:31:04 +02:00
end,
},
mapping = cmp.mapping.preset.insert({
["<C-n>"] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
["<C-p>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.abort(),
2024-05-07 07:18:37 +02:00
["<CR>"] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
2024-04-26 14:31:04 +02:00
["<S-CR>"] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Replace,
select = true,
2024-05-07 07:18:37 +02:00
}), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
2024-04-26 14:31:04 +02:00
["<C-CR>"] = function(fallback)
cmp.abort()
fallback()
end,
}),
sources = cmp.config.sources({
{ name = "nvim_lsp", keyword_length = 1 },
2024-09-16 06:01:11 +02:00
{ name = "snippets" },
2024-04-26 14:31:04 +02:00
{ name = "path" },
}, {
{ name = "buffer", keyword_length = 3 },
}),
formatting = {
format = function(entry, vim_item)
-- Kind icons
2024-05-07 07:18:37 +02:00
vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatenates the icons with the name of the item kind
2024-04-26 14:31:04 +02:00
-- Source
vim_item.menu = ({
buffer = "[Buffer]",
nvim_lsp = "[LSP]",
2024-09-16 06:01:11 +02:00
snippets = "[Snippets]",
2024-04-26 14:31:04 +02:00
nvim_lua = "[Lua]",
latex_symbols = "[LaTeX]",
})[entry.source.name]
return vim_item
end
},
experimental = {
ghost_text = {
hl_group = "CmpGhostText",
},
},
sorting = defaults.sorting,
}
end,
2024-09-16 06:01:11 +02:00
keys = {
{
"<Tab>",
function()
return vim.snippet.active({ direction = 1 }) and "<cmd>lua vim.snippet.jump(1)<cr>" or "<Tab>"
end,
expr = true,
silent = true,
mode = { "i", "s" },
},
{
"<S-Tab>",
function()
return vim.snippet.active({ direction = -1 }) and "<cmd>lua vim.snippet.jump(-1)<cr>" or "<S-Tab>"
end,
expr = true,
silent = true,
mode = { "i", "s" },
},
},
2024-04-26 14:31:04 +02:00
config = function(_, opts)
for _, source in ipairs(opts.sources) do
source.group_index = source.group_index or 1
end
require("cmp").setup(opts)
2024-02-16 14:17:59 +01:00
end,
},
2024-04-26 14:31:04 +02:00
{
"kylechui/nvim-surround",
2024-05-07 07:18:37 +02:00
version = "*", -- Use for stability; omit to use `main` branch for the latest features
2024-04-26 14:31:04 +02:00
event = "VeryLazy",
config = function()
require("nvim-surround").setup({
-- Configuration here, or leave empty to use defaults
})
end
},
2024-02-16 15:27:16 +01:00
{{ end }}
2024-04-26 14:31:04 +02:00
{
"windwp/nvim-autopairs",
event = "InsertEnter",
opts = {
fast_wrap = {},
2024-02-16 14:17:59 +01:00
},
2024-04-26 14:31:04 +02:00
},
2024-02-15 09:53:19 +01:00
}