cmp.lua separated from config.lua -- appears to work
This commit is contained in:
parent
989b3b4eba
commit
6cbcb83a88
1
init.lua
1
init.lua
|
@ -5,6 +5,7 @@
|
||||||
--
|
--
|
||||||
-- main config file
|
-- main config file
|
||||||
require 'jim.config' -- lua/jim/config.lua
|
require 'jim.config' -- lua/jim/config.lua
|
||||||
|
require 'jim.cmp' -- lua/jim/cmp.lua
|
||||||
require 'jim.keymaps' -- lua/jim/keymaps.lua
|
require 'jim.keymaps' -- lua/jim/keymaps.lua
|
||||||
require 'jim.settings' -- lua/jim/settings.lua
|
require 'jim.settings' -- lua/jim/settings.lua
|
||||||
require 'jim.luasnip' -- lua/jim/luasnip.lua
|
require 'jim.luasnip' -- lua/jim/luasnip.lua
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
-- nvim-cmp configuration
|
||||||
|
-- [[ Configure hrsh7th nvim-cmp ]]
|
||||||
|
-- See `:help cmp`
|
||||||
|
local cmp = require 'cmp'
|
||||||
|
local luasnip = require 'luasnip'
|
||||||
|
local ls = require 'luasnip'
|
||||||
|
|
||||||
|
|
||||||
|
cmp.setup {
|
||||||
|
snippet = {
|
||||||
|
expand = function(args)
|
||||||
|
luasnip.lsp_expand(args.body)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
mapping = cmp.mapping.preset.insert {
|
||||||
|
['<C-n>'] = cmp.mapping.select_next_item(),
|
||||||
|
['<C-p>'] = cmp.mapping.select_prev_item(),
|
||||||
|
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
||||||
|
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||||
|
['<C-Space>'] = cmp.mapping.complete {},
|
||||||
|
['<CR>'] = cmp.mapping.confirm {
|
||||||
|
behavior = cmp.ConfirmBehavior.Replace,
|
||||||
|
select = true,
|
||||||
|
},
|
||||||
|
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
--With multiple items, TAB selects NEXT item (CR to complete)
|
||||||
|
-----------------------------------------------------------------
|
||||||
|
--
|
||||||
|
--
|
||||||
|
['<Tab>'] = cmp.mapping(function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_next_item()
|
||||||
|
elseif luasnip.expand_or_locally_jumpable() then
|
||||||
|
luasnip.expand_or_jump()
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end, { 'i', 's' }),
|
||||||
|
['<S-Tab>'] = cmp.mapping(function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_prev_item()
|
||||||
|
elseif luasnip.locally_jumpable(-1) then
|
||||||
|
luasnip.jump(-1)
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end, { 'i', 's' }),
|
||||||
|
},
|
||||||
|
sources = { -- need nvim-cmp extensions?
|
||||||
|
{ name = 'nvim_lsp' },
|
||||||
|
{ name = 'luasnip' },
|
||||||
|
{ name = 'path' },
|
||||||
|
{ name = 'buffer', keyword_length = 5 },
|
||||||
|
},
|
||||||
|
}
|
|
@ -613,61 +613,7 @@ mason_lspconfig.setup_handlers {
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
-- nvim-cmp configuration
|
-- cmp WAS here
|
||||||
-- [[ Configure hrsh7th nvim-cmp ]]
|
--
|
||||||
-- See `:help cmp`
|
|
||||||
local cmp = require 'cmp'
|
|
||||||
local luasnip = require 'luasnip'
|
|
||||||
local ls = require 'luasnip'
|
|
||||||
|
|
||||||
cmp.setup {
|
|
||||||
snippet = {
|
|
||||||
expand = function(args)
|
|
||||||
luasnip.lsp_expand(args.body)
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
mapping = cmp.mapping.preset.insert {
|
|
||||||
['<C-n>'] = cmp.mapping.select_next_item(),
|
|
||||||
['<C-p>'] = cmp.mapping.select_prev_item(),
|
|
||||||
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
|
||||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
|
||||||
['<C-Space>'] = cmp.mapping.complete {},
|
|
||||||
['<CR>'] = cmp.mapping.confirm {
|
|
||||||
behavior = cmp.ConfirmBehavior.Replace,
|
|
||||||
select = true,
|
|
||||||
},
|
|
||||||
|
|
||||||
---------------------------------------
|
|
||||||
-- TJ says don't use <TAB> this way
|
|
||||||
---------------------------------------
|
|
||||||
--
|
|
||||||
-- TAB selects NEXT item (CR to complete)
|
|
||||||
-- ['<Tab>'] = cmp.mapping(function(fallback)
|
|
||||||
-- if cmp.visible() then
|
|
||||||
-- cmp.select_next_item()
|
|
||||||
-- elseif luasnip.expand_or_locally_jumpable() then
|
|
||||||
-- luasnip.expand_or_jump()
|
|
||||||
-- else
|
|
||||||
-- fallback()
|
|
||||||
-- end
|
|
||||||
-- end, { 'i', 's' }),
|
|
||||||
['<S-Tab>'] = cmp.mapping(function(fallback)
|
|
||||||
if cmp.visible() then
|
|
||||||
cmp.select_prev_item()
|
|
||||||
elseif luasnip.locally_jumpable(-1) then
|
|
||||||
luasnip.jump(-1)
|
|
||||||
else
|
|
||||||
fallback()
|
|
||||||
end
|
|
||||||
end, { 'i', 's' }),
|
|
||||||
},
|
|
||||||
sources = { -- need nvim-cmp extensions?
|
|
||||||
{ name = 'nvim_lsp' },
|
|
||||||
{ name = 'luasnip' },
|
|
||||||
{ name = 'path' },
|
|
||||||
{ name = 'buffer', keyword_length = 5 },
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
-- The line beneath this is called `modeline`. See `:help modeline`
|
-- The line beneath this is called `modeline`. See `:help modeline`
|
||||||
-- vim: ts=2 sts=2 sw=2 et
|
-- vim: ts=2 sts=2 sw=2 et
|
||||||
|
|
Loading…
Reference in New Issue