postgres function definition not saving top whitespace
The function body is the only part that is actually saved as string, conserving all white space, code comments etc. Stored in pg_proc.prosrc. It will be parsed etc. at execution time.

The rest of the command is executed immediately and translates to an entry in system catalog pg_proc. What clients like DataGrip later present is the reverse engineered representation derived from system catalog information. Original insignificant whitespace is completely lost in the process. The format is what the client chooses to make it. (DataGrip does not seem to do a great job in the example.)

To preserve original format, you'll have to save your create statement somewhere. Like in the COMMENT on the function - I suggest another layer of dollar quoting, or you'll have to escape single quotes:

COMMENT ON FUNCTION apqp.apqp_list_gentex_tool_report_getlist(text, integer) IS
$com$
create or replace function 
apqp.apqp_list_gentex_tool_report_getlist(_omni_search text    DEFAULT ''::text
                                        , _cust_id     integer DEFAULT 0        
                                         )
 returns TABLE(reason       text
             , program     text
             , mold_number text
             , rev               text
             , stone_part_number text
             , part_description  text
             , cust_request_num  text
             , status text
             )
language sql
as $$ -- and so on
$com$;


Or a code repository or a user table in the DB or whatever. DataGrip has built-in ways to save and handle files:


https://blog.jetbrains.com/datagrip/2019/01/30/working-with-files-in-datagrip/