diff --git a/common/analyzer.go b/common/analyzer.go index c1effac..e859a1a 100644 --- a/common/analyzer.go +++ b/common/analyzer.go @@ -17,10 +17,9 @@ func AnalyzeValues( if err != nil { errors = append(errors, docvalues.ValueError{ - Line: line.Position.Line, - Option: optionName, - Value: line.Value, - DocError: err, + Line: line.Position.Line, + Option: optionName, + Value: line.Value, }) } } diff --git a/root-handler/handler.go b/root-handler/handler.go index f2d7c9d..677604a 100644 --- a/root-handler/handler.go +++ b/root-handler/handler.go @@ -17,12 +17,13 @@ var lspHandler protocol.Handler func SetUpRootHandler() { rootHandler = NewRootHandler() lspHandler = protocol.Handler{ - Initialize: initialize, - Initialized: initialized, - Shutdown: shutdown, - SetTrace: setTrace, - TextDocumentDidOpen: TextDocumentDidOpen, - TextDocumentDidChange: TextDocumentDidChange, + Initialize: initialize, + Initialized: initialized, + Shutdown: shutdown, + SetTrace: setTrace, + TextDocumentDidOpen: TextDocumentDidOpen, + TextDocumentDidChange: TextDocumentDidChange, + TextDocumentCompletion: TextDocumentCompletion, } server := server.NewServer(&lspHandler, lsName, false) diff --git a/root-handler/text-document-completion.go b/root-handler/text-document-completion.go new file mode 100644 index 0000000..bd6478a --- /dev/null +++ b/root-handler/text-document-completion.go @@ -0,0 +1,21 @@ +package roothandler + +import ( + "config-lsp/handlers/fstab" + + "github.com/tliron/glsp" + protocol "github.com/tliron/glsp/protocol_3_16" +) + +func TextDocumentCompletion(context *glsp.Context, params *protocol.CompletionParams) (any, error) { + language := rootHandler.GetLanguageForDocument(params.TextDocument.URI) + + switch language { + case LanguageFstab: + return fstab.TextDocumentCompletion(context, params) + case LanguageSSHDConfig: + return nil, nil + } + + panic("root-handler/TextDocumentCompletion: unexpected language" + language) +}