wishlist icon indicating copy to clipboard operation
wishlist copied to clipboard

Heuristically set buffer options

Open Shatur opened this issue 3 years ago • 3 comments

What? This plugin automatically adjusts 'shiftwidth' and 'expandtab' heuristically based on the current file.

Why? When you work with several projects, it is not very convenient to manually set formatting parameters. It would be nice to be able to define these options automatically.

Potential existing implementations: This functionality is provided by default in VSCode. There is also a great plugin https://github.com/tpope/vim-sleuth, but it is written in Vimscript and can slow down the editor.

Potential pitfalls: It would be nice to implement this feature async.

Shatur avatar Apr 24 '21 14:04 Shatur

~~I disagree to make a heuristic to fix missing code formatting settings. If the language or project has none, it is already unfriendly to contributors.~~

~~Please change title to something like "plugin that extracts and conditionally sets options from code formatters (per buffer)".~~

After thinking more about various formatter config formats (lol), I get convinced about the idea. However I still think languages settings should be hardcoded and used, if the language formatter enforces them.

matu3ba avatar Sep 18 '21 11:09 matu3ba

Please change title to something like "plugin that extracts and conditionally sets options from code formatters (per buffer)".

Sorry, but personally would like to see the plugin exactly as I described. The implementation will be much simpler (no need to handle configuration reading for every possible formatter) and it will work for projects without formatting settings just for free.

Shatur avatar Sep 18 '21 12:09 Shatur

@Shatur Does https://github.com/NMAC427/guess-indent.nvim satisfy all your wishes?

matu3ba avatar Mar 07 '22 10:03 matu3ba