@@ -136,7 +136,6 @@ vim.opt.signcolumn = 'yes'
136136vim .opt .updatetime = 250
137137
138138-- Decrease mapped sequence wait time
139- -- Displays which-key popup sooner
140139vim .opt .timeoutlen = 300
141140
142141-- Configure how new splits should be opened
@@ -158,6 +157,11 @@ vim.opt.cursorline = true
158157-- Minimal number of screen lines to keep above and below the cursor.
159158vim .opt .scrolloff = 10
160159
160+ -- if performing an operation that would fail due to unsaved changes in the buffer (like `:q`),
161+ -- instead raise a dialog asking if you wish to save the current file(s)
162+ -- See `:help 'confirm'`
163+ vim .opt .confirm = true
164+
161165-- [[ Basic Keymaps ]]
162166-- See `:help vim.keymap.set()`
163167
@@ -236,12 +240,22 @@ require('lazy').setup({
236240 -- with the first argument being the link and the following
237241 -- keys can be used to configure plugin behavior/loading/etc.
238242 --
239- -- Use `opts = {}` to force a plugin to be loaded.
243+ -- Use `opts = {}` to automatically pass options to a plugin's `setup()` function, forcing the plugin to be loaded.
240244 --
241245
246+ -- Alternatively, use `config = function() ... end` for full control over the configuration.
247+ -- If you prefer to call `setup` explicitly, use:
248+ -- {
249+ -- 'lewis6991/gitsigns.nvim',
250+ -- config = function()
251+ -- require('gitsigns').setup({
252+ -- -- Your gitsigns configuration here
253+ -- })
254+ -- end,
255+ -- }
256+ --
242257 -- Here is a more advanced example where we pass configuration
243- -- options to `gitsigns.nvim`. This is equivalent to the following Lua:
244- -- require('gitsigns').setup({ ... })
258+ -- options to `gitsigns.nvim`.
245259 --
246260 -- See `:help gitsigns` to understand what the configuration keys do
247261 { -- Adds git related signs to the gutter, as well as utilities for managing changes
@@ -268,14 +282,16 @@ require('lazy').setup({
268282 -- which loads which-key before all the UI elements are loaded. Events can be
269283 -- normal autocommands events (`:help autocmd-events`).
270284 --
271- -- Then, because we use the `config` key, the configuration only runs
272- -- after the plugin has been loaded:
273- -- config = function() ... end
285+ -- Then, because we use the `opts` key (recommended), the configuration runs
286+ -- after the plugin has been loaded as `require(MODULE).setup(opts)`.
274287
275288 { -- Useful plugin to show you pending keybinds.
276289 ' folke/which-key.nvim' ,
277290 event = ' VimEnter' , -- Sets the loading event to 'VimEnter'
278291 opts = {
292+ -- delay between pressing a key and opening which-key (milliseconds)
293+ -- this setting is independent of vim.opt.timeoutlen
294+ delay = 0 ,
279295 icons = {
280296 -- set icon mappings to true if you have a Nerd Font
281297 mappings = vim .g .have_nerd_font ,
@@ -448,22 +464,22 @@ require('lazy').setup({
448464 opts = {
449465 library = {
450466 -- Load luvit types when the `vim.uv` word is found
451- { path = ' luvit-meta /library' , words = { ' vim%.uv' } },
467+ { path = ' ${3rd}/luv /library' , words = { ' vim%.uv' } },
452468 },
453469 },
454470 },
455- { ' Bilal2453/luvit-meta' , lazy = true },
456471 {
457472 -- Main LSP Configuration
458473 ' neovim/nvim-lspconfig' ,
459474 dependencies = {
460475 -- Automatically install LSPs and related tools to stdpath for Neovim
461- { ' williamboman/mason.nvim' , config = true }, -- NOTE: Must be loaded before dependants
476+ -- Mason must be loaded before its dependents so we need to set it up here.
477+ -- NOTE: `opts = {}` is the same as calling `require('mason').setup({})`
478+ { ' williamboman/mason.nvim' , opts = {} },
462479 ' williamboman/mason-lspconfig.nvim' ,
463480 ' WhoIsSethDaniel/mason-tool-installer.nvim' ,
464481
465482 -- Useful status updates for LSP.
466- -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
467483 { ' j-hui/fidget.nvim' , opts = {} },
468484
469485 -- Allows extra capabilities provided by nvim-cmp
@@ -549,13 +565,26 @@ require('lazy').setup({
549565 -- For example, in C this would take you to the header.
550566 map (' gD' , vim .lsp .buf .declaration , ' [G]oto [D]eclaration' )
551567
568+ -- This function resolves a difference between neovim nightly (version 0.11) and stable (version 0.10)
569+ --- @param client vim.lsp.Client
570+ --- @param method vim.lsp.protocol.Method
571+ --- @param bufnr ? integer some lsp support methods only in specific files
572+ --- @return boolean
573+ local function client_supports_method (client , method , bufnr )
574+ if vim .fn .has ' nvim-0.11' == 1 then
575+ return client :supports_method (method , bufnr )
576+ else
577+ return client .supports_method (method , { bufnr = bufnr })
578+ end
579+ end
580+
552581 -- The following two autocommands are used to highlight references of the
553582 -- word under your cursor when your cursor rests there for a little while.
554583 -- See `:help CursorHold` for information about when this is executed
555584 --
556585 -- When you move your cursor, the highlights will be cleared (the second autocommand).
557586 local client = vim .lsp .get_client_by_id (event .data .client_id )
558- if client and client . supports_method ( vim .lsp .protocol .Methods .textDocument_documentHighlight ) then
587+ if client and client_supports_method ( client , vim .lsp .protocol .Methods .textDocument_documentHighlight , event . buf ) then
559588 local highlight_augroup = vim .api .nvim_create_augroup (' kickstart-lsp-highlight' , { clear = false })
560589 vim .api .nvim_create_autocmd ({ ' CursorHold' , ' CursorHoldI' }, {
561590 buffer = event .buf ,
@@ -582,23 +611,42 @@ require('lazy').setup({
582611 -- code, if the language server you are using supports them
583612 --
584613 -- This may be unwanted, since they displace some of your code
585- if client and client . supports_method ( vim .lsp .protocol .Methods .textDocument_inlayHint ) then
614+ if client and client_supports_method ( client , vim .lsp .protocol .Methods .textDocument_inlayHint , event . buf ) then
586615 map (' <leader>th' , function ()
587616 vim .lsp .inlay_hint .enable (not vim .lsp .inlay_hint .is_enabled { bufnr = event .buf })
588617 end , ' [T]oggle Inlay [H]ints' )
589618 end
590619 end ,
591620 })
592621
593- -- Change diagnostic symbols in the sign column (gutter)
594- -- if vim.g.have_nerd_font then
595- -- local signs = { ERROR = '', WARN = '', INFO = '', HINT = '' }
596- -- local diagnostic_signs = {}
597- -- for type, icon in pairs(signs) do
598- -- diagnostic_signs[vim.diagnostic.severity[type]] = icon
599- -- end
600- -- vim.diagnostic.config { signs = { text = diagnostic_signs } }
601- -- end
622+ -- Diagnostic Config
623+ -- See :help vim.diagnostic.Opts
624+ vim .diagnostic .config {
625+ severity_sort = true ,
626+ float = { border = ' rounded' , source = ' if_many' },
627+ underline = { severity = vim .diagnostic .severity .ERROR },
628+ signs = vim .g .have_nerd_font and {
629+ text = {
630+ [vim .diagnostic .severity .ERROR ] = ' ' ,
631+ [vim .diagnostic .severity .WARN ] = ' ' ,
632+ [vim .diagnostic .severity .INFO ] = ' ' ,
633+ [vim .diagnostic .severity .HINT ] = ' ' ,
634+ },
635+ } or {},
636+ virtual_text = {
637+ source = ' if_many' ,
638+ spacing = 2 ,
639+ format = function (diagnostic )
640+ local diagnostic_message = {
641+ [vim .diagnostic .severity .ERROR ] = diagnostic .message ,
642+ [vim .diagnostic .severity .WARN ] = diagnostic .message ,
643+ [vim .diagnostic .severity .INFO ] = diagnostic .message ,
644+ [vim .diagnostic .severity .HINT ] = diagnostic .message ,
645+ }
646+ return diagnostic_message [diagnostic .severity ]
647+ end ,
648+ },
649+ }
602650
603651 -- LSP servers and clients are able to communicate to each other what features they support.
604652 -- By default, Neovim doesn't support everything that is in the LSP specification.
@@ -631,8 +679,8 @@ require('lazy').setup({
631679 --
632680
633681 lua_ls = {
634- -- cmd = {...},
635- -- filetypes = { ...},
682+ -- cmd = { ... },
683+ -- filetypes = { ... },
636684 -- capabilities = {},
637685 settings = {
638686 Lua = {
@@ -647,13 +695,16 @@ require('lazy').setup({
647695 }
648696
649697 -- Ensure the servers and tools above are installed
650- -- To check the current status of installed tools and/or manually install
651- -- other tools, you can run
698+ --
699+ -- To check the current status of installed tools and/or manually install
700+ -- other tools, you can run
652701 -- :Mason
653702 --
654- -- You can press `g?` for help in this menu.
655- require (' mason' ).setup ()
656-
703+ -- You can press `g?` for help in this menu.
704+ --
705+ -- `mason` had to be setup earlier: to configure its options see the
706+ -- `dependencies` table for `nvim-lspconfig` above.
707+ --
657708 -- You can add other tools here that you want Mason to install
658709 -- for you, so that they are available from within Neovim.
659710 local ensure_installed = vim .tbl_keys (servers or {})
@@ -663,6 +714,8 @@ require('lazy').setup({
663714 require (' mason-tool-installer' ).setup { ensure_installed = ensure_installed }
664715
665716 require (' mason-lspconfig' ).setup {
717+ ensure_installed = {}, -- explicitly set to an empty table (Kickstart populates installs via mason-tool-installer)
718+ automatic_installation = false ,
666719 handlers = {
667720 function (server_name )
668721 local server = servers [server_name ] or {}
@@ -755,6 +808,7 @@ require('lazy').setup({
755808 -- into multiple repos for maintenance purposes.
756809 ' hrsh7th/cmp-nvim-lsp' ,
757810 ' hrsh7th/cmp-path' ,
811+ ' hrsh7th/cmp-nvim-lsp-signature-help' ,
758812 },
759813 config = function ()
760814 -- See `:help cmp`
@@ -831,6 +885,7 @@ require('lazy').setup({
831885 { name = ' nvim_lsp' },
832886 { name = ' luasnip' },
833887 { name = ' path' },
888+ { name = ' nvim_lsp_signature_help' },
834889 },
835890 }
836891 end ,
0 commit comments