使用lazyvim时,搭配clang-format格式化代码,会将代码的缩进改为 2 spaces,因为习惯 4 spaces 缩进,遂改之。
options.luavim ~/.config/nvim/lua/config/options.lua
添加以下内容:
local opt = vim.opt
opt.shiftwidth = 4 -- Size of an indent
opt.tabstop = 4 -- Number of spaces tabs count for
stylua.tomlvim ~/.config/nvim/stylua.toml
修改以下内容:
indent_type = "Spaces"
indent_width = 4
新建.clang-format
添加以下内容:
---
BasedOnStyle: llvm
IndentWidth: 4
# 不要给头文件排序
SortIncludes: false
# 列的最大长度是 260
ColumnLimit: 120