Skip to content

Commit 1b0f64f

Browse files
committed
Initial set up to provide pragma completions.
1 parent b649b15 commit 1b0f64f

File tree

2 files changed

+60
-43
lines changed

2 files changed

+60
-43
lines changed

plugins/default/src/Ide/Plugin/Pragmas.hs

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,16 @@ import qualified Language.Haskell.LSP.Types.Lens as J
2121
import Development.IDE as D
2222
import Language.Haskell.LSP.Types
2323

24+
import qualified Language.Haskell.LSP.Core as LSP
25+
import qualified Language.Haskell.LSP.VFS as VFS
26+
2427
-- ---------------------------------------------------------------------
2528

2629
descriptor :: PluginId -> PluginDescriptor
2730
descriptor plId = (defaultPluginDescriptor plId)
2831
{ pluginCommands = commands
2932
, pluginCodeActionProvider = Just codeActionProvider
33+
, pluginCompletionProvider = Just completion
3034
}
3135

3236
-- ---------------------------------------------------------------------
@@ -160,3 +164,54 @@ possiblePragmas =
160164
]
161165

162166
-- ---------------------------------------------------------------------
167+
168+
completion :: CompletionProvider
169+
completion lspFuncs _ide complParams = do
170+
let (TextDocumentIdentifier uri) = complParams ^. J.textDocument
171+
position = complParams ^. J.position
172+
putStrLn $ "Uri" ++ show uri
173+
putStrLn $ "nor uri" ++ show (toNormalizedUri uri)
174+
contents <- LSP.getVirtualFileFunc lspFuncs $ toNormalizedUri uri
175+
fmap Right $ case (contents, uriToFilePath' uri) of
176+
(Just cnts, Just _path) -> do
177+
pfix <- VFS.getCompletionPrefix position cnts
178+
putStrLn $ "pfix" ++ show pfix
179+
return $ Completions $ List [r]
180+
where
181+
r =
182+
CompletionItem
183+
label
184+
kind
185+
tags
186+
detail
187+
documentation
188+
deprecated
189+
preselect
190+
sortText
191+
filterText
192+
insertText
193+
insertTextFormat
194+
textEdit
195+
additionalTextEdits
196+
commitCharacters
197+
command
198+
xd
199+
label = "Example Pragma completion"
200+
kind = Nothing
201+
tags = List []
202+
detail = Nothing
203+
documentation = Nothing
204+
deprecated = Nothing
205+
preselect = Nothing
206+
sortText = Nothing
207+
filterText = Nothing
208+
insertText = Nothing
209+
insertTextFormat = Nothing
210+
textEdit = Nothing
211+
additionalTextEdits = Nothing
212+
commitCharacters = Nothing
213+
command = Nothing
214+
xd = Nothing
215+
_ -> do
216+
putStrLn $ "Need to handle this path"'
217+
return $ Completions $ List []

stack.yaml

Lines changed: 5 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
resolver: lts-14.27 # Last 8.6.5
1+
resolver: nightly-2020-11-22
22

33
packages:
44
- .
@@ -14,70 +14,32 @@ ghc-options:
1414
"$everything": -haddock
1515

1616
extra-deps:
17-
- aeson-1.5.2.0
18-
- apply-refact-0.8.2.1
19-
- ansi-terminal-0.10.3
20-
- base-compat-0.10.5
2117
- github: bubba/brittany
2218
commit: c59655f10d5ad295c2481537fc8abf0a297d9d1c
23-
- butcher-1.3.3.1
2419
- Cabal-3.0.2.0
25-
- cabal-plan-0.6.2.0
2620
- clock-0.7.2
27-
- Diff-0.4.0
28-
- extra-1.7.3
21+
- data-tree-print-0.1.0.2
2922
- floskell-0.10.4
3023
- fourmolu-0.3.0.0
31-
- fuzzy-0.1.0.0
32-
# - ghcide-0.1.0
33-
- ghc-check-0.5.0.1
34-
- ghc-exactprint-0.6.3.2
35-
- ghc-lib-8.10.2.20200916
36-
- ghc-lib-parser-8.10.2.20200916
37-
- ghc-lib-parser-ex-8.10.0.16
38-
- ghc-source-gen-0.4.0.0
39-
- haddock-api-2.22.0@rev:1
40-
- haddock-library-1.8.0
41-
- haskell-lsp-0.22.0.0
42-
- haskell-lsp-types-0.22.0.0
43-
- hie-bios-0.7.1
44-
- hlint-3.2
45-
- HsYAML-0.2.1.0@rev:1
46-
- HsYAML-aeson-0.2.0.0@rev:2
4724
- implicit-hie-cradle-0.3.0.2
4825
- implicit-hie-0.1.2.5
49-
- indexed-profunctors-0.1
50-
- lens-4.18
5126
- lsp-test-0.11.0.6
5227
- monad-dijkstra-0.1.1.2
5328
- opentelemetry-0.4.2
54-
- optics-core-0.2
55-
- optparse-applicative-0.15.1.0
56-
- ormolu-0.1.4.1
57-
- parser-combinators-1.2.1
58-
- primitive-0.7.1.0
5929
- refinery-0.3.0.0
60-
- regex-base-0.94.0.0
61-
- regex-pcre-builtin-0.95.1.1.8.43
62-
- regex-tdfa-1.3.1.0
6330
- retrie-0.1.1.1
64-
- semialign-1.1
65-
# - github: wz1000/shake
66-
# commit: fb3859dca2e54d1bbb2c873e68ed225fa179fbef
6731
- stylish-haskell-0.12.2.0
68-
- tasty-rerun-1.1.17
32+
- semigroups-0.18.5
6933
- temporary-1.2.1.1
70-
- these-1.1.1.1
71-
- type-equality-1
72-
- topograph-1
7334

7435
flags:
7536
haskell-language-server:
7637
pedantic: true
7738
retrie:
7839
BuildExecutable: false
7940

80-
# allow-newer: true
41+
# for data-tree-print's bounds on base (>=4.8 && <4.14); using base-4.14.0.0.
42+
allow-newer: true
8143

8244
nix:
8345
packages: [ icu libcxx zlib ]

0 commit comments

Comments
 (0)