This commit is contained in:
newbie 2024-01-14 19:23:34 +08:00
parent 56c11a3501
commit 373f67612a
5 changed files with 55 additions and 3 deletions

View File

@ -134,12 +134,32 @@ return {
'hrsh7th/cmp-buffer', -- { name = 'buffer' }, 'hrsh7th/cmp-buffer', -- { name = 'buffer' },
'hrsh7th/cmp-path', -- { name = 'path' } 'hrsh7th/cmp-path', -- { name = 'path' }
'hrsh7th/cmp-cmdline', -- { name = 'cmdline' } 'hrsh7th/cmp-cmdline', -- { name = 'cmdline' }
{
'hrsh7th/vim-vsnip', 'hrsh7th/vim-vsnip',
config = function()
-- vim.cmd[[
-- let g:vsnip_snippet_dir = expand('~/.config/nvim/snippets')
-- ]]
G.g.vsnip_snippet_dir = G.fn.stdpath("config") .. "/snippets"
-- G.g.vsnip_filetypes = {
-- "code-snippets"
-- }
end
},
'hrsh7th/cmp-vsnip', 'hrsh7th/cmp-vsnip',
'onsails/lspkind-nvim', 'onsails/lspkind-nvim',
}, },
config = function() config = function()
G.g.vsnip_snippet_dir = G.fn.stdpath("config") .. "/sinppets/acm/" -- vim.cmd[[
-- let g:vsnip_snippet_dir = expand('~/.vsnip')
-- Specify user snippet directory.
-- Also as buffer-local variable: `b:vsnip_snippet_dir`
-- let g:vsnip_snippet_dirs = []
-- ]]
local has_words_before = function() local has_words_before = function()
unpack = unpack or table.unpack unpack = unpack or table.unpack
local line, col = unpack(G.api.nvim_win_get_cursor(0)) local line, col = unpack(G.api.nvim_win_get_cursor(0))
@ -158,7 +178,7 @@ return {
}, },
sources = cmp.config.sources({ sources = cmp.config.sources({
{ name = 'nvim_lsp' }, { name = 'nvim_lsp' },
{ name = 'vnsip' }, { name = 'vsnip' },
}, },
{ name = 'buffer' }, { name = 'buffer' },
{ name = 'path' } { name = 'path' }

32
snippets/lua.json Normal file
View File

@ -0,0 +1,32 @@
{
"Class_Array_tree": {
"prefix": "Class_Array_tree",
"body": [
"",
"template <class T>",
"class Array_tree {",
" public:",
" Array_tree() {}",
" Array_tree(int n) { this->n = n, tree = vector<T>(n + 1); }",
" void add(int id, T key) {",
" for (int i = id; i <= n; i += lowbit(i)) tree[i] += key;",
" }",
"",
" T get_sum(int id) {",
" T sum = 0;",
" for (int i = id; i; i -= lowbit(i)) sum += tree[i];",
" return sum;",
" }",
"",
" T get_sum(int l, int r) { return get_sum(r) - get_sum(l - 1); }",
"",
" private:",
" int n;",
" vector<T> tree;",
" int lowbit(int x) { return x & -x; }",
"};",
""
]
}
}
}