-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes GH-1. Reviewed-by: Titus Wormer <tituswormer@gmail.com> Co-authored-by: Titus Wormer <tituswormer@gmail.com>
- Loading branch information
1 parent
5754b0b
commit 2a72fed
Showing
11 changed files
with
464 additions
and
0 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,9 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true |
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,21 @@ | ||
name: main | ||
on: | ||
- pull_request | ||
- push | ||
jobs: | ||
main: | ||
name: ${{matrix.node}} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{matrix.node}} | ||
- run: npm install | ||
- run: npm test | ||
- uses: codecov/codecov-action@v3 | ||
strategy: | ||
matrix: | ||
node: | ||
- lts/fermium | ||
- node |
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,7 @@ | ||
.DS_Store | ||
*.d.ts | ||
*.log | ||
*.tgz | ||
coverage/ | ||
node_modules/ | ||
yarn.lock |
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 @@ | ||
package-lock=false |
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,2 @@ | ||
coverage/ | ||
*.md |
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 @@ | ||
export {toPoint, toPosition, fromPoint, fromPosition} from './lib/index.js' |
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,58 @@ | ||
/** | ||
* @typedef {import('unist').Point} Point | ||
* @typedef {import('unist').Position} UnistPosition | ||
* @typedef {import('vscode-languageserver-types').Position} LspPosition | ||
* @typedef {import('vscode-languageserver-types').Range} Range | ||
*/ | ||
|
||
/** | ||
* Convert a unist point to an LSP position. | ||
* | ||
* @param {Point} point The unist point to convert. | ||
* @returns {LspPosition} The point converted to an LSP position. | ||
*/ | ||
export function fromPoint(point) { | ||
return { | ||
character: point.column - 1, | ||
line: point.line - 1 | ||
} | ||
} | ||
|
||
/** | ||
* Convert an LSP position to a unist point. | ||
* | ||
* @param {LspPosition} position The LSP position to convert. | ||
* @returns {Point} The position converted to a unist point. | ||
*/ | ||
export function toPoint(position) { | ||
return { | ||
column: position.character + 1, | ||
line: position.line + 1 | ||
} | ||
} | ||
|
||
/** | ||
* Convert a unist position to an LSP range. | ||
* | ||
* @param {UnistPosition} position The unist position to convert. | ||
* @returns {Range} The position converted to an LSP range. | ||
*/ | ||
export function fromPosition(position) { | ||
return { | ||
start: fromPoint(position.start), | ||
end: fromPoint(position.end) | ||
} | ||
} | ||
|
||
/** | ||
* Convert an LSP range to a unist position. | ||
* | ||
* @param {Range} range The LSP range to convert. | ||
* @returns {UnistPosition} The range converted to a unist position. | ||
*/ | ||
export function toPosition(range) { | ||
return { | ||
start: toPoint(range.start), | ||
end: toPoint(range.end) | ||
} | ||
} |
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,74 @@ | ||
{ | ||
"name": "unist-lsp", | ||
"version": "0.0.0", | ||
"description": "Utility to convert between unist and language server protocol", | ||
"license": "MIT", | ||
"keywords": [ | ||
"unist", | ||
"util", | ||
"utility", | ||
"lsp", | ||
"language-server-protocol" | ||
], | ||
"repository": "syntax-tree/unist-lsp", | ||
"bugs": "https://github.com/syntax-tree/unist-lsp/issues", | ||
"funding": { | ||
"type": "opencollective", | ||
"url": "https://opencollective.com/unified" | ||
}, | ||
"author": "Remco Haszing <remcohaszing@gmail.com>", | ||
"contributors": [ | ||
"Remco Haszing <remcohaszing@gmail.com>" | ||
], | ||
"sideEffects": false, | ||
"type": "module", | ||
"exports": "./index.js", | ||
"files": [ | ||
"index.d.ts", | ||
"index.js" | ||
], | ||
"dependencies": { | ||
"@types/unist": "^2.0.0", | ||
"vscode-languageserver-types": "^3.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/tape": "^4.0.0", | ||
"c8": "^7.0.0", | ||
"prettier": "^2.0.0", | ||
"remark-cli": "^11.0.0", | ||
"remark-preset-wooorm": "^9.0.0", | ||
"tape": "^5.0.0", | ||
"type-coverage": "^2.0.0", | ||
"typescript": "^4.0.0", | ||
"xo": "^0.52.0" | ||
}, | ||
"scripts": { | ||
"prepack": "npm run build && npm run format", | ||
"build": "tsc && type-coverage", | ||
"format": "remark . -qfo && prettier -w . --loglevel warn && xo --fix", | ||
"test-api": "node test/index.js", | ||
"test-coverage": "c8 --100 --reporter lcov node test/index.js", | ||
"test": "npm run build && npm run format && npm run test-coverage" | ||
}, | ||
"prettier": { | ||
"tabWidth": 2, | ||
"useTabs": false, | ||
"singleQuote": true, | ||
"bracketSpacing": false, | ||
"semi": false, | ||
"trailingComma": "none" | ||
}, | ||
"xo": { | ||
"prettier": true | ||
}, | ||
"remarkConfig": { | ||
"plugins": [ | ||
"preset-wooorm" | ||
] | ||
}, | ||
"typeCoverage": { | ||
"atLeast": 100, | ||
"detail": true, | ||
"strict": true | ||
} | ||
} |
Oops, something went wrong.