Comments (9)
I see, thank you, your nvim-config has helped me a lot.
from nvim-config.
My requirement has already been resolved. I prefer not to add a .clang-format
file to every cpp project, so I followed the link below to resolve it.
jose-elias-alvarez/null-ls.nvim#953
from nvim-config.
Hi, Good morning to you.
This is my function for the formatting logic.
https://github.com/Alexis12119/nvim-config/blob/main/lua/core/utils.lua#L19-L38
What it does is check if the null-ls
is attached and has a formatting capability. If not, then the lsp attached that has formatting capability will be used for formatting.
This is the Format
command.
https://github.com/Alexis12119/nvim-config/blob/main/lua/core/utils.lua#L98-L101
The format command is calling the format_code()
function to format the file and I mapped the :Format
command to <space>lf
.
Also, I'm using .clang-format
to customize how the clang-format
will format my cpp
file. You can use .clang-format
to change the indent to 4
.
After formatting file through :Format
or <leader>lf
Hope it helps.
from nvim-config.
Is my explanation easy to understand? Because I feel like it's too long.
from nvim-config.
I see,I use clang-format to format my cpp file too but I still don't know how to change the indent to 4.Is it configured in null-ls? What is the relevant documentation like? I have installed clang_format by mason, and the command :NullLsInfo shows that clang_format is working correctly.
from nvim-config.
I created the .clang-fomat
inside the directory of my cpp
file. I changed the indent
through .clang-format
.
from nvim-config.
There is a peculiar phenomenon where, after creating the .clang-format file, I am able to use 4-space indentation correctly. However, even after deleting the null-ls.lua file, it still retains the 4-space indentation. According to my understanding, at this point, it should be using the formatting of the LSP. Is the null-ls.lua file really having an effect?
from nvim-config.
I just noticed that clangd
also uses .clang-format
. It looks like I don't really need clang-format
.
from nvim-config.
Look here:
Not same directory of .clang-format
and cpp file.
Same directory of .clang-format
and cpp file.
from nvim-config.
Related Issues (2)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nvim-config.