coc-extensions / coc-svelte

svelte support for (Neo)Vim
MIT License
176 stars 24 forks source link

Weird behavior using Sveltekit + TS #45

Closed gaylonalfano closed 2 years ago

gaylonalfano commented 2 years ago

Update 12/15 -- Still troubleshooting this, but I discovered that if I use <script type="text/typescript"> then I do get some syntax highlighting and the code formats correctly (e.g., if I press Enter, it correctly indents on the next line, instead of going all the way to the left-hand side.). It doesn't seem to recognize lang="ts" or lang="typescript" for some reason.

Hi there - I have coc-svelte installed and I'm experimenting with Sveltekit. Whenever I use a regular <script> tag inside a .svelte component, the functionality, syntax coloring, etc. works just fine. However, when I add <script lang="ts">, the code coloring turns to all white and the formatting gets really messed up. It still recognizes and allows me to use TS inside, but all the syntax highlight, formatting, etc. is removed. Only when I save will the formatting work (but the syntax highlighting is still gone -- everything is white).

Any help is greatly appreciated!

devstein commented 2 years ago

I'm also having this issue. <script type="text/typescript"> works for me, but isn't recognized by svelte-preprocess

[svelte(script)] [E] Cannot find module './transformers/text/typescript'
Require stack:
- ./node_modules/svelte-preprocess/dist/autoProcess.js
- ./node_modules/svelte-preprocess/dist/index.js
taj-p commented 2 years ago

I've got it working with <script lang="ts"> by adding the following to my init.vim.

let g:vim_svelte_plugin_use_typescript = 1

Note that I have leafOfTree/vim-svelte-plugin installed.

Looking at the configuration for the plugin, it seems that it defaults to not parsing lang="ts" scripts. I'm not sure if this is relevant to coc-svelte, however.

gaylonalfano commented 2 years ago

I've got it working with <script lang="ts"> by adding the following to my init.vim.

let g:vim_svelte_plugin_use_typescript = 1

Note that I have leafOfTree/vim-svelte-plugin installed.

Looking at the configuration for the plugin, it seems that it defaults to not parsing lang="ts" scripts. I'm not sure if this is relevant to coc-svelte, however.

Yes, this worked for me as well! This is what I ended up adding to my init.vim and it's working great. Thanks for sharing!

let g:vim_svelte_plugin_load_full_syntax = 1
let g:vim_svelte_plugin_use_typescript = 1