texlab
texlab copied to clipboard
Formatter
Thank you for working on texlab!
Which code formatter do you use? In Emacs, lsp-format-buffer adds a lot of tabs to my document which is unacceptable to me. Can I / can we tweak the formatter or is it an external project?
For the future, how can I find out myself which formatter is used? I don't see any debug output of texlab, and there doesn't seem to be documentation available (please correct me! :)!.
Thank you!
~~Texlab does not format LaTeX (only BibTeX).~~
Sorry, I spoke too soon: By default, texlab calls latexindent, see https://github.com/latex-lsp/texlab/blob/master/docs/options.md#texlablatexformatter.
OK, thank you. I just had a look at the latexindent documentation, but didn't easily find a section about customizing tab usage. I don't know what you think, but in my opinion, it would be better to use spaces.
I think I don't want anybody touching my TeX code ;) (I have set the latexFormatter to texlab, which disables it.)
But I would be surprised if latexindent doesn't offer a setting to configure that -- even though nothing is easy to find in the extensive documentation.
(page 30 in the manual: set defaultIndent to however many spaces you want to use (instead of \t, the default value).)
Oh great, thank you. I didn't find that. I am not that into Rust yet, and don't feel comfortable editing the code. I guess it would be somewhere here: https://github.com/latex-lsp/texlab/blob/152ee23e6dae738cfce89b999a1775f63e0a9e09/src/options.rs#L62
No, that would be texlab's own formatter -- which isn't implemented yet. latexindent is an external tool that you need to configure yourself using yaml config files.
I have no idea about the texlab code, and still I have to disagree. The location I pointed to seems to specify the options used for latexindent.
Maybe, but my comment about latexindent being an external tool with its own configuration files still stands.
For the reference: https://github.com/cmhughes/latexindent.pl/issues/291
I can't manage to configure indentation on a user-based level, nor on a project basis. The command line flag -y ... works, but I cannot use it with texlab. The configuration with a YAML file does not work (not a texlab bug).
EDIT: It seems that there is one more level of indirection which I was not aware of.
Sorry to bother you again! I just had a look at the LSP formatting command and it seems that lsp-mode (I am using Emacs here) provides the requested formatting configuration:
[Trace - 02:22:15 PM] Sending request 'textDocument/formatting - (55)'.
Params: {
"options": {
"insertSpaces": true,
"tabSize": 2
},
"textDocument": {
"uri": "file:///bla/bla.tex"
}
}
So texlab could now take this info and forward it to latexindent.pl, if that makes sense. Just a suggestion!
In any case, it would be nice to make it easier for future users to configure indenting.
Thank you for working on this package! Feel free to close this issue.
I can't manage to configure indentation on a user-based level, nor on a project basis. The command line flag -y ... works, but I cannot use it with texlab. The configuration with a YAML file does not work (not a texlab bug).
texlab passes the -l flag to latexindent, which means that it loads the settings from the current project directory (use localSettings.yaml, .localSettings.yaml, latexindent.yaml, or .latexindent.yaml). Besides that, you can set texlab.latexindent.local to some custom file name (even an absolute path if you want a global configuration) if you want.
So texlab could now take this info and forward it to latexindent.pl, if that makes sense.
Yes, LSP provides this info but it is quite difficult to forward this information to latexindent because there are no suitable command line flags. Creating a custom YAML file would override the user's YAML file, which is definitely not wanted so I am afraid there is no good way to use this extra information with latexindent.