@@ -90,7 +90,7 @@ P.S. You can delete this when you're done too. It's your config now! :)
9090vim .g .mapleader = ' '
9191vim .g .maplocalleader = ' '
9292
93- -- Set to true if you have a Nerd Font installed
93+ -- Set to true if you have a Nerd Font installed and selected in the terminal
9494vim .g .have_nerd_font = false
9595
9696-- [[ Setting options ]]
@@ -162,9 +162,6 @@ vim.opt.hlsearch = true
162162vim .keymap .set (' n' , ' <Esc>' , ' <cmd>nohlsearch<CR>' )
163163
164164-- Diagnostic keymaps
165- vim .keymap .set (' n' , ' [d' , vim .diagnostic .goto_prev , { desc = ' Go to previous [D]iagnostic message' })
166- vim .keymap .set (' n' , ' ]d' , vim .diagnostic .goto_next , { desc = ' Go to next [D]iagnostic message' })
167- vim .keymap .set (' n' , ' <leader>e' , vim .diagnostic .open_float , { desc = ' Show diagnostic [E]rror messages' })
168165vim .keymap .set (' n' , ' <leader>q' , vim .diagnostic .setloclist , { desc = ' Open diagnostic [Q]uickfix list' })
169166
170167-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier
@@ -207,9 +204,12 @@ vim.api.nvim_create_autocmd('TextYankPost', {
207204-- [[ Install `lazy.nvim` plugin manager ]]
208205-- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info
209206local lazypath = vim .fn .stdpath ' data' .. ' /lazy/lazy.nvim'
210- if not vim .loop .fs_stat (lazypath ) then
207+ if not vim .uv .fs_stat (lazypath ) then
211208 local lazyrepo = ' https://github.com/folke/lazy.nvim.git'
212- vim .fn .system { ' git' , ' clone' , ' --filter=blob:none' , ' --branch=stable' , lazyrepo , lazypath }
209+ local out = vim .fn .system { ' git' , ' clone' , ' --filter=blob:none' , ' --branch=stable' , lazyrepo , lazypath }
210+ if vim .v .shell_error ~= 0 then
211+ error (' Error cloning lazy.nvim:\n ' .. out )
212+ end
213213end --- @diagnostic disable-next-line : undefined-field
214214vim .opt .rtp :prepend (lazypath )
215215
@@ -234,11 +234,6 @@ require('lazy').setup({
234234 --
235235 -- Use `opts = {}` to force a plugin to be loaded.
236236 --
237- -- This is equivalent to:
238- -- require('Comment').setup({})
239-
240- -- "gc" to comment visual regions/lines
241- { ' numToStr/Comment.nvim' , opts = {} },
242237
243238 -- Here is a more advanced example where we pass configuration
244239 -- options to `gitsigns.nvim`. This is equivalent to the following Lua:
@@ -280,12 +275,14 @@ require('lazy').setup({
280275 require (' which-key' ).setup ()
281276
282277 -- Document existing key chains
283- require (' which-key' ).register {
284- [' <leader>c' ] = { name = ' [C]ode' , _ = ' which_key_ignore' },
285- [' <leader>d' ] = { name = ' [D]ocument' , _ = ' which_key_ignore' },
286- [' <leader>r' ] = { name = ' [R]ename' , _ = ' which_key_ignore' },
287- [' <leader>s' ] = { name = ' [S]earch' , _ = ' which_key_ignore' },
288- [' <leader>w' ] = { name = ' [W]orkspace' , _ = ' which_key_ignore' },
278+ require (' which-key' ).add {
279+ { ' <leader>c' , group = ' [C]ode' },
280+ { ' <leader>d' , group = ' [D]ocument' },
281+ { ' <leader>r' , group = ' [R]ename' },
282+ { ' <leader>s' , group = ' [S]earch' },
283+ { ' <leader>w' , group = ' [W]orkspace' },
284+ { ' <leader>t' , group = ' [T]oggle' },
285+ { ' <leader>h' , group = ' Git [H]unk' , mode = { ' n' , ' v' } },
289286 }
290287 end ,
291288 },
@@ -406,17 +403,27 @@ require('lazy').setup({
406403 ' neovim/nvim-lspconfig' ,
407404 dependencies = {
408405 -- Automatically install LSPs and related tools to stdpath for Neovim
409- ' williamboman/mason.nvim' ,
406+ { ' williamboman/mason.nvim' , config = true }, -- NOTE: Must be loaded before dependants
410407 ' williamboman/mason-lspconfig.nvim' ,
411408 ' WhoIsSethDaniel/mason-tool-installer.nvim' ,
412409
413410 -- Useful status updates for LSP.
414411 -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
415412 { ' j-hui/fidget.nvim' , opts = {} },
416413
417- -- `neodev ` configures Lua LSP for your Neovim config, runtime and plugins
414+ -- `lazydev ` configures Lua LSP for your Neovim config, runtime and plugins
418415 -- used for completion, annotations and signatures of Neovim apis
419- { ' folke/neodev.nvim' , opts = {} },
416+ {
417+ ' folke/lazydev.nvim' ,
418+ ft = ' lua' ,
419+ opts = {
420+ library = {
421+ -- Load luvit types when the `vim.uv` word is found
422+ { path = ' luvit-meta/library' , words = { ' vim%.uv' } },
423+ },
424+ },
425+ },
426+ { ' Bilal2453/luvit-meta' , lazy = true },
420427 },
421428 config = function ()
422429 -- Brief aside: **What is LSP?**
@@ -493,10 +500,6 @@ require('lazy').setup({
493500 -- or a suggestion from your LSP for this to activate.
494501 map (' <leader>ca' , vim .lsp .buf .code_action , ' [C]ode [A]ction' )
495502
496- -- Opens a popup that displays documentation about the word under your cursor
497- -- See `:help K` for why this keymap.
498- map (' K' , vim .lsp .buf .hover , ' Hover Documentation' )
499-
500503 -- WARN: This is not Goto Definition, this is Goto Declaration.
501504 -- For example, in C this would take you to the header.
502505 map (' gD' , vim .lsp .buf .declaration , ' [G]oto [D]eclaration' )
@@ -507,16 +510,37 @@ require('lazy').setup({
507510 --
508511 -- When you move your cursor, the highlights will be cleared (the second autocommand).
509512 local client = vim .lsp .get_client_by_id (event .data .client_id )
510- if client and client .server_capabilities .documentHighlightProvider then
513+ if client and client .supports_method (vim .lsp .protocol .Methods .textDocument_documentHighlight ) then
514+ local highlight_augroup = vim .api .nvim_create_augroup (' kickstart-lsp-highlight' , { clear = false })
511515 vim .api .nvim_create_autocmd ({ ' CursorHold' , ' CursorHoldI' }, {
512516 buffer = event .buf ,
517+ group = highlight_augroup ,
513518 callback = vim .lsp .buf .document_highlight ,
514519 })
515520
516521 vim .api .nvim_create_autocmd ({ ' CursorMoved' , ' CursorMovedI' }, {
517522 buffer = event .buf ,
523+ group = highlight_augroup ,
518524 callback = vim .lsp .buf .clear_references ,
519525 })
526+
527+ vim .api .nvim_create_autocmd (' LspDetach' , {
528+ group = vim .api .nvim_create_augroup (' kickstart-lsp-detach' , { clear = true }),
529+ callback = function (event2 )
530+ vim .lsp .buf .clear_references ()
531+ vim .api .nvim_clear_autocmds { group = ' kickstart-lsp-highlight' , buffer = event2 .buf }
532+ end ,
533+ })
534+ end
535+
536+ -- The following code creates a keymap to toggle inlay hints in your
537+ -- code, if the language server you are using supports them
538+ --
539+ -- This may be unwanted, since they displace some of your code
540+ if client and client .supports_method (vim .lsp .protocol .Methods .textDocument_inlayHint ) then
541+ map (' <leader>th' , function ()
542+ vim .lsp .inlay_hint .enable (not vim .lsp .inlay_hint .is_enabled { bufnr = event .buf })
543+ end , ' [T]oggle Inlay [H]ints' )
520544 end
521545 end ,
522546 })
@@ -600,7 +624,8 @@ require('lazy').setup({
600624
601625 { -- Autoformat
602626 ' stevearc/conform.nvim' ,
603- lazy = false ,
627+ event = { ' BufWritePre' },
628+ cmd = { ' ConformInfo' },
604629 keys = {
605630 {
606631 ' <leader>f' ,
@@ -704,6 +729,12 @@ require('lazy').setup({
704729 -- This will expand snippets if the LSP sent a snippet.
705730 [' <C-y>' ] = cmp .mapping .confirm { select = true },
706731
732+ -- If you prefer more traditional completion keymaps,
733+ -- you can uncomment the following lines
734+ -- ['<CR>'] = cmp.mapping.confirm { select = true },
735+ -- ['<Tab>'] = cmp.mapping.select_next_item(),
736+ -- ['<S-Tab>'] = cmp.mapping.select_prev_item(),
737+
707738 -- Manually trigger a completion from nvim-cmp.
708739 -- Generally you don't need this, because nvim-cmp will display
709740 -- completions whenever it has completion options available.
@@ -732,6 +763,11 @@ require('lazy').setup({
732763 -- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps
733764 },
734765 sources = {
766+ {
767+ name = ' lazydev' ,
768+ -- set group index to 0 to skip loading LuaLS completions as lazydev recommends it
769+ group_index = 0 ,
770+ },
735771 { name = ' nvim_lsp' },
736772 { name = ' luasnip' },
737773 { name = ' path' },
@@ -768,7 +804,7 @@ require('lazy').setup({
768804 --
769805 -- Examples:
770806 -- - va) - [V]isually select [A]round [)]paren
771- -- - yinq - [Y]ank [I]nside [N]ext [']quote
807+ -- - yinq - [Y]ank [I]nside [N]ext [Q]uote
772808 -- - ci' - [C]hange [I]nside [']quote
773809 require (' mini.ai' ).setup { n_lines = 500 }
774810
@@ -802,8 +838,7 @@ require('lazy').setup({
802838 ' nvim-treesitter/nvim-treesitter' ,
803839 build = ' :TSUpdate' ,
804840 opts = {
805- ensure_installed = { ' bash' , ' c' , ' html' , ' lua' , ' luadoc' , ' markdown' , ' vim' , ' vimdoc' , ' c_sharp' , ' java' },
806- -- Autoinstall languages that are not installed
841+ ensure_installed = { ' bash' , ' c' , ' diff' , ' html' , ' lua' , ' luadoc' , ' markdown' , ' markdown_inline' , ' query' , ' vim' , ' vimdoc' , ' c_sharp' , ' java' },
807842 auto_install = true ,
808843 highlight = {
809844 enable = true ,
@@ -817,6 +852,8 @@ require('lazy').setup({
817852 config = function (_ , opts )
818853 -- [[ Configure Treesitter ]] See `:help nvim-treesitter`
819854
855+ -- Prefer git instead of curl in order to improve connectivity in some environments
856+ require (' nvim-treesitter.install' ).prefer_git = true
820857 --- @diagnostic disable-next-line : missing-fields
821858 require (' nvim-treesitter.configs' ).setup (opts )
822859
@@ -841,6 +878,9 @@ require('lazy').setup({
841878 -- require 'kickstart.plugins.debug',
842879 -- require 'kickstart.plugins.indent_line',
843880 -- require 'kickstart.plugins.lint',
881+ -- require 'kickstart.plugins.autopairs',
882+ -- require 'kickstart.plugins.neo-tree',
883+ -- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps
844884
845885 -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
846886 -- This is the easiest way to modularize your config.
0 commit comments