diff --git a/langserver/exit.go b/langserver/exit.go index 6921c11..d531470 100644 --- a/langserver/exit.go +++ b/langserver/exit.go @@ -2,11 +2,17 @@ package langserver import ( "context" - lsp "github.com/sourcegraph/go-lsp" "os" + + lsp "github.com/sourcegraph/go-lsp" ) func Exit(ctx context.Context, vs lsp.None) error { - os.Remove(tempFile.Name()) + err := os.Remove(tempFile.Name()) + if err != nil { + return err + } + + os.Exit(0) return nil } diff --git a/langserver/main.go b/langserver/main.go index 545d40a..374aa3d 100644 --- a/langserver/main.go +++ b/langserver/main.go @@ -16,6 +16,7 @@ func CreateServer() *jrpc2.Server { //"textDocument/references": handler.New(TextDocumentReferences), //"textDocument/codeLens": handler.New(TextDocumentCodeLens), "exit": handler.New(Exit), + "shutdown": handler.New(Shutdown), "$/cancelRequest": handler.New(CancelRequest), }, &jrpc2.ServerOptions{ AllowPush: true, diff --git a/langserver/shutdown.go b/langserver/shutdown.go new file mode 100644 index 0000000..e0352f0 --- /dev/null +++ b/langserver/shutdown.go @@ -0,0 +1,17 @@ +package langserver + +import ( + "context" + "os" + + lsp "github.com/sourcegraph/go-lsp" +) + +func Shutdown(ctx context.Context, vs lsp.None) error { + err := os.Remove(tempFile.Name()) + if err != nil { + return err + } + + return nil +}