-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add configuration for block marker regexes
- Loading branch information
Showing
3 changed files
with
86 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { workspace } from 'vscode'; | ||
import { FoldingMarkerDefault, FoldingMarkerList } from './StringProcessingProvider'; | ||
|
||
const defaultFoldingMarkers: FoldingMarkerList<FoldingMarkerDefault> = { | ||
'()': { start: '\\(', end: '\\)' }, | ||
'[]': { start: '\\[', end: '\\]' }, | ||
'{}': { start: '\\{', end: '\\}' }, | ||
'<>': { start: '<[a-zA-Z0-9\\-_=\\s]+', end: '<\\/[a-zA-Z0-9\\-_=\\s]+' }, | ||
}; | ||
|
||
const defaultCompleteBlockMarkers = ['\\}', '<\\/[a-zA-Z0-9\\-_=\\s]+']; | ||
|
||
const defaultIndentIgnoreMarkers = [ | ||
'{', | ||
// eslint-disable-next-line quotes | ||
"end(?:for(?:each)?|if|while|case|def)?\\s*?([\\.\\[\\->\\|\\s]\\s*(?:[$A-Za-z0-9_+\\-\\*\\/\\^\\%\\<\\>\\=\\!\\?\\:]*|'[^']*?'|'[']*?'|\"[^\"]*?\"|`[^`]*?`)\\s*[\\]\\|]?\\s*)*", | ||
'esac|fi', | ||
]; | ||
|
||
export default class ConfigurationProvider { | ||
public static getFoldingMarkers(): FoldingMarkerList { | ||
const additional: FoldingMarkerList = workspace.getConfiguration('blocksort').get('foldingMarkers') || {}; | ||
return { ...additional, ...defaultFoldingMarkers }; | ||
} | ||
|
||
public static getCompleteBlockMarkers(): string[] { | ||
const additional: string[] = workspace.getConfiguration('blocksort').get('completeBlockMarkers') || []; | ||
return [...additional, ...defaultCompleteBlockMarkers]; | ||
} | ||
|
||
public static getIndentIgnoreMarkers(): string[] { | ||
const additional: string[] = workspace.getConfiguration('blocksort').get('indentIgnoreMarkers') || []; | ||
return [...additional, ...defaultIndentIgnoreMarkers]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters