Skip to content
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
7a54a1d
WIP: add basic boilerplate for signature help plugin
jian-lin Jun 8, 2025
9168b74
WIP: finish signature help plugin MVP
jian-lin Jul 10, 2025
4d7fa57
WIP: remove unused dependencies
jian-lin Jul 16, 2025
622c8ec
WIP: fix func-tests
jian-lin Jul 16, 2025
62fbccf
WIP: add basic tests
jian-lin Jul 16, 2025
a6635ca
Change expected test results considering the cursor shape
jian-lin Jul 24, 2025
bf0b4d5
Replace maybe with case for better readability
jian-lin Jul 24, 2025
c95d6e4
Call extractInfoFromSmallestContainingFunctionApplicationAst once
jian-lin Jul 25, 2025
3dc1ec8
Add missing ParameterInformation for multi-line tests
jian-lin Aug 3, 2025
dca1311
Add a signature help test for type constraint with kind signatures
jian-lin Aug 2, 2025
471958f
Add a signature help test for higher-order function
jian-lin Aug 2, 2025
d603ec4
Show more types: each type as one signature help
jian-lin Aug 3, 2025
faa4e48
Adjust import for the removal of hie-compat (#4613)
jian-lin Aug 3, 2025
9bea0e3
Use structured type and type string to generate signature help
jian-lin Aug 7, 2025
db5e59e
Add signature help test: 2 type constraints
jian-lin Aug 7, 2025
fdd5acd
Add signature help test: middle =>
jian-lin Aug 7, 2025
c6ece42
Add signature help test: => in argument
jian-lin Aug 7, 2025
fe2d618
Add 2 signature help tests: RankNTypes(forall in middle)
jian-lin Aug 7, 2025
c3224d7
Add signature help test: LinearTypes
jian-lin Aug 7, 2025
081ea8f
Add another signature help tests: RankNTypes(forall in middle)
jian-lin Aug 7, 2025
a522e88
Show function documentation in signature help
jian-lin Aug 14, 2025
d826d06
Show function argument documentation in signature help
jian-lin Aug 15, 2025
62f2e41
Rename a local variable
jian-lin Aug 16, 2025
35399e7
Do not error if doc is not available
jian-lin Aug 16, 2025
c0f7844
Add a helper function to create markdown doc
jian-lin Aug 16, 2025
eeeb283
Make signature helps reproducible before comparing them
jian-lin Aug 21, 2025
f1d19ba
Do not show uris in the argument documentation
jian-lin Aug 21, 2025
433a8ad
Add a signature help test: imported function with argument doc
jian-lin Aug 21, 2025
d3d7d12
Add a signature help test: imported function with no doc
jian-lin Aug 21, 2025
e0a7e8b
Remove an outdated TODO item
jian-lin Aug 21, 2025
e6702b7
Remember previous active signature
jian-lin Aug 21, 2025
3d7a67b
Update a TODO item
jian-lin Aug 21, 2025
800f908
Show signature help even when there are type applications
jian-lin Aug 21, 2025
cb84480
Fix some tests for ghc > 9.8 due to changed doc
jian-lin Aug 22, 2025
c7931a2
Fix some tests for ghc > 9.8 due to changed type: Any -> ZonkAny 0
jian-lin Aug 22, 2025
b6d4617
Add jian-lin as codeowner of hls-signature-help-plugin
jian-lin Aug 22, 2025
9a1de4e
Add hls-signature-help-plugin to some documentation files
jian-lin Aug 22, 2025
5925c1c
Use T.isInfixOf as equality check for doc string
jian-lin Aug 28, 2025
9c97238
Replace string interpolation lib in signature help tests
jian-lin Aug 30, 2025
195db18
Mark broken tests as expected failures
jian-lin Aug 30, 2025
f5a9858
Remove outdated TODO items
jian-lin Aug 30, 2025
9c87ef4
Format with ormolu
jian-lin Aug 31, 2025
8d6b1bb
Mention signature help plugin in configuration.md
jian-lin Aug 31, 2025
757d4a5
Unify argument and parameter
jian-lin Aug 31, 2025
b5c13a3
Use record syntax for data with many fields
jian-lin Sep 1, 2025
d0200a4
Format empty lambda case
jian-lin Sep 1, 2025
01ff52a
Add comments requested by reviewers
jian-lin Sep 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@ jobs:
name: Compile the plugin-tutorial
run: cabal build plugin-tutorial

- if: matrix.test
name: Test hls-signature-help-plugin test suite
run: cabal test hls-signature-help-plugin-tests || cabal test hls-signature-help-plugin-tests

test_post_job:
if: always()
runs-on: ubuntu-latest
Expand Down
12 changes: 10 additions & 2 deletions ghcide/src/Development/IDE/GHC/Compat/Outputable.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module Development.IDE.GHC.Compat.Outputable (
ppr, pprPanic, text, vcat, (<+>), ($$), empty, hang, nest, punctuate,
printSDocQualifiedUnsafe,
printWithoutUniques,
printWithoutUniquesOneLine,
mkPrintUnqualifiedDefault,
PrintUnqualified,
defaultUserStyle,
Expand All @@ -27,6 +28,7 @@ module Development.IDE.GHC.Compat.Outputable (
pprMsgEnvelopeBagWithLoc,
Error.getMessages,
renderWithContext,
showSDocOneLine,
defaultSDocContext,
errMsgDiagnostic,
unDecorated,
Expand Down Expand Up @@ -76,8 +78,14 @@ type PrintUnqualified = NamePprCtx
--
-- It print with a user-friendly style like: `a_a4ME` as `a`.
printWithoutUniques :: Outputable a => a -> String
printWithoutUniques =
renderWithContext (defaultSDocContext
printWithoutUniques = printWithoutUniques' renderWithContext

printWithoutUniquesOneLine :: Outputable a => a -> String
printWithoutUniquesOneLine = printWithoutUniques' showSDocOneLine

printWithoutUniques' :: Outputable a => (SDocContext -> SDoc -> String) -> a -> String
printWithoutUniques' showSDoc =
showSDoc (defaultSDocContext
{
sdocStyle = defaultUserStyle
, sdocSuppressUniques = True
Expand Down
11 changes: 9 additions & 2 deletions ghcide/src/Development/IDE/GHC/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module Development.IDE.GHC.Util(
dontWriteHieFiles,
disableWarningsAsErrors,
printOutputable,
printOutputableOneLine,
getExtensions,
stripOccNamePrefix,
) where
Expand Down Expand Up @@ -264,11 +265,17 @@ ioe_dupHandlesNotCompatible h =
-- 1. print with a user-friendly style: `a_a4ME` as `a`.
-- 2. unescape escape sequences of printable unicode characters within a pair of double quotes
printOutputable :: Outputable a => a -> T.Text
printOutputable =
printOutputable = printOutputable' printWithoutUniques

printOutputableOneLine :: Outputable a => a -> T.Text
printOutputableOneLine = printOutputable' printWithoutUniquesOneLine

printOutputable' :: Outputable a => (a -> String) -> a -> T.Text
printOutputable' print =
-- IfaceTyLit from GHC.Iface.Type implements Outputable with 'show'.
-- Showing a String escapes non-ascii printable characters. We unescape it here.
-- More discussion at https://github.com/haskell/haskell-language-server/issues/3115.
unescape . T.pack . printWithoutUniques
unescape . T.pack . print
{-# INLINE printOutputable #-}

getExtensions :: ParsedModule -> [Extension]
Expand Down
52 changes: 52 additions & 0 deletions haskell-language-server.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,57 @@ test-suite hls-stan-plugin-tests
default-extensions:
OverloadedStrings

-----------------------------
-- signature help plugin
-----------------------------

flag signatureHelp
description: Enable signature help plugin
default: True
manual: True

common signatureHelp
if flag(signatureHelp)
build-depends: haskell-language-server:hls-signature-help-plugin
cpp-options: -Dhls_signatureHelp

-- TODO(@linj) remove unneeded deps
library hls-signature-help-plugin
import: defaults, pedantic, warnings
if !flag(signatureHelp)
buildable: False
exposed-modules: Ide.Plugin.SignatureHelp
hs-source-dirs: plugins/hls-signature-help-plugin/src
default-extensions:
DerivingStrategies
LambdaCase
OverloadedStrings
build-depends:
, containers
, ghc
, ghcide == 2.11.0.0
, hls-plugin-api == 2.11.0.0
, lsp-types
, text


test-suite hls-signature-help-plugin-tests
import: defaults, pedantic, test-defaults, warnings
if !flag(signatureHelp)
buildable: False
type: exitcode-stdio-1.0
hs-source-dirs: plugins/hls-signature-help-plugin/test
main-is: Main.hs
build-depends:
, ghcide
, haskell-language-server:hls-signature-help-plugin
, hls-test-utils == 2.11.0.0
, lens
, lsp-types
, text
default-extensions:
OverloadedStrings

-----------------------------
-- module name plugin
-----------------------------
Expand Down Expand Up @@ -1846,6 +1897,7 @@ library
, retrie
, hlint
, stan
, signatureHelp
, moduleName
, pragmas
, splice
Expand Down
1 change: 1 addition & 0 deletions hls-plugin-api/src/Ide/Plugin/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ parsePluginConfig def = A.withObject "PluginConfig" $ \o -> PluginConfig
<*> o .:? "diagnosticsOn" .!= plcDiagnosticsOn def -- AZ
<*> o .:? "hoverOn" .!= plcHoverOn def
<*> o .:? "symbolsOn" .!= plcSymbolsOn def
<*> o .:? "signatureHelpOn" .!= plcSignatureHelpOn def
<*> o .:? "completionOn" .!= plcCompletionOn def
<*> o .:? "renameOn" .!= plcRenameOn def
<*> o .:? "selectionRangeOn" .!= plcSelectionRangeOn def
Expand Down
2 changes: 2 additions & 0 deletions hls-plugin-api/src/Ide/Plugin/ConfigUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ pluginsToDefaultConfig IdePlugins {..} =
SMethod_TextDocumentRename -> ["renameOn" A..= plcRenameOn]
SMethod_TextDocumentHover -> ["hoverOn" A..= plcHoverOn]
SMethod_TextDocumentDocumentSymbol -> ["symbolsOn" A..= plcSymbolsOn]
SMethod_TextDocumentSignatureHelp -> ["signatureHelpOn" A..= plcSignatureHelpOn]
SMethod_TextDocumentCompletion -> ["completionOn" A..= plcCompletionOn]
SMethod_TextDocumentPrepareCallHierarchy -> ["callHierarchyOn" A..= plcCallHierarchyOn]
SMethod_TextDocumentSemanticTokensFull -> ["semanticTokensOn" A..= plcSemanticTokensOn]
Expand Down Expand Up @@ -137,6 +138,7 @@ pluginsToVSCodeExtensionSchema IdePlugins {..} = A.object $ mconcat $ singlePlug
SMethod_TextDocumentRename -> [toKey' "renameOn" A..= schemaEntry "rename" plcRenameOn]
SMethod_TextDocumentHover -> [toKey' "hoverOn" A..= schemaEntry "hover" plcHoverOn]
SMethod_TextDocumentDocumentSymbol -> [toKey' "symbolsOn" A..= schemaEntry "symbols" plcSymbolsOn]
SMethod_TextDocumentSignatureHelp -> [toKey' "signatureHelpOn" A..= schemaEntry "signature help" plcSignatureHelpOn]
SMethod_TextDocumentCompletion -> [toKey' "completionOn" A..= schemaEntry "completions" plcCompletionOn]
SMethod_TextDocumentPrepareCallHierarchy -> [toKey' "callHierarchyOn" A..= schemaEntry "call hierarchy" plcCallHierarchyOn]
SMethod_TextDocumentSemanticTokensFull -> [toKey' "semanticTokensOn" A..= schemaEntry "semantic tokens" plcSemanticTokensOn]
Expand Down
12 changes: 11 additions & 1 deletion hls-plugin-api/src/Ide/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ data PluginConfig =
, plcDiagnosticsOn :: !Bool
, plcHoverOn :: !Bool
, plcSymbolsOn :: !Bool
, plcSignatureHelpOn :: !Bool
, plcCompletionOn :: !Bool
, plcRenameOn :: !Bool
, plcSelectionRangeOn :: !Bool
Expand All @@ -281,6 +282,7 @@ instance Default PluginConfig where
, plcDiagnosticsOn = True
, plcHoverOn = True
, plcSymbolsOn = True
, plcSignatureHelpOn = True
, plcCompletionOn = True
, plcRenameOn = True
, plcSelectionRangeOn = True
Expand All @@ -290,7 +292,7 @@ instance Default PluginConfig where
}

instance ToJSON PluginConfig where
toJSON (PluginConfig g ch ca ih cl d h s c rn sr fr st cfg) = r
toJSON (PluginConfig g ch ca ih cl d h s sh c rn sr fr st cfg) = r
where
r = object [ "globalOn" .= g
, "callHierarchyOn" .= ch
Expand All @@ -300,6 +302,7 @@ instance ToJSON PluginConfig where
, "diagnosticsOn" .= d
, "hoverOn" .= h
, "symbolsOn" .= s
, "signatureHelpOn" .= sh
, "completionOn" .= c
, "renameOn" .= rn
, "selectionRangeOn" .= sr
Expand Down Expand Up @@ -541,6 +544,9 @@ instance PluginMethod Request Method_TextDocumentHover where
instance PluginMethod Request Method_TextDocumentDocumentSymbol where
handlesRequest = pluginEnabledWithFeature plcSymbolsOn

instance PluginMethod Request Method_TextDocumentSignatureHelp where
handlesRequest = pluginEnabledWithFeature plcSignatureHelpOn

instance PluginMethod Request Method_CompletionItemResolve where
-- See Note [Resolve in PluginHandlers]
handlesRequest = pluginEnabledResolve plcCompletionOn
Expand Down Expand Up @@ -764,6 +770,10 @@ instance PluginRequestMethod Method_TextDocumentDocumentSymbol where
si = SymbolInformation name' (ds ^. L.kind) Nothing parent (ds ^. L.deprecated) loc
in [si] <> children'

-- TODO(@linj) is this correct?
instance PluginRequestMethod Method_TextDocumentSignatureHelp where
combineResponses _ _ _ _ (x :| _) = x

instance PluginRequestMethod Method_CompletionItemResolve where
-- A resolve request should only have one response.
-- See Note [Resolve in PluginHandlers]
Expand Down
Loading
Loading