161 lines
3.8 KiB
Lua
161 lines
3.8 KiB
Lua
return {
|
|
{
|
|
"windwp/nvim-autopairs",
|
|
lazy = true,
|
|
event = "InsertEnter",
|
|
opts = {
|
|
-- Treesitter config
|
|
check_ts = true,
|
|
ts_config = {
|
|
lua = { "string" }, -- do not add pair in this node
|
|
},
|
|
|
|
-- General config
|
|
map_cr = true,
|
|
},
|
|
},
|
|
{
|
|
"neovim/nvim-lspconfig",
|
|
dependencies = {
|
|
"williamboman/mason-lspconfig.nvim",
|
|
"hrsh7th/cmp-nvim-lsp", -- Interface for nvim-cmp
|
|
},
|
|
init = function()
|
|
require("mason-lspconfig").setup_handlers {
|
|
function(server_name)
|
|
require("lspconfig")[server_name].setup {
|
|
capabilities = capabilites,
|
|
}
|
|
end
|
|
}
|
|
end
|
|
},
|
|
{
|
|
"williamboman/mason-lspconfig.nvim", -- LSP Installer
|
|
dependencies = {
|
|
"williamboman/mason.nvim"
|
|
},
|
|
opts = {
|
|
automatic_installation = true,
|
|
ensure_installed = {
|
|
-- May need cargo (>1.80), unzip and npm
|
|
"asm_lsp",
|
|
"bashls",
|
|
"clangd",
|
|
"neocmake",
|
|
"pyright",
|
|
},
|
|
},
|
|
},
|
|
{
|
|
"hrsh7th/nvim-cmp",
|
|
event = { "InsertEnter", "CmdlineEnter", },
|
|
dependencies = {
|
|
-- Snippet engine
|
|
"L3MON4D3/LuaSnip",
|
|
"saadparwaiz1/cmp_luasnip",
|
|
|
|
-- Plugins
|
|
"hrsh7th/cmp-buffer", -- indexer
|
|
"hrsh7th/cmp-path", -- Autocomplete for filesystem paths
|
|
"hrsh7th/cmp-cmdline", -- Autocomplete for vims commandline
|
|
"hrsh7th/cmp-nvim-lua", -- Autocomplete for vim options
|
|
|
|
-- Looks
|
|
"onsails/lspkind.nvim", -- Add symbols for type
|
|
},
|
|
config = function()
|
|
local cmp = require("cmp")
|
|
|
|
cmp.setup({
|
|
snippet = {
|
|
expand = function(args)
|
|
require("luasnip").lsp_expand(args.body)
|
|
end
|
|
},
|
|
view = {
|
|
entries = {
|
|
name = 'custom',
|
|
selection_order = 'near_cursor'
|
|
}
|
|
},
|
|
formatting = {
|
|
format = require("lspkind").cmp_format({
|
|
mode = "symbol_text",
|
|
maxwidth = 50,
|
|
ellipsis_char = "...",
|
|
show_labelDetails = true,
|
|
}),
|
|
},
|
|
sources = {
|
|
{ name = "nvim_lsp" },
|
|
{ name = "luasnip" },
|
|
{ name = "buffer" },
|
|
{ name = "path" },
|
|
},
|
|
mapping = {
|
|
["<Tab>"] = cmp.mapping(function(fallback)
|
|
if cmp.visible() then
|
|
if #cmp.get_entries() == 1 then
|
|
cmp.confirm({ select = true })
|
|
else
|
|
cmp.select_next_item()
|
|
end
|
|
--[[ Replace with your snippet engine (see above sections on this page)
|
|
elseif snippy.can_expand_or_advance() then
|
|
snippy.expand_or_advance()
|
|
elseif has_words_before() then
|
|
cmp.complete()
|
|
if #cmp.get_entries() == 1 then
|
|
cmp.confirm({ select = true })
|
|
end]]
|
|
else
|
|
fallback()
|
|
end
|
|
end, { "i", "s" }),
|
|
["<S-Tab>"] = cmp.mapping(function(fallback)
|
|
if cmp.visible() then
|
|
cmp.select_prev_item()
|
|
end
|
|
end, { "i", "s", "c" }),
|
|
["<CR>"] = cmp.mapping({
|
|
i = function(fallback)
|
|
if cmp.visible() and cmp.get_active_entry() then
|
|
cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false })
|
|
else
|
|
fallback()
|
|
end
|
|
end,
|
|
s = cmp.mapping.confirm({ select = true }),
|
|
c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace }),
|
|
}),
|
|
},
|
|
enabled = function()
|
|
local context = require("cmp.config.context")
|
|
-- disable in autocomplete in comments
|
|
return not (context.in_treesitter_capture("comment") or context.in_syntax_group("Comment"))
|
|
end
|
|
})
|
|
|
|
cmp.setup.cmdline({ '/', '?' }, {
|
|
mapping = cmp.mapping.preset.cmdline(),
|
|
sources = {
|
|
{ name = 'buffer' }
|
|
}
|
|
}
|
|
)
|
|
|
|
cmp.setup.cmdline(':', {
|
|
mapping = cmp.mapping.preset.cmdline(),
|
|
sources = cmp.config.sources(
|
|
{{ name = 'path' }},
|
|
{{ name = 'cmdline' }}
|
|
),
|
|
matching = { disallow_symbol_nonprefix_matching = false }
|
|
})
|
|
end
|
|
},
|
|
{
|
|
}
|
|
}
|