Sublime Forum

Conventions for text completions?

#1

on my recent contribution to a ST plugin i was asked why my triggers are all lowercase. Personally, i find it annoying to type with caps (like many do). I’ve seen some snippets changing the trigger to lowercase, too.

Referring to tab trigger, comletion triggers and snippets are there conventions for text completions? Anything to consider?

completion.lower().startswith(prefix)
<tabTrigger>fun</tabTrigger>
{
    "scope": "source.python",
    "completions": [
        {
            "trigger": "def",
            "contents": "DEF"
        }
    ]
}
0 Likes

#2

I don’t think there is any convention as such and not sure why triggers can’t be lowercase either.

0 Likes

#3

i just tested the triggers for the text buffer. Sublime Text is case sensitive for the text buffer. I suppose it could be too polluting otherwise.

But for syntax completions it is not intrusive. There is a big community rejecting the use of uppercase in style conventions.

the language is case sensitive (except, when it isn’t of course). here’s a sample snippet:

get_property(isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(isMultiConfig)
	if(NOT "Profile" IN_LIST CMAKE_CONFIGURATION_TYPES)
		list(APPEND CMAKE_CONFIGURATION_TYPES Profile)
	endif()
else()
	set(allowableBuildTypes Debug Release Profile)
	set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "${allowableBuildTypes}")
	if(NOT CMAKE_BUILD_TYPE)
		set(CMAKE_BUILD_TYPE Debug CACHE STRING "" FORCE)
	elseif(NOT CMAKE_BUILD_TYPE IN_LIST allowableBuildTypes)
		message(FATAL_ERROR "Invalid build type: ${CMAKE_BUILD_TYPE}")
	endif()
endif()

and i am providing text completion for every keyword in above snippet (NOT, GLOBAL, PROPERTY, etc)

0 Likes

#4

i noticed that triggers are case insensitive, but something is off.

<tabTrigger>enable_testing</tabTrigger>

triggers on

  • enable
  • eNABLE
  • eNaBlE

but not on

  • ENABLE
  • Enable
0 Likes

#5

I was under the impression that word-completions should basically be the word itself for both the trigger and the completion (You’re nominally just adding that keyword to the completion list even if it doesn’t appear elsewhere in the file).

Lower-case triggers are typically used for snippet completion, where there’s some extra stuff to add to the word itself.

0 Likes