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{
|
||||
Line: line,
|
||||
Character: characterStart + v.End,
|
||||
Character: characterStart + v.End + 1,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package analyzer
|
||||
|
||||
import (
|
||||
"config-lsp/common"
|
||||
docvalues "config-lsp/doc-values"
|
||||
"config-lsp/handlers/ssh_config/ast"
|
||||
"config-lsp/handlers/ssh_config/fields"
|
||||
"config-lsp/utils"
|
||||
@ -41,7 +40,7 @@ func checkOption(
|
||||
checkIsUsingDoubleQuotes(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 {
|
||||
ctx.diagnostics = append(ctx.diagnostics, protocol.Diagnostic{
|
||||
@ -67,19 +66,6 @@ func checkOption(
|
||||
if option.OptionValue != nil {
|
||||
checkIsUsingDoubleQuotes(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 == "" {
|
||||
|
@ -44,7 +44,7 @@ func analyzeValuesAreValid(
|
||||
errs,
|
||||
func(err *docvalues.InvalidValue) protocol.Diagnostic {
|
||||
return protocol.Diagnostic{
|
||||
Range: option.OptionValue.ToLSPRange(),
|
||||
Range: err.GetRange(option.Start.Line, option.OptionValue.Start.Character),
|
||||
Message: err.Err.Error(),
|
||||
Severity: &common.SeverityError,
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import (
|
||||
|
||||
func TextDocumentPrepareRename(context *glsp.Context, params *protocol.PrepareRenameParams) (any, error) {
|
||||
d := sshconfig.DocumentParserMap[params.TextDocument.URI]
|
||||
index := common.LSPCharacterAsIndexPosition(params.Position.Character)
|
||||
line := params.Position.Line
|
||||
|
||||
option, block := d.Config.FindOption(line)
|
||||
@ -20,7 +21,8 @@ func TextDocumentPrepareRename(context *glsp.Context, params *protocol.PrepareRe
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
if option.Key.Key == tagOption && option.OptionValue != nil {
|
||||
if option.OptionValue != nil && option.OptionValue.Value.Value != "" && option.OptionValue.ContainsPosition(index) {
|
||||
if option.Key.Key == tagOption {
|
||||
return option.OptionValue.ToLSPRange(), nil
|
||||
}
|
||||
|
||||
@ -40,6 +42,7 @@ func TextDocumentPrepareRename(context *glsp.Context, params *protocol.PrepareRe
|
||||
|
||||
return value.ToLSPRange(), nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ func TextDocumentRename(context *glsp.Context, params *protocol.RenameParams) (*
|
||||
|
||||
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)
|
||||
|
||||
if option.Key.Key == tagOption {
|
||||
|
Loading…
x
Reference in New Issue
Block a user