Skip to content

Commit

Permalink
hls-pragmas-plugin: Simply completion and add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
akshaymankar committed Jun 12, 2023
1 parent 974d591 commit 90f38f0
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions plugins/hls-pragmas-plugin/src/Ide/Plugin/Pragmas.hs
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,24 @@ completion _ide _ complParams = do
= [ mkPragmaCompl (a <> suffix) b c
| (a, b, c, w) <- validPragmas, w == NewLine
]
| "import" `T.isPrefixOf` line || not (T.null module_) || T.null word
| -- Do not suggest any pragmas any of these conditions:
-- 1. Current line is a an import
-- 2. There is a module name right before the current word.
-- Something like `Text.la` shouldn't suggest adding the
-- 'LANGUAGE' pragma.
-- 3. The user has not typed anything yet.
"import" `T.isPrefixOf` line || not (T.null module_) || T.null word
= []
| otherwise
= [ mkPragmaCompl (prefix <> pragmaTemplate <> suffix) matcher detail
| (pragmaTemplate, matcher, detail, appearWhere) <- validPragmas
, Fuzzy.test word matcher
, (appearWhere == NewLine && line == word)
|| (appearWhere == CanInline && line /= word)
|| (T.elem ' ' matcher && appearWhere == NewLine && Fuzzy.test line matcher)
, -- Only suggest a pragma that need its own line if the whole line
-- fuzzily matches the pragma
(appearWhere == NewLine && Fuzzy.test line matcher ) ||
-- Only suggest a pragma that appears in the middle of a line when
-- the current word is not the only thing in the line and the
-- current word fuzzily matches the pragma
(appearWhere == CanInline && line /= word && Fuzzy.test word matcher)
]
where
line = T.toLower $ VFS.fullLine pfix
Expand Down

0 comments on commit 90f38f0

Please sign in to comment.