Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(lsp-cli): make it better and more docs
- Loading branch information
1 parent
1c1ce1a
commit edc6c27
Showing
8 changed files
with
82 additions
and
31 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 |
---|---|---|
@@ -1,12 +1,3 @@ | ||
# @izaakschroeder/lsp-tools | ||
|
||
Tools to work with your LSP. | ||
|
||
```sh | ||
lsp \ | ||
--connect 'stdio://biome/?arg=lsp-proxy' \ | ||
fix \ | ||
--ignore '**/node_modules/**' \ | ||
--rule 'quickfix.suppressRule.biome.*' \ | ||
'./src/**/*{.ts,.tsx,.js,.jsx,.mjs,.cjs}' | ||
``` | ||
Tools and libraries to fulfill your LSP needs. |
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,27 @@ | ||
import type { CodeActionItem } from '@izaakschroeder/lsp-client'; | ||
|
||
export const createActionRewrite = (patterns: string[]) => { | ||
const rewrites = patterns.map((patterns) => { | ||
const [find, replace] = patterns.split('=', 2); | ||
if (!find || !replace) { | ||
throw new Error(); | ||
} | ||
return (action: CodeActionItem) => { | ||
for (const key in action.edit.changes) { | ||
const changes = action.edit.changes[key]; | ||
if (!changes) { | ||
continue; | ||
} | ||
for (const change of changes) { | ||
change.newText = change.newText.replaceAll(find, replace); | ||
} | ||
} | ||
return action; | ||
}; | ||
}); | ||
return (action: CodeActionItem) => { | ||
return rewrites.reduce((prev, cur) => { | ||
return cur(prev); | ||
}, action); | ||
}; | ||
}; |
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