mirror of
https://github.com/Myzel394/config-lsp.git
synced 2025-06-18 23:15:26 +02:00
fix: Improvements
This commit is contained in:
parent
521a4735ce
commit
4750f8c709
@ -1,5 +0,0 @@
|
|||||||
vim.lsp.start {
|
|
||||||
name = "config-lsp",
|
|
||||||
cmd = { "./result/bin/config-lsp" },
|
|
||||||
root_dir = vim.fn.getcwd(),
|
|
||||||
};
|
|
@ -31,7 +31,7 @@ func (v *InvalidValue) GetRange(line uint32, characterStart uint32) protocol.Ran
|
|||||||
},
|
},
|
||||||
End: protocol.Position{
|
End: protocol.Position{
|
||||||
Line: line,
|
Line: line,
|
||||||
Character: characterStart + v.End,
|
Character: characterStart + v.End + 1,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package analyzer
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"config-lsp/common"
|
"config-lsp/common"
|
||||||
docvalues "config-lsp/doc-values"
|
|
||||||
"config-lsp/handlers/ssh_config/ast"
|
"config-lsp/handlers/ssh_config/ast"
|
||||||
"config-lsp/handlers/ssh_config/fields"
|
"config-lsp/handlers/ssh_config/fields"
|
||||||
"config-lsp/utils"
|
"config-lsp/utils"
|
||||||
@ -41,7 +40,7 @@ func checkOption(
|
|||||||
checkIsUsingDoubleQuotes(ctx, option.Key.Value, option.Key.LocationRange)
|
checkIsUsingDoubleQuotes(ctx, option.Key.Value, option.Key.LocationRange)
|
||||||
checkQuotesAreClosed(ctx, option.Key.Value, option.Key.LocationRange)
|
checkQuotesAreClosed(ctx, option.Key.Value, option.Key.LocationRange)
|
||||||
|
|
||||||
docOption, found := fields.Options[option.Key.Key]
|
_, found := fields.Options[option.Key.Key]
|
||||||
|
|
||||||
if !found {
|
if !found {
|
||||||
ctx.diagnostics = append(ctx.diagnostics, protocol.Diagnostic{
|
ctx.diagnostics = append(ctx.diagnostics, protocol.Diagnostic{
|
||||||
@ -67,19 +66,6 @@ func checkOption(
|
|||||||
if option.OptionValue != nil {
|
if option.OptionValue != nil {
|
||||||
checkIsUsingDoubleQuotes(ctx, option.OptionValue.Value, option.OptionValue.LocationRange)
|
checkIsUsingDoubleQuotes(ctx, option.OptionValue.Value, option.OptionValue.LocationRange)
|
||||||
checkQuotesAreClosed(ctx, option.OptionValue.Value, option.OptionValue.LocationRange)
|
checkQuotesAreClosed(ctx, option.OptionValue.Value, option.OptionValue.LocationRange)
|
||||||
|
|
||||||
invalidValues := docOption.DeprecatedCheckIsValid(option.OptionValue.Value.Value)
|
|
||||||
|
|
||||||
for _, invalidValue := range invalidValues {
|
|
||||||
err := docvalues.LSPErrorFromInvalidValue(option.Start.Line, *invalidValue)
|
|
||||||
err.ShiftCharacter(option.OptionValue.Start.Character)
|
|
||||||
|
|
||||||
ctx.diagnostics = append(ctx.diagnostics, protocol.Diagnostic{
|
|
||||||
Range: err.Range.ToLSPRange(),
|
|
||||||
Message: err.Err.Error(),
|
|
||||||
Severity: &common.SeverityError,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if option.Separator == nil || option.Separator.Value.Value == "" {
|
if option.Separator == nil || option.Separator.Value.Value == "" {
|
||||||
|
@ -44,7 +44,7 @@ func analyzeValuesAreValid(
|
|||||||
errs,
|
errs,
|
||||||
func(err *docvalues.InvalidValue) protocol.Diagnostic {
|
func(err *docvalues.InvalidValue) protocol.Diagnostic {
|
||||||
return protocol.Diagnostic{
|
return protocol.Diagnostic{
|
||||||
Range: option.OptionValue.ToLSPRange(),
|
Range: err.GetRange(option.Start.Line, option.OptionValue.Start.Character),
|
||||||
Message: err.Err.Error(),
|
Message: err.Err.Error(),
|
||||||
Severity: &common.SeverityError,
|
Severity: &common.SeverityError,
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
|
|
||||||
func TextDocumentPrepareRename(context *glsp.Context, params *protocol.PrepareRenameParams) (any, error) {
|
func TextDocumentPrepareRename(context *glsp.Context, params *protocol.PrepareRenameParams) (any, error) {
|
||||||
d := sshconfig.DocumentParserMap[params.TextDocument.URI]
|
d := sshconfig.DocumentParserMap[params.TextDocument.URI]
|
||||||
|
index := common.LSPCharacterAsIndexPosition(params.Position.Character)
|
||||||
line := params.Position.Line
|
line := params.Position.Line
|
||||||
|
|
||||||
option, block := d.Config.FindOption(line)
|
option, block := d.Config.FindOption(line)
|
||||||
@ -20,25 +21,27 @@ func TextDocumentPrepareRename(context *glsp.Context, params *protocol.PrepareRe
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if option.Key.Key == tagOption && option.OptionValue != nil {
|
if option.OptionValue != nil && option.OptionValue.Value.Value != "" && option.OptionValue.ContainsPosition(index) {
|
||||||
return option.OptionValue.ToLSPRange(), nil
|
if option.Key.Key == tagOption {
|
||||||
}
|
return option.OptionValue.ToLSPRange(), nil
|
||||||
|
|
||||||
if option.Key.Key == matchOption {
|
|
||||||
matchBlock := block.(*ast.SSHMatchBlock)
|
|
||||||
entry := matchBlock.MatchValue.GetEntryAtPosition(common.LSPCharacterAsIndexPosition(params.Position.Character))
|
|
||||||
|
|
||||||
if entry == nil {
|
|
||||||
return nil, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
value := entry.GetValueAtPosition(common.LSPCharacterAsIndexPosition(params.Position.Character))
|
if option.Key.Key == matchOption {
|
||||||
|
matchBlock := block.(*ast.SSHMatchBlock)
|
||||||
|
entry := matchBlock.MatchValue.GetEntryAtPosition(common.LSPCharacterAsIndexPosition(params.Position.Character))
|
||||||
|
|
||||||
if value == nil {
|
if entry == nil {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
value := entry.GetValueAtPosition(common.LSPCharacterAsIndexPosition(params.Position.Character))
|
||||||
|
|
||||||
|
if value == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return value.ToLSPRange(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return value.ToLSPRange(), nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
@ -22,7 +22,7 @@ func TextDocumentRename(context *glsp.Context, params *protocol.RenameParams) (*
|
|||||||
|
|
||||||
option, block := d.Config.FindOption(line)
|
option, block := d.Config.FindOption(line)
|
||||||
|
|
||||||
if option != nil && option.OptionValue != nil && option.OptionValue.Value.Value != "" {
|
if option != nil && option.OptionValue != nil && option.OptionValue.Value.Value != "" && option.OptionValue.ContainsPosition(index) {
|
||||||
newName := nameTemplate.Format(formatting.DefaultFormattingOptions, params.NewName)
|
newName := nameTemplate.Format(formatting.DefaultFormattingOptions, params.NewName)
|
||||||
|
|
||||||
if option.Key.Key == tagOption {
|
if option.Key.Key == tagOption {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user