sublimetext2 - Sublime Text selection using Lua/love2d -
say have line of code :
object.property.field; object.property:functionname();
in sublime languages if double click "property" on either line, select word. reason lua/lua love2d syntax highlighting selects whole line ":"
how can change behavior, select single word?
the reason occurring because of strange addition lua love
plugin, assume you're using. you're using sublime 2, select preferences -> browse packages...
open packages
folder, open lua love
subfolder. there file called completions.py
, has content:
#completions.py import sublime import sublime_plugin import re class lovecompletions(sublime_plugin.eventlistener): st = 3000 if sublime.version() == '' else int(sublime.version()) def on_query_completions(self, view, prefix, locations): if self.st < 3000 , ("lua" in view.scope_name(locations[0])): seps = view.settings().get("word_separators") seps = seps.replace('.', '') view.settings().set("word_separators", seps)
even if don't know python, logic pretty easy follow. sets variable st
sublime's version, 3000+ if you're using st3 (current build 3061), , 2221 (i think) st2. sets event listener (the process running in background) checking see if sublime version less 3000 (you're using st2) , have lua
in current scope (basically, file source.lua
or source.lua.love
, if you're using plugin's language definition). if both of true, removes .
character "word_separators"
setting, defined in preferences -> settings-default
, can overridden in preferences -> settings-user
.
the word_separators
setting controls characters considered word separators when double-clicking select word. default value ./\\()\"'-:,.;<>~!@#$%^&*|+=[]{}`~?
so, example, if double-click on foo
part of foo-bar
sublime select foo
, if double-click on foo
part of foo_bar
sublime select whole thing (since -
in word_separators
). .
in word_separators
default, double-clicking on foo
in foo.bar
select foo
, expected behavior people, assume. however, cute little plugin removes .
word_separators
in sublime text 2, in case clicking on property
selects beginning of "word" (the whitespace before object
) next word separator - :
, in case of second example.
ok, know problem is, how fix it? first, while you're in packages/lua love
, delete completions.py
altogether. there's no harm in doing so, , in fact it's causing harm being there. make sure restart sublime after deleting file. next, open preferences -> settings-user
, add .
word_separators
list, anywhere between beginning , ending double-quotes. save file, go source code, , double-clicking should once again behave normally.
good luck!
edit
i submitted pull request delete completions.py
file plugin's github repo, , merged, users in future won't have deal :)
Comments
Post a Comment