Requirements
- Open R via Terminal under macOS
- Autocompletion orders function arguments according to the order of their declaration
As you observed, R arranges the arguments alphabetically when R-4.0.4.pkg is installed. However, when R is installed with Homebrew, they are displayed in the expected order.
So one possible solution could be to uninstall R and install it via Homebrew.
Deinstall R
rm /usr/local/bin/{R,RScript}
sudo rm -r /Applications/R.app
sudo rm -r /Library/Frameworks/R.framework
sudo pkgutil --regexp --forget 'org\.R-project*'
Install R via Homebrew
brew install R
For me it shows the error that some directories like /usr/local/share/info are not writable for my user. copy/paste what brew recommends, for me it is for example:
sudo chown -R $(whoami) /usr/local/lib/pkgconfig /usr/local/share/info /usr/local/share/man/man3 /usr/local/share/man/man5
Then repeat the command:
brew install R
This time it works, it also installs all dependencies like openblas, readline, openssl@1.1 and so on.
Now when you start R, it shows a series of warnings like Setting LC_COLLATE failed
. Assuming you are using zsh, create or edit ~/.zshrc and add the line
export LC_ALL=en_US.UTF-8
Test
Now open a new terminal window and type R. If you use autocompletion with findInterval(
you will see the expected behavior, see screenshot:

Why do the two installations differ?
You can take a look at the configuration of the brew vs. the R-4.0.4.pkg variant. For brew you can find it in /usr/local/Cellar/r/4.0.4_2/lib/R/etc/Makeconf and it looks like this:
configure '--prefix=/usr/local/Cellar/r/4.0.4_2' '--enable-memory-profiling' '--without-cairo' '--without-x' '--with-tcl-config=/usr/local/opt/tcl-tk/lib/tclConfig.sh' '--with-tk-config=/usr/local/opt/tcl-tk/lib/tkConfig.sh' '--with-aqua' '--with-blas=-L/usr/local/opt/openblas/lib -lopenblas' '--enable-R-shlib' '--disable-java' 'PKG_CONFIG_PATH=/usr/local/opt/gmp/lib/pkgconfig:/usr/local/opt/isl/lib/pkgconfig:/usr/local/opt/mpfr/lib/pkgconfig:/usr/local/opt/jpeg/lib/pkgconfig:/usr/local/opt/libpng/lib/pkgconfig:/usr/local/opt/openblas/lib/pkgconfig:/usr/local/opt/pcre2/lib/pkgconfig:/usr/local/opt/readline/lib/pkgconfig:/usr/local/opt/openssl@1.1/lib/pkgconfig:/usr/local/opt/tcl-tk/lib/pkgconfig:/usr/local/opt/xz/lib/pkgconfig' 'PKG_CONFIG_LIBDIR=/usr/lib/pkgconfig:/usr/local/Homebrew/Library/Homebrew/os/mac/pkgconfig/10.15' 'CC=clang' 'CFLAGS=-Wno-implicit-function-declaration' 'LDFLAGS=-L/usr/local/opt/gettext/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/xz/lib' 'CPPFLAGS=-I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/xz/include' 'CXX=clang++' 'OBJC=clang'
For the Framework R-4.0.4.pkg variant you can find the information in the file /Library/Frameworks/R.framework/Resources/etc/Makeconf:
configure 'CC=clang -mmacosx-version-min=10.13' 'CXX=clang++ -mmacosx-version-min=10.13' 'OBJC=clang -mmacosx-version-min=10.13' 'FC=gfortran -mmacosx-version-min=10.13' 'F77=gfortran -mmacosx-version-min=10.13' 'CFLAGS=-Wall -g -O2' 'CXXFLAGS=-Wall -g -O2' 'OBJCFLAGS=-Wall -g -O2' 'FCFLAGS=-Wall -g -O2' 'F77FLAGS=-Wall -g -O2' '--enable-memory-profiling' '--x-libraries=/opt/X11/lib' '--x-includes=/opt/X11/include' '--enable-R-framework' '--build=x86_64-apple-darwin17.0' 'build_alias=x86_64-apple-darwin17.0' 'PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/local/lib/pkgconfig:/opt/X11/lib/pkgconfig'
Note the CPPFLAGS and LDFLAGS for readline and gettext in the brew variant.
Test: Add CPPFLAGS/LDFLAGS to R-4.0.4.pkg Variant
Just to substantiate the theory that these compile/link flags are needed, R is built from source code here.
First, some dependencies are needed if they are not already present on the system.
Xcode
XQuartz-2.8.0.dmg from https://www.xquartz.org
brew install gfortran
brew install xz
brew install cairo
brew install pcre2
brew install libtiff libjpeg
Download the source code R-4.0.4.tar.gz from one of the mirrors.
The adapted configure command could now look like this:
./configure 'CC=clang -mmacosx-version-min=10.13' 'CXX=clang++ -mmacosx-version-min=10.13' 'OBJC=clang -mmacosx-version-min=10.13' 'FC=gfortran -mmacosx-version-min=10.13' 'F77=gfortran -mmacosx-version-min=10.13' 'CFLAGS=-Wall -g -O2' 'CXXFLAGS=-Wall -g -O2' 'OBJCFLAGS=-Wall -g -O2' 'FCFLAGS=-Wall -g -O2' 'F77FLAGS=-Wall -g -O2' '--enable-memory-profiling' '--x-libraries=/opt/X11/lib' '--x-includes=/opt/X11/include' '--enable-R-framework' '--build=x86_64-apple-darwin17.0' 'build_alias=x86_64-apple-darwin17.0' 'PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/local/lib/pkgconfig:/opt/X11/lib/pkgconfig' 'CPPFLAGS=-I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/xz/include' 'LDFLAGS=-L/usr/local/opt/gettext/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/xz/lib' 'CFLAGS=-Wno-implicit-function-declaration'
Afterwards one can call
make
Make sure that you have created a backup before performing the last step. Finally with this command
sudo make install
one would create or overwrite /Library/Frameworks/R.framework. Calling /Library/Frameworks/R.framework/Resources/bin/R
now shows the expected behavior regarding autocompletion of function parameters and also provides the expected capabilities.