Sublime Forum

API Suggestions

#33

Add focused attribute for sidebar in sublime-theme files

In sublimeText when you focus the sidebar with a shortcut, there’s no visual cue to tell you that the sidebar is focused.
If you introduce a new attribute for sidebar in sublime-themes, then themes can change the UI to indicate that the sidebar is focued.

Side Note: Please add some documentation on these special attribures like ‘expanded’, ‘selected’, ‘dirty’. Sublime theme documentation is missing in general.

7 Likes

#34

Changing line color as additional gutter

Importance: Major

line_color or gutter_color could add a subtle color marker to the line like the example screenshot from Atom. This doesn’t replace @oivva suggestion. It extends it. With this addition there would be two things a plugin can modify in the gutter: a) add an icon (already possible and used by many plugin). @oivva suggestion would make it possible to add multiple icons. b) change the line color. The line color could be used to show git changes and the icon for linting or something else. Compared to multiple gutter icons, this does take away any space.

45 Likes

#36

RenderIconAtPos(pos, icon, fn)

Sometimes you want to provide some contexual information that can not be part of the content of the view, something like the error message from the linter or showing an image or a chart in en external tool. Showing an icon beside the text that could trigger other api calls like showing a tooltip or opening another view would be really beneficial. something like this in intelliJ:

2 Likes

#37

I haven’t worked with the tooltip API at all, but I’d love to see something like Atoms.

I know we have basic CSS, but full css styling along with a set of nice looking default CSS rules for tooltips and labels could go a long way.

16 Likes

Style of Inline Errors
#38

I think you can get very close to something like this. You just need a linter plugin to take the time at put it in. The CSS is limited in the API, but it is sufficient for things like this.

0 Likes

#40

Another API that I would like to see is the ability to force an update for the auto-complete list. Our code base is thousands if not hundreds of thousands of functions. I would like be able to serve up a subset of those functions once the user has entered more than 2 characters. I may have missed something with my limited testing of this functionality, but I think being able to inject a new set of data into an open autocomplete list might be helpful.

view.update_autocomplete(completion_tuple)

0 Likes

Interface Suggestions
#41

Last one for now…The ability to affect a single on_query_completions using flags. I would like to create a plugin that will display autocompletions without the in-file suggestions, but since these flags affect all instances of on_query_completions, this is not easily doable.

INHIBIT_WORD_COMPLETIONS
INHIBIT_EXPLICIT_COMPLETIONS

0 Likes

#43

Find in Region by selectors

One thing I would really like to see would be the ability to do a view.find_in_region_by_selectors(region, [selector1, selector2]), which would essentially be an upgrade to the existing view.find_by_selector method, to include:

a. a region within which to restrict the results
b. an array of selectors

The result would of course be sorted by position, and could include the entire scope of the region, or just the selector that matched, like this:

[(region, scope/selector), (region, scope/selector)...]

Why?

Firstly, I know that having an array for multiple selectors may seem pointless, because a selector can include a comma to perform an “or”. i.e. string, comment.
But the problem with this, is that, if the text matching the selectors are adjacent, the region returned will include all of them, and most of the time, it is much more useful to have them separate.

Example:

take a python file containing:

"hello world"#comment
"foobar" # another comment

using the following code:

[view.substr(region) for region in view.find_by_selector('string, comment')]

will return the following:

