tide icon indicating copy to clipboard operation
tide copied to clipboard

EditorConfig Support

Open skylerto opened this issue 8 years ago • 8 comments

Specifically for the code formatting, integration with editorconfig-emacs would be amazing.

skylerto avatar Dec 23 '16 15:12 skylerto

I would greatly appreciate this as well!

bklaase avatar Aug 29 '17 10:08 bklaase

@ananthakumaran what would be needed for implementing this?

Eeemil avatar Feb 08 '19 15:02 Eeemil

For each buffer tide will make a configure rpc request to tsserver. This contains formatOptions, which will be used by tsserver for other rpc requests like format etc. Tide already supports tsfmt.json file. https://github.com/ananthakumaran/tide/blob/master/tide.el#L712. Adding editor config support would be similar, the file needs to be parsed and each option needs to be mapped to the corresponding options in the protocol.

ananthakumaran avatar Feb 08 '19 16:02 ananthakumaran

I might try to implement support for this the coming weeks, but I'm not very experienced in elisp or typescript.

Would it be sane to require https://github.com/editorconfig/editorconfig-emacs as a prerequisite? So that tide won't have to deal with parsing and finding the editorconfig file

Eeemil avatar Feb 11 '19 13:02 Eeemil

Yes, using a standard implementation is better.

ananthakumaran avatar Feb 11 '19 13:02 ananthakumaran

PRs welcome.

josteink avatar Dec 22 '19 10:12 josteink

I think we're 99% of the way there. tide respects typescript-indent-level. Editorconfig will set this accordingly. I think what's happening is tide is usually set up before editorconfig hooks are ran. This means editorconfig does change the typescript settings, but tide is unaware they have been changed out from under itself. Here's a quick and dirty workaround that appears to do the trick -- ensures tide's server knows about the latest changes applied by editorconfig:

(add-hook 'editorconfig-after-apply-functions (defun winny/fix-tide-indentation (props)
                                                (when (and (boundp 'tide-mode) tide-mode)
                                                  (tide-command:configure))))

winny- avatar Jul 20 '22 17:07 winny-

This bug also manifests if user manually sets typescript-indent-level. I think it's the same surprising behavior because in both cases this var is being overridden in a way tide is unaware of. But this is normal and expected emacs behavior - it's probably not a safe bet to assume a var never changes over the lifecycle of a buffer.

Maybe tide could monitor this var (and reconfigure itself) so it behaves in a unsurprising way in all cases?

winny- avatar Jul 20 '22 17:07 winny-