diff --git a/LSP-typescript.sublime-commands b/LSP-typescript.sublime-commands index f8a767b..773df51 100644 --- a/LSP-typescript.sublime-commands +++ b/LSP-typescript.sublime-commands @@ -7,4 +7,13 @@ "default": "// Settings in here override those in \"LSP-typescript/LSP-typescript.sublime-settings\"\n\n{\n\t$0\n}\n" } }, + { + "caption": "LSP-typescript: Organize Imports", + "command": "lsp_execute", + "args": { + "session_name": "LSP-typescript", + "command_name": "_typescript.organizeImports", + "command_args": ["${file}"] + } + }, ] diff --git a/README.md b/README.md index ac9a216..b2ebb80 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,25 @@ TypeScript and JavaScript support for Sublime's LSP plugin provided through [The ### Installation - * Install [LSP](https://packagecontrol.io/packages/LSP) and `LSP-typescript` from Package Control. + * Install [`LSP`](https://packagecontrol.io/packages/LSP) and `LSP-typescript` from Package Control. * For ST3: If you use TypeScript install [TypeScript Syntax](https://packagecontrol.io/packages/TypeScript%20Syntax). If you use React install [JSCustom](https://packagecontrol.io/packages/JSCustom). * For ST4: The TypeScript and React (TSX) syntaxes are built-in so no need to install anything else. * Restart Sublime. ### Configuration -Open configuration file using command palette with `Preferences: LSP-typescript Settings` command or opening it from the Sublime menu. +Open the configuration file using the Command Palette `Preferences: LSP-typescript Settings` command or open it from the Sublime menu. + +### Organize Imports command + +To sort or remove unused imports you can trigger the `LSP-typescript: Organize Imports` command from the Command Palette or create a key binding. For example: + +```json + { "keys": ["ctrl+k"], "command": "lsp_execute", + "args": { + "session_name": "LSP-typescript", + "command_name": "_typescript.organizeImports", + "command_args": ["${file}"] + } + }, +```