Skip to content

Make $scope variable available to commands#12

Open
lethosor wants to merge 1 commit into
mitranim:masterfrom
lethosor:var-scope
Open

Make $scope variable available to commands#12
lethosor wants to merge 1 commit into
mitranim:masterfrom
lethosor:var-scope

Conversation

@lethosor

Copy link
Copy Markdown
Contributor

This makes it possible to configure the same formatter for multiple scopes and change its behavior based on the scope as determined by Sublime, rather than the file extension. This is useful e.g. for files that lack an extension but whose language is known to Sublime.

Inspired by #11, although it may not completely address that use-case.

Comment thread Fmt.py
vars['tab_size'] = str(tab_size)
vars['indent'] = indent
vars['scope'] = view_scope(view)
vars.update(os.environ)

@lethosor lethosor May 30, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is a possible improvement here where os.environ could be given lowest priority. Right now it is given highest priority, so e.g. if someone happens to have an environment variable named file, $file in formatter commands would expand to that, rather than the value returned from view.window().extract_variables() here. I'm not sure when this behavior would be desirable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant