<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Ctags on Clément Joly – Open-Source, Rust &amp; SQLite</title><link>https://joly.pw/tags/ctags/</link><description>Recent content in Ctags on Clément Joly – Open-Source, Rust &amp; SQLite</description><image><title>Clément Joly – Open-Source, Rust &amp; SQLite</title><url>https://joly.pw/images/open-graph-pages.jpg</url><link>https://joly.pw/images/open-graph-pages.jpg</link></image><generator>Hugo</generator><language>en</language><copyright>Clément Joly</copyright><lastBuildDate>Thu, 28 May 2026 23:48:29 +0000</lastBuildDate><atom:link href="https://joly.pw/tags/ctags/index.xml" rel="self" type="application/rss+xml"/><item><title>Ledger.ctags</title><link>https://joly.pw/ledger-ctags/</link><pubDate>Sun, 21 Aug 2022 08:15:54 +0100</pubDate><guid>https://joly.pw/ledger-ctags/</guid><description>Ctags file for ledger-cli</description><content:encoded><![CDATA[
<p style="display: flex; justify-content: space-between">
  <a href="https://github.com/cljoly/ledger.ctags" data-goatcounter-click="ext-github-ledger.ctags" data-goatcounter-title="cljoly/ledger.ctags">
    <span class="svgicon"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
    stroke-linecap="round" stroke-linejoin="round">
    <path
        d="M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22">
    </path>
</svg></span>&nbsp;cljoly/ledger.ctags
  </a>
  <a class="badges" href="https://github.com/cljoly/ledger-ctags" data-goatcounter-click="ext-stargithub-ledger.ctags" data-goatcounter-title="stars cljoly/ledger.ctags">
    <img src="https://img.shields.io/github/stars/cljoly/ledger.ctags?style=social" alt="Github stars for ledger.ctags">
  </a>
</p>

<p>If you are using <a href="https://ledger-cli.org/">Ledger</a> or one of its variants for your <a href="https://plaintextaccounting.org/">plain text accounting</a>, you get to manage your finances a bit more like you manage code. With plain text files, in your favorite editor.</p>
<p>And yet, as opposed to code in most languages, you don’t have a <a href="https://microsoft.github.io/language-server-protocol/">Language Server Protocol implementation</a>. So it’s a bit harder to get completions on accounts, tags, payees… You have to rely on bespoken support from your editor and that’s often imperfect or slow. Plus, if you <a href="https://www.ledger-cli.org/3.0/doc/ledger3.html#index-pre_002ddeclare-account">declare</a> your accounts and payees, you also can’t jump to the definition easily.</p>
<p>Enter ctags configuration for ledger, which this project provides. It generates <code>tag</code> file that’s understood by your editor, often out of the box (<a href="https://vimhelp.org/usr_29.txt.html#29.1">vim/neovim</a>, <a href="https://www.gnu.org/software/emacs/manual/html_node/emacs/Tags-Tables.html">emacs</a>) or with a generic plugin (Atom, VS Code, TextMate and <a href="https://en.wikipedia.org/wiki/Ctags#Editors_that_support_ctags">more</a>). Congrats, your editor now has very fast completions and code navigation!</p>
<h2 id="installation">Installation</h2>
<p>You need to have <a href="https://ctags.io/">ctags</a> installed<sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup>.</p>
<p>Then drop <a href="https://raw.githubusercontent.com/cljoly/ledger.ctags/main/ledger.ctags"><code>ledger.ctags</code></a> in <code>~/.config/ctags</code> (or whatever <code>ctags</code> is configured to read).</p>
<h2 id="usage">Usage</h2>
<pre tabindex="0"><code>ctags my/ledger/journal.ldg
</code></pre><p>will collect all the elements formally <a href="https://www.ledger-cli.org/3.0/doc/ledger3.html#index-pre_002ddeclare-account">declared</a> in the journal file. This means that in the following file:</p>
<pre tabindex="0"><code class="language-ledger" data-lang="ledger">tag UUID
account Assets
payee Shop
commodity EUR

2022-01-01 * Someone
    Expenses:Food   $10
    Liabilities:Credit Card
