Skip to content

Commit

Permalink
feat(LazyVim): introduce global clang-format config
Browse files Browse the repository at this point in the history
I use the .clang-format file of the linux kernel repo, and put it
directly into home.
This affects both clang-format and clangd. It affects the lazyvim
lang.clangd extra and my user level lang.opencl extra.
Though for OpenCl I explicitly specified the the format file with the
--style flag.
  • Loading branch information
Botond Kalocsai committed May 13, 2024
1 parent e198d7d commit f1e90df
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 30 deletions.
7 changes: 7 additions & 0 deletions home/.chezmoiexternals/global_clang-format_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
".clang-format": {
"type": "file",
"url": "https://raw.githubusercontent.com/torvalds/linux/master/.clang-format",
"refreshPeriod": "168h"
}
}
71 changes: 41 additions & 30 deletions home/dot_config/nvim/lua/plugins/extras/lang/opencl.lua
Original file line number Diff line number Diff line change
@@ -1,36 +1,47 @@
return {
{
"brgmnn/vim-opencl",
}, -- NOTE: Contains OpenCL file detection autocommand
{
"neovim/nvim-lspconfig",
opts = {
setup = {
opencl_ls = function()
require("lspconfig").opencl_ls.setup({})
end,
if not vim.g.vscode then
local psep = package.config:sub(1, 1) -- Directory path separator on platform

return {
{
"brgmnn/vim-opencl", -- For syntax highlighting
lazy = false,
}, -- NOTE: Contains OpenCL file detection autocommand
{
"neovim/nvim-lspconfig",
opts = {
setup = {
opencl_ls = function()
require("lspconfig").opencl_ls.setup({})
end,
},
},
},
},
{
"williamboman/mason.nvim",
opts = function(_, opts)
table.insert(opts.ensure_installed, "clang-format")
end,
},
{
"stevearc/conform.nvim",
opts = {
formatters_by_ft = {
["opencl"] = { "clang-format" },
},
formatters = {
["clang-format"] = {
args = {
"--style={BasedOnStyle: chromium, IndentWidth: 8}",
{
"williamboman/mason.nvim",
opts = function(_, opts)
table.insert(opts.ensure_installed, "clang-format")
end,
},
{
"stevearc/conform.nvim",
opts = {
formatters_by_ft = {
["opencl"] = { "clang-format" },
},
formatters = {
["clang-format"] = {
args = {
"--fallback-style=Chromium",
"--style=file:"
.. vim.env.HOME
.. psep
.. ".clang-format",
},
},
},
},
},
},
}
}
else
return {}
end

0 comments on commit f1e90df

Please sign in to comment.