Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244--- @type LazySpec | LazySpec[]return { -- Autocompletion 'hrsh7th/nvim-cmp', -- Lazy load or InsertEnter event = { 'InsertEnter', 'VeryLazy' }, dependencies = { -- Snippet Engine & its associated nvim-cmp source { 'L3MON4D3/LuaSnip', build = (function() -- Build Step is needed for regex support in snippets. -- This step is not supported in many windows environments. -- Remove the below condition to re-enable on windows. if vim.fn.has 'win32' == 1 or vim.fn.executable 'make' == 0 then return end return 'make install_jsregexp' end)(), dependencies = { -- `friendly-snippets` contains a variety of premade snippets. -- See the README about individual language/framework/plugin snippets: -- https://github.com/rafamadriz/friendly-snippets -- { -- 'rafamadriz/friendly-snippets', -- config = function() -- require('luasnip.loaders.from_vscode').lazy_load() -- end, -- }, }, }, 'saadparwaiz1/cmp_luasnip',
'hrsh7th/cmp-nvim-lsp', 'hrsh7th/cmp-buffer', 'hrsh7th/cmp-path', 'hrsh7th/cmp-cmdline', 'hrsh7th/cmp-nvim-lsp-signature-help', }, config = function() -- See `:help cmp` local cmp = require 'cmp' -- Load LuaSnip local luasnip = require 'luasnip' luasnip.config.setup {}
local kind_icons = { Text = '', Method = '', Function = '', Constructor = '', Field = '', Variable = '', Class = '', Interface = '', Module = '', Property = '', Unit = '', Value = '', Enum = '', Keyword = '', Snippet = '', Color = '', File = '', Reference = '', Folder = '', EnumMember = '', Constant = '', Struct = '', Event = '', Operator = '', TypeParameter = '', }
cmp.setup { snippet = { expand = function(args) luasnip.lsp_expand(args.body) end, },
-- Show the text that will be inserted -- TODO: Make this work with Copilot auto-suggestions experimental = { ghost_text = false, },
completion = { keyword_length = 1, completeopt = 'menu,menuone,noinsert', autocomplete = { cmp.TriggerEvent.TextChanged, cmp.TriggerEvent.InsertEnter, }, },
-- Apperances window = { completion = { border = 'solid', scrolloff = 0, winblend = 0, winhighlight = 'Normal:Pmenu,FloatBorder:Pmenu,CursorLine:PmenuSel,Search:None', }, documentation = { border = 'solid', }, },
view = { docs = { auto_open = true, }, entries = { name = 'custom', }, },
formatting = { format = function(entry, vim_item) -- Kind icons vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatenates the icons with the name of the item kind -- Source vim_item.menu = ({ buffer = '[Buffer]', nvim_lsp = '', luasnip = '[LuaSnip]', nvim_lua = '[Lua]', latex_symbols = '[LaTeX]', })[entry.source.name] return vim_item end, }, -- For an understanding of why these mappings were -- chosen, you will need to read `:help ins-completion` -- -- No, but seriously. Please read `:help ins-completion`, it is really good! mapping = cmp.mapping.preset.insert { -- Select the [n]ext item ['<C-n>'] = cmp.mapping.select_next_item(), -- Select the [p]revious item ['<C-p>'] = cmp.mapping.select_prev_item(),
-- Scroll the documentation window [b]ack / [f]orward ['<C-b>'] = cmp.mapping.scroll_docs(-4), ['<C-f>'] = cmp.mapping.scroll_docs(4),
-- Accept ([y]es) the completion. -- This will auto-import if your LSP supports it. -- This will expand snippets if the LSP sent a snippet. ['<C-y>'] = cmp.mapping.confirm { select = true },
-- If you prefer more traditional completion keymaps, -- you can uncomment the following lines ['<CR>'] = cmp.mapping.confirm { select = false }, --['<Tab>'] = cmp.mapping.select_next_item(), --['<S-Tab>'] = cmp.mapping.select_prev_item(),
-- Manually trigger a completion from nvim-cmp. -- Generally you don't need this, because nvim-cmp will display -- completions whenever it has completion options available. ['<C-Space>'] = cmp.mapping.complete {}, ['<C-x>'] = cmp.mapping.complete {},
-- Up/Down arrows navigate the menu if it's visible ['<Down>'] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() else fallback() -- let Down act normally if menu not open end end, { 'i', 'c' }),
['<Up>'] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() else fallback() -- normal Up otherwise end end, { 'i' }),
-- Think of <c-l> as moving to the right of your snippet expansion. -- So if you have a snippet that's like: -- function $name($args) -- $body -- end -- -- <c-l> will move you to the right of each of the expansion locations. -- <c-h> is similar, except moving you backwards. ['<C-l>'] = cmp.mapping(function() if luasnip.expand_or_locally_jumpable() then luasnip.expand_or_jump() end end, { 'i', 's' }), ['<C-h>'] = cmp.mapping(function() if luasnip.locally_jumpable(-1) then luasnip.jump(-1) end end, { 'i', 's' }),
-- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see: -- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps }, sources = { { name = 'lazydev', -- set group index to 0 to skip loading LuaLS completions as lazydev recommends it group_index = 0, }, { name = 'nvim_lsp' }, { name = 'luasnip' }, { name = 'path' }, { name = 'nvim_lsp_signature_help' }, { name = 'buffer' }, }, }
-- `/` cmdline setup. cmp.setup.cmdline({ '/', '?' }, { mapping = cmp.mapping.preset.cmdline(), sources = { { name = 'buffer' }, }, preselect = cmp.PreselectMode.None, })
-- `:` cmdline setup. cmp.setup.cmdline(':', { mapping = cmp.mapping.preset.cmdline(), sources = cmp.config.sources({ { name = 'path' }, }, { { name = 'cmdline', option = { ignore_cmds = { 'Man', '!' }, }, }, matching = { disallow_symbol_nonprefix_matching = false }, }), preselect = cmp.PreselectMode.None, }) end,}