-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcompletions.lua
More file actions
91 lines (87 loc) · 3.07 KB
/
Copy pathcompletions.lua
File metadata and controls
91 lines (87 loc) · 3.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
return {
-- completions
"hrsh7th/nvim-cmp", -- completion engine
event = "InsertEnter",
dependencies = {
"hrsh7th/cmp-buffer", -- buffer completion
"hrsh7th/cmp-path", -- path completion
{ "hrsh7th/cmp-cmdline", event = "CmdlineEnter" }, -- cmdline completion
"hrsh7th/cmp-nvim-lsp-signature-help", -- signature completion
-- snippets
"L3MON4D3/LuaSnip", -- snippet engine
"saadparwaiz1/cmp_luasnip", -- snippet engine
"OurCodeBase/friendly-snippets", -- snippet collection
},
config = function()
local cmp = require'cmp'
local luasnip = require("luasnip")
cmp.setup({
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
mapping = cmp.mapping.preset.insert({
['<M-Up>'] = cmp.mapping.scroll_docs(-4),
['<M-Down>'] = cmp.mapping.scroll_docs(4),
['<M-Space>'] = cmp.mapping.complete(),
['<M-c>'] = cmp.mapping.abort(),
['<CR>'] = cmp.mapping.confirm({ select = true }),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then cmp.select_next_item()
elseif luasnip.locally_jumpable(1) then luasnip.jump(1)
else fallback()
end
end, { "i", "s" }),
["<M-Left>"] = cmp.mapping(function(fallback)
if luasnip.jumpable(-1) then luasnip.jump(-1)
else fallback()
end
end, { "i", "s" }),
}),
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
{ name = 'buffer' },
{ name = 'path' },
{ name = 'nvim_lsp_signature_help' },
}),
})
cmp.setup.cmdline({ '/', '?' }, {
mapping = {
['<CR>'] = cmp.mapping.confirm({ select = true }),
['<Up>'] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 'c' }),
['<Down>'] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 'c' }),
},
sources = {
{ name = 'buffer' }
}
})
cmp.setup.cmdline(':', {
mapping = {
['<CR>'] = cmp.mapping.confirm({ select = true }),
['<Up>'] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 'c' }),
['<Down>'] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 'c' }),
},
sources = cmp.config.sources({
{ name = 'path' },
{ name = 'cmdline' },
}),
matching = { disallow_symbol_nonprefix_matching = true }
})
-- expand javascript react snippets for javascript.
luasnip.filetype_extend( "javascriptreact", { "html" })
luasnip.filetype_extend( "javascript", { "html", "javascriptreact" })
luasnip.filetype_extend( "html", { "css", "javascript" })
-- if file extension endswith ejs.
if vim.fn.fnamemodify(vim.fn.expand('%:t'), ':e') == 'ejs' then
luasnip.filetype_extend( "html", { "ejs" })
end
-- this loads friendly-snippets as lazy-load.
require('luasnip.loaders.from_vscode').lazy_load()
end
}