A post was merged into an existing topic: Interface Suggestions
API Suggestions
Multiple gutter with event capability
Importance: medium
Motivation: Allow plugins to integrate better with sublime
There are few plugins that I could think of that would benefit on a better gutter:
- plugins that are wrapper around debuggers will allow you to CRUD breakpoints. For this kind of plugins events are an absolute must.
- plugins that are merely indicators: color/brackets/git/whatever highlights. For this kind of plugins events are kind of useless.
I believe that letting plugins to create their own gutters are a good idea as long it respects the following rules:
- Plugin canât create their own gutter User must allow in settings the âblessedâ plugins, so they donât end up with gutter hell.
- User canât allow more than X plugins to create gutters. In other words, sublime can have max of X gutters (for the same reason as above)
- Current gutter remains, so all unblessed plugins fight for their place in the same way as they do today.
I think this should also be here:
It would be nice to have a serializable undo redo/history. So we can undo after closing and reopening sublime⌠give an api so we do this as we wish.
More flexible scope manipulation
Importance: high
Motivation: allow painless text manipulation by scopes
Working with scopes is a pain at the moment because we canât be specific about extracting text for a given scope selector. Instead we have to use extract_scope(point) with its âintelligenceâ which varies by language. Or, we use find_by_selector(selector), then iterate through the list of regions to find the one that intersects the position we want. Or we move position by position back and forth and check we are in/out of scope. These workarounds are labour & CPU intensive for what should be a very simple thing. The solution:
extract_scope(point, selector)
The above proposed change will extract the region for the given selector if provided. Better still would be:
extract_scope(point, selectors)
Where selectors is a space delimited string of selectors, the largest of which (except topmost source.*) is selected.
Finally we could have a greedy flag which allows the above API to choose the least or most specific selector:
extract_scope(point, selectors, greedy, single)
And the single flag will allow an individual scope to be extracted in the case where they are back to back (like <div><div><div>
)
Rounding off, it would be useful to have more flexibility with find_by_selector(selector), so that we can restrict its operation to a given region or regions. Presently it returns all matching regions in the file, a performance overhead if one needs to iterate through it repeatedly.
find_by_selector(selector, Region or [Regions])
Extend snippet/completion scope
(Iâm assuming this qualifies as an API suggestion, Iâm not entirely sure though)
One of the most frequent requests for my packages is extending the scope of snippets or completions to other syntaxes. Iâve had a situation where I was asked to extend the scope for HTML completions and add support for JSX. Immediately after those changes were applied, I got complaints from other users of my package about this change. Itâs not always easy to judge whether such a change makes sense, especially if youâre not familiar with the syntax.
Therefor, I would love if Sublime Text would allow users to extend/manipulate the scope in which snippets/completions are working without having them to alter the actual files, e.g. in the user settings.
Workspace APIs (for GIT branches)
I would like to write a plugin to change workspaces based on the current Git branch.
Currently changing branches in Git can leave the current workspace in a mess:
- Files become unsaved if they do not exist in the new branch (they are removed from disk)
- Files open may have nothing to do with the Git branch checkout
- Need to close the branch irrelevant files
- Need to reopen the branch relevant files
I tend to manually create a new workspace for each branch:
GIT.[Branchname].sublime-workspace
I have to manually switch workspaces after a checkout.
I have to manually delete workspaces when I delete the branch.
I would like to be able to load workspaces, create and delete them.
- API to get the path of the current .sublime-workspace file
- API to load a .sublime-workspace file (âQuick Switch Workspaceâ)
- API to save a .sublime-workspace file (âSave Workspace AsâŚâ)
- API to delete a .sublime-workspace file
Additionally, unrelated to workspaces, but useful for this plugin:
- API to monitor specific file for changes
This would allow notification of when the .git/HEAD file is modified (when a checkout occurs), to trigger the workspace switch.
An API to hide a set of lines matching a given criteria (regex or âŚ). When called with None, unhide all hidden lines.
Once hidden, those lines would be excluded from search and edit operations. Similar to what the âALLâ command does on XEDIT and similar editors.
To illustrate, here is a simple directory listing:
Then, after hidding the lines not containing âdirâ:
Very handy while working with log files and line-oriented files (csv exports, âŚ).
You can still view/search/edit the non-hidden lines, add new content, and so on.
- Select the lines you want to hide
- Menu
Edit -> Code Folding -> Fold
You can use RegReplace to do it using REGEXP
Menu Edit -> Code Folding -> Fold
Nope:
those lines would be excluded from search and edit operations.
More consistent output panels
Output panels have really odd behaviors currently. In exec.py
, there is this code:
if not hasattr(self, 'output_view'):
# Try not to call get_output_panel until the regexes are assigned
self.output_view = self.window.create_output_panel("exec")
# [...]
self.output_view.settings().set("result_file_regex", file_regex)
self.output_view.settings().set("result_line_regex", line_regex)
self.output_view.settings().set("result_base_dir", working_dir)
self.output_view.settings().set("word_wrap", word_wrap)
self.output_view.settings().set("line_numbers", False)
self.output_view.settings().set("gutter", False)
self.output_view.settings().set("scroll_past_end", False)
self.output_view.assign_syntax(syntax)
# Call create_output_panel a second time after assigning the above
# settings, so that it'll be picked up as a result buffer
self.window.create_output_panel("exec")
Observations:
-
Window.create_output_panel
is run twice. But only at the first time. - calling
.assign_syntax
on the output panel turns it from a widget into an actual view. This causes it to infer its settings from the usualPreferences.sublime-settings
files (or more likely, they are not overridden from some widget-specific thing). As a result, the output panel will have its gutter and line numbers visible, whichexec.py
has to disable explicitly. (more on this) - On each call of
Window.create_output_panel
, its entire contents are erased. Settings are not reset, though.
Priority: minor (itâs âalwaysâ been like this and changing behavior of create_output_panel
especially wrt 3. would be a breaking change)
Related: API Suggestions
[BUG ST2/3] set_syntax_file() clear 'is_widget' setting
Putting scopes to work
So far, scopes use is limited: syntax coloration and some limited hard-coded features (âgo to symbolâ, mostly).
What about extending them, in two ways:
- being able to specify a scope for the search/replace api (so that we could search/replace for a given expression in comments only, or not in comments, extract all test fragments with a given scope, like we currently extract the list of symbols, jump to the next or previous string (or any scope), and so on);
- being able to new âstylingâ options for scopes, with styling being âeditable/readonlyâ, or âsearchable/notsearchableâ, and so on.
Priority: minor
Speaking about putting scopes to work:
Iâd like to have scope based folding instead of just indent based folding.
Similar to the tmPreferences
files used by the symbol list,
a setting file would allow to control which scope can be folded.
Importance: Major
Also Iâd like scope based auto-indentation.
Now the Indentation.tmPreferences
is doing regex matching while all the information we need is already extracted by the syntax.
Importance: Minor (since there is already a working mechanism albeit limited)
Configure auto-indent with multiple scopes per line
I also wanted to suggest an indentation system that is based on scopes (and the powerful syntax lexing thatâs happening all the time anyway), but hold back onto creating an issue for it since I havenât yet drafted out a specific suggestion on how I would imagine this feature.
I also wonder if it should be part of the syntax definition or utilize a separate scope-selector-oriented mechanism like tmPreferences do.
Another thing that Iâd like is improved parsing of the output panel.
For now errors have to be extracted through two regexes, one for the file and one for the line, character offset and message.
So here are 3 suggestions in increasing order of complexity.
-
the output of the C# compiler doesnât print full path to files, only the name of the file.
This prevent the ânext_resultâ command to open the correct file.
Proposed fixed: if the matched path doesnât exist try to open a file in the current project with the same name. -
Sometimes the error message is on different line than the line number (eg in Python). So there is no way to capture the error message.
Proposed fix: add a third regex for the error message. -
There is no distinctions between errors and warnings. You have to choose when you create the build system if you want to catch both or only errors. Ideally the build system would provide a way to extract both, and the user could choose which one to display.
Dev Build 3118
Matching multiline build system output file_regex
I hate it that I always find something to comment on in these threads, but I just canât help it. If thatâs not desired, Iâll continue replying to posts in new threads, but Iâm on mobile atm.
To 1.: relative file paths are a possibility (and by default relative to the active viewâs fileâs directory. It can be configured with a setting that you can inspect from exec.py.
To 2.: you can capture the message in the regular expressions, but nothing is really done with it. I think it shows in the status bar on some action.
If you capture the message in a build systems, it is shown in phantoms. I think there is a build-error tooltips package out there that also uses the messages. So, in 3118 this works as described here.
I wasnât aware of that so I updated my feature request.
The problem is that it must be one regex matching both line number and error message.
But for python where the error message is on a different line than the line number, you canât capture it (confirmed by Jps in the build 3118 thread).
Syntax-specific option for case-insensitive goto-definition
There was some discussion here:
Essentially, for languages that are case-insensitive (Fortran is the example I care about) it is desirable that goto-definition is case insensitive (e.g. you define MYFUNCTION
but then call MyFunction
, currently goto-definition doesnât work for this case). This is already partly solved by the ability to perform a symbol transformation to convert all indexed symbols to lowercase, but goto-definition will then not work on any word that is not lowercase. I see at least three possible solutions:
-
Add a
caseInsensitive
option to thetmPreferences
. This works for case insensitive languages but is the least general approach. It has the advantage that the original capitalisation would be preserved in the symbol list. -
Apply
symbolTransformation
to the current word before looking it up in the index. This might break something else, Iâm not sure. -
Add a
lookupSymbolTransformation
to thetmPreferences
that would be applied to the current word before looking it up in the index.
Importance: major for case-insensitive languages
Full set of character codes in minihtml
For arbitrary text, the python function html.escape
often produces HTML codes that minihtml
doesnât understand, such as '
for '
:
import html
view.add_phantom("id", sublime.Region(0,0), html.escape("'"), sublime.LAYOUT_BLOCK)
Obviously this makes it difficult to display arbitrary strings in Phantoms or Popups.
Importance: minor
Edit: It seems that minihtml currently works reliably with only the following substitutions (I have tested with all ASCII characters):
def to_html(s):
s = s.replace('&', '&')
s = s.replace('<', '<')
return s