add clang lsp and auto format

This commit is contained in:
FunneMonkee 2025-09-17 19:28:04 +01:00
parent 3235754376
commit 61f3a43ee3
1 changed files with 34 additions and 30 deletions

View File

@ -565,39 +565,39 @@ require('lazy').setup({
-- - settings (table): Override the default settings passed when initializing the server. -- - settings (table): Override the default settings passed when initializing the server.
-- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
local servers = { local servers = {
-- clangd = {}, clangd = {},
-- gopls = {}, -- gopls = {},
-- pyright = {}, -- pyright = {},
rust_analyzer = {}, rust_analyzer = {},
-- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs -- ... etc. see `:help lspconfig-all` for a list of all the pre-configured lsps
-- --
-- Some languages (like typescript) have entire language plugins that can be useful: -- some languages (like typescript) have entire language plugins that can be useful:
-- https://github.com/pmizio/typescript-tools.nvim -- https://github.com/pmizio/typescript-tools.nvim
-- --
-- But for many setups, the LSP (`tsserver`) will work just fine -- but for many setups, the lsp (`tsserver`) will work just fine
-- tsserver = {}, -- tsserver = {},
-- --
jdtls = { jdtls = {
cmd = { cmd = {
'java', 'java',
'-Declipse.application=org.eclipse.jdt.ls.core.id1', '-declipse.application=org.eclipse.jdt.ls.core.id1',
'-Dosgi.bundles.defaultStartLevel=4', '-dosgi.bundles.defaultstartlevel=4',
'-Declipse.product=org.eclipse.jdt.ls.core.product', '-declipse.product=org.eclipse.jdt.ls.core.product',
'-Dlog.protocol=true', '-dlog.protocol=true',
'-Dlog.level=ALL', '-dlog.level=all',
'-Xmx2048m', '-xmx2048m',
'--add-modules=ALL-SYSTEM', '--add-modules=all-system',
'--add-opens', '--add-opens',
'java.base/java.util=ALL-UNNAMED', 'java.base/java.util=all-unnamed',
'--add-opens', '--add-opens',
'java.base/java.lang=ALL-UNNAMED', 'java.base/java.lang=all-unnamed',
'-javaagent:' .. require('mason-registry').get_package('jdtls'):get_install_path() .. '/lombok.jar', '-javaagent:' .. require('mason-registry').get_package('jdtls'):get_install_path() .. '/lombok.jar',
'-jar', '-jar',
'/Users/lmpinto/.local/share/nvim/mason/packages/jdtls/plugins/org.eclipse.equinox.launcher_1.6.800.v20240330-1250.jar', '/users/lmpinto/.local/share/nvim/mason/packages/jdtls/plugins/org.eclipse.equinox.launcher_1.6.800.v20240330-1250.jar',
'-configuration', '-configuration',
'/Users/lmpinto/.local/share/nvim/mason/packages/jdtls/config_mac', '/users/lmpinto/.local/share/nvim/mason/packages/jdtls/config_mac',
'-data', '-data',
'/Users/lmpinto/.local/share/eclipse/report-creator', '/users/lmpinto/.local/share/eclipse/report-creator',
}, },
root_dir = vim.fs.dirname(vim.fs.find({ 'gradlew', '.git', 'mvnw' }, { upward = true })[1]), root_dir = vim.fs.dirname(vim.fs.find({ 'gradlew', '.git', 'mvnw' }, { upward = true })[1]),
}, },
@ -607,30 +607,30 @@ require('lazy').setup({
-- filetypes = { ...}, -- filetypes = { ...},
-- capabilities = {}, -- capabilities = {},
settings = { settings = {
Lua = { lua = {
completion = { completion = {
callSnippet = 'Replace', callsnippet = 'replace',
}, },
-- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings -- you can toggle below to ignore lua_ls's noisy `missing-fields` warnings
-- diagnostics = { disable = { 'missing-fields' } }, -- diagnostics = { disable = { 'missing-fields' } },
}, },
}, },
}, },
} }
-- Ensure the servers and tools above are installed -- ensure the servers and tools above are installed
-- To check the current status of installed tools and/or manually install -- to check the current status of installed tools and/or manually install
-- other tools, you can run -- other tools, you can run
-- :Mason -- :mason
-- --
-- You can press `g?` for help in this menu. -- you can press `g?` for help in this menu.
require('mason').setup() require('mason').setup()
-- You can add other tools here that you want Mason to install -- you can add other tools here that you want mason to install
-- for you, so that they are available from within Neovim. -- for you, so that they are available from within neovim.
local ensure_installed = vim.tbl_keys(servers or {}) local ensure_installed = vim.tbl_keys(servers or {})
vim.list_extend(ensure_installed, { vim.list_extend(ensure_installed, {
'stylua', -- Used to format Lua code 'stylua', -- used to format lua code
}) })
require('mason-tool-installer').setup { ensure_installed = ensure_installed } require('mason-tool-installer').setup { ensure_installed = ensure_installed }
@ -638,9 +638,9 @@ require('lazy').setup({
handlers = { handlers = {
function(server_name) function(server_name)
local server = servers[server_name] or {} local server = servers[server_name] or {}
-- This handles overriding only values explicitly passed -- this handles overriding only values explicitly passed
-- by the server configuration above. Useful when disabling -- by the server configuration above. useful when disabling
-- certain features of an LSP (for example, turning off formatting for tsserver) -- certain features of an lsp (for example, turning off formatting for tsserver)
server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {})
require('lspconfig')[server_name].setup(server) require('lspconfig')[server_name].setup(server)
end, end,
@ -668,7 +668,10 @@ require('lazy').setup({
-- Disable "format_on_save lsp_fallback" for languages that don't -- Disable "format_on_save lsp_fallback" for languages that don't
-- have a well standardized coding style. You can add additional -- have a well standardized coding style. You can add additional
-- languages here or re-enable it for the disabled ones. -- languages here or re-enable it for the disabled ones.
local disable_filetypes = { c = true, cpp = true, java = true } local disable_filetypes = { --c = true,
cpp = true,
java = true,
}
return { return {
timeout_ms = 500, timeout_ms = 500,
lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype], lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype],
@ -676,6 +679,7 @@ require('lazy').setup({
end, end,
formatters_by_ft = { formatters_by_ft = {
lua = { 'stylua' }, lua = { 'stylua' },
c = { 'clang_format' },
-- Conform can also run multiple formatters sequentially -- Conform can also run multiple formatters sequentially
-- python = { "isort", "black" }, -- python = { "isort", "black" },
-- --