[’“hello world”#comment\n"foobar"’, ‘# another comment’]

Now, imagine that one wants to know the location of all the comments in the file and all the strings in the file, while preserving the order. With the current API, the “most efficient” workaround is to do this (view.substr is just for demonstration of what gets returned):

[view.substr(region) for region in sorted(view.find_by_selector('string') + view.find_by_selector('comment'))]

[’“hello world”’, ‘#comment\n’, ‘“foobar”’, ‘# another comment’]

which involves sorting a potentially incredibly massive list.

Now this is where the proposed region restriction comes in handy. Most of the time when I am developing plugins, I am only interested in a small subset of the file/view at a time, and I feel that being able to get results only for a particular region will make the plugin code easier to read/understand and write, while at the same time being more efficient. (Even if the same process would have to happen in the C code, it would be a lot quicker than processing it in Python I think.)

Importance: Minor


One possibility would be to alter the find_by_selector method, to include the new functionality, in such a way as not to affect existing plugins that rely on the current behavior:

  • make the region parameter optional (and come after the selector), and default to the entire view if None
  • if the selector parameter is a string, use the current functionality and return type (list of regions)
  • if the selector parameter is an array, return the list of tuples, where each tuple would contain the region and the scope of that region or the selector that matched.

I guess if multiple selectors matched, and the API would return the matching selector(s) as opposed to the scope at the region, then the return value of the matched selectors could be a list, to avoid repeating the region in the return value. i.e.:

[(region1, [selector1, selector2]), (region2, [selector1])...]

instead of:

[(region1, selector1), (region1, selector2), (region2, selector1)...]
9 Likes

find_by_selector and nested scopes
#44

Sets of APIs to Improve one aspect of the performance of ST:

  1. application does not trigger “on load” when the app is opened. This means, that any package that needs that event should trigger it in a synthetic way. So imagine many packages doing this…
  2. application does not have “on application close”, so if you need to save to disk some data related to the views you have opened you need workarounds, like on_deactivated. So we hitting hard drive on every focus lost… because there’s no reliable way to save data about the views; and this workaround is not even reliable. [data that does not fit in ST view settings object, etc], imagine you need to save something to sqlite
11 Likes

#45

All file events, give events for:

Any change on disk about a file/folder is created/changes/reloads/gets deleted, even if not opened. The current ugly hack is to recurse the folder till eternity.

6 Likes

Adding folder name completion and syntax highlighting to an existing plugin?
#46

Dispatch events for when a view is scrolled, so we can for example scroll other unfocused views in relation to the current focused view. The current ugly hack is to loop forever and see if the scroll changed

6 Likes

#47

This gonna be hard to explain and Im sorry, We need “light” versions of on_selection_modified and on_modified .

Because these two apis are too verbose and everyone use it wrong, Then later people complain ST lags, when they triggering heavy tasks on every key press or cursor move. Some people even believe they use it right because they move to threads, and actually this is worse, there’s no need to dispatch 30 gonna-be-useless threads because you hold a key to type or to move the cursor for a few seconds.

The current workaround for this is insane, you loop in a thread with while(True) and sleep, then try to check if the view/selection changed and also if it is worth to wait a bit more

I suggest something in the lines of ;

  1. on_after_selection_modified - event fires when the cursor stops moving for some given milliseconds
  2. on_after_modified - event fires when the user stops modifying the view for some given milliseconds
6 Likes

Interface Suggestions
#48

This is a pretty curated list, and Im sure you will found some worth post, specially all of these related to bugs, ST API works most of the time but has some bugs that are really frustrating and defeats the purpose of having an api in the first place, because you need workarounds that does not couple correctly or does decouple with other functionality and everything becomes a workaround of a workaround to make things work.

This is the most important stuff. Current API should work, flawless, if does not because of some edge case, then explain it

2 Likes

#49

Some APIs conflict with ST itself, for example, you have an API to scroll the view to a certain position, but you don’t have any way to stop ST Core from scrolling a view. So you start fighting and racing with ST to see which one will scroll a view. Defeats the purpose of the API because you cannot use it, sublime will simply overwrite it as it wish.

For an API to work correctly, every default behaviour of the editor should be configurable. There are many, many examples of this. For example imagine you want to run a task to all the file selected on sidebar, and you need to do this repetitively, well if you change of view, your selection on sidebar vanishes, hence an API to get the current selection of files gonna be useless for a lot of cases. Want another example? on_close is not dispatched if you switch projects

1 Like

#50

This is more a dream than anything else, it would be nice to have “linked regions”, regions that are foreign to the current document, this will allow to change for example more than one file from the same view.

Something like this, I did on package FindResultsApplyChanges https://github.com/titoBouzout/FindResultsApplyChanges

Basically you can edit the view of the find results directly and then press CTRL+S to save the changes you did to the different files

The possibilities of this are out of my imagination

9 Likes

split this topic #51

A post was merged into an existing topic: Interface Suggestions

0 Likes

#52

Possibly an API to expose the fussy match logic that Sublime has implemented such that we could apply the matching algorithm to a list of strings or list of objects.

Example
sublime.fuzzy_match(list, match_string, key)

  • list: list to apply the matching against
  • match_string: used to match against
  • key: A key to be used if supplying a list of objects or tuples.

Not sure if anyone would find this helpful or not, but there have been some cases where I want to apply the fuzzy matching against a list of items without using one of the built in panels.

11 Likes

#54

Add to this settings too:

"minimap": true,
"status_bar": true,
"tabs": true
1 Like

Custom Key Bindings -- syntax and conventions for sorting lines
#55

Placeholder for fold

Importance: Minor
Description: Add an optional placeholder argument to the fold function, i.e. change the signature to fold(regions, <placeholder>) and fold([regions], <placeholder>). If the function is executed the placeholder text is inside the yellow rectangle instead of the 3 dots.
In addition add a function is_folded(point), which returns whether a point is currently folded.
Motivation: This could be used to fold redundant and unnecessary code away to improve readability while keeping the key information. E.g. fold all function keywords in JavaScript to f or python lambda: to λ. In LaTeX it could be used to fold labels to l and greek characters and some operators to their unicode character, e.g. \alpha to α.

12 Likes

Looking for an orgmode like link presentation
#56

Directly accept colors in add_regions

Importance: Major
Description: Change the add_regions method to accept rgb encoded colors. The function add_regions(key, [regions], <scope>, <icon>, <flags>) currently only accepts a scope and retrieves the color from the colorscheme. It would be nice, if it was possible to pass rbg encoded colors as an argument. This could either be done by changing the signature to accept an additional keyword argument <color> or by adding a flag sublime.SCOPE_IS_COLOR to treat the scope as a color.
Motivation: When creating a highlighted region one often just wants to define the color itself instead of a scope with a similar color.
At the moment some packages (e.g. SublimeLinter and ColorHighlighter) even change the colorscheme of the user to inject their colors. This has some disadvantages for the user and does not scale as a general solution.

17 Likes

Interface Suggestions