@@ -481,8 +481,8 @@ require('lazy').setup({
481
481
-- Useful status updates for LSP.
482
482
{ ' j-hui/fidget.nvim' , opts = {} },
483
483
484
- -- Allows extra capabilities provided by blink. cmp
485
- ' saghen/blink. cmp' ,
484
+ -- Allows extra capabilities provided by nvim- cmp
485
+ ' hrsh7th/ cmp-nvim-lsp ' ,
486
486
},
487
487
config = function ()
488
488
-- Brief aside: **What is LSP?**
@@ -649,9 +649,10 @@ require('lazy').setup({
649
649
650
650
-- LSP servers and clients are able to communicate to each other what features they support.
651
651
-- By default, Neovim doesn't support everything that is in the LSP specification.
652
- -- When you add blink.cmp, luasnip, etc. Neovim now has *more* capabilities.
653
- -- So, we create new capabilities with blink.cmp, and then broadcast that to the servers.
654
- local capabilities = require (' blink.cmp' ).get_lsp_capabilities ()
652
+ -- When you add nvim-cmp, luasnip, etc. Neovim now has *more* capabilities.
653
+ -- So, we create new capabilities with nvim cmp, and then broadcast that to the servers.
654
+ local capabilities = vim .lsp .protocol .make_client_capabilities ()
655
+ capabilities = vim .tbl_deep_extend (' force' , capabilities , require (' cmp_nvim_lsp' ).default_capabilities ())
655
656
656
657
-- Enable the following language servers
657
658
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
@@ -770,14 +771,12 @@ require('lazy').setup({
770
771
},
771
772
772
773
{ -- Autocompletion
773
- ' saghen/blink.cmp' ,
774
- event = ' VimEnter' ,
775
- version = ' 1.*' ,
774
+ ' hrsh7th/nvim-cmp' ,
775
+ event = ' InsertEnter' ,
776
776
dependencies = {
777
- -- Snippet Engine
777
+ -- Snippet Engine & its associated nvim-cmp source
778
778
{
779
779
' L3MON4D3/LuaSnip' ,
780
- version = ' 2.*' ,
781
780
build = (function ()
782
781
-- Build Step is needed for regex support in snippets.
783
782
-- This step is not supported in many windows environments.
@@ -798,74 +797,95 @@ require('lazy').setup({
798
797
-- end,
799
798
-- },
800
799
},
801
- opts = {},
802
800
},
803
- ' folke/lazydev.nvim' ,
801
+ ' saadparwaiz1/cmp_luasnip' ,
802
+
803
+ -- Adds other completion capabilities.
804
+ -- nvim-cmp does not ship with all sources by default. They are split
805
+ -- into multiple repos for maintenance purposes.
806
+ ' hrsh7th/cmp-nvim-lsp' ,
807
+ ' hrsh7th/cmp-path' ,
808
+ ' hrsh7th/cmp-nvim-lsp-signature-help' ,
804
809
},
805
- --- @module ' blink.cmp'
806
- --- @type blink.cmp.Config
807
- opts = {
808
- keymap = {
809
- -- 'default' (recommended) for mappings similar to built-in completions
810
- -- <c-y> to accept ([y]es) the completion.
811
- -- This will auto-import if your LSP supports it.
812
- -- This will expand snippets if the LSP sent a snippet.
813
- -- 'super-tab' for tab to accept
814
- -- 'enter' for enter to accept
815
- -- 'none' for no mappings
816
- --
817
- -- For an understanding of why the 'default' preset is recommended,
818
- -- you will need to read `:help ins-completion`
810
+ config = function ()
811
+ -- See `:help cmp`
812
+ local cmp = require ' cmp'
813
+ local luasnip = require ' luasnip'
814
+ luasnip .config .setup {}
815
+
816
+ cmp .setup {
817
+ snippet = {
818
+ expand = function (args )
819
+ luasnip .lsp_expand (args .body )
820
+ end ,
821
+ },
822
+ completion = { completeopt = ' menu,menuone,noinsert' },
823
+
824
+ -- For an understanding of why these mappings were
825
+ -- chosen, you will need to read `:help ins-completion`
819
826
--
820
827
-- No, but seriously. Please read `:help ins-completion`, it is really good!
821
- --
822
- -- All presets have the following mappings:
823
- -- <tab>/<s-tab>: move to right/left of your snippet expansion
824
- -- <c-space>: Open menu or open docs if already open
825
- -- <c-n>/<c-p> or <up>/<down>: Select next/previous item
826
- -- <c-e>: Hide menu
827
- -- <c-k>: Toggle signature help
828
- --
829
- -- See :h blink-cmp-config-keymap for defining your own keymap
830
- preset = ' default' ,
831
-
832
- -- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see:
833
- -- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps
834
- },
835
-
836
- appearance = {
837
- -- 'mono' (default) for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
838
- -- Adjusts spacing to ensure icons are aligned
839
- nerd_font_variant = ' mono' ,
840
- },
841
-
842
- completion = {
843
- -- By default, you may press `<c-space>` to show the documentation.
844
- -- Optionally, set `auto_show = true` to show the documentation after a delay.
845
- documentation = { auto_show = false , auto_show_delay_ms = 500 },
846
- },
828
+ mapping = cmp .mapping .preset .insert {
829
+ -- Select the [n]ext item
830
+ [' <C-n>' ] = cmp .mapping .select_next_item (),
831
+ -- Select the [p]revious item
832
+ [' <C-p>' ] = cmp .mapping .select_prev_item (),
833
+
834
+ -- Scroll the documentation window [b]ack / [f]orward
835
+ [' <C-b>' ] = cmp .mapping .scroll_docs (- 4 ),
836
+ [' <C-f>' ] = cmp .mapping .scroll_docs (4 ),
837
+
838
+ -- Accept ([y]es) the completion.
839
+ -- This will auto-import if your LSP supports it.
840
+ -- This will expand snippets if the LSP sent a snippet.
841
+ [' <C-y>' ] = cmp .mapping .confirm { select = true },
842
+
843
+ -- If you prefer more traditional completion keymaps,
844
+ -- you can uncomment the following lines
845
+ -- ['<CR>'] = cmp.mapping.confirm { select = true },
846
+ -- ['<Tab>'] = cmp.mapping.select_next_item(),
847
+ -- ['<S-Tab>'] = cmp.mapping.select_prev_item(),
848
+
849
+ -- Manually trigger a completion from nvim-cmp.
850
+ -- Generally you don't need this, because nvim-cmp will display
851
+ -- completions whenever it has completion options available.
852
+ [' <C-Space>' ] = cmp .mapping .complete {},
853
+
854
+ -- Think of <c-l> as moving to the right of your snippet expansion.
855
+ -- So if you have a snippet that's like:
856
+ -- function $name($args)
857
+ -- $body
858
+ -- end
859
+ --
860
+ -- <c-l> will move you to the right of each of the expansion locations.
861
+ -- <c-h> is similar, except moving you backwards.
862
+ [' <C-l>' ] = cmp .mapping (function ()
863
+ if luasnip .expand_or_locally_jumpable () then
864
+ luasnip .expand_or_jump ()
865
+ end
866
+ end , { ' i' , ' s' }),
867
+ [' <C-h>' ] = cmp .mapping (function ()
868
+ if luasnip .locally_jumpable (- 1 ) then
869
+ luasnip .jump (- 1 )
870
+ end
871
+ end , { ' i' , ' s' }),
847
872
848
- sources = {
849
- default = { ' lsp' , ' path' , ' snippets' , ' lazydev' },
850
- providers = {
851
- lazydev = { module = ' lazydev.integrations.blink' , score_offset = 100 },
873
+ -- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see:
874
+ -- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps
852
875
},
853
- },
854
-
855
- snippets = { preset = ' luasnip' },
856
-
857
- -- Blink.cmp includes an optional, recommended rust fuzzy matcher,
858
- -- which automatically downloads a prebuilt binary when enabled.
859
- --
860
- -- By default, we use the Lua implementation instead, but you may enable
861
- -- the rust implementation via `'prefer_rust_with_warning'`
862
- --
863
- -- See :h blink-cmp-config-fuzzy for more information
864
- fuzzy = { implementation = ' lua' },
865
-
866
- -- Shows a signature help window while you type arguments for a function
867
- signature = { enabled = true },
868
- },
876
+ sources = {
877
+ {
878
+ name = ' lazydev' ,
879
+ -- set group index to 0 to skip loading LuaLS completions as lazydev recommends it
880
+ group_index = 0 ,
881
+ },
882
+ { name = ' nvim_lsp' },
883
+ { name = ' luasnip' },
884
+ { name = ' path' },
885
+ { name = ' nvim_lsp_signature_help' },
886
+ },
887
+ }
888
+ end ,
869
889
},
870
890
871
891
{ -- You can easily change to a different colorscheme.
0 commit comments