-
Notifications
You must be signed in to change notification settings - Fork 167
Can't use TSX support in LanguageClient-neovim #90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@cormacrelf are you sure? The following appears to work fine for me: let g:LanguageClient_serverCommands = {
\ 'typescript': ['~/.node-bin/javascript-typescript-langserver', '--stdio'],
\ 'typescript.tsx': ['~/.node-bin/javascript-typescript-langserver', '--stdio'],
\} |
That’s what I did. You do have to be in a file with TSX in it. |
Seems to be working fine too @cormacrelf . Did you try logging the client and server output?
{
"compilerOptions": {
"target": "ESNEXT",
"module": "commonjs",
"jsx": "preserve",
"strict": true,
"allowSyntheticDefaultImports": false,
"esModuleInterop": true
}
} |
I have the same issue, but I guess this is because |
Ah, now I understand the point @cormacrelf was making! Indeed, I use HerringtonDarkholme/yats.vim, it sets |
There is way too many TS vim plugins, and it seems the one from leafgarland is the most popular (most github stars) but not the most complete/effective (no TSX syntax highlighting, ...). I'll try yats.vim, thanks for sharing! |
Why does the file type need to be |
Without the "typescript.tsx" filetype, typescript-language-server won't pass the `--jsx` option to TypeScript, which causes it to think that imported components aren't actually used: import Foo from './Foo'; // 'Foo' is declared but its value is never read. export default function X() { return <Foo />; } and probably a bunch of other problems as well. typescript-language-server/typescript-language-server#90
I'm having problem using typescript react with sublime LSP also, any fixes available nothing in this issue worked. |
@tsujp Add this line to your vimrc:
I found this suggestion here. It did the trick. If you want to know more about what the line does, search the help docs for autocmd |
alternatively adding a modeline is also an option instead of a autocmd I dont event have typescript.vim I dont really know why I am having this issue tho :D |
The clients have to adjust to languageIds supported by this server, not the other way around. The IDs are pretty standardized these days across clients. As for Sublime Text, you might just want to assign the TSX syntax to all typescript files. That shouldn't cause issues for plain TS files. |
Uh oh!
There was an error while loading. Please reload this page.
The languageId -> TS/TSX function only supports the languageIds used in VSCode. They are
typescript
, andtypescriptreact
for TSX.In Vim, however, the convention is to use
typescript.tsx
, which means editing tsx files either doesn't work (typescript.tsx
), or spews forth thousands of syntax errors (with justtypescript
). That option isn't configurable in LanguageClient-neovim, it must use the&filetype
variable.Could that function be amended to recognise the Vim form as well? Same goes for
javascript.jsx
.The text was updated successfully, but these errors were encountered: