From cada5fb3b67481a7444f48825227206b5efbc23d Mon Sep 17 00:00:00 2001 From: doupongzeng Date: Wed, 21 Jun 2023 14:05:15 +0800 Subject: [PATCH] feat(pack): add cpp base pack --- lua/astrocommunity/pack/cpp/README.md | 17 +++++++++++++++++ lua/astrocommunity/pack/cpp/cpp.lua | 21 +++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 lua/astrocommunity/pack/cpp/README.md create mode 100644 lua/astrocommunity/pack/cpp/cpp.lua diff --git a/lua/astrocommunity/pack/cpp/README.md b/lua/astrocommunity/pack/cpp/README.md new file mode 100644 index 000000000..dd8594d5e --- /dev/null +++ b/lua/astrocommunity/pack/cpp/README.md @@ -0,0 +1,17 @@ +# cpp Language Pack + +This plugin pack does the following: + +- Adds `cpp` `c` Treesitter parser +- Adds `clangd` language server +- Adds `clang-format` formatter + +tips: the offset_encondings of clangd will confilicts whit null-ls, so add the following file in your user_config. +```lua +-- /lsp/config/clangd.lua +return { + capabilities = { + offsetEncoding = "utf-8", + }, +} +``` diff --git a/lua/astrocommunity/pack/cpp/cpp.lua b/lua/astrocommunity/pack/cpp/cpp.lua new file mode 100644 index 000000000..27bc0f994 --- /dev/null +++ b/lua/astrocommunity/pack/cpp/cpp.lua @@ -0,0 +1,21 @@ +local utils = require "astronvim.utils" +return { + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + if opts.ensure_installed ~= "all" then + opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, { "cpp", "c" }) + end + end, + }, + { + "williamboman/mason-lspconfig.nvim", + opts = function(_, opts) opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, "clangd") end, + }, + { + "jay-babu/mason-null-ls.nvim", + opts = function(_, opts) + opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, "clang-format") + end, + }, +}