Revert "just formatting"

This reverts commit 18e5475a9edec2d4c4f3ce994cac4bfd04df0172.
This commit is contained in:
dlond 2025-05-21 01:07:37 +12:00
parent c0474f5c11
commit 3d1eeaa62c
4 changed files with 153 additions and 179 deletions

View file

@ -1,40 +1,40 @@
-- Formatter configuration
return {
-- ========================================
-- Formatter Configuration (conform.nvim)
-- ========================================
{
'stevearc/conform.nvim',
event = 'BufWritePre', -- Format on save
-- cmd = { 'ConformInfo' }, -- Optional: If you want the command available
-- keys = { ... } -- Optional: Define keys if needed
opts = {
formatters_by_ft = {
lua = { 'stylua' },
c = { 'clang_format' },
cpp = { 'clang_format' },
-- Use ruff for Python formatting (includes isort and is faster than black
-- Ensure 'ruff' is installed via Home Manager (pkgs.ruff)
python = { 'ruff_format', 'ruff_fix' },
-- python = { 'isort', 'black' },
nix = { 'alejandra' }, -- Add nix formatter
-- Add other filetypes and formatters, e.g.:
-- javascript = { "prettier" },
-- typescript = { "prettier" },
-- css = { "prettier" },
-- html = { "prettier" },
-- json = { "prettier" },
-- yaml = { "prettier" },
-- markdown = { "prettier" },
-- bash = { "shfmt" },
},
-- Configure format_on_save behavior
format_on_save = {
-- I recommend these options, but adjust to your liking
timeout_ms = 500, -- Stop formatting if it takes too long
lsp_fallback = true, -- Fallback to LSP formatting if conform fails
},
-- ========================================
-- Formatter Configuration (conform.nvim)
-- ========================================
{
'stevearc/conform.nvim',
event = 'BufWritePre', -- Format on save
-- cmd = { 'ConformInfo' }, -- Optional: If you want the command available
-- keys = { ... } -- Optional: Define keys if needed
opts = {
formatters_by_ft = {
lua = { 'stylua' },
c = { 'clang_format' },
cpp = { 'clang_format' },
-- Use ruff for Python formatting (includes isort and is faster than black
-- Ensure 'ruff' is installed via Home Manager (pkgs.ruff)
python = { 'ruff_format', 'ruff_fix' },
-- python = { 'isort', 'black' },
nix = { 'alejandra' }, -- Add nix formatter
-- Add other filetypes and formatters, e.g.:
-- javascript = { "prettier" },
-- typescript = { "prettier" },
-- css = { "prettier" },
-- html = { "prettier" },
-- json = { "prettier" },
-- yaml = { "prettier" },
-- markdown = { "prettier" },
-- bash = { "shfmt" },
},
-- Configure format_on_save behavior
format_on_save = {
-- I recommend these options, but adjust to your liking
timeout_ms = 500, -- Stop formatting if it takes too long
lsp_fallback = true, -- Fallback to LSP formatting if conform fails
},
},
},
},
}

View file

@ -17,11 +17,6 @@ return {
config = function(_, opts)
-- This config function runs AFTER the plugin and its dependencies are loaded.
-- It sets up the LSP servers.
local nix_paths_status, nix_paths = pcall(require, 'custom.nix_paths')
if not nix_paths_status then
print('Error loading custom.nix_paths: ' .. (nix_paths or 'Unknown error'))
nix_paths = {} -- Provide an empty table to avoid further errors
end
-- Get LSP capabilities, augmented by nvim-cmp
local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities())
@ -41,34 +36,13 @@ return {
-- Iterate through the defined servers list and set them up with lspconfig
for _, server_name in ipairs(servers_to_setup) do
local server_opts = {
capabilities = capabilities,
}
if server_name == 'clangd' then
if nix_paths.clangd_query_driver and nix_paths.macos_sdk_path and nix_paths.libcxx_include_path then
server_opts.cmd = {
'clangd',
'--query-driver=' .. nix_paths.clangd_query_driver,
-- '-isysroot',
-- nix_paths.macos_sdk_path,
-- '-isystem',
-- nix_paths.libcxx_include_path,
}
else
print 'Warning: Nix paths for clangd not fully defined in custom.nix_paths.lua. Clangd might not work correctly.'
-- Fallback or default cmd if paths are missing
server_opts.cmd = { 'clangd' }
end
end
require('lspconfig')[server_name].setup(server_opts)
-- print('Attempting to set up LSP server: ' .. server_name) -- Debug print
-- require('lspconfig')[server_name].setup {
-- capabilities = capabilities, -- Pass augmented capabilities
-- -- Add any server-specific overrides here if needed, e.g.:
-- -- For lua_ls:
-- -- settings = { Lua = { diagnostics = { globals = {'vim'} } } },
-- }
require('lspconfig')[server_name].setup {
capabilities = capabilities, -- Pass augmented capabilities
-- Add any server-specific overrides here if needed, e.g.:
-- For lua_ls:
-- settings = { Lua = { diagnostics = { globals = {'vim'} } } },
}
end
-- Setup keymaps and diagnostics based on kickstart's original init.lua LSP section