GithubHelp home page GithubHelp logo

Google C++ style about guess-indent.nvim HOT 4 OPEN

nmac427 avatar nmac427 commented on June 3, 2024
Google C++ style

from guess-indent.nvim.

Comments (4)

zhongsanming avatar zhongsanming commented on June 3, 2024 1

I don't know much lua or nvim plugin writing or ident detect, can we maybe just ignore access modifiers? Let say if a C++ line matches regex "^\s*(private|public|protected)\s*:\s*$", then skip this line.

from guess-indent.nvim.

NMAC427 avatar NMAC427 commented on June 3, 2024

Thanks for letting me know. I'm not yet sure how to best fix this issue.
I have an idea on how I could modify the heuristic, but I'm worried that it might make it worse overall.

I created a new branch with a modified heuristic which works better with the Google C++ style, though it still tails with the example you provided (it is too short).

from guess-indent.nvim.

agronskiy avatar agronskiy commented on June 3, 2024

Hey @zhongsanming, a fellow C++ Google Style Guide user here. I arrived here because of a different problem (in Neovim 0.8 without editorconfig.nvim plugin, the guess-indent.nvim failed to respect my EditorConfig -- now solved), but here's a solution we happily use in our codebase:

just add an .editorconfig to your root directory of the project, with approx the following content:

# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
trim_trailing_whitespace = true

[*.{h,cpp}]
indent_style = space
indent_size = 4

AND in case you are under 0.9 version of Neovim, install gpanders/editorconfig.nvim so the guess-indent understands the buffer vim.b.editorconfig variable here

local editorconfig = vim.b.editorconfig
.

After that, the guess-indent should be good! My justification is that Google Style Guide is quite nontrivial in that part and having editorconfig anyways helps.

from guess-indent.nvim.

zhongsanming avatar zhongsanming commented on June 3, 2024

@agronskiy Thank you for this nice solution, I'll give it a try.

from guess-indent.nvim.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.