Update init.lua

This commit is contained in:
subcrip 2024-03-29 08:46:25 +08:00
parent 2f297983d5
commit fab5fedd72
1 changed files with 40 additions and 11 deletions

View File

@ -417,7 +417,9 @@ local plugins = {
}
},
{ 'Civitasv/cmake-tools.nvim' },
{ 'p00f/cphelper.nvim' }
{ 'p00f/cphelper.nvim' },
{ "savq/melange-nvim" },
{ 'hrsh7th/vim-vsnip' }
}
local opts = {
}
@ -469,7 +471,8 @@ require("monokai-pro").setup({
},
})
vim.cmd([[colorscheme monokai-pro]])
-- vim.cmd([[colorscheme monokai-pro]])
vim.cmd([[colorscheme melange]])
local builtin = require("telescope.builtin")
vim.keymap.set('n', '<leader>p', builtin.find_files, {})
@ -498,21 +501,47 @@ end
vim.opt.completeopt = "menu,menuone,noselect"
local has_words_before = function()
unpack = unpack or table.unpack
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end
local feedkey = function(key, mode)
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
end
cmp.setup({
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert({
["<C-k>"] = cmp.mapping.select_prev_item(), -- previous suggestion
["<C-j>"] = cmp.mapping.select_next_item(), -- next suggestion
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(), -- show completion suggestions
["<ESC>"] = cmp.mapping.abort(), -- close completion window
["<tab>"] = cmp.mapping.confirm({ select = true }),
}),
mapping = {
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.confirm({ select = true })
elseif luasnip_status and luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function()
if cmp.visible() then
cmp.select_prev_item()
elseif vim.fn["vsnip#jumpable"](-1) == 1 then
feedkey("<Plug>(vsnip-jump-prev)", "")
end
end, { "i", "s" }),
['<C-k>'] = cmp.mapping.select_prev_item(),
['<C-j>'] = cmp.mapping.select_next_item(),
['<ESC>'] = cmp.mapping.abort(),
},
-- sources for autocompletion
sources = cmp.config.sources({
{ name = "nvim_lsp" }, -- LSP