Skip to content

Commit b444564

Browse files
committed
Merge branch 'master' of github.com:nvim-lua/kickstart.nvim into upstream
2 parents cecbf2b + 38f4744 commit b444564

File tree

1 file changed

+58
-13
lines changed

1 file changed

+58
-13
lines changed

init.lua

Lines changed: 58 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ vim.opt.scrolloff = 10
7070

7171
-- adjust conceallevel to work with obsidian.nvim
7272
vim.opt.conceallevel = 1
73+
-- if performing an operation that would fail due to unsaved changes in the buffer (like `:q`),
74+
-- instead raise a dialog asking if you wish to save the current file(s)
75+
-- See `:help 'confirm'`
76+
vim.opt.confirm = true
7377

7478
-- [[ Basic Keymaps ]]
7579
-- See `:help vim.keymap.set()`
@@ -475,13 +479,26 @@ require('lazy').setup({
475479
-- For example, in C this would take you to the header.
476480
map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
477481

482+
-- This function resolves a difference between neovim nightly (version 0.11) and stable (version 0.10)
483+
---@param client vim.lsp.Client
484+
---@param method vim.lsp.protocol.Method
485+
---@param bufnr? integer some lsp support methods only in specific files
486+
---@return boolean
487+
local function client_supports_method(client, method, bufnr)
488+
if vim.fn.has 'nvim-0.11' == 1 then
489+
return client:supports_method(method, bufnr)
490+
else
491+
return client.supports_method(method, { bufnr = bufnr })
492+
end
493+
end
494+
478495
-- The following two autocommands are used to highlight references of the
479496
-- word under your cursor when your cursor rests there for a little while.
480497
-- See `:help CursorHold` for information about when this is executed
481498
--
482499
-- When you move your cursor, the highlights will be cleared (the second autocommand).
483500
local client = vim.lsp.get_client_by_id(event.data.client_id)
484-
if client and client:supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight) then
501+
if client and client_supports_method(client, vim.lsp.protocol.Methods.textDocument_documentHighlight, event.buf) then
485502
local highlight_augroup = vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = false })
486503
vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
487504
buffer = event.buf,
@@ -508,23 +525,42 @@ require('lazy').setup({
508525
-- code, if the language server you are using supports them
509526
--
510527
-- This may be unwanted, since they displace some of your code
511-
if client and client:supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then
528+
if client and client_supports_method(client, vim.lsp.protocol.Methods.textDocument_inlayHint, event.buf) then
512529
map('<leader>th', function()
513530
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf })
514531
end, '[T]oggle Inlay [H]ints')
515532
end
516533
end,
517534
})
518535

519-
-- Change diagnostic symbols in the sign column (gutter)
520-
-- if vim.g.have_nerd_font then
521-
-- local signs = { ERROR = '', WARN = '', INFO = '', HINT = '' }
522-
-- local diagnostic_signs = {}
523-
-- for type, icon in pairs(signs) do
524-
-- diagnostic_signs[vim.diagnostic.severity[type]] = icon
525-
-- end
526-
-- vim.diagnostic.config { signs = { text = diagnostic_signs } }
527-
-- end
536+
-- Diagnostic Config
537+
-- See :help vim.diagnostic.Opts
538+
vim.diagnostic.config {
539+
severity_sort = true,
540+
float = { border = 'rounded', source = 'if_many' },
541+
underline = { severity = vim.diagnostic.severity.ERROR },
542+
signs = vim.g.have_nerd_font and {
543+
text = {
544+
[vim.diagnostic.severity.ERROR] = '󰅚 ',
545+
[vim.diagnostic.severity.WARN] = '󰀪 ',
546+
[vim.diagnostic.severity.INFO] = '󰋽 ',
547+
[vim.diagnostic.severity.HINT] = '󰌶 ',
548+
},
549+
} or {},
550+
virtual_text = {
551+
source = 'if_many',
552+
spacing = 2,
553+
format = function(diagnostic)
554+
local diagnostic_message = {
555+
[vim.diagnostic.severity.ERROR] = diagnostic.message,
556+
[vim.diagnostic.severity.WARN] = diagnostic.message,
557+
[vim.diagnostic.severity.INFO] = diagnostic.message,
558+
[vim.diagnostic.severity.HINT] = diagnostic.message,
559+
}
560+
return diagnostic_message[diagnostic.severity]
561+
end,
562+
},
563+
}
528564

529565
-- LSP servers and clients are able to communicate to each other what features they support.
530566
-- By default, Neovim doesn't support everything that is in the LSP specification.
@@ -593,7 +629,7 @@ require('lazy').setup({
593629
require('mason-tool-installer').setup { ensure_installed = ensure_installed }
594630

595631
require('mason-lspconfig').setup {
596-
ensure_installed = {},
632+
ensure_installed = {}, -- explicitly set to an empty table (Kickstart populates installs via mason-tool-installer)
597633
automatic_installation = false,
598634
handlers = {
599635
function(server_name)
@@ -687,6 +723,7 @@ require('lazy').setup({
687723
-- into multiple repos for maintenance purposes.
688724
'hrsh7th/cmp-nvim-lsp',
689725
'hrsh7th/cmp-path',
726+
'hrsh7th/cmp-nvim-lsp-signature-help',
690727
},
691728
config = function()
692729
-- See `:help cmp`
@@ -764,6 +801,7 @@ require('lazy').setup({
764801
{ name = 'ruff' },
765802
{ name = 'luasnip' },
766803
{ name = 'path' },
804+
{ name = 'nvim_lsp_signature_help' },
767805
{ name = 'buffer' },
768806
},
769807
}
@@ -779,7 +817,14 @@ require('lazy').setup({
779817
'catppuccin/nvim',
780818
name = 'catppuccin',
781819
priority = 1000, -- Make sure to load this before all the other start plugins.
782-
init = function()
820+
config = function()
821+
---@diagnostic disable-next-line: missing-fields
822+
require('tokyonight').setup {
823+
styles = {
824+
comments = { italic = false }, -- Disable italics in comments
825+
},
826+
}
827+
783828
-- Load the colorscheme here.
784829
-- Like many other themes, this one has different styles, and you could load
785830
-- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'.

0 commit comments

Comments
 (0)