Skip to content

Commit

Permalink
feat(pack): add cpp base pack (#295)
Browse files Browse the repository at this point in the history
Co-authored-by: Micah Halter <[email protected]>
  • Loading branch information
doupongzeng and mehalter authored Jun 23, 2023
1 parent 901fc36 commit 8ac4492
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
20 changes: 20 additions & 0 deletions lua/astrocommunity/pack/cpp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# C/C++ Language Pack

This plugin pack does the following:

- Adds `cpp` `c` `objc` `cuda` `proto` Treesitter parsers
- Adds `clangd` language server
- Adds `clang-format` formatter
- Adds [clangd_extensions.nvim](https://github.com/p00f/clangd_extensions.nvim) for language specific tooling
- Adds [cmake-tools.nvim](https://github.com/Civitasv/cmake-tools.nvim) for building and debugging

tips: the offset_encondings of clangd will confilicts whit null-ls, so add the following file in your user_config.

```lua
-- <user_config_path>/lsp/config/clangd.lua
return {
capabilities = {
offsetEncoding = "utf-8",
},
}
```
36 changes: 36 additions & 0 deletions lua/astrocommunity/pack/cpp/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
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", "objc", "cuda", "proto" })
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,
},
{
"p00f/clangd_extensions.nvim",
ft = { "c", "cpp", "objc", "objcpp", "cuda", "proto" },
init = function() utils.list_insert_unique(astronvim.lsp.skip_setup, "clangd") end,
opts = function() return { server = require("astronvim.utils.lsp").config "clangd" } end,
},
{
"Civitasv/cmake-tools.nvim",
ft = { "c", "cpp", "objc", "objcpp", "cuda", "proto" },
dependencies = {
{
"jay-babu/mason-nvim-dap.nvim",
opts = function(_, opts) opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, "codelldb") end,
},
},
opts = {},
},
}

0 comments on commit 8ac4492

Please sign in to comment.