Skip to content
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

Broken indent in TypeScript with vim-polyglot #75

Closed
fcanela opened this issue Jan 24, 2020 · 13 comments
Closed

Broken indent in TypeScript with vim-polyglot #75

fcanela opened this issue Jan 24, 2020 · 13 comments

Comments

@fcanela
Copy link

fcanela commented Jan 24, 2020

In the first place, thanks for creating & maintaining the plugin. I have recently found an issue with indenting and tracked it down to a conflict of plugins.

What happens:
When both plugins are enabled, the indentation level is not preserved when pressing enter to create a new line.

Example:

  const blabla = 'blabla'
// The new line is created at this indentation level

Expected:

  const blabla = 'blabla'
  // I would expect it having 2 spaces at start, maintaining the indentation level

The auto-indentation after curly braces is also disabled.

if (true) {
// The new line is created at this indentation level

Expected:

if (true) {
  // The new line is expected to be at this indentation level

All the expected behaviors occur when I disable vim-styled-components and stop when I reenable it. The behavior affected .ts files but not .js.

Minimal init.vim to replicate:

call plug#begin('~/.local/share/nvim/plugged')                                                                                           
Plug 'sheerun/vim-polyglot'                                                                                                              
Plug 'styled-components/vim-styled-components', { 'branch': 'main' }                                                                     
call plug#end() 

I am using NVIM v0.3.8 under Ubuntu 18.04.

I think this could be related to issue #74. I have also tried to apply the code of #62 to my init.vim without success.

@stevematney
Copy link
Contributor

I thought this might be caused by a conflict with yats.vim which is what vim-polyglot uses for TypeScript syntax highlighting and indentation, but when you load just yats.vim and vim-styled-components, indentation works fine. It seems that the conflict is with code specific to vim-polyglot.

@Jayphen
Copy link

Jayphen commented Mar 10, 2020

I'm experiencing this too.

I notice when I run :verbose set indentexpr? with this plugin disabled, I can see Last set from <snip>/vim-polyglot/indent/typescript.vim line 19

If I enable this plugin and run the command again, I see Last set from <snip>/vim-polyglot/after/indent/javascript.vim.

I have no idea what this means, but perhaps it helps debugging.

edit: https://github.com/styled-components/vim-styled-components/blob/main/after/indent/typescript.vim erm, is it this?

If I comment out the above, the indenting works.

Personally I've removed the indent/typescript.vim file from the plugin locally, because I only use css-in-js in typescriptreact files anyway. Keen to know if there's a proper solution

@insidewhy
Copy link

If I load vim-styled-components after vim-jsx-pretty, then indentation works in more places, like function bodies. But still doesn't work in json. Had to stop using vim-styled-components.

@insidewhy
Copy link

@stevematney BTW this happens without using vim-polyglot, I'm just using plugged here.

@cj
Copy link

cj commented May 19, 2020

Just remove https://github.com/styled-components/vim-styled-components/blob/main/after/indent/typescriptreact.vim#L1 from all the files in the indent folder.

@alex-shamshurin
Copy link

alex-shamshurin commented Jul 30, 2020

The same issue is here. Is there any update ?

@joaohenrique-hs
Copy link

The same issue is here too :/

@joaohenrique-hs
Copy link

When I open another file with other types, when come back to typescript file, indentation works perfectly, even using vim-styled-components

@fleischie
Copy link
Collaborator

I merged a PR that advertised to fix this issue. I did not test it, but it is available on the develop branch. If you want you can check it out.

@joaohenrique-hs
Copy link

In my tests, it's working perfectly!!!
Thanks for the fix :)

@richardxia
Copy link

Is there any chance that the fix can be merged from the develop branch into the main branch? I also tested the develop branch, and it fixed the issue for me as well.

I also noticed that the only other change present in develop that's not in main is the message in the README about this project needing a maintainer. Since GitHub only shows the default branch's README by default, that message is not currently being displayed on the main page of the project. You might get more volunteers if you just merged develop into main so that message is more visible. (I sadly don't think I can volunteer because I don't really know vimscript, but I appreciate the work you've done!)

@fleischie
Copy link
Collaborator

Cut a new release with the proposed changes, @richardxia thanks for letting me know...

@richardxia
Copy link

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants