5
5
* @TODO : Complete quotes for strings
6
6
*/
7
7
8
- import { Point , Range } from 'atom'
8
+ import { CompositeDisposable , Point , Range } from 'atom'
9
9
10
10
import { client } from '../connection'
11
11
import modules from './modules'
12
12
13
13
import { getLocalContext } from '../misc/blocks'
14
14
15
15
const bracketScope = 'meta.bracket.julia'
16
- const completions = client . import ( 'completions' )
16
+ const baselineCompletionAdapter = client . import ( 'completions' )
17
17
const completionDetail = client . import ( 'completiondetail' )
18
18
19
19
class AutoCompleteProvider {
@@ -24,6 +24,22 @@ class AutoCompleteProvider {
24
24
suggestionPriority = atom . config . get ( 'julia-client.juliaOptions.autoCompletionSuggestionPriority' )
25
25
filterSuggestions = false
26
26
27
+ activate ( ) {
28
+ this . subscriptions = new CompositeDisposable ( )
29
+ this . subscriptions . add (
30
+ atom . config . observe ( 'julia-client.juliaOptions.fuzzyCompletionMode' , v => {
31
+ this . fuzzyCompletionMode = v
32
+ } ) ,
33
+ atom . config . observe ( 'julia-client.juliaOptions.noAutoParenthesis' , v => {
34
+ this . noAutoParenthesis = v
35
+ } )
36
+ )
37
+ }
38
+
39
+ deactivate ( ) {
40
+ this . subscriptions . dispose ( )
41
+ }
42
+
27
43
getSuggestions ( data ) {
28
44
if ( ! client . isActive ( ) ) return [ ]
29
45
const { editor, bufferPosition, activatedManually } = data
@@ -57,8 +73,7 @@ class AutoCompleteProvider {
57
73
baselineCompletions ( data , line ) {
58
74
const { editor, bufferPosition : { row, column } , activatedManually } = data
59
75
const { context, startRow } = getLocalContext ( editor , row )
60
-
61
- return completions ( {
76
+ return baselineCompletionAdapter ( {
62
77
// general
63
78
line,
64
79
path : editor . getPath ( ) ,
@@ -69,6 +84,7 @@ class AutoCompleteProvider {
69
84
startRow,
70
85
column : column + 1 ,
71
86
// configurations
87
+ is_fuzzy : this . fuzzyCompletionMode ,
72
88
force : activatedManually || false ,
73
89
} ) . then ( completions => {
74
90
return completions . map ( completion => {
@@ -119,7 +135,7 @@ class AutoCompleteProvider {
119
135
}
120
136
121
137
onDidInsertSuggestion ( { editor, suggestion : { type } } ) {
122
- if ( type !== 'function' || atom . config . get ( 'julia-client.juliaOptions. noAutoParenthesis' ) ) return
138
+ if ( type !== 'function' || this . noAutoParenthesis ) return
123
139
editor . mutateSelectedText ( selection => {
124
140
if ( ! selection . isEmpty ( ) ) return
125
141
const { row, column } = selection . getBufferRange ( ) . start
0 commit comments