trying to fix auto indenting on some files part 4?

This commit is contained in:
dlond 2025-05-20 20:23:40 +12:00
parent 1b1e2947f6
commit 1cd72c0f25
1 changed files with 122 additions and 112 deletions

View File

@ -28,6 +28,7 @@ return {
"clangd", "clangd",
"pyright", "pyright",
"nixd", "nixd",
"ruff_lsp",
-- Add other servers like "bashls", "yamlls", "gopls", "rust_analyzer" etc. -- Add other servers like "bashls", "yamlls", "gopls", "rust_analyzer" etc.
-- Ensure the corresponding packages (e.g., pkgs.bash-language-server) -- Ensure the corresponding packages (e.g., pkgs.bash-language-server)
-- are in your Home Manager home.packages list. -- are in your Home Manager home.packages list.
@ -74,15 +75,24 @@ return {
end end
end end
if client and client_supports_method(client, 'textDocument/documentHighlight', event.buf) then if client and client_supports_method(client, 'textDocument/documentHighlight', event.buf) then
local highlight_augroup = vim.api.nvim_create_augroup('kickstart-lsp-highlight-override', { clear = false }) local highlight_augroup = vim.api.nvim_create_augroup('kickstart-lsp-highlight-override',
vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { buffer = event.buf, group = highlight_augroup, callback = vim.lsp.buf.document_highlight }) { clear = false })
vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, { buffer = event.buf, group = highlight_augroup, callback = vim.lsp.buf.clear_references }) vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' },
vim.api.nvim_create_autocmd('LspDetach', { group = vim.api.nvim_create_augroup('kickstart-lsp-detach-override', { clear = true }), callback = function(event2) vim.lsp.buf.clear_references(); vim.api.nvim_clear_autocmds { group = 'kickstart-lsp-highlight-override', buffer = event2.buf } end }) { buffer = event.buf, group = highlight_augroup, callback = vim.lsp.buf.document_highlight })
vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' },
{ buffer = event.buf, group = highlight_augroup, callback = vim.lsp.buf.clear_references })
vim.api.nvim_create_autocmd('LspDetach',
{ group = vim.api.nvim_create_augroup('kickstart-lsp-detach-override', { clear = true }), callback = function(
event2)
vim.lsp.buf.clear_references(); vim.api.nvim_clear_autocmds { group = 'kickstart-lsp-highlight-override', buffer = event2.buf }
end })
end end
-- Inlay hints toggle -- Inlay hints toggle
if client and client_supports_method(client, 'textDocument/inlayHint', event.buf) then if client and client_supports_method(client, 'textDocument/inlayHint', event.buf) then
map('<leader>th', function() vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf }) end, '[T]oggle Inlay [H]ints') map('<leader>th',
function() vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf }) end,
'[T]oggle Inlay [H]ints')
end end
end, end,
}) })
@ -100,12 +110,13 @@ return {
virtual_text = { virtual_text = {
source = 'if_many', spacing = 2, source = 'if_many', spacing = 2,
format = function(diagnostic) format = function(diagnostic)
local diagnostic_message = { [vim.diagnostic.severity.ERROR] = diagnostic.message, [vim.diagnostic.severity.WARN] = diagnostic.message, [vim.diagnostic.severity.INFO] = diagnostic.message, [vim.diagnostic.severity.HINT] = diagnostic.message } local diagnostic_message = { [vim.diagnostic.severity.ERROR] = diagnostic.message,
[vim.diagnostic.severity.WARN] = diagnostic.message, [vim.diagnostic.severity.INFO] =
diagnostic.message, [vim.diagnostic.severity.HINT] = diagnostic.message }
return diagnostic_message[diagnostic.severity] return diagnostic_message[diagnostic.severity]
end, end,
}, },
} }
end, -- End of config function end, -- End of config function
}, },
@ -118,4 +129,3 @@ return {
}, },
}, },
} }