Open Hi-Angel opened 8 years ago
@Hi-Angel Do you have Hint enabled? The default implementation of the describe name hook is
describeName :: String -> YiM String
describeName name = do
HelpCache cache <- getEditorDyn
description <- case name `M.lookup` cache of
Nothing -> do
result <- io $ LHI.runInterpreter $ do
LHI.set [LHI.searchPath LHI.:= []]
-- when haveUserContext $ do
-- LHI.loadModules [contextFile]
-- LHI.setTopLevelModules ["Env"]
LHI.setImportsQ [("Yi", Nothing), ("Yi.Keymap",Just "Yi.Keymap")]
LHI.typeOf name
let newDescription = either show id result
putEditorDyn $ HelpCache $ M.insert name newDescription cache
return newDescription
Just description -> return description
return $ name ++ " :: " ++ description
but only with Hint enabled.
Without hint:
publishedActionsEvaluator :: Evaluator
publishedActionsEvaluator = Evaluator
{ getAllNamesInScopeImpl = askCfg <&> M.keys . (^. publishedActions)
, execEditorActionImpl = \s ->
askCfg <&> M.lookup s . (^. publishedActions) >>= mapM_ runAction
, describeNamedActionImpl = return -- TODO: try to show types using TemplateHaskell!
}
So this task should be to do that TODO
about using TemplateHaskell
For this to work, we need to directly put the types into the publishedActions
config variable. We need a PublishedAction
datatype and need a function publishAction :: String -> Q Dec
whose return type is really a PublishedAction
. Then we will set up the list of types like $(publishAction "pointB")
@jhance how do I enable hint? I found here that by -f hint
flag, but it gives me yi: Panic: frontend not found
.
That should work... maybe try -f hint -f vty
@jhance nope, the same output.
Thats quite puzzling, is this a stable release or off master
?
Actually hint should be enabled by default, so its extra weird...
@jhance yep; in fact I just migrated to Archlinux, and I installed Haskell just yesterday to compile yi. So I can even list actions out of my memory (okay, and bash history):
cabal install
(here I got a little error)
Btw, I'm wondering, how would I execute functions inside Yi? E.g. how would I execute printMsg "hello"
in editor?
@Hi-Angel You could run like :yi printMsg "hello"
. However without hint support you may be limited in what functions you can run :(
I'm going to try switching my yi installation to the master
branch and see what happens.
I'm not sure if that relevant, but I got here ghc-8.0.1
to which I didn't even manage to find changelog, only a status page.
We should have ghc8 support iirc, although the stack config I've been using is locked to lts.
Can you tell if you have hint
installed as a dependency?
Hmm, I cannot reproduce this issue on master. I do :help pointB
and see pointB :: BufferM Point
. I used stack instead of cabal. This is my stack file:
resolver: lts-6.8
packages:
- yi-language
- yi
extra-deps: []
flags: {}
I build against yi-language
master but that should not be an issue.
Okay, I'm not at home ATM, I'll try when I got there to build it again with stack.
@jhance well, I'm in office managed to chroot into an Archlinux :Ь I didn't build with stack yet, am I understand right: I should copy the code you posted into a yi.yaml
, and run stack build
?
UPD: ah, never mind, I figured it out, it should've been stack.yaml
@Hi-Angel No, to build with stack you should probably run stack init
and then stack install --flag yi:hint --flag yi:vty
(the --flag yi:hint
and --flag yi:vty
are enabled by default and should not be necessary).
Alternatively, you can also try to run stack install yi --flag yi:hint --flag yi:vty
which installs Yi from stackage.
Edit: I just tried stack init
and stack install --flag yi:hint --flag yi:vty
and it works for me.
Edit2: I also tried the alternative and it works too (but it must be run from outside a stack project).
Thank you!
Okay, so I compiled it with stack install
(i.e. without --flag yi:hint --flag yi:vty
), and I see the same problem. I'll try in a minute to recompile it again with the flags (I'm not sure, do I need to run something to clean binary files, or a simple restart would be enough?).
You can run stack clean
to be sure that everything is cleaned, but I don't think it's necessary.
Anyway, I ran stack clean
, then compiled with stack install --flag yi:hint --flag yi:vty
, and I still getting the error
$ ~/.local/bin/yi -f hint -f vty
yi: Panic: frontend not found
You shouldn't run yi
with -f hint -f vty
. Yi should be run with just yi [file]
. Check yi --help
for all options. (The -f option is for selecting the frontend that is why it couldn't find the frontend).
Okay, so… Now, when I'm pressing :
(in vim keybindings), and typing any help
or yi
, it says Unknown command
. The cabal build, at least, has help
executed.
Also, per comments, commands with explicit hint
are triggering errors:
$ stack exec yi -- -f vty -f hint
Run from outside a project, using implicit global project config
Using resolver: lts-5.13 from implicit global project's config file: /home/constantine/.stack/global-project/stack.yaml
yi: Panic: frontend not found
$ stack exec yi -- -f hint
Run from outside a project, using implicit global project config
Using resolver: lts-5.13 from implicit global project's config file: /home/constantine/.stack/global-project/stack.yaml
yi: Panic: frontend not found
Oh, I'm sorry, never mind, the last time I ran commands were in the wrong tab, it was in the host system, not the chrooted one…
Anyway, the problem with frontend panic still persist, and trying to execute yi printMsg "hello"
results in:
error: WontCompile [GhcError {errMsg = "<interactive>:2:1:\n No instance for (Show x0) arising from a use of `makeAction'\n The type variable `x0' is ambiguous\n Note: there are several potential instances:\n instance Show a => Show (Maybe a) -- Defined in
Then it goes beyond the screen.
The -f hint
and -f vty
are compile time flags. They only need to be added when you are building Yi with cabal. The reason that Yi is complaining about missing the frontend is because the -f frontend
is a run time argument of Yi. Yi thinks you want to use the hint
frontend (which doesn't exist).
While playing around with :yi
I found out that there are still a lot of problems. I don't think it is ready for use.
Also the example-configs are outdated and need to be updated.
:yi printMsg "hello"
should be :yi EditorA $ printMsg "hello"
(see #872) but hint has issues (see #870) so it wont work yet. I split the rest of the issues in this thread into their own issues.
The core issue (of not being able to show types in some cases) still remains and isn't one of the separate issues you created.
If hint is disabled all published actions have type Action
right?
Damn, that close button is in the same place as the cancel button...
I feel like if you close and reopen in 5 seconds github should just not say you did either. It happens alot
Feature request: help message (e.g. typing :help in vim mode) could be more useful if after names it would include according types.