From f1e90dfcf47e5ec2e858056cd72f2986aeca0ab4 Mon Sep 17 00:00:00 2001 From: Botond Kalocsai Date: Mon, 13 May 2024 14:32:59 +0200 Subject: [PATCH] feat(LazyVim): introduce global clang-format config 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. --- .../global_clang-format_config.json | 7 ++ .../nvim/lua/plugins/extras/lang/opencl.lua | 71 +++++++++++-------- 2 files changed, 48 insertions(+), 30 deletions(-) create mode 100644 home/.chezmoiexternals/global_clang-format_config.json diff --git a/home/.chezmoiexternals/global_clang-format_config.json b/home/.chezmoiexternals/global_clang-format_config.json new file mode 100644 index 0000000..eea625f --- /dev/null +++ b/home/.chezmoiexternals/global_clang-format_config.json @@ -0,0 +1,7 @@ +{ + ".clang-format": { + "type": "file", + "url": "https://raw.githubusercontent.com/torvalds/linux/master/.clang-format", + "refreshPeriod": "168h" + } +} diff --git a/home/dot_config/nvim/lua/plugins/extras/lang/opencl.lua b/home/dot_config/nvim/lua/plugins/extras/lang/opencl.lua index 82e8c4c..ae0435f 100644 --- a/home/dot_config/nvim/lua/plugins/extras/lang/opencl.lua +++ b/home/dot_config/nvim/lua/plugins/extras/lang/opencl.lua @@ -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