Sublime Forum

LaTeX autocompletion for personal custom commands

#1

Hi everybody,

I’am using ST3 with LaTeXTools [1], LaTeX-cwl and Skim as PDF viewer (on macOS Sierra).

Everything is OK including :

  • forward AND reverse sync betwwen Skim and ST3 (yes !!!);
  • “classic” command completion (one of the most important features for me)

And my question is: how to include personal custom LaTeX command or environment in order to have
autocompletion?

I have read that it’s possible to write my own cwl file. Is it the right way for personal command autocompletion?

If yes, I have 3 precise questions:

  1. What is the right syntax for cwl files? Maybe (quite sure) I can use the examples here : https://github.com/LaTeXing/LaTeX-cwl

  2. Where to put my personal cwl file? I have read in :
    ~/Library/Application Support/Sublime Text 3/Packages/User/cwl/
    (for a mac). Is it right?

  3. How to say (to ST? to LaTeXTools? to LaTeX-cwl?) to use my perso.cwl file ? I made
    some tests and after restarting ST: nothing at all !

I begin to became crazy with this. Please help :cry: !

Thanks everybody, and happy sublime editing or coding.


Pierre
From France (sorry for my poor english)

[1] After research I have discovered another LaTeX plug : LaTeXing. Because everything
(except personal command completion) works, I don’t want to switch right now. Maybe later,
if you give me some good reason :wink:

1 Like

#2

How do you create your custom completions? If you create them via \newcommand/\newenvironment they should appear automatically after a while and you can clear the cache (C-l,C-d,C-c or C-l,backspace) manually to have them instantly. If you have them via an included package your file need to have the same name as the package and must be placed inside the folder Packages/User/cwl. If you get them from somewhere else you can use an arbitrary file name and add the file name to the cwl_list setting inside the LaTeXTools settings.

Reference: https://latextools.readthedocs.io/en/latest/completions/#latex-cwl-support

1 Like

#3

Hi and thanks for the answer.

My commands are created via \newcommand and \newenvironment but inside (several) personal packages.

QUESTION : “(C-l,C-d,C-corC-l,backspace)”, sorry I don’t understand C=Command or Controll ? Is it a classic ST command ?

I made some progress and know it works. Here is what I made:

  • a" perso.cwl" in /User/cwl/ with my commands (only those I really use today)
  • a copy of all “*.cwl” on the page https://github.com/LaTeXing/LaTeX-cwl in the same folder /User/cwl/
  • modification of the file Packages/User/LaTeXTools.sublime-settings, adding:
    “cwl_list”: [
    “xxxx.cwl”,
    “xxxx.cwl”,
    “xxxx.cwl”,

    “perso.cwl”
    ],

After restarting ST: everything seems to work fine. I prefer to keep everything like it is (Rules #1 “When a system works change nothing !” :wink:

Cheers,
Pierre

0 Likes

#4

C = ctrl on Windows and Linux and “super” (I think this is the apple key?) on OSX
Both commands are provided by LaTeXTools:
C-l,C-d,C-c : clears the internatl document cache
C-l,C-backspace : clear all document data (created files from the build process, internal document cache, …)

You can just install the LaTeX-cwl package, and only add your files there, but this is also fine.

If they are created inside package and not inside your document you need write a cwl files as you did. However if the cwl file has the same name as the package they should be included automatically.

0 Likes