@@ -156,6 +156,11 @@ vim.opt.cursorline = true
156156-- Minimal number of screen lines to keep above and below the cursor.
157157vim .opt .scrolloff = 10
158158
159+ -- if performing an operation that would fail due to unsaved changes in the buffer (like `:q`),
160+ -- instead raise a dialog asking if you wish to save the current file(s)
161+ -- See `:help 'confirm'`
162+ vim .opt .confirm = true
163+
159164-- [[ Basic Keymaps ]]
160165-- See `:help vim.keymap.set()`
161166
@@ -189,6 +194,12 @@ vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right win
189194vim .keymap .set (' n' , ' <C-j>' , ' <C-w><C-j>' , { desc = ' Move focus to the lower window' })
190195vim .keymap .set (' n' , ' <C-k>' , ' <C-w><C-k>' , { desc = ' Move focus to the upper window' })
191196
197+ -- NOTE: Some terminals have colliding keymaps or are not able to send distinct keycodes
198+ -- vim.keymap.set("n", "<C-S-h>", "<C-w>H", { desc = "Move window to the left" })
199+ -- vim.keymap.set("n", "<C-S-l>", "<C-w>L", { desc = "Move window to the right" })
200+ -- vim.keymap.set("n", "<C-S-j>", "<C-w>J", { desc = "Move window to the lower" })
201+ -- vim.keymap.set("n", "<C-S-k>", "<C-w>K", { desc = "Move window to the upper" })
202+
192203-- [[ Basic Autocommands ]]
193204-- See `:help lua-guide-autocommands`
194205
@@ -325,11 +336,7 @@ require('lazy').setup({
325336
326337 -- Document existing key chains
327338 spec = {
328- { ' <leader>c' , group = ' [C]ode' , mode = { ' n' , ' x' } },
329- { ' <leader>d' , group = ' [D]ocument' },
330- { ' <leader>r' , group = ' [R]ename' },
331339 { ' <leader>s' , group = ' [S]earch' },
332- { ' <leader>w' , group = ' [W]orkspace' },
333340 { ' <leader>t' , group = ' [T]oggle' },
334341 { ' <leader>h' , group = ' Git [H]unk' , mode = { ' n' , ' v' } },
335342 },
@@ -346,7 +353,6 @@ require('lazy').setup({
346353 { -- Fuzzy Finder (files, lsp, etc)
347354 ' nvim-telescope/telescope.nvim' ,
348355 event = ' VimEnter' ,
349- branch = ' 0.1.x' ,
350356 dependencies = {
351357 ' nvim-lua/plenary.nvim' ,
352358 { -- If encountering errors, see telescope-fzf-native README for installation instructions
@@ -475,8 +481,8 @@ require('lazy').setup({
475481 -- Useful status updates for LSP.
476482 { ' j-hui/fidget.nvim' , opts = {} },
477483
478- -- Allows extra capabilities provided by nvim- cmp
479- ' hrsh7th/ cmp-nvim-lsp ' ,
484+ -- Allows extra capabilities provided by blink. cmp
485+ ' saghen/blink. cmp' ,
480486 },
481487 config = function ()
482488 -- Brief aside: **What is LSP?**
@@ -521,42 +527,42 @@ require('lazy').setup({
521527 vim .keymap .set (mode , keys , func , { buffer = event .buf , desc = ' LSP: ' .. desc })
522528 end
523529
524- -- Jump to the definition of the word under your cursor.
525- -- This is where a variable was first declared, or where a function is defined, etc.
526- -- To jump back, press <C-t>.
527- map (' gd' , require (' telescope.builtin' ).lsp_definitions , ' [G]oto [D]efinition' )
530+ -- Rename the variable under your cursor.
531+ -- Most Language Servers support renaming across files, etc.
532+ map (' grn' , vim .lsp .buf .rename , ' [R]e[n]ame' )
533+
534+ -- Execute a code action, usually your cursor needs to be on top of an error
535+ -- or a suggestion from your LSP for this to activate.
536+ map (' gra' , vim .lsp .buf .code_action , ' [G]oto Code [A]ction' , { ' n' , ' x' })
528537
529538 -- Find references for the word under your cursor.
530- map (' gr ' , require (' telescope.builtin' ).lsp_references , ' [G]oto [R]eferences' )
539+ map (' grr ' , require (' telescope.builtin' ).lsp_references , ' [G]oto [R]eferences' )
531540
532541 -- Jump to the implementation of the word under your cursor.
533542 -- Useful when your language has ways of declaring types without an actual implementation.
534- map (' gI ' , require (' telescope.builtin' ).lsp_implementations , ' [G]oto [I]mplementation' )
543+ map (' gri ' , require (' telescope.builtin' ).lsp_implementations , ' [G]oto [I]mplementation' )
535544
536- -- Jump to the type of the word under your cursor.
537- -- Useful when you're not sure what type a variable is and you want to see
538- -- the definition of its *type*, not where it was *defined*.
539- map (' <leader>D' , require (' telescope.builtin' ).lsp_type_definitions , ' Type [D]efinition' )
545+ -- Jump to the definition of the word under your cursor.
546+ -- This is where a variable was first declared, or where a function is defined, etc.
547+ -- To jump back, press <C-t>.
548+ map (' grd' , require (' telescope.builtin' ).lsp_definitions , ' [G]oto [D]efinition' )
549+
550+ -- WARN: This is not Goto Definition, this is Goto Declaration.
551+ -- For example, in C this would take you to the header.
552+ map (' grD' , vim .lsp .buf .declaration , ' [G]oto [D]eclaration' )
540553
541554 -- Fuzzy find all the symbols in your current document.
542555 -- Symbols are things like variables, functions, types, etc.
543- map (' <leader>ds ' , require (' telescope.builtin' ).lsp_document_symbols , ' [D]ocument [S]ymbols ' )
556+ map (' gO ' , require (' telescope.builtin' ).lsp_document_symbols , ' Open Document Symbols ' )
544557
545558 -- Fuzzy find all the symbols in your current workspace.
546559 -- Similar to document symbols, except searches over your entire project.
547- map (' <leader>ws ' , require (' telescope.builtin' ).lsp_dynamic_workspace_symbols , ' [W]orkspace [S]ymbols ' )
560+ map (' gW ' , require (' telescope.builtin' ).lsp_dynamic_workspace_symbols , ' Open Workspace Symbols ' )
548561
549- -- Rename the variable under your cursor.
550- -- Most Language Servers support renaming across files, etc.
551- map (' <leader>rn' , vim .lsp .buf .rename , ' [R]e[n]ame' )
552-
553- -- Execute a code action, usually your cursor needs to be on top of an error
554- -- or a suggestion from your LSP for this to activate.
555- map (' <leader>ca' , vim .lsp .buf .code_action , ' [C]ode [A]ction' , { ' n' , ' x' })
556-
557- -- WARN: This is not Goto Definition, this is Goto Declaration.
558- -- For example, in C this would take you to the header.
559- map (' gD' , vim .lsp .buf .declaration , ' [G]oto [D]eclaration' )
562+ -- Jump to the type of the word under your cursor.
563+ -- Useful when you're not sure what type a variable is and you want to see
564+ -- the definition of its *type*, not where it was *defined*.
565+ map (' grt' , require (' telescope.builtin' ).lsp_type_definitions , ' [G]oto [T]ype Definition' )
560566
561567 -- This function resolves a difference between neovim nightly (version 0.11) and stable (version 0.10)
562568 --- @param client vim.lsp.Client
@@ -643,10 +649,9 @@ require('lazy').setup({
643649
644650 -- LSP servers and clients are able to communicate to each other what features they support.
645651 -- By default, Neovim doesn't support everything that is in the LSP specification.
646- -- When you add nvim-cmp, luasnip, etc. Neovim now has *more* capabilities.
647- -- So, we create new capabilities with nvim cmp, and then broadcast that to the servers.
648- local capabilities = vim .lsp .protocol .make_client_capabilities ()
649- capabilities = vim .tbl_deep_extend (' force' , capabilities , require (' cmp_nvim_lsp' ).default_capabilities ())
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 ()
650655
651656 -- Enable the following language servers
652657 -- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
@@ -744,16 +749,14 @@ require('lazy').setup({
744749 -- have a well standardized coding style. You can add additional
745750 -- languages here or re-enable it for the disabled ones.
746751 local disable_filetypes = { c = true , cpp = true }
747- local lsp_format_opt
748752 if disable_filetypes [vim .bo [bufnr ].filetype ] then
749- lsp_format_opt = ' never '
753+ return nil
750754 else
751- lsp_format_opt = ' fallback'
755+ return {
756+ timeout_ms = 500 ,
757+ lsp_format = ' fallback' ,
758+ }
752759 end
753- return {
754- timeout_ms = 500 ,
755- lsp_format = lsp_format_opt ,
756- }
757760 end ,
758761 formatters_by_ft = {
759762 lua = { ' stylua' },
@@ -767,12 +770,14 @@ require('lazy').setup({
767770 },
768771
769772 { -- Autocompletion
770- ' hrsh7th/nvim-cmp' ,
771- event = ' InsertEnter' ,
773+ ' saghen/blink.cmp' ,
774+ event = ' VimEnter' ,
775+ version = ' 1.*' ,
772776 dependencies = {
773- -- Snippet Engine & its associated nvim-cmp source
777+ -- Snippet Engine
774778 {
775779 ' L3MON4D3/LuaSnip' ,
780+ version = ' 2.*' ,
776781 build = (function ()
777782 -- Build Step is needed for regex support in snippets.
778783 -- This step is not supported in many windows environments.
@@ -793,95 +798,74 @@ require('lazy').setup({
793798 -- end,
794799 -- },
795800 },
801+ opts = {},
796802 },
797- ' saadparwaiz1/cmp_luasnip' ,
798-
799- -- Adds other completion capabilities.
800- -- nvim-cmp does not ship with all sources by default. They are split
801- -- into multiple repos for maintenance purposes.
802- ' hrsh7th/cmp-nvim-lsp' ,
803- ' hrsh7th/cmp-path' ,
804- ' hrsh7th/cmp-nvim-lsp-signature-help' ,
803+ ' folke/lazydev.nvim' ,
805804 },
806- config = function ()
807- -- See `:help cmp`
808- local cmp = require ' cmp'
809- local luasnip = require ' luasnip'
810- luasnip .config .setup {}
811-
812- cmp .setup {
813- snippet = {
814- expand = function (args )
815- luasnip .lsp_expand (args .body )
816- end ,
817- },
818- completion = { completeopt = ' menu,menuone,noinsert' },
819-
820- -- For an understanding of why these mappings were
821- -- chosen, you will need to read `:help ins-completion`
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`
822819 --
823820 -- No, but seriously. Please read `:help ins-completion`, it is really good!
824- mapping = cmp .mapping .preset .insert {
825- -- Select the [n]ext item
826- [' <C-n>' ] = cmp .mapping .select_next_item (),
827- -- Select the [p]revious item
828- [' <C-p>' ] = cmp .mapping .select_prev_item (),
829-
830- -- Scroll the documentation window [b]ack / [f]orward
831- [' <C-b>' ] = cmp .mapping .scroll_docs (- 4 ),
832- [' <C-f>' ] = cmp .mapping .scroll_docs (4 ),
833-
834- -- Accept ([y]es) the completion.
835- -- This will auto-import if your LSP supports it.
836- -- This will expand snippets if the LSP sent a snippet.
837- [' <C-y>' ] = cmp .mapping .confirm { select = true },
838-
839- -- If you prefer more traditional completion keymaps,
840- -- you can uncomment the following lines
841- -- ['<CR>'] = cmp.mapping.confirm { select = true },
842- -- ['<Tab>'] = cmp.mapping.select_next_item(),
843- -- ['<S-Tab>'] = cmp.mapping.select_prev_item(),
844-
845- -- Manually trigger a completion from nvim-cmp.
846- -- Generally you don't need this, because nvim-cmp will display
847- -- completions whenever it has completion options available.
848- [' <C-Space>' ] = cmp .mapping .complete {},
849-
850- -- Think of <c-l> as moving to the right of your snippet expansion.
851- -- So if you have a snippet that's like:
852- -- function $name($args)
853- -- $body
854- -- end
855- --
856- -- <c-l> will move you to the right of each of the expansion locations.
857- -- <c-h> is similar, except moving you backwards.
858- [' <C-l>' ] = cmp .mapping (function ()
859- if luasnip .expand_or_locally_jumpable () then
860- luasnip .expand_or_jump ()
861- end
862- end , { ' i' , ' s' }),
863- [' <C-h>' ] = cmp .mapping (function ()
864- if luasnip .locally_jumpable (- 1 ) then
865- luasnip .jump (- 1 )
866- end
867- end , { ' i' , ' s' }),
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' ,
868831
869- -- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see:
870- -- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps
871- },
872- sources = {
873- {
874- name = ' lazydev' ,
875- -- set group index to 0 to skip loading LuaLS completions as lazydev recommends it
876- group_index = 0 ,
877- },
878- { name = ' nvim_lsp' },
879- { name = ' luasnip' },
880- { name = ' path' },
881- { name = ' nvim_lsp_signature_help' },
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+ },
847+
848+ sources = {
849+ default = { ' lsp' , ' path' , ' snippets' , ' lazydev' },
850+ providers = {
851+ lazydev = { module = ' lazydev.integrations.blink' , score_offset = 100 },
882852 },
883- }
884- end ,
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+ },
885869 },
886870
887871 { -- You can easily change to a different colorscheme.
0 commit comments