neoclide / coc-tsserver

Tsserver extension for coc.nvim that provide rich features like VSCode for javascript & typescript
MIT License
1.05k stars 68 forks source link

add or remove braces to arrow function #309

Closed linde12 closed 3 years ago

linde12 commented 3 years ago

I cant get this feature to work (or maybe it needs implementation in coc-tsserver?) It should be available in typescript: https://github.com/Microsoft/TypeScript/pull/23423

The only option i get is to create a function statement. I want to be able to quickly add braces around an arrow function, e.g. if i have something like:

<button onClick={() => setCount(count + 1)}>
  Click me!
</button>

Then i want to be able to quickly convert that arrow function to a block as such:

<button onClick={() => {
  return setCount(count + 1)
}}>
  Click me!
</button>

image

vim version: NVIM v0.5.0 node version: v14.17.2 coc.nvim version: 0.0.80-3086844413 coc.nvim directory: /home/linde/.vim/plugged/coc.nvim term: alacritty platform: linux

fannheyward commented 3 years ago

In my tests, put your cursor on => and fire <Plug>(coc-codeaction-cursor), you will get:

截屏2021-08-31 上午9 52 35

After the first action executed:

截屏2021-08-31 上午9 53 20
fannheyward commented 3 years ago

What's your coc-tsserver version? I'm using 1.8.6.

chemzqm commented 3 years ago

Check log of your tsserver https://github.com/neoclide/coc-tsserver#troubleshooting

linde12 commented 3 years ago

In my tests, put your cursor on => and fire <Plug>(coc-codeaction-cursor), you will get:

截屏2021-08-31 上午9 52 35

After the first action executed:

截屏2021-08-31 上午9 53 20

Thank you! I was using coc-codeaction, i didn't know of coc-codeaction-cursor :smiley:

chemzqm commented 3 years ago

coc-codeaction-cursor is recommended