Skip to content

Commit e8b97a8

Browse files
committed
nvim-cmp, buffer-cmp, path-cmp, luasnip and other plugins has been added for autocompletion...
1 parent 574ba27 commit e8b97a8

File tree

4 files changed

+103
-0
lines changed

4 files changed

+103
-0
lines changed

init.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@ require("lualine").setup {
2828
require("user.options")
2929
-- settings for vscode key shortcuts.
3030
require("user.keymaps")
31+
-- settings for auto completion.
32+
require("user.completion")

lua/user/completion.lua

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
local cmp = require'cmp'
2+
3+
cmp.setup({
4+
snippet = {
5+
expand = function(args)
6+
require('luasnip').lsp_expand(args.body)
7+
end,
8+
},
9+
window = {
10+
completion = cmp.config.window.bordered(),
11+
documentation = cmp.config.window.bordered(),
12+
},
13+
mapping = cmp.mapping.preset.insert({
14+
['<A-Down>'] = cmp.mapping.scroll_docs(-4),
15+
['<A-Up>'] = cmp.mapping.scroll_docs(4),
16+
['<C-Space>'] = cmp.mapping.complete(),
17+
['<C-a>'] = cmp.mapping.abort(),
18+
['<CR>'] = cmp.mapping.confirm({ select = false }),
19+
}),
20+
sources = cmp.config.sources({
21+
{ name = 'nvim_lsp' },
22+
{ name = 'luasnip' },
23+
}, {
24+
{ name = 'buffer' },
25+
})
26+
})
27+
28+
cmp.setup.cmdline({ '/', '?' }, {
29+
mapping = {
30+
['<CR>'] = cmp.mapping.confirm({ select = true }),
31+
['<Up>'] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 'c' }),
32+
['<Down>'] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 'c' }),
33+
},
34+
sources = {
35+
{ name = 'buffer' }
36+
}
37+
})
38+
39+
cmp.setup.cmdline(':', {
40+
mapping = {
41+
['<CR>'] = cmp.mapping.confirm({ select = true }),
42+
['<Up>'] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 'c' }),
43+
['<Down>'] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 'c' }),
44+
},
45+
sources = cmp.config.sources({
46+
{ name = 'path' }
47+
}, {
48+
{ name = 'cmdline' }
49+
}),
50+
matching = { disallow_symbol_nonprefix_matching = true }
51+
})
52+
53+
require('luasnip.loaders.from_vscode').lazy_load()

lua/user/packer.lua

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,19 @@ return require('packer').startup(function(use)
2727
require("nvim-autopairs").setup {}
2828
end
2929
}
30+
-- Plugin for nvim-completion.
31+
use 'hrsh7th/nvim-cmp'
32+
-- Plugin for buffer completion.
33+
use 'hrsh7th/cmp-buffer'
34+
-- Plugin for path completion.
35+
use 'hrsh7th/cmp-path'
36+
-- Plugin for cmdline completion.
37+
use 'hrsh7th/cmp-cmdline'
38+
-- Plugin for snippets.
39+
use 'L3MON4D3/LuaSnip'
40+
use 'saadparwaiz1/cmp_luasnip'
41+
-- Plugin for snippet collection.
42+
use 'OurCodeBase/friendly-snippets'
3043
if packer_bootstrap then
3144
require('packer').sync()
3245
end

plugin/packer_compiled.lua

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,41 @@ end
7474
time([[try_loadstring definition]], false)
7575
time([[Defining packer_plugins]], true)
7676
_G.packer_plugins = {
77+
LuaSnip = {
78+
loaded = true,
79+
path = "/data/data/com.termux/files/home/.local/share/nvim/site/pack/packer/start/LuaSnip",
80+
url = "https://github.com/L3MON4D3/LuaSnip"
81+
},
82+
["cmp-buffer"] = {
83+
loaded = true,
84+
path = "/data/data/com.termux/files/home/.local/share/nvim/site/pack/packer/start/cmp-buffer",
85+
url = "https://github.com/hrsh7th/cmp-buffer"
86+
},
87+
["cmp-cmdline"] = {
88+
loaded = true,
89+
path = "/data/data/com.termux/files/home/.local/share/nvim/site/pack/packer/start/cmp-cmdline",
90+
url = "https://github.com/hrsh7th/cmp-cmdline"
91+
},
92+
["cmp-path"] = {
93+
loaded = true,
94+
path = "/data/data/com.termux/files/home/.local/share/nvim/site/pack/packer/start/cmp-path",
95+
url = "https://github.com/hrsh7th/cmp-path"
96+
},
97+
cmp_luasnip = {
98+
loaded = true,
99+
path = "/data/data/com.termux/files/home/.local/share/nvim/site/pack/packer/start/cmp_luasnip",
100+
url = "https://github.com/saadparwaiz1/cmp_luasnip"
101+
},
77102
["everforest-nvim"] = {
78103
loaded = true,
79104
path = "/data/data/com.termux/files/home/.local/share/nvim/site/pack/packer/start/everforest-nvim",
80105
url = "https://github.com/OurCodeBase/everforest-nvim"
81106
},
107+
["friendly-snippets"] = {
108+
loaded = true,
109+
path = "/data/data/com.termux/files/home/.local/share/nvim/site/pack/packer/start/friendly-snippets",
110+
url = "https://github.com/OurCodeBase/friendly-snippets"
111+
},
82112
["lualine.nvim"] = {
83113
loaded = true,
84114
path = "/data/data/com.termux/files/home/.local/share/nvim/site/pack/packer/start/lualine.nvim",
@@ -92,6 +122,11 @@ _G.packer_plugins = {
92122
path = "/data/data/com.termux/files/home/.local/share/nvim/site/pack/packer/opt/nvim-autopairs",
93123
url = "https://github.com/windwp/nvim-autopairs"
94124
},
125+
["nvim-cmp"] = {
126+
loaded = true,
127+
path = "/data/data/com.termux/files/home/.local/share/nvim/site/pack/packer/start/nvim-cmp",
128+
url = "https://github.com/hrsh7th/nvim-cmp"
129+
},
95130
["packer.nvim"] = {
96131
loaded = true,
97132
path = "/data/data/com.termux/files/home/.local/share/nvim/site/pack/packer/start/packer.nvim",

0 commit comments

Comments
 (0)