Skip to content

Commit c6ca634

Browse files
authored
Merge pull request #34 from Myzel394/small-fixes-windows
Improvements
2 parents e1ec57f + 091de78 commit c6ca634

29 files changed

+652
-477
lines changed

flake.lock

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"aarch64-windows"
2424
] (system:
2525
let
26-
version = "0.1.2"; # CI:CD-VERSION
26+
version = "0.1.3"; # CI:CD-VERSION
2727
pkgs = import nixpkgs {
2828
inherit system;
2929
overlays = [

server/common/log.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package common
2+
3+
import "github.com/tliron/commonlog"
4+
5+
var Log = commonlog.GetLogger("config-lsp")

server/common/options.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package common
2+
3+
import (
4+
"os"
5+
"slices"
6+
)
7+
8+
// Global options for the server
9+
type ServerOptionsType struct {
10+
// If true, the server will not return any errors if the
11+
// language was undetectable.
12+
// This is used for example in the VS Code extension, where
13+
// we show a native warning. The error message boxes just clutter
14+
// the interface.
15+
NoUndetectableErrors bool
16+
}
17+
18+
var ServerOptions = new(ServerOptionsType)
19+
20+
func InitServerOptions() {
21+
if slices.Contains(os.Args, "--no-undetectable-errors") {
22+
Log.Info("config-lsp will not return errors for undetectable files")
23+
ServerOptions.NoUndetectableErrors = true
24+
}
25+
}

server/handlers/ssh_config/analyzer/options.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ func checkOption(
6666
invalidValues := docOption.DeprecatedCheckIsValid(option.OptionValue.Value.Value)
6767

6868
for _, invalidValue := range invalidValues {
69-
err := docvalues.LSPErrorFromInvalidValue(option.Start.Line, *invalidValue)
70-
err.ShiftCharacter(option.OptionValue.Start.Character)
69+
err := docvalues.LSPErrorFromInvalidValue(option.Start.Line, *invalidValue).ShiftCharacter(option.OptionValue.Start.Character)
7170

7271
ctx.diagnostics = append(ctx.diagnostics, protocol.Diagnostic{
7372
Range: err.Range.ToLSPRange(),

server/handlers/ssh_config/analyzer/values.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
func analyzeValuesAreValid(
99
ctx *analyzerContext,
1010
) {
11+
// Check if there are unknown options
1112
for _, info := range ctx.document.Config.GetAllOptions() {
1213
option := info.Option
1314
block := info.Block

server/handlers/sshd_config/analyzer/match.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,7 @@ func analyzeMatchValueIsValid(
129129
invalidValues := docOption.DeprecatedCheckIsValid(value.Value.Raw)
130130

131131
for _, invalidValue := range invalidValues {
132-
err := docvalues.LSPErrorFromInvalidValue(value.Start.Line, *invalidValue)
133-
err.ShiftCharacter(value.Start.Character)
132+
err := docvalues.LSPErrorFromInvalidValue(value.Start.Line, *invalidValue).ShiftCharacter(value.Start.Character)
134133

135134
ctx.diagnostics = append(ctx.diagnostics, protocol.Diagnostic{
136135
Range: err.Range.ToLSPRange(),

server/handlers/sshd_config/analyzer/options.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ func checkOption(
6868
invalidValues := docOption.DeprecatedCheckIsValid(option.OptionValue.Value.Value)
6969

7070
for _, invalidValue := range invalidValues {
71-
err := docvalues.LSPErrorFromInvalidValue(option.Start.Line, *invalidValue)
72-
err.ShiftCharacter(option.OptionValue.Start.Character)
71+
err := docvalues.LSPErrorFromInvalidValue(option.Start.Line, *invalidValue).ShiftCharacter(option.OptionValue.Start.Character)
7372

7473
ctx.diagnostics = append(ctx.diagnostics, protocol.Diagnostic{
7574
Range: err.Range.ToLSPRange(),

server/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
"config-lsp/common"
45
roothandler "config-lsp/root-handler"
56
"fmt"
67
"os"
@@ -23,5 +24,6 @@ func main() {
2324
// This increases logging verbosity (optional)
2425
commonlog.Configure(1, nil)
2526

27+
common.InitServerOptions()
2628
roothandler.SetUpRootHandler()
2729
}

server/root-handler/common.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ package roothandler
22

33
// The comment below at the end of the line is required for the CI:CD to work.
44
// Do not remove it
5-
var Version = "0.1.2" // CI:CD-VERSION
5+
var Version = "0.1.3" // CI:CD-VERSION

0 commit comments

Comments
 (0)