-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for emacs [nockma-mode](anoma/juvix-mode#25). The list of features is given in the link. It adds the following commands: 1. `juvix dev nockma ide check`. Parses a nockma file (used by flycheck only). 2. `juvix dev nockma ide highlight`. Highlights a nockma file. 3. `juvix dev nockma ide rules`. Shows all evaluation rules properly highlighted in emacs.
- Loading branch information
1 parent
200daad
commit 536ba6c
Showing
52 changed files
with
1,428 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module Commands.Dev.Nockma.Ide where | ||
|
||
import Commands.Base | ||
import Commands.Dev.Nockma.Ide.Check as Check | ||
import Commands.Dev.Nockma.Ide.Highlight as Highlight | ||
import Commands.Dev.Nockma.Ide.Options | ||
import Commands.Dev.Nockma.Ide.Rules as Rules | ||
|
||
runCommand :: | ||
forall r. | ||
(Members AppEffects r) => | ||
NockmaIdeCommand -> | ||
Sem r () | ||
runCommand = \case | ||
NockmaIdeHighlight opts -> Highlight.runCommand opts | ||
NockmaIdeCheck opts -> Check.runCommand opts | ||
NockmaIdeRules {} -> Rules.runCommand |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module Commands.Dev.Nockma.Ide.Check where | ||
|
||
import Commands.Base hiding (Atom) | ||
import Commands.Dev.Nockma.Ide.Check.Options | ||
import Juvix.Compiler.Nockma.Highlight | ||
import Juvix.Compiler.Nockma.Translation.FromSource qualified as Nockma | ||
|
||
runCommand :: forall r. (Members AppEffects r) => NockmaCheckOptions -> Sem r () | ||
runCommand opts = do | ||
afile <- fromAppPathFile (opts ^. nockmaCheckFile) | ||
void | ||
. runAppError @JuvixError | ||
. ignoreHighlightBuilder | ||
$ Nockma.parseTermFile afile | ||
renderStdOutLn ("Ok" :: Text) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module Commands.Dev.Nockma.Ide.Check.Options where | ||
|
||
import CommonOptions | ||
|
||
newtype NockmaCheckOptions = NockmaCheckOptions | ||
{ _nockmaCheckFile :: AppPath File | ||
} | ||
deriving stock (Data) | ||
|
||
makeLenses ''NockmaCheckOptions | ||
|
||
parseNockmaCheckOptions :: Parser NockmaCheckOptions | ||
parseNockmaCheckOptions = do | ||
_nockmaCheckFile <- parseInputFile FileExtNockma | ||
pure NockmaCheckOptions {..} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module Commands.Dev.Nockma.Ide.Highlight where | ||
|
||
import Commands.Base hiding (Atom) | ||
import Commands.Dev.Nockma.Ide.Highlight.Options | ||
import Juvix.Compiler.Nockma.Highlight | ||
import Juvix.Compiler.Nockma.Translation.FromSource qualified as Nockma | ||
|
||
runCommand :: forall r. (Members AppEffects r) => NockmaHighlightOptions -> Sem r () | ||
runCommand opts = silenceProgressLog . runPipelineOptions $ do | ||
afile <- fromAppPathFile (opts ^. nockmaHighlightFile) | ||
hinput <- | ||
fmap (filterInput afile) | ||
. runJuvixErrorHighlight | ||
. execHighlightBuilder | ||
$ Nockma.parseTermFile afile | ||
renderStdOutRaw (highlight hinput) | ||
newline | ||
|
||
runJuvixErrorHighlight :: forall r. Sem (Error JuvixError ': r) HighlightInput -> Sem r HighlightInput | ||
runJuvixErrorHighlight m = do | ||
res <- runError m | ||
return $ case res of | ||
Right r -> r | ||
Left err -> | ||
emptyHighlightInput | ||
{ _highlightErrors = [getLoc err] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module Commands.Dev.Nockma.Ide.Highlight.Options where | ||
|
||
import CommonOptions | ||
|
||
newtype NockmaHighlightOptions = NockmaHighlightOptions | ||
{ _nockmaHighlightFile :: AppPath File | ||
} | ||
deriving stock (Data) | ||
|
||
makeLenses ''NockmaHighlightOptions | ||
|
||
parseNockmaHighlightOptions :: Parser NockmaHighlightOptions | ||
parseNockmaHighlightOptions = do | ||
_nockmaHighlightFile <- parseInputFile FileExtNockma | ||
pure NockmaHighlightOptions {..} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
module Commands.Dev.Nockma.Ide.Options where | ||
|
||
import Commands.Dev.Nockma.Ide.Check.Options | ||
import Commands.Dev.Nockma.Ide.Highlight.Options | ||
import CommonOptions | ||
|
||
data NockmaIdeCommand | ||
= NockmaIdeHighlight NockmaHighlightOptions | ||
| NockmaIdeCheck NockmaCheckOptions | ||
| NockmaIdeRules | ||
deriving stock (Data) | ||
|
||
parseNockmaIdeCommand :: Parser NockmaIdeCommand | ||
parseNockmaIdeCommand = | ||
hsubparser $ | ||
mconcat | ||
[ commandHighlight, | ||
commandCheck, | ||
commandRules | ||
] | ||
where | ||
commandHighlight :: Mod CommandFields NockmaIdeCommand | ||
commandHighlight = command "highlight" runInfo | ||
where | ||
runInfo :: ParserInfo NockmaIdeCommand | ||
runInfo = | ||
info | ||
(NockmaIdeHighlight <$> parseNockmaHighlightOptions) | ||
(progDesc "Highlight a nockma term (only for Emacs)") | ||
|
||
commandRules :: Mod CommandFields NockmaIdeCommand | ||
commandRules = command "rules" runInfo | ||
where | ||
runInfo :: ParserInfo NockmaIdeCommand | ||
runInfo = | ||
info | ||
(pure NockmaIdeRules) | ||
(progDesc "Print the nockma evaluation rules") | ||
|
||
commandCheck :: Mod CommandFields NockmaIdeCommand | ||
commandCheck = command "check" runInfo | ||
where | ||
runInfo :: ParserInfo NockmaIdeCommand | ||
runInfo = | ||
info | ||
(NockmaIdeCheck <$> parseNockmaCheckOptions) | ||
(progDesc "Parse a nockma term") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module Commands.Dev.Nockma.Ide.Rules where | ||
|
||
import Commands.Base | ||
import Juvix.Compiler.Nockma.Highlight.Doc | ||
import Juvix.Emacs.Render | ||
import Juvix.Emacs.SExp | ||
|
||
runCommand :: forall r. (Members AppEffects r) => Sem r () | ||
runCommand = do | ||
let (txt, format) = renderEmacs allRules | ||
ret = Pair (String txt) format | ||
renderStdOutLn (toPlainText ret) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.