@@ -245,12 +245,22 @@ require('lazy').setup({
245245 -- with the first argument being the link and the following
246246 -- keys can be used to configure plugin behavior/loading/etc.
247247 --
248- -- Use `opts = {}` to force a plugin to be loaded.
248+ -- Use `opts = {}` to automatically pass options to a plugin's `setup()` function, forcing the plugin to be loaded.
249249 --
250250
251+ -- Alternatively, use `config = function() ... end` for full control over the configuration.
252+ -- If you prefer to call `setup` explicitly, use:
253+ -- {
254+ -- 'lewis6991/gitsigns.nvim',
255+ -- config = function()
256+ -- require('gitsigns').setup({
257+ -- -- Your gitsigns configuration here
258+ -- })
259+ -- end,
260+ -- }
261+ --
251262 -- Here is a more advanced example where we pass configuration
252- -- options to `gitsigns.nvim`. This is equivalent to the following Lua:
253- -- require('gitsigns').setup({ ... })
263+ -- options to `gitsigns.nvim`.
254264 --
255265 -- See `:help gitsigns` to understand what the configuration keys do
256266 { -- Adds git related signs to the gutter, as well as utilities for managing changes
@@ -571,13 +581,26 @@ require('lazy').setup({
571581 -- For example, in C this would take you to the header.
572582 map (' gD' , vim .lsp .buf .declaration , ' [G]oto [D]eclaration' )
573583
584+ -- This function resolves a difference between neovim nightly (version 0.11) and stable (version 0.10)
585+ --- @param client vim.lsp.Client
586+ --- @param method vim.lsp.protocol.Method
587+ --- @param bufnr ? integer some lsp support methods only in specific files
588+ --- @return boolean
589+ local function client_supports_method (client , method , bufnr )
590+ if vim .fn .has ' nvim-0.11' == 1 then
591+ return client :supports_method (method , bufnr )
592+ else
593+ return client .supports_method (method , { bufnr = bufnr })
594+ end
595+ end
596+
574597 -- The following two autocommands are used to highlight references of the
575598 -- word under your cursor when your cursor rests there for a little while.
576599 -- See `:help CursorHold` for information about when this is executed
577600 --
578601 -- When you move your cursor, the highlights will be cleared (the second autocommand).
579602 local client = vim .lsp .get_client_by_id (event .data .client_id )
580- if client and client . supports_method ( vim .lsp .protocol .Methods .textDocument_documentHighlight ) then
603+ if client and client_supports_method ( client , vim .lsp .protocol .Methods .textDocument_documentHighlight , event . buf ) then
581604 local highlight_augroup = vim .api .nvim_create_augroup (' kickstart-lsp-highlight' , { clear = false })
582605 vim .api .nvim_create_autocmd ({ ' CursorHold' , ' CursorHoldI' }, {
583606 buffer = event .buf ,
@@ -604,23 +627,42 @@ require('lazy').setup({
604627 -- code, if the language server you are using supports them
605628 --
606629 -- This may be unwanted, since they displace some of your code
607- if client and client . supports_method ( vim .lsp .protocol .Methods .textDocument_inlayHint ) then
630+ if client and client_supports_method ( client , vim .lsp .protocol .Methods .textDocument_inlayHint , event . buf ) then
608631 map (' <leader>th' , function ()
609632 vim .lsp .inlay_hint .enable (not vim .lsp .inlay_hint .is_enabled { bufnr = event .buf })
610633 end , ' [T]oggle Inlay [H]ints' )
611634 end
612635 end ,
613636 })
614637
615- -- Change diagnostic symbols in the sign column (gutter)
616- -- if vim.g.have_nerd_font then
617- -- local signs = { ERROR = '', WARN = '', INFO = '', HINT = '' }
618- -- local diagnostic_signs = {}
619- -- for type, icon in pairs(signs) do
620- -- diagnostic_signs[vim.diagnostic.severity[type]] = icon
621- -- end
622- -- vim.diagnostic.config { signs = { text = diagnostic_signs } }
623- -- end
638+ -- Diagnostic Config
639+ -- See :help vim.diagnostic.Opts
640+ vim .diagnostic .config {
641+ severity_sort = true ,
642+ float = { border = ' rounded' , source = ' if_many' },
643+ underline = { severity = vim .diagnostic .severity .ERROR },
644+ signs = vim .g .have_nerd_font and {
645+ text = {
646+ [vim .diagnostic .severity .ERROR ] = ' ' ,
647+ [vim .diagnostic .severity .WARN ] = ' ' ,
648+ [vim .diagnostic .severity .INFO ] = ' ' ,
649+ [vim .diagnostic .severity .HINT ] = ' ' ,
650+ },
651+ } or {},
652+ virtual_text = {
653+ source = ' if_many' ,
654+ spacing = 2 ,
655+ format = function (diagnostic )
656+ local diagnostic_message = {
657+ [vim .diagnostic .severity .ERROR ] = diagnostic .message ,
658+ [vim .diagnostic .severity .WARN ] = diagnostic .message ,
659+ [vim .diagnostic .severity .INFO ] = diagnostic .message ,
660+ [vim .diagnostic .severity .HINT ] = diagnostic .message ,
661+ }
662+ return diagnostic_message [diagnostic .severity ]
663+ end ,
664+ },
665+ }
624666
625667 -- LSP servers and clients are able to communicate to each other what features they support.
626668 -- By default, Neovim doesn't support everything that is in the LSP specification.
@@ -784,6 +826,7 @@ require('lazy').setup({
784826 -- into multiple repos for maintenance purposes.
785827 ' hrsh7th/cmp-nvim-lsp' ,
786828 ' hrsh7th/cmp-path' ,
829+ ' hrsh7th/cmp-nvim-lsp-signature-help' ,
787830 },
788831 config = function ()
789832 -- See `:help cmp`
@@ -860,6 +903,7 @@ require('lazy').setup({
860903 { name = ' nvim_lsp' },
861904 { name = ' luasnip' },
862905 { name = ' path' },
906+ { name = ' nvim_lsp_signature_help' },
863907 },
864908 }
865909 end ,
@@ -872,14 +916,18 @@ require('lazy').setup({
872916 -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`.
873917 ' folke/tokyonight.nvim' ,
874918 priority = 1000 , -- Make sure to load this before all the other start plugins.
875- init = function ()
919+ config = function ()
920+ --- @diagnostic disable-next-line : missing-fields
921+ require (' tokyonight' ).setup {
922+ styles = {
923+ comments = { italic = false }, -- Disable italics in comments
924+ },
925+ }
926+
876927 -- Load the colorscheme here.
877928 -- Like many other themes, this one has different styles, and you could load
878929 -- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'.
879930 vim .cmd .colorscheme ' tokyonight-night'
880-
881- -- You can configure highlights by doing something like:
882- vim .cmd .hi ' Comment gui=none'
883931 end ,
884932 },
885933
0 commit comments