From b299ed09e29cad7796b3c568e31aad9497537891 Mon Sep 17 00:00:00 2001 From: baldeau Date: Sat, 21 Sep 2024 10:41:48 +0200 Subject: [PATCH] add c/c++ support --- README.md | 2 ++ lua/main/init.lua | 10 ---------- lua/plugins/lsp.lua | 20 ++++++++++++++++++++ lua/plugins/prettier.lua | 14 ++++++++++++++ 4 files changed, 36 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index beefb7b..e6c1192 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,8 @@ Just clone this repo into `~/.config/nvim` and launch neovim. - Dart - Go - Rust +- C/C++ +- Lua ## Screenshots diff --git a/lua/main/init.lua b/lua/main/init.lua index 956baa1..9c01ea2 100644 --- a/lua/main/init.lua +++ b/lua/main/init.lua @@ -21,16 +21,6 @@ vim.wo.relativenumber = true -- If you want to see more details: --require("oil").set_columns({ "icon", "permission", "size" }) -require("conform").setup({ - formatters_by_ft = { - lua = { "stylua" }, - rust = { "rustfmt", lsp_format = "fallback" }, - javascript = { "prettier", stop_after_first = true }, - dart = { "dart format", lsp_format = "fallback" }, - go = { "gofmt" }, - }, -}) - -- flutter telescope integration require("telescope").load_extension("flutter") diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 85d754b..0727354 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -138,5 +138,25 @@ return { require("lspconfig")["rust_analyzer"].setup({ capabilities = capabilities, }) + require("lspconfig")["sourcekit"].setup({ + capabilities = capabilities, + }) + require("lspconfig")["clangd"].setup({ + cmd = { + "clangd", + "--background-index", + "-j=8", + "--query-driver=/usr/bin/**/clang-*,/bin/clang,/bin/clang++,/usr/bin/gcc,/usr/bin/g++", + "--clang-tidy", + "--clang-tidy-checks=*", + "--all-scopes-completion", + "--cross-file-rename", + "--completion-style=detailed", + "--header-insertion-decorators", + "--header-insertion=iwyu", + "--pch-storage=memory", + }, + capabilities = capabilities, + }) end, } diff --git a/lua/plugins/prettier.lua b/lua/plugins/prettier.lua index cf82d30..4fdce65 100644 --- a/lua/plugins/prettier.lua +++ b/lua/plugins/prettier.lua @@ -2,6 +2,20 @@ return { { "stevearc/conform.nvim", opts = {}, + config = function() + require("conform").setup({ + formatters_by_ft = { + lua = { "stylua" }, + rust = { "rustfmt", lsp_format = "fallback" }, + javascript = { "prettier", stop_after_first = true }, + dart = { "dart format", lsp_format = "fallback" }, + go = { "gofmt" }, + swift = { "swiftformat" }, + c = { "clang-format" }, + cpp = { "clang-format" }, + }, + }) + end, }, { "m4xshen/autoclose.nvim",