Comments (5)
vscode.languages.registerFoldingRangeProvider({ pattern: "**/*.tw*" }, {
provideFoldingRanges(document: vscode.TextDocument, context: vscode.FoldingContext) {
const lines = document.getText().split(/\r?\n/);
let r: vscode.FoldingRange[] = [];
let open = 0;
lines.forEach((el, i) => {
const last = i === lines.length - 1;
if (/^::.*/.test(el) || last) {
if (open < i) r.push(new vscode.FoldingRange(open, i - (last ? 0 : 1), vscode.FoldingRangeKind.Region));
open = i;
}
});
return r;
}
});
Providers for CompletionItem
and FoldingRange
(these I've tested, so far) overwrite normal plaintext behavior. There are issues open in the VSCode repo for this, but I doubt it's going to change anytime soon.
from twee3-language-tools.
I already had a Folding Range Provider
set up, but then found out that custom providers kill indentation based folding.
A regex based folding in language configurations would be ideal, but as both the opening and closing tags are identical, and because it goes line by line, I haven't been able to settle on anything so far.
from twee3-language-tools.
Yeah I tried the regex-based config and ran into the same problem. I never considered this would have issues with indent-based folding. Do you still have the code for this?
from twee3-language-tools.
This doc https://code.visualstudio.com/docs/editor/codebasics#_folding seems to indicate that you can turn indentation folding back on (at least for some languages) if you don't want the syntax aware folding. Does that help? I'm fairly new to twee so I'm not sure when indentation folding would be useful in a twee file?
It would definitely be useful to collapse a file down to the passage titles to make it easy to re-order passages.
Since the 1.22 release, folding regions can also be computed based on syntax tokens of the editor's configured language.
The following languages already provide syntax aware folding: Markdown, HTML, CSS, LESS, SCSS, and JSON.If you prefer to switch back to indentation-based folding for one (or all) of the languages above, use:
"[html]": { "editor.foldingStrategy": "indentation" },
Regions can also be defined by markers defined by each language. The following languages currently have markers defined:
from twee3-language-tools.
@mielikki Unfortunately, no, that doesn't help. Turning it off doesn't help. Having it there allows for some sort of folding for those who do indent...
The problems with folding is described in the previous comments, and they're sadly still the same problems.
from twee3-language-tools.
Related Issues (20)
- extension is catching closing tags, but not opening tags. [bug] HOT 2
- Syntax highlighting issue with Twee link markup inside SugarCube macro HOT 2
- SugarCube, bad highlighting for `$var.prop_name` HOT 1
- Feature request: Syntax highlighting inside SugarCube backquotes
- Allow warnings about IFID missing in StoryData to be turned off HOT 1
- The quickfix link sometimes disappears on mouse hover HOT 1
- New (July) update causes CPU to run continuously HOT 2
- Support relative path variable substitution in SugarCube 2 macro definition descriptions HOT 1
- Add enums for sc2 macro definitions
- Auto-indentation rules HOT 4
- Reopen Story Map on reload
- Story Map view resets when going to it from another file/tab HOT 3
- If the passage has a [nobr] tag or a section wrapped in a <<nobr>><<script>>, give a warning about // comments
- Add light-mode to story-map.
- Group: Tag and :: Passage vs :: Passage []
- [Sugarcube 2] "Malformed container macro! Opening tag not found!" in backtick-enclosed multi-line string
- Harlowe StoryMap missing arrow links between passages when changers are used HOT 3
- Add setting to toggle the "Go to macro definition" feature
- Request: Display folder relative to workspace folder
- Large Twee 3 Projects have a hard time with vscode. HOT 2
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 twee3-language-tools.