-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
97 lines (85 loc) · 3.48 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
'use babel';
import { CompositeDisposable } from 'atom';
import autocompleteProviders from './lib/autocomplete/index';
import MarkerManager from './lib/marker-manager';
import DocumentModel from './lib/model';
// Available actions
import insertLineBreak from './lib/actions/insert-line-break';
import { removeMarkers, supressAutoPopup } from './lib/actions/remove-markers';
import matchingPair from './lib/actions/matching-pair';
import increment from './lib/actions/increment-decrement';
import removeTag from './lib/actions/remove-tag';
import splitJoinTag from './lib/actions/split-join-tag';
import toggleBlockComment from './lib/actions/toggle-block-comment';
import updateImageSize from './lib/actions/update-image-size';
import convertDataUrl from './lib/actions/convert-data-url';
import evaluateMath from './lib/actions/evaluate-math-expression';
import { balanceInward, balanceOutward } from './lib/actions/balance';
import { nextEditPoint, previousEditPoint } from './lib/actions/edit-point';
import { selectNextItem, selectPreviousItem } from './lib/actions/select-item';
const config = {
enableMathCompletions: {
type: 'boolean',
default: true,
title: 'Enable evaluated math expression completions',
description: 'Displays auto-complete popup with evaluated result when you type simple math expression'
},
displayPopupOnMove: {
type: 'boolean',
default: true,
title: 'Display autocomplete popup when caret moves inside abbreviation',
description: `By default, \`autocomplete-plus\` hides autocomplete popup when cursor moves without changing text.
This option will force autocomplete popup to stay visible when cursor is moved inside abbreviation marker,
but may introduce side-effects. Disable this option if you exprience issues with autocomplete.`
}
};
const incrementFactory = delta =>
(editor, env, evt) => increment(editor, delta, env, evt);
let disposables;
const actions = {
'remove-abbreviation-marker': removeMarkers,
'supress-autopopup': supressAutoPopup,
'insert-formatted-line-break': insertLineBreak,
'balance-outward': balanceOutward,
'balance-inward': balanceInward,
'go-to-next-edit-point': nextEditPoint,
'go-to-previous-edit-point': previousEditPoint,
'go-to-matching-pair': matchingPair,
'select-next-item': selectNextItem,
'select-previous-item': selectPreviousItem,
'remove-tag': removeTag,
'split-join-tag': splitJoinTag,
'toggle-block-comment': toggleBlockComment,
'update-image-size': updateImageSize,
'convert-data-url': convertDataUrl,
'evaluate-math-expression': evaluateMath,
'increment-number-by-1': incrementFactory(1),
'increment-number-by-10': incrementFactory(10),
'increment-number-by-0_1': incrementFactory(0.1),
'decrement-number-by-1': incrementFactory(-1),
'decrement-number-by-10': incrementFactory(-10),
'decrement-number-by-0_1': incrementFactory(-0.1)
};
export function getAutocomplete() {
return autocompleteProviders();
}
export function activate() {
disposables = new CompositeDisposable();
const markerManager = new MarkerManager();
const documentModel = new DocumentModel();
const env = { markerManager, documentModel };
disposables.add(markerManager);
disposables.add(documentModel);
Object.keys(actions).forEach(action => {
const handler = evt =>
actions[action](evt.currentTarget.getModel(), env, evt);
disposables.add(atom.commands.add('atom-text-editor', `emmet:${action}`, handler));
});
}
export function deactivate() {
if (disposables) {
disposables.dispose();
disposables = null;
}
}
export { config };