Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ask about formatting #557

Closed
fakeczg opened this issue Mar 10, 2023 · 8 comments
Closed

Ask about formatting #557

fakeczg opened this issue Mar 10, 2023 · 8 comments
Labels
duplicate This issue or pull request already exists formatting Lsp-formatting related issues usage User-specific issues

Comments

@fakeczg
Copy link

fakeczg commented Mar 10, 2023

Suppose I have a .clang-format file in my project directory,will the format match the style of this file for formatting?

@Jint-lzxy
Copy link
Collaborator

Duplicate of #470. Please change this line:

return { "-style={BasedOnStyle: LLVM, IndentWidth: 4}" }

to

return { "-style=file" } 

@Jint-lzxy Jint-lzxy added usage User-specific issues duplicate This issue or pull request already exists labels Mar 10, 2023
@aarnphm
Copy link
Collaborator

aarnphm commented Mar 12, 2023

					f.clang_format.with {
						extra_args = {
							string.format(
								"--style=file:%s/.clang-format",
								require("user.utils").get_root()
							),
						},
					},

then you can implement the get_root using require('lspconfig').util.root_pattern({".git"})

@fakeczg
Copy link
Author

fakeczg commented Mar 13, 2023

thanks!

@yinghaoyu
Copy link

yinghaoyu commented Oct 25, 2023

Duplicate of #470. Please change this line:

return { "-style={BasedOnStyle: LLVM, IndentWidth: 4}" }

to

return { "-style=file" } 

It sames failure. My file tree like this:

├── .git
├── src
│   ├── xxx.cpp
├── .clang-format

@Jint-lzxy
Copy link
Collaborator

It sames failure.

Can u provide a complete .clang-format file that could reproduce this issue? I've just tested ur hierarchy and clang-format works as expected w/ versions: 15.0.0, 17.0.3, and trunk (2282af2 from 2023-10-25).

@yinghaoyu
Copy link

PointerAlignment: Left
BreakBeforeBraces: Allman
IndentWidth: 2
TabWidth: 2
BasedOnStyle: Chromium
ColumnLimit: 160
DerivePointerAlignment: false
IndentCaseLabels: false
PointerAlignment: Right
SpaceAfterCStyleCast: true

@Jint-lzxy
Copy link
Collaborator

ur map keys must be unique:

.clang-format:9:1: error: redefinition of 'PointerAlignment' (map keys must be unique)
PointerAlignment: Right
^
.clang-format:1:1: note: previous definition is here
PointerAlignment: Left
^
1 error generated.

@yinghaoyu
Copy link

Wow, It works and thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists formatting Lsp-formatting related issues usage User-specific issues
Projects
None yet
Development

No branches or pull requests

4 participants