From f685bda6aec7f214b5637a999292548496b1b0af Mon Sep 17 00:00:00 2001 From: Ting-gian LUA Date: Thu, 14 Dec 2023 23:44:42 +0800 Subject: [PATCH] [ fix ] Patch path to the "data" directory when the executable is built on GitHub Actions --- CHANGELOG.md | 8 +++++++- agda-language-server.cabal | 10 ++++++++-- app/Main.hs | 15 ++++++++++++++- package.yaml | 4 +++- src/Server.hs | 4 +++- 5 files changed, 35 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed29086..0724fcc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). -## v0.2.6.4.0 - unreleased +## v0.2.6.4.0.2 - 2023-12-14 + +### Fixed +- Add missing handlers for `lsp` methods. +- Patch path to the "data" directory when the executable is built on GitHub Actions. + +## v0.2.6.4.0.0 - 2023-12-12 ### Changed - Embed Agda-2.6.4. diff --git a/agda-language-server.cabal b/agda-language-server.cabal index 1bd5d1f..77aedd3 100644 --- a/agda-language-server.cabal +++ b/agda-language-server.cabal @@ -1,11 +1,11 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.36.0. +-- This file has been generated from package.yaml by hpack version 0.35.2. -- -- see: https://github.com/sol/hpack name: agda-language-server -version: 0.2.6.4.0 +version: 0.2.6.4.0.2 synopsis: An implementation of language server protocal (LSP) for Agda 2. description: Please see the README on GitHub at category: Development @@ -83,6 +83,8 @@ library , base >=4.7 && <5 , bytestring , containers + , directory + , filepath , lsp <2 , lsp-types <2 , mtl @@ -125,6 +127,8 @@ executable als , base >=4.7 && <5 , bytestring , containers + , directory + , filepath , lsp <2 , lsp-types <2 , mtl @@ -194,6 +198,8 @@ test-suite als-test , base >=4.7 && <5 , bytestring , containers + , directory + , filepath , lsp <2 , lsp-types <2 , mtl diff --git a/app/Main.hs b/app/Main.hs index 196d3a5..f880241 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -1,9 +1,12 @@ module Main where +import Control.Monad (when) import Options import Server (run) import System.Console.GetOpt -import System.Environment (getArgs) +import System.Directory (doesDirectoryExist) +import System.Environment +import System.FilePath (()) import System.IO import Text.Read (readMaybe) @@ -14,6 +17,16 @@ main = do hSetEncoding stdout utf8 hSetEncoding stdin utf8 + -- The GitHub CI-built executable lacks the correct data directory path. + -- If there's directory named "data" in the executable's directory, + -- then we assume that the executable is built by GitHub CI + -- and we should set the $Agda_datadir environment variable to the correct directory. + executablePath <- getExecutablePath + let dataDir = executablePath "data" + isBuiltByCI <- doesDirectoryExist dataDir + when isBuiltByCI $ do + setEnv "Agda_datadir" dataDir + options <- getOptionsFromArgv if optHelp options then putStrLn usageMessage diff --git a/package.yaml b/package.yaml index 48d2c76..e13907c 100644 --- a/package.yaml +++ b/package.yaml @@ -1,5 +1,5 @@ name: agda-language-server -version: 0.2.6.4.0.1 +version: 0.2.6.4.0.2 github: "banacorn/agda-language-server" license: MIT author: "Ting-Gian LUA" @@ -55,6 +55,8 @@ dependencies: - aeson - bytestring - containers + - directory + - filepath - lsp-types < 2 - lsp < 2 - mtl diff --git a/src/Server.hs b/src/Server.hs index d7b110d..7ca31a0 100644 --- a/src/Server.hs +++ b/src/Server.hs @@ -110,7 +110,9 @@ handlers = result <- Handler.onHover uri pos responder $ Right result, notificationHandler SInitialized $ \_not -> pure (), - notificationHandler STextDocumentDidOpen $ \_not -> pure () + notificationHandler STextDocumentDidOpen $ \_not -> pure (), + notificationHandler STextDocumentDidSave $ \_not -> pure (), + notificationHandler STextDocumentDidChange $ \_not -> pure () -- -- syntax highlighting -- , requestHandler STextD_cumentSemanticTokensFull $ \req responder -> do -- result <- Handler.onHighlight (req ^. (params . textDocument . uri))