2024-02-15 09:53:19 +01:00
return {
2024-02-16 15:27:16 +01:00
{{- if eq .chezmoi.os "openbsd" }}
2024-02-15 09:53:19 +01:00
-- snippets
{
"L3MON4D3/LuaSnip",
build = (not jit.os:find("Windows"))
and "echo 'NOTE: jsregexp is optional, so not a big deal if it fails to build'; make install_jsregexp"
or nil,
dependencies = {
"rafamadriz/friendly-snippets",
config = function()
require("luasnip.loaders.from_vscode").lazy_load()
end,
},
opts = {
history = true,
delete_check_events = "TextChanged",
},
-- stylua: ignore
keys = {
{
"<tab>",
function()
return require("luasnip").jumpable(1) and "<Plug>luasnip-jump-next" or "<tab>"
end,
expr = true,
silent = true,
mode = "i",
},
{ "<tab>", function() require("luasnip").jump(1) end, mode = "s" },
{ "<s-tab>", function() require("luasnip").jump(-1) end, mode = { "i", "s" } },
},
},
-- auto completion
{
"hrsh7th/nvim-cmp",
version = false, -- last release is way too old
event = "InsertEnter",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"saadparwaiz1/cmp_luasnip",
},
opts = function()
vim.api.nvim_set_hl(0, "CmpGhostText", { link = "Comment", default = true })
2024-03-18 20:21:43 +01:00
local kind_icons = {
2024-03-18 21:02:55 +01:00
Text = " ",
Method = " ",
Function = " ",
Constructor = " ",
Field = " ",
Variable = " ",
Class = " ",
Interface = " ",
Module = " ",
Property = " ",
2024-03-18 20:21:43 +01:00
Unit = "",
2024-03-18 21:02:55 +01:00
Value = " ",
Enum = " ",
Keyword = " ",
Snippet = " ",
Color = " ",
File = " ",
Reference = " ",
Folder = " ",
EnumMember = " ",
Constant = " ",
Struct = " ",
Event = " ",
Operator = " ",
2024-03-18 20:21:43 +01:00
TypeParameter = "",
}
2024-02-15 09:53:19 +01:00
local luasnip = require('luasnip')
local cmp = require("cmp")
local defaults = require("cmp.config.default")()
return {
completion = {
completeopt = "menu,menuone,noinsert",
},
snippet = {
expand = function(args)
2024-03-18 20:21:43 +01:00
luasnip.lsp_expand(args.body)
2024-02-15 09:53:19 +01: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(),
["<CR>"] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
["<S-CR>"] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Replace,
select = true,
}), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
["<C-CR>"] = function(fallback)
cmp.abort()
fallback()
end,
}),
sources = cmp.config.sources({
{ name = "nvim_lsp", keyword_length = 1 },
{ name = "luasnip", keyword_length = 2 },
{ name = "path" },
}, {
{ name = "buffer", keyword_length = 3 },
}),
formatting = {
2024-03-18 20:21:43 +01:00
format = function(entry, vim_item)
-- Kind icons
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
-- Source
vim_item.menu = ({
buffer = "[Buffer]",
nvim_lsp = "[LSP]",
luasnip = "[LuaSnip]",
nvim_lua = "[Lua]",
latex_symbols = "[LaTeX]",
})[entry.source.name]
return vim_item
end
2024-02-15 09:53:19 +01:00
},
experimental = {
ghost_text = {
hl_group = "CmpGhostText",
},
},
sorting = defaults.sorting,
}
end,
config = function(_, opts)
for _, source in ipairs(opts.sources) do
source.group_index = source.group_index or 1
end
require("cmp").setup(opts)
end,
},
2024-03-18 20:21:43 +01:00
{
"kylechui/nvim-surround",
version = "*", -- Use for stability; omit to use `main` branch for the latest features
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
{{ else }}
2024-02-16 14:17:59 +01:00
{
"hrsh7th/nvim-cmp",
opts = function(_, opts)
local cmp = require("cmp")
opts.sources = cmp.config.sources(vim.list_extend(opts.sources, { { name = "neorg" } }))
end,
},
2024-02-16 15:27:16 +01:00
{{ end }}
2024-03-18 20:21:43 +01:00
{
"windwp/nvim-autopairs",
event = "InsertEnter",
opts = {
fast_wrap = {},
},
2024-02-16 14:17:59 +01:00
},
2024-02-15 09:53:19 +01:00
}