add autopairs and create bindings for jumping through params in snippets
This commit is contained in:
@@ -5,6 +5,26 @@ require("lazy").setup({
|
||||
{
|
||||
"hrsh7th/nvim-cmp",
|
||||
dependencies = {
|
||||
-- Code snippet engine
|
||||
{
|
||||
"L3MON4D3/LuaSnip",
|
||||
version = "v2.*",
|
||||
},
|
||||
{
|
||||
"windwp/nvim-autopairs",
|
||||
opts = {
|
||||
fast_wrap = {},
|
||||
disable_filetype = { "TelescopePrompt", "vim" },
|
||||
},
|
||||
config = function(_, opts)
|
||||
require("nvim-autopairs").setup(opts)
|
||||
|
||||
-- setup cmp for autopairs
|
||||
local cmp_autopairs = require "nvim-autopairs.completion.cmp"
|
||||
require("cmp").event:on("confirm_done", cmp_autopairs.on_confirm_done())
|
||||
end,
|
||||
},
|
||||
|
||||
"hrsh7th/cmp-nvim-lsp", -- lsp auto-completion
|
||||
"hrsh7th/cmp-buffer", -- buffer auto-completion
|
||||
"hrsh7th/cmp-path", -- path auto-completion
|
||||
@@ -14,12 +34,6 @@ require("lazy").setup({
|
||||
require("config.nvim-cmp")
|
||||
end,
|
||||
},
|
||||
-- Code snippet engine
|
||||
{
|
||||
"L3MON4D3/LuaSnip",
|
||||
version = "v2.*",
|
||||
},
|
||||
|
||||
-- LSP manager
|
||||
"williamboman/mason.nvim",
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
|
||||
@@ -65,6 +65,8 @@ local on_attach = function(client, bufnr)
|
||||
--end, bufopts)
|
||||
end
|
||||
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||
|
||||
-- Configure each language
|
||||
-- How to add LSP for a specific language?
|
||||
-- 1. use `:Mason` to install corresponding LSP
|
||||
@@ -73,5 +75,6 @@ end
|
||||
for _, lsp in ipairs(servers) do
|
||||
lspconfig[lsp].setup {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
}
|
||||
end
|
||||
|
||||
@@ -7,6 +7,9 @@ end
|
||||
local luasnip = require("luasnip")
|
||||
local cmp = require("cmp")
|
||||
|
||||
vim.keymap.set({ "i", "s" }, "<C-L>", function() luasnip.jump(1) end, { silent = true })
|
||||
vim.keymap.set({ "i", "s" }, "<C-H>", function() luasnip.jump(-1) end, { silent = true })
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
-- REQUIRED - you must specify a snippet engine
|
||||
@@ -76,4 +79,5 @@ cmp.setup({
|
||||
{ name = 'buffer' }, -- For buffer word completion
|
||||
{ name = 'path' }, -- For path completion
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user