Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- { "L3MON4D3/LuaSnip", -- {{{
- -- follow latest release.
- version = "v2.*", -- Replace <CurrentMajor> by the latest released major (first number of latest release)
- -- install jsregexp (optional!).
- -- doesn't work on Windows
- -- build = "make install_jsregexp",
- opts = {},
- dependencies = {
- -- VSCode-style snippets that should work with any snippet engine, including
- -- LuaSnip
- "rafamadriz/friendly-snippets",
- },
- setup = function(_, opts)
- local ls = require("luasnip")
- ls.setup(opts)
- vim.keymap.set({"i"}, "<c-j>", function() ls.expand_or_jump() end, {silent = true})
- -- vim.keymap.set({"i", "s"}, "<c-j>", function() ls.jump(1) end, {silent = true})
- vim.keymap.set({"i", "s"}, "<c-k>", function() ls.jump(-1) end, {silent = true})
- vim.keymap.set({"i", "s"}, "<c-e>", function()
- if ls.choice_active() then
- ls.change_choice(1)
- end
- end, {silent = true})
- local s = ls.snippet
- local t = ls.text_node
- local i = ls.insert_node
- ls.add_snippets("all", {
- s("ternary", {
- -- equivalent to "${1:cond} ? ${2:then} : ${3:else}"
- i(1, "cond"), t(" ? "), i(2, "then"), t(" : "), i(3, "else")
- })
- })
- -- apparently this is needed for luasnip to recognize friendly-snippets.
- -- source:
- -- https://github.com/rafamadriz/friendly-snippets/tree/main
- require("luasnip.loaders.from_vscode").lazy_load()
- end,
- }, -- }}}
- { "hrsh7th/nvim-cmp", -- {{{
- dependencies = {
- "neovim/nvim-lspconfig",
- "williamboman/mason.nvim",
- "williamboman/mason-lspconfig.nvim",
- -- these are little plugins for nvim-cmp that provide different kinds of
- -- completion
- --
- -- note that cmp-nvim-lsp needs additional completion inside of
- -- `ide_stuff.lua` in order to work (search for `cmp_nvim_lsp` in there to
- -- find it)
- {"hrsh7th/cmp-nvim-lsp"}, -- LSP completions
- {"hrsh7th/cmp-buffer"}, -- buffer name completions
- {"hrsh7th/cmp-path"}, -- filesystem path completions (don't use backslashes on Windows or it breaks :/)
- {"hrsh7th/cmp-cmdline"}, -- completions for `/` search and `:` ex commands
- { "saadparwaiz1/cmp_luasnip", -- {{{
- dependencies = {
- "L3MON4D3/LuaSnip",
- "hrsh7th/nvim-cmp",
- },
- }, -- }}}
- -- "hrsh7th/vim-vsnip",
- "L3MON4D3/LuaSnip",
- },
- config = function()
- local cmp = require('cmp')
- cmp.setup({
- snippet = {
- -- REQUIRED - you must specify a snippet engine
- expand = function(args)
- -- vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
- require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
- -- require('snippy').expand_snippet(args.body) -- For `snippy` users.
- -- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users.
- vim.snippet.expand(args.body) -- For native neovim snippets (Neovim v0.10+)
- -- For `mini.snippets` users:
- -- local insert = MiniSnippets.config.expand.insert or MiniSnippets.default_insert
- -- insert({ body = args.body }) -- Insert at cursor
- -- cmp.resubscribe({ "TextChangedI", "TextChangedP" })
- -- require("cmp.config").set_onetime({ sources = {} })
- end,
- },
- window = {
- -- completion = cmp.config.window.bordered(),
- -- documentation = cmp.config.window.bordered(),
- },
- mapping = cmp.mapping.preset.insert({
- ['<C-b>'] = cmp.mapping.scroll_docs(-4),
- ['<C-f>'] = cmp.mapping.scroll_docs(4),
- ['<C-Space>'] = cmp.mapping.complete(),
- ['<C-e>'] = cmp.mapping.abort(),
- ['<CR>'] = cmp.mapping.confirm({ select = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
- }),
- sources = cmp.config.sources({
- { name = 'nvim_lsp' },
- -- { name = 'vsnip' }, -- For vsnip users.
- -- { name = 'ultisnips' }, -- For ultisnips users.
- -- { name = 'snippy' }, -- For snippy users.
- { name = 'luasnip' }, -- For luasnip users.
- }, {
- { name = 'buffer' },
- }),
- })
- -- Set configuration for specific filetype.
- cmp.setup.filetype('gitcommit', {
- sources = cmp.config.sources({
- { name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git).
- }, {
- { name = 'buffer' },
- })
- })
- -- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
- cmp.setup.cmdline({ '/', '?' }, {
- mapping = cmp.mapping.preset.cmdline(),
- sources = {
- { name = 'buffer' }
- }
- })
- -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
- cmp.setup.cmdline(':', {
- mapping = cmp.mapping.preset.cmdline(),
- sources = cmp.config.sources({
- { name = 'path' }
- }, {
- { name = 'cmdline' }
- }),
- matching = { disallow_symbol_nonprefix_matching = false }
- })
- end,
- }, -- }}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement