User Tools

Site Tools


dev:formattingconventions

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
dev:formattingconventions [2016/03/16 13:44] – Added subtitles, some rephrasing pseewalddev:formattingconventions [2016/08/28 13:23] – instructions on editor integration 89.206.117.172
Line 1: Line 1:
 ====== Code Formatting Conventions and Prettify Tool ====== ====== Code Formatting Conventions and Prettify Tool ======
-Uniform formatting of CP2K source code will be enabled in the near future by a prettify script that is an almost complete auto-formatter for Fortran 90 source code. As a rule of thumb, developers should not worry about the format of their code and just let prettify do its magic by running ''make -j pretty''.+Uniform formatting of CP2K source code is enabled by a prettify script that is an almost complete auto-formatter for Fortran 90 source code. As a rule of thumb, developers should not worry about the format of their code and just let prettify do its magic by running ''make -j pretty''.
 ===== Formatting conventions ===== ===== Formatting conventions =====
 The following formatting conventions are automatically enforced by the ''make -j pretty'' command: The following formatting conventions are automatically enforced by the ''make -j pretty'' command:
Line 9: Line 9:
   * Removal of extraneous whitespace and consecutive blank lines.   * Removal of extraneous whitespace and consecutive blank lines.
   * Uppercase notation for all Fortran and OpenMP keywords.   * Uppercase notation for all Fortran and OpenMP keywords.
 +===== Editor integration =====
 +You can optionally integrate prettify into your editor. First install prettify with the ''setup.py'' script in ''cp2k/tools/prettify'':
 +<code>
 +./setup.py install
 +</code>
 +or
 +<code>
 +./setup.py install --user
 +</code>
 + Then configure your editor such that it calls 
 +<code>fprettify --no-normalize-use --no-report-errors
 +</code> 
 +for reformatting. For Vim, this is done by adding the following line to your vimrc:
 +<code vim>
 +autocmd Filetype fortran setlocal formatprg=fprettify\ --no-normalize-use\ --no-report-errors
 +</code>
 +Reformat selected lines with ''gq'' and the whole file with ''gggqG''. Note that editor integration only supports whitespace formatting (so you should still run ''make pretty'' before a commit).
 ===== Manual formatting ===== ===== Manual formatting =====
 The following formatting decisions are still manual and are never changed by prettify: The following formatting decisions are still manual and are never changed by prettify:
dev/formattingconventions.txt · Last modified: 2020/08/21 10:15 by 127.0.0.1