Skip to content

Commit 90f38f0

Browse files
committed
hls-pragmas-plugin: Simply completion and add comments
1 parent 974d591 commit 90f38f0

File tree

1 file changed

+14
-5
lines changed
  • plugins/hls-pragmas-plugin/src/Ide/Plugin

1 file changed

+14
-5
lines changed

plugins/hls-pragmas-plugin/src/Ide/Plugin/Pragmas.hs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,15 +195,24 @@ completion _ide _ complParams = do
195195
= [ mkPragmaCompl (a <> suffix) b c
196196
| (a, b, c, w) <- validPragmas, w == NewLine
197197
]
198-
| "import" `T.isPrefixOf` line || not (T.null module_) || T.null word
198+
| -- Do not suggest any pragmas any of these conditions:
199+
-- 1. Current line is a an import
200+
-- 2. There is a module name right before the current word.
201+
-- Something like `Text.la` shouldn't suggest adding the
202+
-- 'LANGUAGE' pragma.
203+
-- 3. The user has not typed anything yet.
204+
"import" `T.isPrefixOf` line || not (T.null module_) || T.null word
199205
= []
200206
| otherwise
201207
= [ mkPragmaCompl (prefix <> pragmaTemplate <> suffix) matcher detail
202208
| (pragmaTemplate, matcher, detail, appearWhere) <- validPragmas
203-
, Fuzzy.test word matcher
204-
, (appearWhere == NewLine && line == word)
205-
|| (appearWhere == CanInline && line /= word)
206-
|| (T.elem ' ' matcher && appearWhere == NewLine && Fuzzy.test line matcher)
209+
, -- Only suggest a pragma that need its own line if the whole line
210+
-- fuzzily matches the pragma
211+
(appearWhere == NewLine && Fuzzy.test line matcher ) ||
212+
-- Only suggest a pragma that appears in the middle of a line when
213+
-- the current word is not the only thing in the line and the
214+
-- current word fuzzily matches the pragma
215+
(appearWhere == CanInline && line /= word && Fuzzy.test word matcher)
207216
]
208217
where
209218
line = T.toLower $ VFS.fullLine pfix

0 commit comments

Comments
 (0)