···2929 then go (x :: acc) xs
3030 else (joinBy "/" (xs :< x <>> Nil), joinBy "." acc)
31313232-3332switchModule : FileSource → String → M (Maybe ModContext)
3433switchModule repo modns = do
3534 -- TODO processing on hover is expensive, but info is not always there
···6968 pure $ HasHover e.fc ("\{show e.name} : \{rpprint Nil ty}")
70697170 where
7171+ -- We don't want to pick up the paren token when on the border
7272+ isIdent : BTok → Bool
7373+ isIdent (MkBounded (Tok Ident _) _) = True
7474+ isIdent (MkBounded (Tok UIdent _) _) = True
7575+ isIdent (MkBounded (Tok MixFix _) _) = True
7676+ isIdent (MkBounded (Tok Projection _) _) = True
7777+ isIdent _ = False
7878+7279 getTok : List BTok → Maybe String
7380 getTok Nil = Nothing
7481 getTok (tok :: toks) =
7575- if tok.bounds.startCol <= col && (col <= tok.bounds.endCol)
8282+ if tok.bounds.startCol <= col && col <= tok.bounds.endCol && isIdent tok
7683 then Just $ value tok else getTok toks
77847885data FileEdit = MkEdit FC String
+23-1
src/LSP.newt
···1616import Lib.ProcessDecl
1717import Lib.Prettier
1818import Lib.Error
1919+import Lib.Compile
19202021pfunc js_castArray : Array JSObject → JSObject := `x => x`
2122pfunc js_castInt : Int → JSObject := `x => x`
···224225 modifyIORef state $ [ topContext := top ]
225226 pure $ jsonToJObject $ JsonArray json
226227227227-#export updateFile checkFile hoverInfo codeActionInfo
228228+compileJS : String → JSObject
229229+compileJS fn = unsafePerformIO $ do
230230+ let (base, modName) = decomposeName fn
231231+ st <- readIORef state
232232+ when (st.baseDir /= base) $ \ _ => resetState base
233233+ repo <- lspFileSource
234234+ (Right (top, src)) <- (do
235235+ putStrLn "woo"
236236+ mod <- processModule emptyFC repo Nil modName
237237+ docs <- compile
238238+ let src = unlines $
239239+ ( "const bouncer = (f,ini) => { let obj = ini; while (obj.tag) obj = f(obj); return obj.h0 };"
240240+ :: Nil)
241241+ ++ map (render 90 ∘ noAlt) docs
242242+ pure src).runM st.topContext
243243+ | Left err => pure $ js_castStr "// \{errorMsg err}"
244244+ modifyIORef state [ topContext := top ]
245245+ pure $ js_castStr src
246246+247247+248248+249249+#export updateFile checkFile hoverInfo codeActionInfo compileJS
+8-8
src/Lib/Derive.newt
···37373838 where
3939 arr : Raw → Raw → Raw
4040- arr a b = RPi emptyFC (BI fc "_" Explicit Many) a b
4040+ arr a b = RPi fc (BI fc "_" Explicit Many) a b
41414242 rvar : String → Raw
4343- rvar nm = RVar emptyFC nm
4343+ rvar nm = RVar fc nm
44444545 getExplictNames : SnocList String → Tm → List String
4646 getExplictNames acc (Pi fc nm Explicit quant a b) = getExplictNames (acc :< nm) b
···4949 getExplictNames acc _ = acc <>> Nil
50505151 buildApp : String → List Raw → Raw
5252- buildApp nm nms = foldl (\ t u => RApp emptyFC t u Explicit) (rvar nm) $ nms
5252+ buildApp nm nms = foldl (\ t u => RApp fc t u Explicit) (rvar nm) $ nms
53535454 equate : (Raw × Raw) → Raw
5555 equate (a,b) = buildApp "_==_" (a :: b :: Nil)
···89899090 where
9191 arr : Raw → Raw → Raw
9292- arr a b = RPi emptyFC (BI fc "_" Explicit Many) a b
9292+ arr a b = RPi fc (BI fc "_" Explicit Many) a b
93939494 rvar : String → Raw
9595- rvar nm = RVar emptyFC nm
9595+ rvar nm = RVar fc nm
96969797 lstring : String → Raw
9898- lstring s = RLit emptyFC (LString s)
9898+ lstring s = RLit fc (LString s)
9999100100 getExplictNames : SnocList String → Tm → List String
101101 getExplictNames acc (Pi fc nm Explicit quant a b) = getExplictNames (acc :< nm) b
···104104 getExplictNames acc _ = acc <>> Nil
105105106106 buildApp : String → List Raw → Raw
107107- buildApp nm nms = foldl (\ t u => RApp emptyFC t u Explicit) (rvar nm) $ nms
107107+ buildApp nm nms = foldl (\ t u => RApp fc t u Explicit) (rvar nm) $ nms
108108109109 equate : (Raw × Raw) → Raw
110110 equate (a,b) = buildApp "_==_" (a :: b :: Nil)
···118118 let names = getExplictNames Lin ty
119119 anames <- map rvar <$> traverse freshName names
120120 let left = buildApp "show" $ buildApp nm anames :: Nil
121121- let shows = map (\ nm => RApp emptyFC (rvar "show") nm Explicit) anames
121121+ let shows = map (\ nm => RApp fc (rvar "show") nm Explicit) anames
122122 let right = case anames of
123123 Nil => lstring nm
124124 _ =>