Use 4-space indent for C/C++ in nvim
Drop the 2-space C/C++ override and set IndentWidth: 4 in clangd's fallback style so formatting matches the editor. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
+1
-1
@@ -35,7 +35,7 @@ this file only covers what's different. Press `<space>` and wait for which-key,
|
||||
|
||||
## Behaviour changes from LazyVim
|
||||
|
||||
- 4-space indent by default; C/C++ uses 2 spaces and has format-on-save **off**
|
||||
- 4-space indent everywhere (clangd fallback style matches); C/C++ has format-on-save **off**
|
||||
(format manually with `<space>cf`)
|
||||
- `nvim a b c` opens the files side by side
|
||||
- Inactive windows are dimmed (vimade); markdown renders inline (markview)
|
||||
|
||||
@@ -7,14 +7,10 @@
|
||||
-- Or remove existing autocmds by their group name (which is prefixed with `lazyvim_` for the defaults)
|
||||
-- e.g. vim.api.nvim_del_augroup_by_name("lazyvim_wrap_spell")
|
||||
|
||||
-- C/C++ uses 2-space indent to match clang-format's LLVM default
|
||||
-- Disable LazyVim's format-on-save for C/C++
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = { "c", "cpp" },
|
||||
callback = function()
|
||||
vim.opt_local.tabstop = 2
|
||||
vim.opt_local.shiftwidth = 2
|
||||
vim.opt_local.softtabstop = 2
|
||||
-- Disable LazyVim's format-on-save for C/C++
|
||||
vim.b.autoformat = false
|
||||
end,
|
||||
})
|
||||
|
||||
@@ -12,8 +12,9 @@ return {
|
||||
"--completion-style=detailed",
|
||||
"--function-arg-placeholders",
|
||||
-- ColumnLimit: 0 = fix indentation only; keep existing line
|
||||
-- breaks, never rewrap or join lines
|
||||
"--fallback-style={BasedOnStyle: LLVM, ColumnLimit: 0}",
|
||||
-- breaks, never rewrap or join lines. IndentWidth: 4 matches
|
||||
-- the editor's shiftwidth
|
||||
"--fallback-style={BasedOnStyle: LLVM, IndentWidth: 4, ColumnLimit: 0}",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user