Skip to content

Commit

Permalink
fix to compile
Browse files Browse the repository at this point in the history
  • Loading branch information
B04902047 committed May 20, 2024
1 parent 3c51d7d commit 0678493
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 38 deletions.
2 changes: 2 additions & 0 deletions gcl.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ library
Server.Handler.GoToDefn
Server.Handler.Hover
Server.Handler2
Server.Handler2.AutoCompletion
Server.Handler2.CustomMethod
Server.Handler2.CustomMethod.HelloWorld
Server.Handler2.CustomMethod.InsertProofTemplate
Expand Down Expand Up @@ -229,6 +230,7 @@ test-suite gcl-test
Server.Handler.GoToDefn
Server.Handler.Hover
Server.Handler2
Server.Handler2.AutoCompletion
Server.Handler2.CustomMethod
Server.Handler2.CustomMethod.HelloWorld
Server.Handler2.CustomMethod.InsertProofTemplate
Expand Down
7 changes: 1 addition & 6 deletions src/Server/Handler2.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import qualified Server.Handler2.CustomMethod as CustomMethod
import qualified Server.Handler2.GoToDefinition as GoToDefinition
import qualified Server.Handler2.Hover as Hover
import qualified Server.Handler2.SemanticTokens as SemanticTokens
import qualified Server.Handler2.Reload as Reload

-- handlers of the LSP server
handlers :: Handlers ServerM
Expand All @@ -34,7 +33,7 @@ handlers = mconcat
requestHandler LSP.STextDocumentCompletion $ \req responder -> do
let completionContext = req ^. LSP.params . LSP.context
let position = req ^. LSP.params . LSP.position
AutoCompletion.handler position completionContext >>= (responder . Right . InR)
AutoCompletion.handler position completionContext >>= (responder . Right)
, -- "textDocument/definition" - go to definition
requestHandler LSP.STextDocumentDefinition $ \req responder -> do
let uri = req ^. (LSP.params . LSP.textDocument . LSP.uri)
Expand All @@ -53,9 +52,5 @@ handlers = mconcat
requestHandler (LSP.SCustomMethod "guabao") $ \req responder -> do
let params = req ^. LSP.params
CustomMethod.handler params (responder . Right . JSON.toJSON)
, -- "guabao/reload"
requestHandler (LSP.SCustomMethod "guabao/reload") $ \req responder -> do
let params = req ^. LSP.params
Reload.handler params (responder . Right . JSON.toJSON)
]

32 changes: 12 additions & 20 deletions src/Server/Handler2/AutoCompletion.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{-# LANGUAGE OverloadedStrings #-}

{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE DuplicateRecordFields #-}

module Server.Handler2.AutoCompletion where

import Data.Text ( Text )
Expand All @@ -14,7 +16,7 @@ handler position completionContext
| shouldTriggerUnicodeCompletion completionContext
= return $ CompletionList True (List (unicodeCompletionItems position))
| shouldTriggerDighole completionContext
= return $ CompletionList False (List [specBracketsCompletionItem])
= return $ CompletionList False (List [specBracketsCompletionItem position])
| otherwise
= return $ CompletionList True (List [])

Expand Down Expand Up @@ -197,37 +199,27 @@ makeItems position labels kind symbol detail doc = flip map labels $ \label ->
Just $ List [TextEdit (Range (Position ln (col - 1)) position) ""]
-- tempReplaceWithSymbol = Just $ CompletionEditText $ TextEdit (Range position (Position ln (col + 1 ))) "symbol"

specBracketsCompletionItem :: CompletionItem
specBracketsCompletionItem =
CompletionItem
specBracketsCompletionItem :: Position -> CompletionItem
specBracketsCompletionItem position = CompletionItem
{ _label = "?"
, _kind = Just CiSnippet
, _tags = Nothing -- ^ Tags for this completion item.
, _detail = Nothing -- ^ A human-readable string with additional
-- information about this item, like type or
-- symbol information.
, _tags = Nothing
, _detail = Nothing
, _documentation = Just (CompletionDocString "Type \"?\" and a space to insert a spec.")
, _deprecated = Nothing
, _preselect = Just True
-- ^ Select this item when showing.
-- *Note* that only one completion item can be selected and that the
-- tool / client decides which item that is. The rule is that the *first*
-- item of those that match best is selected.
, _sortText = Nothing
, _filterText = Nothing
, _insertText = Just "[! !]"
, _insertTextFormat = Just PlainText
, _insertTextMode = Nothing
-- ^ How whitespace and indentation is handled during completion
-- item insertion. If not provided the client's default value depends on
-- the @textDocument.completion.insertTextMode@ client capability.
, _textEdit = removeQuestionMark
, _additionalTextEdits = Nothing
, _commitCharacters = Just (List [" "])
, _command = Nothing
, _xdata = Nothing
} deriving (Read,Show,Eq)
where
Position line column = position
removeQuestionMark =
Just $ List [TextEdit (Range (Position line (column - 1)) position) ""]
}
where
Position line column = position
removeQuestionMark =
Just $ CompletionEditText $ TextEdit (Range (Position line (column - 1)) position) ""
12 changes: 0 additions & 12 deletions src/Server/Handler2/Reload.hs

This file was deleted.

0 comments on commit 0678493

Please sign in to comment.