From 2cb98aa4206fb288f6223fff68d36436d91c04f5 Mon Sep 17 00:00:00 2001 From: 0rphee <0rph3e@proton.me> Date: Mon, 23 Oct 2023 12:06:38 -0600 Subject: [PATCH 1/7] Re-add deleted stan files from #3782 --- bench/config.yaml | 1 + cabal.project | 1 + docs/features.md | 6 + haskell-language-server.cabal | 11 + plugins/hls-stan-plugin/LICENSE | 201 ++++++++++++++++++ plugins/hls-stan-plugin/hls-stan-plugin.cabal | 83 ++++++++ .../hls-stan-plugin/src/Ide/Plugin/Stan.hs | 123 +++++++++++ plugins/hls-stan-plugin/test/Main.hs | 46 ++++ .../test/testdata/.hie/Main.hie | Bin 0 -> 1056 bytes .../hls-stan-plugin/test/testdata/hie.yaml | 4 + plugins/hls-stan-plugin/test/testdata/test.hs | 4 + src/HlsPlugins.hs | 7 + stack-lts21.yaml | 1 + stack.yaml | 1 + 14 files changed, 489 insertions(+) create mode 100644 plugins/hls-stan-plugin/LICENSE create mode 100644 plugins/hls-stan-plugin/hls-stan-plugin.cabal create mode 100644 plugins/hls-stan-plugin/src/Ide/Plugin/Stan.hs create mode 100644 plugins/hls-stan-plugin/test/Main.hs create mode 100644 plugins/hls-stan-plugin/test/testdata/.hie/Main.hie create mode 100644 plugins/hls-stan-plugin/test/testdata/hie.yaml create mode 100644 plugins/hls-stan-plugin/test/testdata/test.hs diff --git a/bench/config.yaml b/bench/config.yaml index 146c3876bf..f8a062dc3d 100644 --- a/bench/config.yaml +++ b/bench/config.yaml @@ -221,4 +221,5 @@ configurations: # - rename # - retrie # - splice +# - stan # # - stylish-haskell diff --git a/cabal.project b/cabal.project index 75dbc2656b..a6f139f07a 100644 --- a/cabal.project +++ b/cabal.project @@ -28,6 +28,7 @@ packages: ./plugins/hls-qualify-imported-names-plugin ./plugins/hls-code-range-plugin ./plugins/hls-change-type-signature-plugin + ./plugins/hls-stan-plugin ./plugins/hls-gadt-plugin ./plugins/hls-explicit-fixity-plugin ./plugins/hls-explicit-record-fields-plugin diff --git a/docs/features.md b/docs/features.md index 05b5de40f8..41767d64ed 100644 --- a/docs/features.md +++ b/docs/features.md @@ -38,6 +38,12 @@ Provided by: `hls-hlint-plugin` Provides hlint hints as diagnostics. +### Stan hints + +Provided by: `hls-stan-plugin` + +Provides Stan hints as diagnostics. + ### Cabal parse errors and warnings Provided by: `hls-cabal-plugin` diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index 715950a049..314f7cc261 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -104,6 +104,11 @@ flag hlint default: True manual: True +flag stan + description: Enable stan plugin + default: True + manual: True + flag moduleName description: Enable moduleName plugin default: True @@ -241,6 +246,11 @@ common hlint build-depends: hls-hlint-plugin == 2.4.0.0 cpp-options: -Dhls_hlint +common stan + if flag(stan) && (impl(ghc >= 8.10) && impl(ghc < 9.0)) + build-depends: hls-stan-plugin == 2.2.0.0 + cpp-options: -Dhls_stan + common moduleName if flag(moduleName) build-depends: hls-module-name-plugin == 2.4.0.0 @@ -339,6 +349,7 @@ library , rename , retrie , hlint + , stan , moduleName , pragmas , splice diff --git a/plugins/hls-stan-plugin/LICENSE b/plugins/hls-stan-plugin/LICENSE new file mode 100644 index 0000000000..261eeb9e9f --- /dev/null +++ b/plugins/hls-stan-plugin/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/plugins/hls-stan-plugin/hls-stan-plugin.cabal b/plugins/hls-stan-plugin/hls-stan-plugin.cabal new file mode 100644 index 0000000000..a9dfad2634 --- /dev/null +++ b/plugins/hls-stan-plugin/hls-stan-plugin.cabal @@ -0,0 +1,83 @@ +cabal-version: 2.4 +name: hls-stan-plugin +version: 2.2.0.0 +synopsis: Stan integration plugin with Haskell Language Server +description: + Please see the README on GitHub at + +license: Apache-2.0 +license-file: LICENSE +author: The Haskell IDE Team +maintainer: uhbif19@gmail.com +copyright: The Haskell IDE Team +category: Development +build-type: Simple +extra-source-files: + LICENSE + test/testdata/*.hs + +source-repository head + type: git + location: https://github.com/haskell/haskell-language-server.git + +flag pedantic + description: Enable -Werror + default: False + manual: True + +library + if impl(ghc < 8.10) || impl(ghc >= 9.0) + buildable: False + else + buildable: True + exposed-modules: Ide.Plugin.Stan + hs-source-dirs: src + build-depends: + base + , containers + , data-default + , deepseq + , hashable + , hls-plugin-api + , ghc + , ghcide + , lsp-types + , text + , transformers + , unordered-containers + , stan + + default-language: Haskell2010 + default-extensions: + LambdaCase + NamedFieldPuns + DeriveGeneric + TypeFamilies + StandaloneDeriving + DuplicateRecordFields + OverloadedStrings + +test-suite test + if impl(ghc < 8.10) || impl(ghc >= 9.0) + buildable: False + else + buildable: True + type: exitcode-stdio-1.0 + default-language: Haskell2010 + hs-source-dirs: test + main-is: Main.hs + ghc-options: -threaded -rtsopts -with-rtsopts=-N + build-depends: + aeson + , base + , containers + , filepath + , hls-stan-plugin + , hls-plugin-api + , hls-test-utils == 2.2.0.0 + , lens + , lsp-types + , text + default-extensions: + NamedFieldPuns + OverloadedStrings diff --git a/plugins/hls-stan-plugin/src/Ide/Plugin/Stan.hs b/plugins/hls-stan-plugin/src/Ide/Plugin/Stan.hs new file mode 100644 index 0000000000..732d94066e --- /dev/null +++ b/plugins/hls-stan-plugin/src/Ide/Plugin/Stan.hs @@ -0,0 +1,123 @@ +module Ide.Plugin.Stan (descriptor, Log) where + +import Control.DeepSeq (NFData) +import Control.Monad (void) +import Control.Monad.IO.Class (liftIO) +import Control.Monad.Trans.Class (lift) +import Control.Monad.Trans.Maybe (MaybeT (MaybeT), runMaybeT) +import Data.Default +import Data.Foldable (toList) +import Data.Hashable (Hashable) +import qualified Data.HashMap.Strict as HM +import qualified Data.Map as Map +import Data.Maybe (fromJust, mapMaybe) +import qualified Data.Text as T +import Development.IDE +import Development.IDE (Diagnostic (_codeDescription)) +import Development.IDE.Core.Rules (getHieFile, + getSourceFileSource) +import Development.IDE.Core.RuleTypes (HieAstResult (..)) +import qualified Development.IDE.Core.Shake as Shake +import Development.IDE.GHC.Compat (HieASTs (HieASTs), + RealSrcSpan (..), mkHieFile', + mkRealSrcLoc, mkRealSrcSpan, + runHsc, srcSpanEndCol, + srcSpanEndLine, + srcSpanStartCol, + srcSpanStartLine, tcg_exports) +import Development.IDE.GHC.Error (realSrcSpanToRange) +import GHC.Generics (Generic) +import HieTypes (HieASTs, HieFile) +import Ide.Plugin.Config +import Ide.Types (PluginDescriptor (..), + PluginId, configHasDiagnostics, + defaultConfigDescriptor, + defaultPluginDescriptor, + pluginEnabledConfig) +import qualified Language.LSP.Protocol.Types as LSP +import Stan.Analysis (Analysis (..), runAnalysis) +import Stan.Category (Category (..)) +import Stan.Core.Id (Id (..)) +import Stan.Inspection (Inspection (..)) +import Stan.Inspection.All (inspectionsIds, inspectionsMap) +import Stan.Observation (Observation (..)) + +descriptor :: Recorder (WithPriority Log) -> PluginId -> PluginDescriptor IdeState +descriptor recorder plId = (defaultPluginDescriptor plId) + { pluginRules = rules recorder plId + , pluginConfigDescriptor = defaultConfigDescriptor + { configHasDiagnostics = True + } + } + +newtype Log = LogShake Shake.Log deriving (Show) + +instance Pretty Log where + pretty = \case + LogShake log -> pretty log + +data GetStanDiagnostics = GetStanDiagnostics + deriving (Eq, Show, Generic) + +instance Hashable GetStanDiagnostics + +instance NFData GetStanDiagnostics + +type instance RuleResult GetStanDiagnostics = () + +rules :: Recorder (WithPriority Log) -> PluginId -> Rules () +rules recorder plId = do + define (cmapWithPrio LogShake recorder) $ + \GetStanDiagnostics file -> do + config <- getPluginConfigAction plId + if pluginEnabledConfig plcDiagnosticsOn config then do + maybeHie <- getHieFile file + case maybeHie of + Nothing -> return ([], Nothing) + Just hie -> do + let enabledInspections = HM.fromList [(LSP.fromNormalizedFilePath file, inspectionsIds)] + -- This should use Cabal config for extensions and Stan config for inspection preferences is the future + let analysis = runAnalysis Map.empty enabledInspections [] [hie] + return (analysisToDiagnostics file analysis, Just ()) + else return ([], Nothing) + + action $ do + files <- getFilesOfInterestUntracked + void $ uses GetStanDiagnostics $ HM.keys files + where + analysisToDiagnostics :: NormalizedFilePath -> Analysis -> [FileDiagnostic] + analysisToDiagnostics file = mapMaybe (observationToDianostic file) . toList . analysisObservations + observationToDianostic :: NormalizedFilePath -> Observation -> Maybe FileDiagnostic + observationToDianostic file Observation {observationSrcSpan, observationInspectionId} = + do + inspection <- HM.lookup observationInspectionId inspectionsMap + let + -- Looking similar to Stan CLI output + -- We do not use `prettyShowInspection` cuz Id is redundant here + -- `prettyShowSeverity` and `prettyShowCategory` would contain color + -- codes and are replaced, too + message :: T.Text + message = + T.unlines $ + [ " ✲ Name: " <> inspectionName inspection, + " ✲ Description: " <> inspectionDescription inspection, + " ✲ Severity: " <> (T.pack $ show $ inspectionSeverity inspection), + " ✲ Category: " <> T.intercalate " " + (map (("#" <>) . unCategory) $ toList $ inspectionCategory inspection), + "Possible solutions:" + ] + ++ map (" - " <>) (inspectionSolution inspection) + return ( file, + ShowDiag, + LSP.Diagnostic + { _range = realSrcSpanToRange observationSrcSpan, + _severity = Just LSP.DiagnosticSeverity_Hint, + _code = Just (LSP.InR $ unId (inspectionId inspection)), + _source = Just "stan", + _message = message, + _relatedInformation = Nothing, + _tags = Nothing, + _codeDescription = Nothing, + _data_ = Nothing + } + ) diff --git a/plugins/hls-stan-plugin/test/Main.hs b/plugins/hls-stan-plugin/test/Main.hs new file mode 100644 index 0000000000..6c27e399d3 --- /dev/null +++ b/plugins/hls-stan-plugin/test/Main.hs @@ -0,0 +1,46 @@ +module Main + ( main, + ) +where + +import Control.Lens ((^.)) +import Control.Monad (void) +import Data.List (find) +import Data.Text (Text) +import qualified Data.Text as T +import qualified Data.Text.IO as T +import qualified Ide.Plugin.Stan as Stan +import qualified Language.LSP.Protocol.Lens as L +import System.FilePath +import Test.Hls + +main :: IO () +main = defaultTestRunner tests + +tests :: TestTree +tests = + testGroup + "stan suggestions" + [ testCase "provides diagnostics" $ + runStanSession "" $ do + doc <- openDoc "test.hs" "haskell" + diags@(reduceDiag : _) <- waitForDiagnosticsFromSource doc "stan" + liftIO $ do + length diags @?= 1 + reduceDiag ^. L.range @?= Range (Position 0 0) (Position 3 19) + reduceDiag ^. L.severity @?= Just DiagnosticSeverity_Hint + let expectedPrefix = " ✲ Name: " + assertBool "" $ T.isPrefixOf expectedPrefix (reduceDiag ^. L.message) + reduceDiag ^. L.source @?= Just "stan" + return () + ] + +testDir :: FilePath +testDir = "test/testdata" + +stanPlugin :: PluginTestDescriptor Stan.Log +stanPlugin = mkPluginTestDescriptor Stan.descriptor "stan" + +runStanSession :: FilePath -> Session a -> IO a +runStanSession subdir = + failIfSessionTimeout . runSessionWithServer def stanPlugin (testDir subdir) diff --git a/plugins/hls-stan-plugin/test/testdata/.hie/Main.hie b/plugins/hls-stan-plugin/test/testdata/.hie/Main.hie new file mode 100644 index 0000000000000000000000000000000000000000..0c7367ab46d26d5db6079a385348b51447d72c49 GIT binary patch literal 1056 zcmZ8g+iuf95Z#$w-yJ&_xAelr@QR4qMxuQvmD;M*NUe%mRG!_$B^Ie|c^yb3K826q z3-}4%`2ZgI0%n~{QKMvbX3p%{xg~mcvbVjpYwvZpx4OGFW4y~4emAN_R^6dw4A{md zqeG}KB9bnc5KKc36e$P-gDhPsmav4d9L;vQWTh2s%0Lgh{@wn zJMS)-Dnn%t~yv71|~ua#CS+hjd+U&2fJNUwC{lw{IbY&jpgXvXuSLsTeU1}G_VNvLjJed@w z7D);x<6{{YRwOUJB;{FJK@3HEKg+{W-jAy^&%!jj%@3dyH?d6o)9AQ+RmJ_!-4D|u uk!}>r<9IZxUDk3uFoCK0Y1n^Nl y = 2 + | otherwise = 3 diff --git a/src/HlsPlugins.hs b/src/HlsPlugins.hs index aadd56bbde..4d37185998 100644 --- a/src/HlsPlugins.hs +++ b/src/HlsPlugins.hs @@ -50,6 +50,10 @@ import qualified Ide.Plugin.Retrie as Retrie import qualified Ide.Plugin.Hlint as Hlint #endif +#if hls_stan +import qualified Ide.Plugin.Stan as Stan +#endif + #if hls_moduleName import qualified Ide.Plugin.ModuleName as ModuleName #endif @@ -186,6 +190,9 @@ idePlugins recorder = pluginDescToIdePlugins allPlugins #if hls_hlint let pId = "hlint" in Hlint.descriptor (pluginRecorder pId) pId: #endif +#if hls_stan + let pId = "stan" in Stan.descriptor (pluginRecorder pId) pId : +#endif #if hls_splice Splice.descriptor "splice" : #endif diff --git a/stack-lts21.yaml b/stack-lts21.yaml index 5f26370a2a..ae19bc5e6c 100644 --- a/stack-lts21.yaml +++ b/stack-lts21.yaml @@ -33,6 +33,7 @@ packages: - ./plugins/hls-rename-plugin - ./plugins/hls-retrie-plugin - ./plugins/hls-splice-plugin + # - ./plugins/hls-stan-plugin - ./plugins/hls-stylish-haskell-plugin ghc-options: diff --git a/stack.yaml b/stack.yaml index bba26fd4b6..a89f47f2f1 100644 --- a/stack.yaml +++ b/stack.yaml @@ -33,6 +33,7 @@ packages: - ./plugins/hls-rename-plugin - ./plugins/hls-retrie-plugin - ./plugins/hls-splice-plugin + # - ./plugins/hls-stan-plugin - ./plugins/hls-stylish-haskell-plugin ghc-options: From 942e914e8f125f192b43867503dbd0e7903b4ac3 Mon Sep 17 00:00:00 2001 From: 0rphee <0rph3e@proton.me> Date: Mon, 23 Oct 2023 17:41:16 -0600 Subject: [PATCH 2/7] Bump ghc and dependency bounds for stan plugin Fix ghc bounds for stan plugin Update index-state --- cabal.project | 2 +- haskell-language-server.cabal | 4 ++-- plugins/hls-stan-plugin/hls-stan-plugin.cabal | 17 +++++++++-------- plugins/hls-stan-plugin/src/Ide/Plugin/Stan.hs | 2 +- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/cabal.project b/cabal.project index a6f139f07a..6f1eb57888 100644 --- a/cabal.project +++ b/cabal.project @@ -35,7 +35,7 @@ packages: ./plugins/hls-refactor-plugin ./plugins/hls-overloaded-record-dot-plugin -index-state: 2023-10-06T06:12:29Z +index-state: 2023-10-30T20:39:48Z tests: True test-show-details: direct diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index 314f7cc261..8c8c7eb77e 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -247,8 +247,8 @@ common hlint cpp-options: -Dhls_hlint common stan - if flag(stan) && (impl(ghc >= 8.10) && impl(ghc < 9.0)) - build-depends: hls-stan-plugin == 2.2.0.0 + if flag(stan) && (impl(ghc > 8.8.1) && impl(ghc <= 9.2.3) || impl(ghc >= 9.4.0) && impl(ghc < 9.8.0)) + build-depends: hls-stan-plugin == 2.4.0.0 cpp-options: -Dhls_stan common moduleName diff --git a/plugins/hls-stan-plugin/hls-stan-plugin.cabal b/plugins/hls-stan-plugin/hls-stan-plugin.cabal index a9dfad2634..bd38ea5fbc 100644 --- a/plugins/hls-stan-plugin/hls-stan-plugin.cabal +++ b/plugins/hls-stan-plugin/hls-stan-plugin.cabal @@ -1,6 +1,6 @@ cabal-version: 2.4 name: hls-stan-plugin -version: 2.2.0.0 +version: 2.4.0.0 synopsis: Stan integration plugin with Haskell Language Server description: Please see the README on GitHub at @@ -26,10 +26,10 @@ flag pedantic manual: True library - if impl(ghc < 8.10) || impl(ghc >= 9.0) - buildable: False - else + if (impl(ghc > 8.8.1) && impl(ghc <= 9.2.3) || impl(ghc >= 9.4.0) && impl(ghc < 9.8.0)) buildable: True + else + buildable: False exposed-modules: Ide.Plugin.Stan hs-source-dirs: src build-depends: @@ -38,6 +38,7 @@ library , data-default , deepseq , hashable + , hie-compat , hls-plugin-api , ghc , ghcide @@ -58,10 +59,10 @@ library OverloadedStrings test-suite test - if impl(ghc < 8.10) || impl(ghc >= 9.0) - buildable: False - else + if (impl(ghc > 8.8.1) && impl(ghc <= 9.2.3) || impl(ghc >= 9.4.0) && impl(ghc < 9.8.0)) buildable: True + else + buildable: False type: exitcode-stdio-1.0 default-language: Haskell2010 hs-source-dirs: test @@ -74,7 +75,7 @@ test-suite test , filepath , hls-stan-plugin , hls-plugin-api - , hls-test-utils == 2.2.0.0 + , hls-test-utils == 2.4.0.0 , lens , lsp-types , text diff --git a/plugins/hls-stan-plugin/src/Ide/Plugin/Stan.hs b/plugins/hls-stan-plugin/src/Ide/Plugin/Stan.hs index 732d94066e..c44805df7a 100644 --- a/plugins/hls-stan-plugin/src/Ide/Plugin/Stan.hs +++ b/plugins/hls-stan-plugin/src/Ide/Plugin/Stan.hs @@ -1,5 +1,6 @@ module Ide.Plugin.Stan (descriptor, Log) where +import Compat.HieTypes (HieASTs, HieFile) import Control.DeepSeq (NFData) import Control.Monad (void) import Control.Monad.IO.Class (liftIO) @@ -27,7 +28,6 @@ import Development.IDE.GHC.Compat (HieASTs (HieASTs), srcSpanStartLine, tcg_exports) import Development.IDE.GHC.Error (realSrcSpanToRange) import GHC.Generics (Generic) -import HieTypes (HieASTs, HieFile) import Ide.Plugin.Config import Ide.Types (PluginDescriptor (..), PluginId, configHasDiagnostics, From 01602a539dc201bf3ce51b90a130627fd1059097 Mon Sep 17 00:00:00 2001 From: 0rphee <0rph3e@proton.me> Date: Mon, 30 Oct 2023 14:15:46 -0600 Subject: [PATCH 3/7] Add hls-stan-plugin dependencies to stack.yaml --- stack-lts21.yaml | 15 ++++++++++++++- stack.yaml | 15 ++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/stack-lts21.yaml b/stack-lts21.yaml index ae19bc5e6c..2ff1179cb6 100644 --- a/stack-lts21.yaml +++ b/stack-lts21.yaml @@ -33,7 +33,7 @@ packages: - ./plugins/hls-rename-plugin - ./plugins/hls-retrie-plugin - ./plugins/hls-splice-plugin - # - ./plugins/hls-stan-plugin + - ./plugins/hls-stan-plugin - ./plugins/hls-stylish-haskell-plugin ghc-options: @@ -55,6 +55,19 @@ extra-deps: - lsp-test-0.16.0.0 - lsp-types-2.0.2.0 +# stan dependencies not found in the stackage snapshot +- stan-0.1.0.2 +- clay-0.14.0 +- colourista-0.1.0.2 +- dir-traverse-0.2.3.0 +- extensions-0.1.0.0 +- relude-1.2.1.0 +- slist-0.2.1.0 +- tomland-1.3.3.2 +- trial-0.0.0.0 +- trial-optparse-applicative-0.0.0.0 +- trial-tomland-0.0.0.0 +- validation-selective-0.2.0.0 configure-options: ghcide: diff --git a/stack.yaml b/stack.yaml index a89f47f2f1..fcab6c3892 100644 --- a/stack.yaml +++ b/stack.yaml @@ -33,7 +33,7 @@ packages: - ./plugins/hls-rename-plugin - ./plugins/hls-retrie-plugin - ./plugins/hls-splice-plugin - # - ./plugins/hls-stan-plugin + - ./plugins/hls-stan-plugin - ./plugins/hls-stylish-haskell-plugin ghc-options: @@ -56,6 +56,19 @@ extra-deps: - lsp-test-0.16.0.0 - lsp-types-2.0.2.0 +# stan dependencies not found in the stackage snapshot +- stan-0.1.0.2 +- clay-0.14.0 +- colourista-0.1.0.2 +- dir-traverse-0.2.3.0 +- extensions-0.1.0.1 +- relude-1.2.1.0 +- slist-0.2.1.0 +- tomland-1.3.3.2 +- trial-0.0.0.0 +- trial-optparse-applicative-0.0.0.0 +- trial-tomland-0.0.0.0 +- validation-selective-0.2.0.0 configure-options: ghcide: From 300559b66cf5e16d73c9b1ca50bbf38e9a49e544 Mon Sep 17 00:00:00 2001 From: 0rphee <0rph3e@proton.me> Date: Mon, 30 Oct 2023 14:40:01 -0600 Subject: [PATCH 4/7] Re-add hls-stan-plugin info to docs --- docs/configuration.md | 2 +- docs/support/plugin-support.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/configuration.md b/docs/configuration.md index 4e06d21c4c..6da737d6b4 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -50,7 +50,7 @@ Here is a list of the additional settings currently supported by `haskell-langua Plugins have a generic config to control their behaviour. The schema of such config is: - `haskell.plugin.${pluginName}.globalOn`: usually with default true. Whether the plugin is enabled at runtime or it is not. That is the option you might use if you want to disable completely a plugin. - - Actual plugin names are: `ghcide-code-actions-fill-holes`, `ghcide-completions`, `ghcide-hover-and-symbols`, `ghcide-type-lenses`, `ghcide-code-actions-type-signatures`, `ghcide-code-actions-bindings`, `ghcide-code-actions-imports-exports`, `eval`, `moduleName`, `pragmas`, `importLens`, `class`, `hlint`, `retrie`, `rename`, `splice`. + - Actual plugin names are: `ghcide-code-actions-fill-holes`, `ghcide-completions`, `ghcide-hover-and-symbols`, `ghcide-type-lenses`, `ghcide-code-actions-type-signatures`, `ghcide-code-actions-bindings`, `ghcide-code-actions-imports-exports`, `eval`, `moduleName`, `pragmas`, `importLens`, `class`, `hlint`, `retrie`, `rename`, `splice`, `stan`. - So to disable the import lens with an explicit list of module definitions you could set `haskell.plugin.importLens.globalOn: false` - `haskell.plugin.${pluginName}.${lspCapability}On`: usually with default true. Whether a concrete plugin capability is enabled. - Capabilities are the different ways a lsp server can interact with the editor. The current available capabilities of the server are: `callHierarchy`, `codeActions`, `codeLens`, `diagnostics`, `hover`, `symbols`, `completion`, `rename`. diff --git a/docs/support/plugin-support.md b/docs/support/plugin-support.md index aa16132943..e21e5e4412 100644 --- a/docs/support/plugin-support.md +++ b/docs/support/plugin-support.md @@ -62,5 +62,6 @@ For example, a plugin to provide a formatter which has itself been abandoned has | `hls-stylish-haskell-plugin` | 2 | | | `hls-overloaded-record-dot-plugin` | 2 | 8.10, 9.0 | | `hls-floskell-plugin` | 3 | 9.6 | +| `hls-stan-plugin` | 3 | 8.6, 9.2.(4-8), 9.8 | | `hls-retrie-plugin` | 3 | | | `hls-splice-plugin` | 3 | | From 2bcdb045561e1b84d4fbd8ee10477a7246f91b2d Mon Sep 17 00:00:00 2001 From: 0rphee <0rph3e@proton.me> Date: Mon, 30 Oct 2023 14:50:31 -0600 Subject: [PATCH 5/7] Add myself (@0rphee) to CODEOWNERS --- CODEOWNERS | 1 + 1 file changed, 1 insertion(+) diff --git a/CODEOWNERS b/CODEOWNERS index fdb10aa538..fa6be0f263 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -29,6 +29,7 @@ /plugins/hls-code-range-plugin @kokobd /plugins/hls-splice-plugin @konn /plugins/hls-stylish-haskell-plugin @Ailrun +/plugins/hls-stan-plugin @0rphee /plugins/hls-explicit-record-fields-plugin @ozkutuk /plugins/hls-overloaded-record-dot-plugin @joyfulmantis From f82ae7a6cd971d87cd54989740d05e5bf9c9fabd Mon Sep 17 00:00:00 2001 From: 0rphee <0rph3e@proton.me> Date: Sat, 18 Nov 2023 08:07:49 -0600 Subject: [PATCH 6/7] Re-add hls-stan-plugin test suite to gh action --- .github/workflows/test.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 48d0668db9..1551958630 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -159,6 +159,10 @@ jobs: name: Test hls-splice-plugin run: cabal test hls-splice-plugin --test-options="$TEST_OPTS" || cabal test hls-splice-plugin --test-options="$TEST_OPTS" + - if: matrix.test && matrix.ghc != '9.2' && !startsWith(matrix.ghc,'9.8') + name: Test hls-stan-plugin + run: cabal test hls-stan-plugin --test-options="$TEST_OPTS" || cabal test hls-stan-plugin --test-options="$TEST_OPTS" + - if: matrix.test && !startsWith(matrix.ghc,'9.8') name: Test hls-stylish-haskell-plugin run: cabal test hls-stylish-haskell-plugin --test-options="$TEST_OPTS" || cabal test hls-stylish-haskell-plugin --test-options="$TEST_OPTS" From 2dfd661a7b6debc24b91dd76713b377adb98d211 Mon Sep 17 00:00:00 2001 From: 0rphee <0rph3e@proton.me> Date: Sat, 18 Nov 2023 09:35:57 -0600 Subject: [PATCH 7/7] Update hls-stan-plugin bounds --- .github/workflows/test.yml | 2 +- docs/support/plugin-support.md | 2 +- haskell-language-server.cabal | 2 +- plugins/hls-stan-plugin/hls-stan-plugin.cabal | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1551958630..400ad0c3df 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -159,7 +159,7 @@ jobs: name: Test hls-splice-plugin run: cabal test hls-splice-plugin --test-options="$TEST_OPTS" || cabal test hls-splice-plugin --test-options="$TEST_OPTS" - - if: matrix.test && matrix.ghc != '9.2' && !startsWith(matrix.ghc,'9.8') + - if: matrix.test && matrix.ghc != '9.2' name: Test hls-stan-plugin run: cabal test hls-stan-plugin --test-options="$TEST_OPTS" || cabal test hls-stan-plugin --test-options="$TEST_OPTS" diff --git a/docs/support/plugin-support.md b/docs/support/plugin-support.md index f79c59e30e..42118574fb 100644 --- a/docs/support/plugin-support.md +++ b/docs/support/plugin-support.md @@ -62,6 +62,6 @@ For example, a plugin to provide a formatter which has itself been abandoned has | `hls-stylish-haskell-plugin` | 2 | 9.8 | | `hls-overloaded-record-dot-plugin` | 2 | 9.0 | | `hls-floskell-plugin` | 3 | 9.6, 9.8 | -| `hls-stan-plugin` | 3 | 9.2.(4-8), 9.8 | +| `hls-stan-plugin` | 3 | 9.2.(4-8) | | `hls-retrie-plugin` | 3 | 9.8 | | `hls-splice-plugin` | 3 | 9.8 | diff --git a/haskell-language-server.cabal b/haskell-language-server.cabal index 1215e3357d..c925b91691 100644 --- a/haskell-language-server.cabal +++ b/haskell-language-server.cabal @@ -247,7 +247,7 @@ common hlint cpp-options: -Dhls_hlint common stan - if flag(stan) && (impl(ghc > 8.8.1) && impl(ghc <= 9.2.3) || impl(ghc >= 9.4.0) && impl(ghc < 9.8.0)) + if flag(stan) && (impl(ghc > 8.8.1) && impl(ghc <= 9.2.3) || impl(ghc >= 9.4.0) && impl(ghc < 9.10.0)) build-depends: hls-stan-plugin == 2.4.0.0 cpp-options: -Dhls_stan diff --git a/plugins/hls-stan-plugin/hls-stan-plugin.cabal b/plugins/hls-stan-plugin/hls-stan-plugin.cabal index bd38ea5fbc..51574b257e 100644 --- a/plugins/hls-stan-plugin/hls-stan-plugin.cabal +++ b/plugins/hls-stan-plugin/hls-stan-plugin.cabal @@ -26,7 +26,7 @@ flag pedantic manual: True library - if (impl(ghc > 8.8.1) && impl(ghc <= 9.2.3) || impl(ghc >= 9.4.0) && impl(ghc < 9.8.0)) + if (impl(ghc > 8.8.1) && impl(ghc <= 9.2.3) || impl(ghc >= 9.4.0) && impl(ghc < 9.10.0)) buildable: True else buildable: False @@ -59,7 +59,7 @@ library OverloadedStrings test-suite test - if (impl(ghc > 8.8.1) && impl(ghc <= 9.2.3) || impl(ghc >= 9.4.0) && impl(ghc < 9.8.0)) + if (impl(ghc > 8.8.1) && impl(ghc <= 9.2.3) || impl(ghc >= 9.4.0) && impl(ghc < 9.10.0)) buildable: True else buildable: False