-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 to fix the pathing issue fully
- Loading branch information
1 parent
8a4b03e
commit 3a7608c
Showing
13 changed files
with
143 additions
and
63 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package langserver | ||
|
||
import ( | ||
"context" | ||
lsp "github.com/sourcegraph/go-lsp" | ||
log "github.com/sirupsen/logrus" | ||
) | ||
|
||
type documentLinkParams struct { | ||
TextDocument lsp.TextDocumentItem `json:"textDocument"` | ||
} | ||
|
||
type DocumentLink struct { | ||
Range lsp.Range `json:"range"` | ||
|
||
/** | ||
* The uri this link points to. If missing a resolve request is sent later. | ||
*/ | ||
Target string `json:"target"` | ||
|
||
Tooltip string `json:"tooltip"` | ||
} | ||
|
||
func TextDocumentDocumentLink(ctx context.Context, vs documentLinkParams) ([]DocumentLink, error) { | ||
log.Info(vs) | ||
|
||
return []DocumentLink{ | ||
DocumentLink{ | ||
Range: lsp.Range{ | ||
Start: lsp.Position{ | ||
Line: 1, | ||
Character: 1, | ||
}, | ||
End: lsp.Position{ | ||
Line: 1, | ||
Character: 10, | ||
}, | ||
}, | ||
Target: "https://github.com", | ||
Tooltip: "https://github.com", | ||
}, | ||
}, 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package langserver | ||
|
||
import ( | ||
"github.com/go-language-server/uri" | ||
) | ||
|
||
func absolutePath(in string) (uri.URI, error) { | ||
return uri.Parse(string(in)) | ||
} |
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,33 @@ | ||
package langserver | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestAbsolutePath(t *testing.T) { | ||
tests := []struct { | ||
path string | ||
expected string | ||
}{ | ||
{ | ||
path: "file:///C:/Users/acmeuser/git/tf-test/main.tf", | ||
expected: "C:/Users/acmeuser/git/tf-test/main.tf", | ||
}, | ||
{ | ||
path: "file:///etc/fstab", | ||
expected: "/etc/fstab", | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
uri, err := absolutePath(test.path) | ||
if err != nil { | ||
t.Errorf("Parsing path '%s' resulted in error: %s", test.path, err) | ||
} | ||
res := uri.Filename() | ||
|
||
if res != test.expected { | ||
t.Errorf("Unexpected result. Got '%s', Expected '%s'", res, test.expected) | ||
} | ||
} | ||
} |
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
Oops, something went wrong.