Comments (6)
We currently have
<key>decreaseIndentPattern</key>
<string>^\s*(end|else|elseif|catch|finally).*$</string>
<key>increaseIndentPattern</key>
<string>^\s*(if|else|elseif|for|while|begin|function|type|macro|immutable|try|catch|finally|let|quote|do).*$</string>
in https://github.com/JuliaEditorSupport/Julia-sublime/blob/master/Indentation.tmPreferences.
Note the ^\s*
, i.e. begin
cannot be preceded by non-space characters in order to trigger auto-indent. One could of course remove ^\s*
, but this might open up for problems such as auto-indent being triggered if you type 'begin' in a string.
What do you think about this?
from julia-sublime.
I looked at Ruby because it has a similar syntax. They go all in:
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
<key>name</key>
<string>Indent</string>
<key>scope</key>
<string>source.ruby</string>
<key>settings</key>
<dict>
<key>decreaseIndentPattern</key>
<string>^\s*([}\]]\s*$|(end|rescue|ensure|else|elsif|when)\b)</string>
<key>increaseIndentPattern</key>
<string>(?x)^
(\s*
(
module|class|def
|unless|if|else|elsif
|case|when
|begin|rescue|ensure
|for|while|until
|
(?=.*? \b(do|begin|case|if|unless)\b )
# the look-ahead above is to quickly discard non-candidates
(
"(\\.|[^\\"])*+" # eat a double quoted string
| '(\\.|[^\\'])*+' # eat a single quoted string
| [^#"'] # eat all but comments and strings
)*
(
\s (do|begin|case)
| [-+=&|*/~%^<>~](?<!\$.) \s*+ (if|unless)
)
)\b
(?! [^;]*+ ; .*? \bend\b )
|
(
"(\\.|[^\\"])*+" # eat a double quoted string
| '(\\.|[^\\'])*+' # eat a single quoted string
| [^#"'] # eat all but comments and strings
)*
(
\{ (?! [^}]*+ \} )
| \[ (?! [^\]]*+ \] )
)
).*$
</string>
</dict>
</dict>
</plist>
from julia-sublime.
Another option that wouldn't exactly fix this but would fix my case would be to have a snippet for begin-end, if-end, etc. that would mimic the behaviour of {}
in e.g., C. begin
snippet would generate begin end
with the cursor in the middle, and then pressing ENTER would expand to (using my example as a template):
1 + begin
# cursor here
end
from julia-sublime.
Woah, looks interesting. I don't have time to look at this now. If you want, feel free to tweak the ruby version to work with Julia and submit at pull request. Regarding the snippet, you can add that manually, I don't think that should be part of the package.
Although, perhaps it would be nice to have snippets for all syntax that contains mandatory closing words (such as begin-end, if-end, while-end etc.). What do you think about this? Perhaps it would be annoying, perhaps one often re-writes code and types begin
while end
is already inserted, this would cause double end
s...
from julia-sublime.
I feel discouraged from adding indentation regex similar to Ruby (it's quite messy, I prefer simplicity). I've changed my mind regarding a snippet for begin, it's a splendid idea that fixes this issue. I've pushed commit 54f5325 which adds such a snippet.
Feel free to reopen this issue, or open new ones if you feel anything can be improved.
from julia-sublime.
Works like a charm, thanks :)
I love the turnaround on Sublime package releases! I could just update within the editor with no fuss.
from julia-sublime.
Related Issues (20)
- Syntax hangs HOT 3
- Bug: trying to open julia/base/reducedim.jl fails HOT 3
- Syntax highlighting completely broken on ST4 HOT 16
- Definition / goto is broken for function definitions prefixed with package name HOT 3
- Syntax highlighting bug HOT 1
- Unicode Completion in Search Bar HOT 18
- Unicode expansion for other file types HOT 2
- Can not work in Markdown code block HOT 3
- Scope and syntax highlighting issue in the sequence scope
- Fix order of match blocks for macro rule HOT 4
- Docstrings are treated as regular strings if they are indented HOT 4
- Multi-line Comments HOT 4
- Recognizing keyword argument in f(x; kwd) HOT 11
- Package Control.sublime-package installation - I am lost... HOT 1
- Syntax highlighting for function name starting with `struct` broken
- v 4133 and unicode tab completion HOT 3
- Syntax highlighting inside quote block
- Error loading syntax file
- Correct syntax highlighting for "import Foo as Bar"
- Vector transpose breaks highlighting HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from julia-sublime.