@@ -210,22 +210,24 @@ completion _ide _ complParams = do
210
210
result <$> VFS. getCompletionPrefix position cnts
211
211
where
212
212
result (Just pfix)
213
- | " {-# language" `T.isPrefixOf` T. toLower ( VFS. fullLine pfix)
213
+ | " {-# language" `T.isPrefixOf` line
214
214
= J. List $ map buildCompletion
215
215
(Fuzzy. simpleFilter (VFS. prefixText pfix) allPragmas)
216
- | " {-# options_ghc" `T.isPrefixOf` T. toLower ( VFS. fullLine pfix)
216
+ | " {-# options_ghc" `T.isPrefixOf` line
217
217
= J. List $ map mkExtCompl
218
218
(Fuzzy. simpleFilter (VFS. prefixText pfix) flags)
219
- -- if there already is a closing bracket - complete without one
220
- | isPragmaPrefix (VFS. fullLine pfix) && " }" `T.isSuffixOf` VFS. fullLine pfix
221
- = J. List $ map (\ (a, b, c) -> mkPragmaCompl a b c) (validPragmas Nothing )
222
- -- if there is no closing bracket - complete with one
223
- | isPragmaPrefix (VFS. fullLine pfix)
224
- = J. List $ map (\ (a, b, c) -> mkPragmaCompl a b c) (validPragmas (Just " }" ))
219
+ | " {-#" `T.isPrefixOf` line
220
+ = J. List $ map (\ (a, b, c) -> mkPragmaCompl (a <> suffix) b c) validPragmas
225
221
| otherwise
226
222
= J. List []
223
+ where
224
+ line = T. toLower $ VFS. fullLine pfix
225
+ suffix
226
+ | " #-}" `T.isSuffixOf` line = " "
227
+ | " -}" `T.isSuffixOf` line = " #"
228
+ | " }" `T.isSuffixOf` line = " #-"
229
+ | otherwise = " #-}"
227
230
result Nothing = J. List []
228
- isPragmaPrefix line = " {-#" `T.isPrefixOf` line
229
231
buildCompletion p =
230
232
J. CompletionItem
231
233
{ _label = p,
@@ -247,24 +249,22 @@ completion _ide _ complParams = do
247
249
_xdata = Nothing
248
250
}
249
251
_ -> return $ J. List []
252
+
250
253
-----------------------------------------------------------------------
251
- validPragmas :: Maybe T. Text -> [(T. Text , T. Text , T. Text )]
252
- validPragmas mSuffix =
253
- [ (" LANGUAGE ${1:extension} #- " <> suffix , " LANGUAGE" , " {-# LANGUAGE #-}" )
254
- , (" OPTIONS_GHC -${1:option} #- " <> suffix , " OPTIONS_GHC" , " {-# OPTIONS_GHC #-}" )
255
- , (" INLINE ${1:function} #- " <> suffix , " INLINE" , " {-# INLINE #-}" )
256
- , (" NOINLINE ${1:function} #- " <> suffix , " NOINLINE" , " {-# NOINLINE #-}" )
257
- , (" INLINABLE ${1:function} #- " <> suffix , " INLINABLE" , " {-# INLINABLE #-}" )
258
- , (" WARNING ${1:message} #- " <> suffix , " WARNING" , " {-# WARNING #-}" )
259
- , (" DEPRECATED ${1:message} #- " <> suffix , " DEPRECATED" , " {-# DEPRECATED #-}" )
260
- , (" ANN ${1:annotation} #- " <> suffix , " ANN" , " {-# ANN #-}" )
261
- , (" RULES #- " <> suffix , " RULES" , " {-# RULES #-}" )
262
- , (" SPECIALIZE ${1:function} #- " <> suffix , " SPECIALIZE" , " {-# SPECIALIZE #-}" )
263
- , (" SPECIALIZE INLINE ${1:function} #- " <> suffix , " SPECIALIZE INLINE" , " {-# SPECIALIZE INLINE #-}" )
254
+ validPragmas :: [(T. Text , T. Text , T. Text )]
255
+ validPragmas =
256
+ [ (" LANGUAGE ${1:extension}" , " LANGUAGE" , " {-# LANGUAGE #-}" )
257
+ , (" OPTIONS_GHC -${1:option}" , " OPTIONS_GHC" , " {-# OPTIONS_GHC #-}" )
258
+ , (" INLINE ${1:function}" , " INLINE" , " {-# INLINE #-}" )
259
+ , (" NOINLINE ${1:function}" , " NOINLINE" , " {-# NOINLINE #-}" )
260
+ , (" INLINABLE ${1:function}" , " INLINABLE" , " {-# INLINABLE #-}" )
261
+ , (" WARNING ${1:message}" , " WARNING" , " {-# WARNING #-}" )
262
+ , (" DEPRECATED ${1:message}" , " DEPRECATED" , " {-# DEPRECATED #-}" )
263
+ , (" ANN ${1:annotation}" , " ANN" , " {-# ANN #-}" )
264
+ , (" RULES" , " RULES" , " {-# RULES #-}" )
265
+ , (" SPECIALIZE ${1:function}" , " SPECIALIZE" , " {-# SPECIALIZE #-}" )
266
+ , (" SPECIALIZE INLINE ${1:function}" , " SPECIALIZE INLINE" , " {-# SPECIALIZE INLINE #-}" )
264
267
]
265
- where suffix = case mSuffix of
266
- (Just s) -> s
267
- Nothing -> " "
268
268
269
269
270
270
mkPragmaCompl :: T. Text -> T. Text -> T. Text -> J. CompletionItem
0 commit comments