</code></pre><p>only <code>UUID</code>, <code>Assets</code>, <code>Shop</code> and <code>EUR</code> are detected, because they are the only one declared and so the only ones with a definition to jump to. <code>Someone</code>, <code>Expenses</code>, <code>Expenses:Food</code>, <code>$</code>, <code>Liabilities</code> and <code>Liabilities:Credit  Card</code> are not declared, so they are ignored by ctags.</p>
<h3 id="initial-list-of-accounts-payees">Initial List of Accounts, Payees…</h3>
<p>As mentioned, ctags only collects elements that are declared. You could write the declarations manually, if you want to have fine-grained control of which accounts you want to actively use and have completions for. But to ease initial bootstrapping, you may want to start by adding everything you currently use in your ledger journals. You can do that with a couple commands.</p>
<p>For accounts, you can use this bash snippet:</p>
<pre tabindex="0"><code>ledger accounts | awk &#39;{ print &#34;account&#34;, $0}&#39;
</code></pre><p>For payees:</p>
<pre tabindex="0"><code>ledger payees | awk &#39;{ print &#34;payee&#34;, $0}&#39;
</code></pre><p>For tags:</p>
<pre tabindex="0"><code>ledger tags | awk &#39;{ print &#34;tag&#34;, $0}&#39;
</code></pre><p>The snippets above output proper ledger definitions for accounts, payees and tags. You can insert these outputs in your journal or in a separate file with all your declarations (say <code>declarations.ledger</code>), that you can then <code>include</code> in your main journal file.</p>
<p>Don’t forget that ctags does not follow includes, so you should pass the file with the definitions to ctags (e.g. <code>ctags declarations.ledger</code>)</p>
<h3 id="multiple-files">Multiple files</h3>
<p>If you have multiple ledger journal files, pass them all to ctags (e.g. <code>ctags *.ledger *.ldg</code>) or run it on the current directory:</p>
<div class="highlight"><pre tabindex="0" style="color:#abb2bf;background-color:#282c34;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>ctags -R .
</span></span></code></pre></div><hr>
<h2 id="automatic-update-with-chezmoi">Automatic Update with Chezmoi</h2>
<p>Chezmoi <a href="https://www.chezmoi.io/reference/special-files-and-directories/chezmoiexternal-format/">external</a> feature allows you to auto update and manage the <code>ledger.ctags</code> file, by adding the following to your <code>~/.local/share/chezmoi/.chezmoiexternal.toml</code>:</p>
<div class="highlight"><pre tabindex="0" style="color:#abb2bf;background-color:#282c34;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-toml" data-lang="toml"><span style="display:flex;"><span>[<span style="color:#98c379">&#34;.config/ctags/&#34;</span>]
</span></span><span style="display:flex;"><span>    <span style="color:#e06c75">type</span> = <span style="color:#98c379">&#34;archive&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e06c75">include</span> = [ <span style="color:#98c379">&#34;*/ledger.ctags&#34;</span> ]
</span></span><span style="display:flex;"><span>    <span style="color:#e06c75">url</span> = <span style="color:#98c379">&#34;https://github.com/cljoly/ledger.ctags/archive/master.zip/&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e06c75">stripComponents</span> = <span style="color:#d19a66">1</span>
</span></span></code></pre></div><h2 id="contributing">Contributing</h2>
<p>Contributions (documentation or code improvements in particular) are welcome, see <a href="https://cj.rs/docs/contribute/">contributing</a>!</p>
<p>Feel free <a href="https://github.com/cljoly/ledger.ctags/issues/new">to fill an issue</a> if your <em>declared</em> accounts, tags, payee, alias… are not properly detected.</p>
<h2 id="acknowledgments">Acknowledgments</h2>
<p>I would like to thank the creators, and all the contributors, of <a href="https://ctags.io/">ctags</a> and <a href="https://ledger-cli.org/">ledger</a>. This is small configuration to make these two great projects work better together.</p>

<div class="badges">

<p><a href="https://cj.rs/riss">

  <img loading="lazy" src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDQiIGhlaWdodD0iMjAiIHJvbGU9ImltZyIgYXJpYS1sYWJlbD0icG93ZXJlZCBieTogcmlzcyI+PHRpdGxlPnBvd2VyZWQgYnk6IHJpc3M8L3RpdGxlPjxmaWx0ZXIgaWQ9ImJsdXIiPjxmZUdhdXNzaWFuQmx1ciBpbj0iU291cmNlR3JhcGhpYyIgc3RkRGV2aWF0aW9uPSIxNiIvPjwv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KC4xKSIgdGV4dExlbmd0aD0iNjUwIj5wb3dlcmVkIGJ5PC90ZXh0Pjx0ZXh0IHg9IjM4NSIgeT0iMTQwIiB0cmFuc2Zvcm09InNjYWxlKC4xKSIgZmlsbD0iI2ZmZiIgdGV4dExlbmd0aD0iNjUwIj5wb3dlcmVkIGJ5PC90ZXh0Pjx0ZXh0IGFyaWEtaGlkZGVuPSJ0cnVlIiB4PSI4ODUiIHk9IjE1MCIgZmlsbD0iIzAxMDEwMSIgZmlsbC1vcGFjaXR5PSIuODAiIGZpbHRlcj0idXJsKCNibHVyKSIgdHJhbnNmb3JtPSJzY2FsZSguMSkiIHRleHRMZW5ndGg9IjE5MCI+cmlzczwvdGV4dD48dGV4dCBhcmlhLWhpZGRlbj0idHJ1ZSIgeD0iODg1IiB5PSIxNTAiIGZpbGw9IiMwMTAxMDEiIGZpbGwtb3BhY2l0eT0iLjMiIHRyYW5zZm9ybT0ic2NhbGUoLjEpIiB0ZXh0TGVuZ3RoPSIxOTAiPnJpc3M8L3RleHQ+PHRleHQgeD0iODg1IiB5PSIxNDAiIHRyYW5zZm9ybT0ic2NhbGUoLjEpIiBmaWxsPSIjZmZmIiB0ZXh0TGVuZ3RoPSIxOTAiPnJpc3M8L3RleHQ+PC9nPjwvc3ZnPg=="></a></p>

</div>

<div class="footnotes" role="doc-endnotes">
<hr>
<ol>
<li id="fn:1">
<p>Another implementation may work, but it’s untested. Feel free to send a PR though!&#160;<a href="#fnref:1" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li>
</ol>
</div>
]]></content:encoded></item></channel></rss>