-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Read c3lsp.json configuration file on workspace initialization and ov…
…erwrite setted options.
- Loading branch information
1 parent
a2b64e3
commit c6036f3
Showing
6 changed files
with
101 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"C3": { | ||
"version": "0.6.2", | ||
"path": "c3c", | ||
"stdlib-path": "" | ||
}, | ||
"Diagnostics": { | ||
"enabled": true, | ||
"delay": 2000 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package server | ||
|
||
import ( | ||
"encoding/json" | ||
"io" | ||
"log" | ||
"os" | ||
"time" | ||
|
||
"github.com/pherrymason/c3-lsp/pkg/option" | ||
) | ||
|
||
type C3Opts struct { | ||
Version option.Option[string] `json:"version"` | ||
Path option.Option[string] `json:"path"` | ||
StdlibPath option.Option[string] `json:"stdlib-path"` | ||
} | ||
|
||
type DiagnosticsOpts struct { | ||
Enabled bool `json:"enabled"` | ||
Delay time.Duration `json:"delay"` | ||
} | ||
|
||
// ServerOpts holds the options to create a new Server. | ||
type ServerOpts struct { | ||
C3 C3Opts `json:"C3Opts"` | ||
Diagnostics DiagnosticsOpts `json:"Diagnostics"` | ||
|
||
LogFilepath option.Option[string] | ||
SendCrashReports bool | ||
Debug bool | ||
} | ||
|
||
func (s *Server) loadServerConfigurationForWorkspace(path string) { | ||
file, err := os.Open(path + "/c3lsp.json") | ||
if err != nil { | ||
// No configuration project file found. | ||
log.Print("No configuration " + path + "/c3lsp.json found") | ||
return | ||
} | ||
defer file.Close() | ||
|
||
log.Print("Reading configuration " + path + "/c3lsp.json") | ||
|
||
// Lee el archivo | ||
data, err := io.ReadAll(file) | ||
if err != nil { | ||
log.Fatalf("Error reading config json: %v", err) | ||
} | ||
|
||
var options ServerOpts | ||
err = json.Unmarshal(data, &options) | ||
if err != nil { | ||
log.Fatalf("Error deserializing config json: %v", err) | ||
} | ||
|
||
s.options = options | ||
|
||
// Change log filepath? | ||
// Should be able to do that form c3lsp.json? | ||
|
||
// Enable/disable sendCrashReports | ||
// Should be able to do that form c3lsp.json? | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters