@@ -135,7 +135,6 @@ vim.opt.signcolumn = 'yes'
135135vim .opt .updatetime = 250
136136
137137-- Decrease mapped sequence wait time
138- -- Displays which-key popup sooner
139138vim .opt .timeoutlen = 300
140139
141140-- Configure how new splits should be opened
@@ -157,6 +156,11 @@ vim.opt.cursorline = true
157156-- Minimal number of screen lines to keep above and below the cursor.
158157vim .opt .scrolloff = 10
159158
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+
160164-- [[ Basic Keymaps ]]
161165-- See `:help vim.keymap.set()`
162166
@@ -235,12 +239,22 @@ require('lazy').setup({
235239 -- with the first argument being the link and the following
236240 -- keys can be used to configure plugin behavior/loading/etc.
237241 --
238- -- Use `opts = {}` to force a plugin to be loaded.
242+ -- Use `opts = {}` to automatically pass options to a plugin's `setup()` function, forcing the plugin to be loaded.
239243 --
240244
245+ -- Alternatively, use `config = function() ... end` for full control over the configuration.
246+ -- If you prefer to call `setup` explicitly, use:
247+ -- {
248+ -- 'lewis6991/gitsigns.nvim',
249+ -- config = function()
250+ -- require('gitsigns').setup({
251+ -- -- Your gitsigns configuration here
252+ -- })
253+ -- end,
254+ -- }
255+ --
241256 -- Here is a more advanced example where we pass configuration
242- -- options to `gitsigns.nvim`. This is equivalent to the following Lua:
243- -- require('gitsigns').setup({ ... })
257+ -- options to `gitsigns.nvim`.
244258 --
245259 -- See `:help gitsigns` to understand what the configuration keys do
246260 { -- Adds git related signs to the gutter, as well as utilities for managing changes
@@ -267,19 +281,21 @@ require('lazy').setup({
267281 -- which loads which-key before all the UI elements are loaded. Events can be
268282 -- normal autocommands events (`:help autocmd-events`).
269283 --
270- -- Then, because we use the `config` key, the configuration only runs
271- -- after the plugin has been loaded:
272- -- config = function() ... end
284+ -- Then, because we use the `opts` key (recommended), the configuration runs
285+ -- after the plugin has been loaded as `require(MODULE).setup(opts)`.
273286
274287 { -- Useful plugin to show you pending keybinds.
275288 ' folke/which-key.nvim' ,
276289 event = ' VimEnter' , -- Sets the loading event to 'VimEnter'
277290 opts = {
291+ -- delay between pressing a key and opening which-key (milliseconds)
292+ -- this setting is independent of vim.opt.timeoutlen
293+ delay = 0 ,
278294 icons = {
279295 -- set icon mappings to true if you have a Nerd Font
280296 mappings = vim .g .have_nerd_font ,
281297 -- If you are using a Nerd Font: set icons.keys to an empty table which will use the
282- -- default whick -key.nvim defined Nerd Font icons, otherwise define a string table
298+ -- default which -key.nvim defined Nerd Font icons, otherwise define a string table
283299 keys = vim .g .have_nerd_font and {} or {
284300 Up = ' <Up> ' ,
285301 Down = ' <Down> ' ,
@@ -446,22 +462,22 @@ require('lazy').setup({
446462 opts = {
447463 library = {
448464 -- Load luvit types when the `vim.uv` word is found
449- { path = ' luvit-meta /library' , words = { ' vim%.uv' } },
465+ { path = ' ${3rd}/luv /library' , words = { ' vim%.uv' } },
450466 },
451467 },
452468 },
453- { ' Bilal2453/luvit-meta' , lazy = true },
454469 {
455470 -- Main LSP Configuration
456471 ' neovim/nvim-lspconfig' ,
457472 dependencies = {
458473 -- Automatically install LSPs and related tools to stdpath for Neovim
459- { ' williamboman/mason.nvim' , config = true }, -- NOTE: Must be loaded before dependants
474+ -- Mason must be loaded before its dependents so we need to set it up here.
475+ -- NOTE: `opts = {}` is the same as calling `require('mason').setup({})`
476+ { ' williamboman/mason.nvim' , opts = {} },
460477 ' williamboman/mason-lspconfig.nvim' ,
461478 ' WhoIsSethDaniel/mason-tool-installer.nvim' ,
462479
463480 -- Useful status updates for LSP.
464- -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
465481 { ' j-hui/fidget.nvim' , opts = {} },
466482
467483 -- Allows extra capabilities provided by nvim-cmp
@@ -547,13 +563,26 @@ require('lazy').setup({
547563 -- For example, in C this would take you to the header.
548564 map (' gD' , vim .lsp .buf .declaration , ' [G]oto [D]eclaration' )
549565
566+ -- This function resolves a difference between neovim nightly (version 0.11) and stable (version 0.10)
567+ --- @param client vim.lsp.Client
568+ --- @param method vim.lsp.protocol.Method
569+ --- @param bufnr ? integer some lsp support methods only in specific files
570+ --- @return boolean
571+ local function client_supports_method (client , method , bufnr )
572+ if vim .fn .has ' nvim-0.11' == 1 then
573+ return client :supports_method (method , bufnr )
574+ else
575+ return client .supports_method (method , { bufnr = bufnr })
576+ end
577+ end
578+
550579 -- The following two autocommands are used to highlight references of the
551580 -- word under your cursor when your cursor rests there for a little while.
552581 -- See `:help CursorHold` for information about when this is executed
553582 --
554583 -- When you move your cursor, the highlights will be cleared (the second autocommand).
555584 local client = vim .lsp .get_client_by_id (event .data .client_id )
556- if client and client . supports_method ( vim .lsp .protocol .Methods .textDocument_documentHighlight ) then
585+ if client and client_supports_method ( client , vim .lsp .protocol .Methods .textDocument_documentHighlight , event . buf ) then
557586 local highlight_augroup = vim .api .nvim_create_augroup (' kickstart-lsp-highlight' , { clear = false })
558587 vim .api .nvim_create_autocmd ({ ' CursorHold' , ' CursorHoldI' }, {
559588 buffer = event .buf ,
@@ -580,22 +609,42 @@ require('lazy').setup({
580609 -- code, if the language server you are using supports them
581610 --
582611 -- This may be unwanted, since they displace some of your code
583- if client and client . supports_method ( vim .lsp .protocol .Methods .textDocument_inlayHint ) then
612+ if client and client_supports_method ( client , vim .lsp .protocol .Methods .textDocument_inlayHint , event . buf ) then
584613 map (' <leader>th' , function ()
585614 vim .lsp .inlay_hint .enable (not vim .lsp .inlay_hint .is_enabled { bufnr = event .buf })
586615 end , ' [T]oggle Inlay [H]ints' )
587616 end
588617 end ,
589618 })
590619
591- -- Change diagnostic symbols in the sign column (gutter)
592- if vim .g .have_nerd_font then
593- local signs = { Error = ' ' , Warn = ' ' , Hint = ' ' , Info = ' ' }
594- for type , icon in pairs (signs ) do
595- local hl = ' DiagnosticSign' .. type
596- vim .fn .sign_define (hl , { text = icon , texthl = hl , numhl = hl })
597- end
598- end
620+ -- Diagnostic Config
621+ -- See :help vim.diagnostic.Opts
622+ vim .diagnostic .config {
623+ severity_sort = true ,
624+ float = { border = ' rounded' , source = ' if_many' },
625+ underline = { severity = vim .diagnostic .severity .ERROR },
626+ signs = vim .g .have_nerd_font and {
627+ text = {
628+ [vim .diagnostic .severity .ERROR ] = ' ' ,
629+ [vim .diagnostic .severity .WARN ] = ' ' ,
630+ [vim .diagnostic .severity .INFO ] = ' ' ,
631+ [vim .diagnostic .severity .HINT ] = ' ' ,
632+ },
633+ } or {},
634+ virtual_text = {
635+ source = ' if_many' ,
636+ spacing = 2 ,
637+ format = function (diagnostic )
638+ local diagnostic_message = {
639+ [vim .diagnostic .severity .ERROR ] = diagnostic .message ,
640+ [vim .diagnostic .severity .WARN ] = diagnostic .message ,
641+ [vim .diagnostic .severity .INFO ] = diagnostic .message ,
642+ [vim .diagnostic .severity .HINT ] = diagnostic .message ,
643+ }
644+ return diagnostic_message [diagnostic .severity ]
645+ end ,
646+ },
647+ }
599648
600649 -- LSP servers and clients are able to communicate to each other what features they support.
601650 -- By default, Neovim doesn't support everything that is in the LSP specification.
@@ -633,8 +682,8 @@ require('lazy').setup({
633682 --
634683
635684 lua_ls = {
636- -- cmd = {...},
637- -- filetypes = { ...},
685+ -- cmd = { ... },
686+ -- filetypes = { ... },
638687 -- capabilities = {},
639688 settings = {
640689 Lua = {
@@ -649,13 +698,16 @@ require('lazy').setup({
649698 }
650699
651700 -- Ensure the servers and tools above are installed
652- -- To check the current status of installed tools and/or manually install
653- -- other tools, you can run
701+ --
702+ -- To check the current status of installed tools and/or manually install
703+ -- other tools, you can run
654704 -- :Mason
655705 --
656- -- You can press `g?` for help in this menu.
657- require (' mason' ).setup ()
658-
706+ -- You can press `g?` for help in this menu.
707+ --
708+ -- `mason` had to be setup earlier: to configure its options see the
709+ -- `dependencies` table for `nvim-lspconfig` above.
710+ --
659711 -- You can add other tools here that you want Mason to install
660712 -- for you, so that they are available from within Neovim.
661713 local ensure_installed = vim .tbl_keys (servers or {})
@@ -665,6 +717,8 @@ require('lazy').setup({
665717 require (' mason-tool-installer' ).setup { ensure_installed = ensure_installed }
666718
667719 require (' mason-lspconfig' ).setup {
720+ ensure_installed = {}, -- explicitly set to an empty table (Kickstart populates installs via mason-tool-installer)
721+ automatic_installation = false ,
668722 handlers = {
669723 function (server_name )
670724 local server = servers [server_name ] or {}
@@ -757,6 +811,7 @@ require('lazy').setup({
757811 -- into multiple repos for maintenance purposes.
758812 ' hrsh7th/cmp-nvim-lsp' ,
759813 ' hrsh7th/cmp-path' ,
814+ ' hrsh7th/cmp-nvim-lsp-signature-help' ,
760815 },
761816 config = function ()
762817 -- See `:help cmp`
@@ -833,6 +888,7 @@ require('lazy').setup({
833888 { name = ' nvim_lsp' },
834889 { name = ' luasnip' },
835890 { name = ' path' },
891+ { name = ' nvim_lsp_signature_help' },
836892 },
837893 }
838894 end ,
@@ -845,14 +901,18 @@ require('lazy').setup({
845901 -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`.
846902 ' folke/tokyonight.nvim' ,
847903 priority = 1000 , -- Make sure to load this before all the other start plugins.
848- init = function ()
904+ config = function ()
905+ --- @diagnostic disable-next-line : missing-fields
906+ require (' tokyonight' ).setup {
907+ styles = {
908+ comments = { italic = false }, -- Disable italics in comments
909+ },
910+ }
911+
849912 -- Load the colorscheme here.
850913 -- Like many other themes, this one has different styles, and you could load
851914 -- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'.
852915 vim .cmd .colorscheme ' tokyonight-night'
853-
854- -- You can configure highlights by doing something like:
855- vim .cmd .hi ' Comment gui=none'
856916 end ,
857917 },
858918
0 commit comments