Allow customizing what is used for ‘Go to File Counterpart’ (⌥⌘↑)

The user can now set ‘counterpart’ in .tm_properties to the absolute path of what should be used for ⌥⌘↑. If the file does not exist (on disk or as an open tab) then TextMate will fallback to searching the current folder for a file with same name.

To switch between go source and go test files one could add the following:

   [ *.go ]
   counterpart = "${TM_FILEPATH/(_test)?\.go$/${1:?:_test}.go/}"

Here the regular expression transformation will remove ‘_test’ from the file name if it exists, otherwise add it.

One could also do multiple settings like:

   [ *.go ]
   counterpart = "${TM_FILEPATH/(?=\.go$)/_test/}"

   [ *_test.go ]
   counterpart = "${TM_FILEPATH/_test(?=\.go$)//}"

Here ‘*.go’ files get the ‘_test’ added to their name, though files matched by the ‘*_test.go’ glob will instead have it removed.