@@ -546,8 +546,8 @@ require('lazy').setup({
546546 -- Useful status updates for LSP.
547547 { ' j-hui/fidget.nvim' , opts = {} },
548548
549- -- Allows extra capabilities provided by blink. cmp
550- ' saghen/blink. cmp' ,
549+ -- Allows extra capabilities provided by nvim- cmp
550+ ' hrsh7th/ cmp-nvim-lsp ' ,
551551 },
552552 config = function ()
553553 -- Brief aside: **What is LSP?**
@@ -714,9 +714,10 @@ require('lazy').setup({
714714
715715 -- LSP servers and clients are able to communicate to each other what features they support.
716716 -- By default, Neovim doesn't support everything that is in the LSP specification.
717- -- When you add blink.cmp, luasnip, etc. Neovim now has *more* capabilities.
718- -- So, we create new capabilities with blink.cmp, and then broadcast that to the servers.
719- local capabilities = require (' blink.cmp' ).get_lsp_capabilities ()
717+ -- When you add nvim-cmp, luasnip, etc. Neovim now has *more* capabilities.
718+ -- So, we create new capabilities with nvim cmp, and then broadcast that to the servers.
719+ local capabilities = vim .lsp .protocol .make_client_capabilities ()
720+ capabilities = vim .tbl_deep_extend (' force' , capabilities , require (' cmp_nvim_lsp' ).default_capabilities ())
720721
721722 -- Enable the following language servers
722723 -- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
@@ -829,20 +830,18 @@ require('lazy').setup({
829830 -- python = { "isort", "black" },
830831 --
831832 -- You can use 'stop_after_first' to run the first available formatter from the list
832- -- javascript = { " prettierd", " prettier" , stop_after_first = true },
833+ javascript = { ' prettierd' , ' prettier' , stop_after_first = true },
833834 },
834835 },
835836 },
836837
837838 { -- Autocompletion
838- ' saghen/blink.cmp' ,
839- event = ' VimEnter' ,
840- version = ' 1.*' ,
839+ ' hrsh7th/nvim-cmp' ,
840+ event = ' InsertEnter' ,
841841 dependencies = {
842- -- Snippet Engine
842+ -- Snippet Engine & its associated nvim-cmp source
843843 {
844844 ' L3MON4D3/LuaSnip' ,
845- version = ' 2.*' ,
846845 build = (function ()
847846 -- Build Step is needed for regex support in snippets.
848847 -- This step is not supported in many windows environments.
@@ -863,90 +862,95 @@ require('lazy').setup({
863862 end ,
864863 },
865864 },
866- opts = {},
867865 },
868- -- mapping = cmp.mapping.preset.insert {
869- -- -- Select the [n]ext item
870- -- ['<C-j>'] = cmp.mapping.select_next_item(),
871- -- -- Select the [p]revious item
872- -- ['<C-k>'] = cmp.mapping.select_prev_item(),
873- --
874- -- -- Scroll the documentation window [b]ack / [f]orward
875- -- ['<C-u>'] = cmp.mapping.scroll_docs(-4),
876- -- ['<C-d>'] = cmp.mapping.scroll_docs(4),
877- --
878- -- -- Accept ([y]es) the completion.
879- -- -- This will auto-import if your LSP supports it.
880- -- -- This will expand snippets if the LSP sent a snippet.
881- -- ['<Tab>'] = cmp.mapping.confirm { select = true },
882- ' folke/lazydev.nvim' ,
866+ ' saadparwaiz1/cmp_luasnip' ,
867+
868+ -- Adds other completion capabilities.
869+ -- nvim-cmp does not ship with all sources by default. They are split
870+ -- into multiple repos for maintenance purposes.
871+ ' hrsh7th/cmp-nvim-lsp' ,
872+ ' hrsh7th/cmp-path' ,
873+ ' hrsh7th/cmp-nvim-lsp-signature-help' ,
883874 },
884- --- @module ' blink.cmp'
885- --- @type blink.cmp.Config
886- opts = {
887- keymap = {
888- -- 'default' (recommended) for mappings similar to built-in completions
889- -- <c-y> to accept ([y]es) the completion.
890- -- This will auto-import if your LSP supports it.
891- -- This will expand snippets if the LSP sent a snippet.
892- -- 'super-tab' for tab to accept
893- -- 'enter' for enter to accept
894- -- 'none' for no mappings
895- --
896- -- For an understanding of why the 'default' preset is recommended,
897- -- you will need to read `:help ins-completion`
875+ config = function ()
876+ -- See `:help cmp`
877+ local cmp = require ' cmp'
878+ local luasnip = require ' luasnip'
879+ luasnip .config .setup {}
880+
881+ cmp .setup {
882+ snippet = {
883+ expand = function (args )
884+ luasnip .lsp_expand (args .body )
885+ end ,
886+ },
887+ completion = { completeopt = ' menu,menuone,noinsert' },
888+
889+ -- For an understanding of why these mappings were
890+ -- chosen, you will need to read `:help ins-completion`
898891 --
899892 -- No, but seriously. Please read `:help ins-completion`, it is really good!
900- --
901- -- All presets have the following mappings:
902- -- <tab>/<s-tab>: move to right/left of your snippet expansion
903- -- <c-space>: Open menu or open docs if already open
904- -- <c-n>/<c-p> or <up>/<down>: Select next/previous item
905- -- <c-e>: Hide menu
906- -- <c-k>: Toggle signature help
907- --
908- -- See :h blink-cmp-config-keymap for defining your own keymap
909- preset = ' super-tab' ,
910- [' <C-j>' ] = { ' select_next' , ' fallback' },
911- [' <C-k>' ] = { ' select_prev' , ' fallback' },
912-
913- -- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see:
914- -- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps
915- },
916-
917- appearance = {
918- -- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
919- -- Adjusts spacing to ensure icons are aligned
920- nerd_font_variant = ' mono' ,
921- },
922-
923- completion = {
924- -- By default, you may press `<c-space>` to show the documentation.
925- -- Optionally, set `auto_show = true` to show the documentation after a delay.
926- documentation = { auto_show = false , auto_show_delay_ms = 500 },
927- },
893+ mapping = cmp .mapping .preset .insert {
894+ -- Select the [n]ext item
895+ [' <C-j>' ] = cmp .mapping .select_next_item (),
896+ -- Select the [p]revious item
897+ [' <C-k>' ] = cmp .mapping .select_prev_item (),
898+
899+ -- Scroll the documentation window [b]ack / [f]orward
900+ [' <C-d>' ] = cmp .mapping .scroll_docs (- 4 ),
901+ [' <C-u>' ] = cmp .mapping .scroll_docs (4 ),
902+
903+ -- Accept ([y]es) the completion.
904+ -- This will auto-import if your LSP supports it.
905+ -- This will expand snippets if the LSP sent a snippet.
906+ [' <Tab>' ] = cmp .mapping .confirm { select = true },
907+
908+ -- If you prefer more traditional completion keymaps,
909+ -- you can uncomment the following lines
910+ -- ['<CR>'] = cmp.mapping.confirm { select = true },
911+ -- ['<Tab>'] = cmp.mapping.select_next_item(),
912+ -- ['<S-Tab>'] = cmp.mapping.select_prev_item(),
913+
914+ -- Manually trigger a completion from nvim-cmp.
915+ -- Generally you don't need this, because nvim-cmp will display
916+ -- completions whenever it has completion options available.
917+ [' <C-Space>' ] = cmp .mapping .complete {},
918+
919+ -- Think of <c-l> as moving to the right of your snippet expansion.
920+ -- So if you have a snippet that's like:
921+ -- function $name($args)
922+ -- $body
923+ -- end
924+ --
925+ -- <c-l> will move you to the right of each of the expansion locations.
926+ -- <c-h> is similar, except moving you backwards.
927+ [' <C-l>' ] = cmp .mapping (function ()
928+ if luasnip .expand_or_locally_jumpable () then
929+ luasnip .expand_or_jump ()
930+ end
931+ end , { ' i' , ' s' }),
932+ [' <C-h>' ] = cmp .mapping (function ()
933+ if luasnip .locally_jumpable (- 1 ) then
934+ luasnip .jump (- 1 )
935+ end
936+ end , { ' i' , ' s' }),
928937
929- sources = {
930- default = { ' lsp' , ' path' , ' snippets' , ' lazydev' },
931- providers = {
932- lazydev = { module = ' lazydev.integrations.blink' , score_offset = 100 },
938+ -- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see:
939+ -- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps
933940 },
934- },
935-
936- snippets = { preset = ' luasnip' },
937-
938- -- Blink.cmp includes an optional, recommended rust fuzzy matcher,
939- -- which automatically downloads a prebuilt binary when enabled.
940- --
941- -- By default, we use the Lua implementation instead, but you may enable
942- -- the rust implementation via `'prefer_rust_with_warning'`
943- --
944- -- See :h blink-cmp-config-fuzzy for more information
945- fuzzy = { implementation = ' lua' },
946-
947- -- Shows a signature help window while you type arguments for a function
948- signature = { enabled = true },
949- },
941+ sources = {
942+ {
943+ name = ' lazydev' ,
944+ -- set group index to 0 to skip loading LuaLS completions as lazydev recommends it
945+ group_index = 0 ,
946+ },
947+ { name = ' nvim_lsp' },
948+ { name = ' luasnip' },
949+ { name = ' path' },
950+ { name = ' nvim_lsp_signature_help' },
951+ },
952+ }
953+ end ,
950954 },
951955
952956 { -- You can easily change to a different colorscheme.
0 commit comments