-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
192 additions
and
4 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,12 @@ | ||
package analyzer | ||
|
||
import ( | ||
"config-lsp/handlers/sshd_config" | ||
protocol "github.com/tliron/glsp/protocol_3_16" | ||
) | ||
|
||
func Analyze( | ||
d *sshdconfig.SSHDocument, | ||
) []protocol.Diagnostic { | ||
return nil | ||
} |
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,14 @@ | ||
package lsp | ||
|
||
import ( | ||
"github.com/tliron/glsp" | ||
protocol "github.com/tliron/glsp/protocol_3_16" | ||
) | ||
|
||
func TextDocumentCodeAction(context *glsp.Context, params *protocol.CodeActionParams) ([]protocol.CodeAction, error) { | ||
// document := hosts.DocumentParserMap[params.TextDocument.URI] | ||
// | ||
// actions := make([]protocol.CodeAction, 0, 1) | ||
|
||
return nil, nil | ||
} |
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,10 @@ | ||
package lsp | ||
|
||
import ( | ||
"github.com/tliron/glsp" | ||
protocol "github.com/tliron/glsp/protocol_3_16" | ||
) | ||
|
||
func TextDocumentCompletion(context *glsp.Context, params *protocol.CompletionParams) (any, error) { | ||
return nil, nil | ||
} |
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,42 @@ | ||
package lsp | ||
|
||
import ( | ||
"config-lsp/common" | ||
"config-lsp/handlers/sshd_config/analyzer" | ||
"config-lsp/handlers/sshd_config" | ||
"config-lsp/utils" | ||
|
||
"github.com/tliron/glsp" | ||
protocol "github.com/tliron/glsp/protocol_3_16" | ||
) | ||
|
||
func TextDocumentDidChange( | ||
context *glsp.Context, | ||
params *protocol.DidChangeTextDocumentParams, | ||
) error { | ||
content := params.ContentChanges[0].(protocol.TextDocumentContentChangeEventWhole).Text | ||
common.ClearDiagnostics(context, params.TextDocument.URI) | ||
|
||
document := sshdconfig.DocumentParserMap[params.TextDocument.URI] | ||
document.Config.Clear() | ||
|
||
diagnostics := make([]protocol.Diagnostic, 0) | ||
errors := document.Config.Parse(content) | ||
|
||
if len(errors) > 0 { | ||
diagnostics = append(diagnostics, utils.Map( | ||
errors, | ||
func(err common.LSPError) protocol.Diagnostic { | ||
return err.ToDiagnostic() | ||
}, | ||
)...) | ||
} | ||
|
||
diagnostics = append(diagnostics, analyzer.Analyze(document)...) | ||
|
||
if len(diagnostics) > 0 { | ||
common.SendDiagnostics(context, params.TextDocument.URI, diagnostics) | ||
} | ||
|
||
return nil | ||
} |
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,13 @@ | ||
package lsp | ||
|
||
import ( | ||
"config-lsp/handlers/sshd_config" | ||
"github.com/tliron/glsp" | ||
protocol "github.com/tliron/glsp/protocol_3_16" | ||
) | ||
|
||
func TextDocumentDidClose(context *glsp.Context, params *protocol.DidCloseTextDocumentParams) error { | ||
delete(sshdconfig.DocumentParserMap, params.TextDocument.URI) | ||
|
||
return nil | ||
} |
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,45 @@ | ||
package lsp | ||
|
||
import ( | ||
"config-lsp/common" | ||
"config-lsp/handlers/sshd_config" | ||
"config-lsp/handlers/sshd_config/analyzer" | ||
"config-lsp/handlers/sshd_config/ast" | ||
"config-lsp/utils" | ||
|
||
"github.com/tliron/glsp" | ||
protocol "github.com/tliron/glsp/protocol_3_16" | ||
) | ||
|
||
func TextDocumentDidOpen( | ||
context *glsp.Context, | ||
params *protocol.DidOpenTextDocumentParams, | ||
) error { | ||
common.ClearDiagnostics(context, params.TextDocument.URI) | ||
|
||
parser := ast.NewSSHConfig() | ||
document := sshdconfig.SSHDocument{ | ||
Config: parser, | ||
} | ||
sshdconfig.DocumentParserMap[params.TextDocument.URI] = &document | ||
|
||
errors := parser.Parse(params.TextDocument.Text) | ||
|
||
diagnostics := utils.Map( | ||
errors, | ||
func(err common.LSPError) protocol.Diagnostic { | ||
return err.ToDiagnostic() | ||
}, | ||
) | ||
|
||
diagnostics = append( | ||
diagnostics, | ||
analyzer.Analyze(&document)..., | ||
) | ||
|
||
if len(diagnostics) > 0 { | ||
common.SendDiagnostics(context, params.TextDocument.URI, diagnostics) | ||
} | ||
|
||
return nil | ||
} |
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,13 @@ | ||
package lsp | ||
|
||
import ( | ||
"github.com/tliron/glsp" | ||
protocol "github.com/tliron/glsp/protocol_3_16" | ||
) | ||
|
||
func TextDocumentHover( | ||
context *glsp.Context, | ||
params *protocol.HoverParams, | ||
) (*protocol.Hover, error) { | ||
return nil, nil | ||
} |
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,10 @@ | ||
package lsp | ||
|
||
import ( | ||
"github.com/tliron/glsp" | ||
protocol "github.com/tliron/glsp/protocol_3_16" | ||
) | ||
|
||
func TextDocumentSignatureHelp(context *glsp.Context, params *protocol.SignatureHelpParams) (*protocol.SignatureHelp, error) { | ||
return nil, nil | ||
} |
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,10 @@ | ||
package lsp | ||
|
||
import ( | ||
"github.com/tliron/glsp" | ||
protocol "github.com/tliron/glsp/protocol_3_16" | ||
) | ||
|
||
func WorkspaceExecuteCommand(context *glsp.Context, params *protocol.ExecuteCommandParams) (*protocol.ApplyWorkspaceEditParams, error) { | ||
return nil, nil | ||
} |
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,14 @@ | ||
package sshdconfig | ||
|
||
import ( | ||
"config-lsp/handlers/sshd_config/ast" | ||
|
||
protocol "github.com/tliron/glsp/protocol_3_16" | ||
) | ||
|
||
type SSHDocument struct { | ||
Config *ast.SSHConfig | ||
} | ||
|
||
var DocumentParserMap = map[protocol.DocumentUri]*SSHDocument{} | ||
|
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
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