<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>HEIR – Development</title><link>https://heir.dev/docs/development/</link><description>Recent content in Development on HEIR</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="https://heir.dev/docs/development/index.xml" rel="self" type="application/rss+xml"/><item><title>Docs: AI Tool Use Policy</title><link>https://heir.dev/docs/development/ai_policy/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://heir.dev/docs/development/ai_policy/</guid><description>
&lt;p>&lt;em>Nb., this policy was adapted from the
&lt;a href="https://github.com/llvm/llvm-project/pull/154441">LLVM AI Tool Use Policy&lt;/a>.&lt;/em>&lt;/p>
&lt;h2 id="policy">Policy&lt;/h2>
&lt;p>This project&amp;rsquo;s policy is that contributors can use whatever tools they would
like to craft their contributions, but there must be a &lt;strong>human in the loop&lt;/strong>.
&lt;strong>Contributors must read and review all LLM-generated code or text before they
ask other project members to review it.&lt;/strong> The contributor is always the author
and is fully accountable for their contributions. Contributors should be
sufficiently confident that the contribution is high enough quality that asking
for a review is a good use of scarce maintainer time, and they should be &lt;strong>able
to answer questions about their work&lt;/strong> during review.&lt;/p>
&lt;p>We expect that new contributors will be less confident in their contributions,
and our guidance to them is to &lt;strong>start with small contributions&lt;/strong> that they can
fully understand to build confidence. We aspire to be a welcoming community that
helps new contributors grow their expertise, but learning involves taking small
steps, getting feedback, and iterating. Passing maintainer feedback to an LLM
doesn&amp;rsquo;t help anyone grow, and does not sustain our community.&lt;/p>
&lt;p>Contributors are expected to &lt;strong>be transparent and label contributions that
contain substantial amounts of tool-generated content&lt;/strong>. Our policy on labelling
is intended to facilitate reviews, and not to track which parts of the project
are generated. Contributors should note tool usage in their pull request
description, commit message, or wherever authorship is normally indicated for
the work. For instance, use a commit message trailer like
&lt;code>Assisted-by: &amp;lt;name of code assistant&amp;gt;&lt;/code>. This transparency helps the community
develop best practices and understand the role of these new tools.&lt;/p>
&lt;p>This policy includes, but is not limited to, the following kinds of
contributions:&lt;/p>
&lt;ul>
&lt;li>Code, usually in the form of a pull request&lt;/li>
&lt;li>RFCs or design proposals&lt;/li>
&lt;li>Issues or security vulnerabilities&lt;/li>
&lt;li>Comments and feedback on pull requests&lt;/li>
&lt;/ul>
&lt;h2 id="details">Details&lt;/h2>
&lt;p>To ensure sufficient self review and understanding of the work, it is strongly
recommended that contributors write PR descriptions themselves (if needed, using
tools for translation or copy-editing). The description should explain the
motivation, implementation approach, expected impact, and any open questions or
uncertainties to the same extent as a contribution made without tool assistance.&lt;/p>
&lt;p>An important implication of this policy is that it bans agents that take action
in our digital spaces without human approval, such as the GitHub
&lt;a href="https://github.com/claude/">&lt;code>@claude&lt;/code> agent&lt;/a>. Similarly, automated review tools
that publish comments without human review are not allowed. However, an opt-in
review tool that &lt;strong>keeps a human in the loop&lt;/strong> is acceptable under this policy.
As another example, using an LLM to generate documentation, which a contributor
manually reviews for correctness, edits, and then posts as a PR, is an approved
use of tools under this policy.&lt;/p>
&lt;p>AI tools must not be used to fix GitHub issues labelled
&lt;a href="https://github.com/google/heir/issues/?q=is%3Aissue%20state%3Aopen%20label%3A%22good%20first%20issue%22">&lt;code>good first issue&lt;/code>&lt;/a>. These issues are generally not urgent,
and are intended to be learning opportunities for new contributors to get
familiar with the codebase. Fully automating the process of fixing this issue
squanders the learning opportunity and doesn&amp;rsquo;t add much value to the project.
&lt;strong>New contributors using AI tools to fix issues labelled as &amp;ldquo;good first issues&amp;rdquo;
is forbidden&lt;/strong>.&lt;/p>
&lt;p>Finally, new contributors not recognized by the maintainers should first meet a
project maintainer in a non-textual format before their first contribution will
be accepted. This includes:&lt;/p>
&lt;ul>
&lt;li>Meeting a maintainer in person.&lt;/li>
&lt;li>Attending office hours or a working group meeting (cf. our
&lt;a href="https://heir.dev/community/">community calendar&lt;/a>).&lt;/li>
&lt;li>Scheduling a video call with a maintainer (reach out via
&lt;a href="https://heir.dev/community/">Discord&lt;/a> or email).&lt;/li>
&lt;/ul>
&lt;p>New PRs from unrecognized contributors that appear to be AI-generated will be
closed with a reference to this policy. New issues or issue comments from
unrecognized contributors will be directed to this policy.&lt;/p>
&lt;h2 id="extractive-contributions">Extractive Contributions&lt;/h2>
&lt;p>The reason for our &amp;ldquo;human-in-the-loop&amp;rdquo; contribution policy is that processing
patches, PRs, RFCs, and comments is not free &amp;ndash; it takes a lot of maintainer
time and energy to review those contributions! Sending the unreviewed output of
an LLM to open source project maintainers &lt;em>extracts&lt;/em> work from them in the form
of design and code review, so we call this kind of contribution an &amp;ldquo;extractive
contribution&amp;rdquo;.&lt;/p>
&lt;p>Our &lt;strong>golden rule&lt;/strong> is that a contribution should be worth more to the project
than the time it takes to review it. These ideas are captured by this quote from
the book &lt;a href="https://press.stripe.com/working-in-public">Working in Public&lt;/a> by Nadia Eghbal:&lt;/p>
&lt;blockquote>
&lt;p>&amp;ldquo;When attention is being appropriated, producers need to weigh the costs and
benefits of the transaction. To assess whether the appropriation of attention
is net-positive, it&amp;rsquo;s useful to distinguish between &lt;em>extractive&lt;/em> and
&lt;em>non-extractive&lt;/em> contributions. Extractive contributions are those where the
marginal cost of reviewing and merging that contribution is greater than the
marginal benefit to the project&amp;rsquo;s producers. In the case of a code
contribution, it might be a pull request that&amp;rsquo;s too complex or unwieldy to
review, given the potential upside.&amp;rdquo; &amp;ndash; Nadia Eghbal&lt;/p>
&lt;/blockquote>
&lt;p>Prior to the advent of LLMs, open source project maintainers would often review
any and all changes sent to the project simply because posting a change for
review was a sign of interest from a potential long-term contributor. While new
tools enable more development, it shifts effort from the implementer to the
reviewer, and our policy exists to ensure that we value and do not squander
maintainer time.&lt;/p>
&lt;p>Reviewing changes from new contributors is part of growing the next generation
of contributors and sustaining the project. We want the HEIR project to be
welcoming and open to aspiring scientists and engineers who are willing to
invest time and effort to learn and grow, because growing our contributor base
and recruiting new maintainers helps sustain the project over the long term.&lt;/p>
&lt;h2 id="handling-violations">Handling Violations&lt;/h2>
&lt;p>If a maintainer judges that a contribution doesn&amp;rsquo;t comply with this policy, they
should paste the following response to request changes:&lt;/p>
&lt;pre tabindex="0">&lt;code>This PR doesn&amp;#39;t appear to comply with our policy on tool-generated content,
and requires additional justification for why it is valuable enough to the
project for us to review it. Please see our developer policy on
AI-generated contributions: https://heir.dev/docs/development/ai_policy/
&lt;/code>&lt;/pre>&lt;p>The best ways to make a change less extractive and more valuable are to reduce
its size or complexity or to increase its usefulness to the community. These
factors are impossible to weigh objectively, and our project policy leaves this
determination up to the maintainers of the project, i.e. those who are doing the
work of sustaining the project.&lt;/p>
&lt;p>If or when it becomes clear that a GitHub issue or PR is off-track and not
moving in the right direction, maintainers should apply the &lt;code>extractive&lt;/code> label
to help other reviewers prioritize their review time.&lt;/p>
&lt;p>If a contributor responds but doesn&amp;rsquo;t make their change meaningfully less
extractive, maintainers should escalate to the relevant admin to lock the
conversation.&lt;/p>
&lt;h2 id="references">References&lt;/h2>
&lt;p>Our policy was informed by experiences in other communities:&lt;/p>
&lt;ul>
&lt;li>&lt;a href="https://communityblog.fedoraproject.org/council-policy-proposal-policy-on-ai-assisted-contributions/">Fedora Council Policy Proposal: Policy on AI-Assisted Contributions (fetched 2025-10-01)&lt;/a>:
Some of the text above was copied from the Fedora project policy proposal,
which is licensed under the
&lt;a href="https://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License&lt;/a>. This link
serves as attribution.&lt;/li>
&lt;li>&lt;a href="https://github.com/rust-lang/compiler-team/issues/893">Rust draft policy on burdensome PRs&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://sethmlarson.dev/slop-security-reports">Seth Larson&amp;rsquo;s post&lt;/a> on slop security reports in the Python
ecosystem&lt;/li>
&lt;li>The METR paper
&lt;a href="https://metr.org/blog/2025-07-10-early-2025-ai-experienced-os-dev-study/">Measuring the Impact of Early-2025 AI on Experienced Open-Source Developer Productivity&lt;/a>.&lt;/li>
&lt;li>&lt;a href="https://www.qemu.org/docs/master/devel/code-provenance.html#use-of-ai-content-generators">QEMU bans use of AI content generators&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://simonwillison.net/2024/May/8/slop/">Slop is the new name for unwanted AI-generated content&lt;/a>&lt;/li>
&lt;/ul>
&lt;!-- mdformat global-off --></description></item><item><title>Docs: Bazel tips</title><link>https://heir.dev/docs/development/bazel/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://heir.dev/docs/development/bazel/</guid><description>
&lt;h2 id="bazel-cheat-sheet">Bazel cheat sheet&lt;/h2>
&lt;h3 id="commands">Commands&lt;/h3>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th style="text-align:left">Task&lt;/th>
&lt;th style="text-align:left">Command&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td style="text-align:left">Build everything (slow)&lt;/td>
&lt;td style="text-align:left">&lt;code>bazel build //...:all&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align:left">Build tests not marked as manual&lt;/td>
&lt;td style="text-align:left">&lt;code>bazel build --build_tag_filters=-manual //...:all&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align:left">Build a specific library target&lt;/td>
&lt;td style="text-align:left">&lt;code>bazel build //lib/Dialect/Polynomial/IR\:Dialect&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align:left">Build heir-opt&lt;/td>
&lt;td style="text-align:left">&lt;code>bazel build //tools:heir-opt&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align:left">List targets in a directory&lt;/td>
&lt;td style="text-align:left">&lt;code>bazel query //lib/Dialect/Polynomial/IR\:all&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align:left">Run all tests&lt;/td>
&lt;td style="text-align:left">&lt;code>bazel test //...:all&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align:left">Run a subset of tests by path&lt;/td>
&lt;td style="text-align:left">&lt;code>bazel test //tests/Dialect/...&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align:left">Run unit tests&lt;/td>
&lt;td style="text-align:left">&lt;code>bazel test //lib/...:all&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align:left">Run lit and end-to-end tests&lt;/td>
&lt;td style="text-align:left">&lt;code>bazel test //tests/...:all&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align:left">Run only lit tests (fast)&lt;/td>
&lt;td style="text-align:left">&lt;code>bazel test $(bazel query 'filter(&amp;quot;\.mlir\.test$&amp;quot;, //...)')&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align:left">Run end-to-end tests (slow)&lt;/td>
&lt;td style="text-align:left">&lt;code>bazel test //tests/Examples/...:all&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align:left">Clear build cache&lt;/td>
&lt;td style="text-align:left">&lt;code>bazel clean&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align:left">Clear build cache and system analysis (where is clang, etc.)&lt;/td>
&lt;td style="text-align:left">&lt;code>bazel clean --expunge&lt;/code>&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h3 id="bazel-flags">Bazel flags&lt;/h3>
&lt;p>These flags are for &lt;code>bazel&lt;/code>, and so they go before the target, and before any
&lt;code>--&lt;/code> that separates flags for &lt;code>bazel&lt;/code> from flags for the binary target being
run, i.e., &lt;code>heir-opt&lt;/code> or &lt;code>heir-translate&lt;/code>. These can also be persistently
configured in a &lt;code>.bazelrc&lt;/code> file.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th style="text-align:left">Flag&lt;/th>
&lt;th style="text-align:left">Description&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td style="text-align:left">&lt;code>-c opt&lt;/code>&lt;/td>
&lt;td style="text-align:left">Build with optimizations enabled (&lt;code>-O3&lt;/code>).&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align:left">&lt;code>-c dbg&lt;/code>&lt;/td>
&lt;td style="text-align:left">Build with debug symbols (better stack traces)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align:left">&lt;code>-c fastbuild&lt;/code>&lt;/td>
&lt;td style="text-align:left">Sets compiler flags to optimize for fast build time&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align:left">&lt;code>--subcommands&lt;/code>&lt;/td>
&lt;td style="text-align:left">Shows subcommands that bazel invokes while building (e.g., raw &lt;code>clang&lt;/code> or &lt;code>heir-opt&lt;/code> commands run.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align:left">&lt;code>--test_tag_filters&lt;/code> and &lt;code>--build_tag_filters &lt;/code>&lt;/td>
&lt;td style="text-align:left">Filter targets by the &lt;code>tag&lt;/code> set on the build target. E.g., &lt;code>--build_tag_filters=-manual&lt;/code> will exclude any targets with the &lt;code>manual&lt;/code> tag.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h2 id="build-file-formatting">BUILD file formatting&lt;/h2>
&lt;p>The &lt;code>buildifier&lt;/code> tool can be used to format BUILD files. You can download the
latest Buildifier release from the
&lt;a href="https://github.com/bazelbuild/buildtools/releases/latest/">Bazel Release Page&lt;/a>.
See &lt;a href="https://heir.dev/docs/development/ide/">IDE configuration&lt;/a> for tips on integrating this
with your IDE.&lt;/p>
&lt;h2 id="avoiding-rebuilds">Avoiding rebuilds&lt;/h2>
&lt;p>Bazel is notoriously fickle when it comes to deciding whether a full rebuild is
necessary, which is bad for HEIR because rebuilding LLVM from scratch takes 15
minutes or more. We try to avoid this as much as possible by setting default
options in the project root&amp;rsquo;s &lt;code>.bazelrc&lt;/code>.&lt;/p>
&lt;p>The main things that cause a rebuild are:&lt;/p>
&lt;ul>
&lt;li>Pulling an update from the remote &lt;code>main&lt;/code> branch. The pinned LLVM commit is
updated roughly once a day via automation
(&lt;a href="https://github.com/google/heir/commit/c6d4eeee3b91935108769cde0f9ef4e477bb869e">example commit&lt;/a>)
and changing that commit triggers a full rebuild of LLVM.&lt;/li>
&lt;li>A change to the &lt;code>.bazelrc&lt;/code> that implicitly causes a flag change. Note HEIR has
its own project-specific &lt;code>.bazelrc&lt;/code> in the root directory.&lt;/li>
&lt;li>A change to the command-line flags passed to bazel, e.g., &lt;code>-c opt&lt;/code> vs &lt;code>-c dbg&lt;/code>
for optimization level and debug symbols. The default is &lt;code>-c dbg&lt;/code>, and you may
want to override this to optimize performance of generated code. For example,
the OpenFHE backend generates much faster code when compiled with &lt;code>-c opt&lt;/code>.&lt;/li>
&lt;li>A change to relevant command-line variables, such as &lt;code>PATH&lt;/code>, which is avoided
by the &lt;code>incompatible_strict_action_env&lt;/code> flag. Note activating a python
virtualenv triggers a &lt;code>PATH&lt;/code> change. The default is
&lt;code>incompatible_strict_action_env=true&lt;/code>, and you would override this in the
event that you want your shell&amp;rsquo;s environment variables to change and be
inherited by bazel.&lt;/li>
&lt;/ul>
&lt;h2 id="pointing-heir-to-a-local-clone-of-llvm-project">Pointing HEIR to a local clone of &lt;code>llvm-project&lt;/code>&lt;/h2>
&lt;p>Occasionally changes in HEIR will need to be made in tandem with upstream
changes in MLIR. In particular, we occasionally find upstream bugs that only
occur with HEIR passes, and we are the primary owners/users of the upstream
&lt;code>polynomial&lt;/code> dialect.&lt;/p>
&lt;p>To tell &lt;code>bazel&lt;/code> to use a local clone of &lt;code>llvm-project&lt;/code> instead of a pinned
commit hash, replace &lt;code>bazel/import_llvm.bzl&lt;/code> with the following file:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>cat &amp;gt; bazel/import_llvm.bzl &lt;span style="color:#4e9a06">&amp;lt;&amp;lt; EOF
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#4e9a06">&amp;#34;&amp;#34;&amp;#34;Provides the repository macro to import LLVM.&amp;#34;&amp;#34;&amp;#34;
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#4e9a06">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#4e9a06">def import_llvm(name):
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#4e9a06"> &amp;#34;&amp;#34;&amp;#34;Imports LLVM.&amp;#34;&amp;#34;&amp;#34;
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#4e9a06"> native.new_local_repository(
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#4e9a06"> name = name,
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#4e9a06"> # this BUILD file is intentionally empty, because the LLVM project
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#4e9a06"> # internally contains a set of bazel BUILD files overlaying the project.
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#4e9a06"> build_file_content = &amp;#34;# empty&amp;#34;,
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#4e9a06"> path = &amp;#34;/path/to/llvm-project&amp;#34;,
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#4e9a06"> )
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#4e9a06">EOF&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The next &lt;code>bazel build&lt;/code> will require a full rebuild if the checked-out LLVM
commit differs from the pinned commit hash in &lt;code>bazel/import_llvm.bzl&lt;/code>.&lt;/p>
&lt;p>Note that you cannot reuse the LLVM CMake build artifacts in the bazel build.
Based on what you&amp;rsquo;re trying to do, this may require some extra steps.&lt;/p>
&lt;ul>
&lt;li>If you just want to run existing MLIR and HEIR tests against local
&lt;code>llvm-project&lt;/code> changes, you can run the tests from HEIR using
&lt;code>bazel test @llvm-project//mlir/...:all&lt;/code>. New &lt;code>lit&lt;/code> tests can be added in
&lt;code>llvm-project&lt;/code>&amp;rsquo;s existing directories and tested this way without a rebuild.&lt;/li>
&lt;li>If you add new CMake targets in &lt;code>llvm-project&lt;/code>, then to incorporate them into
HEIR you need to add new bazel targets in
&lt;code>llvm-project/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel&lt;/code>. This is
required if, for example, a new dialect or pass is added in MLIR upstream.&lt;/li>
&lt;/ul>
&lt;p>Send any upstream changes to HEIR-relevant MLIR files to @j2kun (Jeremy Kun) who
has LLVM commit access and can also suggest additional MLIR reviewers.&lt;/p>
&lt;h2 id="finding-upstream-dependency-targets">Finding upstream dependency targets&lt;/h2>
&lt;p>Whenever a new dependency is added in C++ or Tablegen, a new bazel BUILD
dependency is required, which requires finding the path to the relevant target
that provides the file you want. In HEIR the BUILD target should be defined in
the same directory as the file you want to depend on (e.g., the targets that
provide &lt;code>foo.h&lt;/code> are in &lt;code>BUILD&lt;/code> in the same directory), but upstream MLIR&amp;rsquo;s bazel
layout is different.&lt;/p>
&lt;p>LLVM&amp;rsquo;s bazel overlay for MLIR is contained in a
&lt;a href="https://github.com/llvm/llvm-project/blob/main/utils/bazel/llvm-project-overlay/mlir/BUILD.bazel">single file&lt;/a>,
and so you can manually look there to find the right target. With bazel, if you
know the filepath of interested you can also run:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>bazel query --keep_going &lt;span style="color:#4e9a06">&amp;#39;same_pkg_direct_rdeps(@llvm-project//mlir:&amp;lt;path&amp;gt;)&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>where &lt;code>&amp;lt;path&amp;gt;&lt;/code> is the path relative to &lt;code>mlir/&lt;/code> in the &lt;code>llvm-project&lt;/code> project
root. For example, to find the target that provides
&lt;code>mlir/include/mlir/Pass/PassBase.td&lt;/code>, run&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>bazel query --keep_going &lt;span style="color:#4e9a06">&amp;#39;same_pkg_direct_rdeps(@llvm-project//mlir:include/mlir/Pass/PassBase.td)&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>And the output will be something like&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>@llvm-project//mlir:PassBaseTdFiles
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>You can find more examples and alternative queries at the
&lt;a href="https://bazel.build/query/language#rdeps">Bazel query docs&lt;/a>.&lt;/p>
&lt;!-- mdformat global-off --></description></item><item><title>Docs: Boilerplate tools</title><link>https://heir.dev/docs/development/boilerplate/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://heir.dev/docs/development/boilerplate/</guid><description>
&lt;p>The script &lt;code>scripts/templates/templates.py&lt;/code> contains commands for generating new
dialects and transforms, filling in most of the boilerplate Tablegen and C++.
These commands do &lt;strong>not&lt;/strong> add the code needed to register the new passes or
dialects in &lt;code>heir-opt&lt;/code>.&lt;/p>
&lt;p>These should be used when the tablegen files containing existing pass
definitions in the expected filepaths are not already present. Otherwise, you
must modify the existing tablegen files directly.&lt;/p>
&lt;p>Run &lt;code>python scripts/templates/templates.py --help&lt;/code> and
&lt;code>python scripts/templates/templates.py &amp;lt;subcommand&amp;gt; --help&lt;/code> for the available
commands and options.&lt;/p>
&lt;h2 id="creating-a-new-pass">Creating a New Pass&lt;/h2>
&lt;h3 id="general-passes">General passes&lt;/h3>
&lt;p>If the pass does not operate from and to a specific dialect, use something
similar to:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>python scripts/templates/templates.py new_transform &lt;span style="color:#4e9a06">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#4e9a06">&lt;/span>--pass_name&lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span>ForgetSecrets &lt;span style="color:#4e9a06">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#4e9a06">&lt;/span>--pass_flag&lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span>forget-secrets
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="dialect-transforms">Dialect Transforms&lt;/h3>
&lt;p>To create a pass that operates within on a dialect, run a command similar to:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>python scripts/templates/templates.py new_dialect_transform &lt;span style="color:#4e9a06">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#4e9a06">&lt;/span>--pass_name&lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span>ForgetSecrets &lt;span style="color:#4e9a06">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#4e9a06">&lt;/span>--pass_flag&lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span>forget-secrets &lt;span style="color:#4e9a06">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#4e9a06">&lt;/span>--dialect_name&lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span>Secret &lt;span style="color:#4e9a06">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#4e9a06">&lt;/span>--dialect_namespace&lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span>secret
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="conversion-pass">Conversion Pass&lt;/h3>
&lt;p>To create a new conversion pass, i.e., a pass that lowers from one dialect to
another, run a command similar to:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>python scripts/templates/templates.py new_conversion_pass &lt;span style="color:#4e9a06">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#4e9a06">&lt;/span>--source_dialect_name&lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span>CGGI &lt;span style="color:#4e9a06">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#4e9a06">&lt;/span>--source_dialect_namespace&lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span>cggi &lt;span style="color:#4e9a06">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#4e9a06">&lt;/span>--source_dialect_mnemonic&lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span>cggi &lt;span style="color:#4e9a06">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#4e9a06">&lt;/span>--target_dialect_name&lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span>TfheRust &lt;span style="color:#4e9a06">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#4e9a06">&lt;/span>--target_dialect_namespace&lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span>tfhe_rust &lt;span style="color:#4e9a06">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#4e9a06">&lt;/span>--target_dialect_mnemonic&lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span>tfhe_rust
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>In order to build the resulting code, you must fix the labeled &lt;code>FIXME&lt;/code>s in the
type converter and the op conversion patterns.&lt;/p>
&lt;h2 id="creating-a-new-dialect">Creating a New Dialect&lt;/h2>
&lt;p>To create a new dialect, run something like&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>python scripts/templates/templates.py new_dialect &lt;span style="color:#4e9a06">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#4e9a06">&lt;/span>--dialet_name&lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span>TensorExt &lt;span style="color:#4e9a06">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#4e9a06">&lt;/span>--dialect_namespace&lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span>tensor_ext &lt;span style="color:#4e9a06">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#4e9a06">&lt;/span>--enable_attributes&lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span>False &lt;span style="color:#4e9a06">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#4e9a06">&lt;/span>--enable_types&lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span>True &lt;span style="color:#4e9a06">\
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#4e9a06">&lt;/span>--enable_ops&lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span>True
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Note that all &lt;code>--enable&lt;/code> flags are &lt;code>True&lt;/code> by default, so if you know your
dialect will not have attributes or types, you have to explicitly disable those
options.&lt;/p>
&lt;!-- mdformat global-off --></description></item><item><title>Docs: IDE configuration</title><link>https://heir.dev/docs/development/ide/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://heir.dev/docs/development/ide/</guid><description>
&lt;h2 id="heir-lsp">heir-lsp&lt;/h2>
&lt;p>HEIR provides an LSP server that extends the MLIR LSP server with HEIR&amp;rsquo;s
dialects.&lt;/p>
&lt;p>Build the LSP binary, then move it to a location on your path or point your IDE
to &lt;code>bazel-bin/tools/heir-lsp&lt;/code>.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>bazel build //tools:heir-lsp
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>cp bazel-bin/tools/heir-lsp /usr/local/bin
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Note that if you change any HEIR dialects, or if HEIR&amp;rsquo;s dependency on MLIR
updates and the upstream MLIR has dialect changes (which happens roughly daily),
you need to rebuild &lt;code>heir-lsp&lt;/code> for it to recognize the changes.&lt;/p>
&lt;h2 id="clangd">clangd&lt;/h2>
&lt;p>Most IDE configured to use clangd can be powered from a file called
&lt;code>compile_commands.json&lt;/code>. To generate that for HEIR, run&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-shell" data-lang="shell">&lt;span style="display:flex;">&lt;span>bazel run @hedron_compile_commands//:refresh_all
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>This will need to be regenerated when there are major &lt;code>BUILD&lt;/code> file changes. If
you encounter errors like &lt;code>*.h.inc&lt;/code> not found, or syntax errors inside these
files, you may need to build those targets and then re-run the &lt;code>refresh_all&lt;/code>
command above.&lt;/p>
&lt;p>Note that you will most likely also need to install the actual &lt;code>clangd&lt;/code> language
server, e.g., &lt;code>sudo apt-get install clangd&lt;/code> on debian/ubuntu.&lt;/p>
&lt;h2 id="ibazel-file-watcher">ibazel file watcher&lt;/h2>
&lt;p>&lt;a href="https://github.com/bazelbuild/bazel-watcher">&lt;code>ibazel&lt;/code>&lt;/a> is a shell around
&lt;code>bazel&lt;/code> that watches a build target for file changes and automatically rebuilds.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>ibazel build //tools:heir-opt
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="vs-code">VS Code&lt;/h2>
&lt;p>While a wide variety of IDEs and editors can be used for HEIR development, we
currently only provide support for &lt;a href="https://code.visualstudio.com/">VSCode&lt;/a>.&lt;/p>
&lt;h3 id="setup">Setup&lt;/h3>
&lt;p>For the best experience, we recommend following these steps:&lt;/p>
&lt;ul>
&lt;li>
&lt;p>Install the
&lt;a href="https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.vscode-mlir">MLIR&lt;/a>,
&lt;a href="https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.vscode-clangd">clangd&lt;/a>
and
&lt;a href="https://marketplace.visualstudio.com/items?itemName=BazelBuild.vscode-bazel">Bazel&lt;/a>
extensions&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Install and rename Buildifier:&lt;/p>
&lt;p>You can download the latest Buildifier release, e.g., for linux-amd64 (see the
&lt;a href="https://github.com/bazelbuild/buildtools/releases/latest/">Bazel Release Page&lt;/a>
for a list of available binaries):&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>wget -c https://github.com/bazelbuild/buildtools/releases/latest/download/buildifier-linux-amd64
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>mv buildifier-linux-amd64 buildifier
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>chmod +x buildifier
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Just as with bazel, you will want to move this somewhere on your PATH, e.g.:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>mkdir -p ~/bin
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#204a87">echo&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;export PATH=$PATH:~/bin&amp;#39;&lt;/span> &amp;gt;&amp;gt; ~/.bashrc
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>mv buildifier ~/bin/buildifier
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>VS Code should automatically detect buildifier. If this is not successful, you
can manually set the &amp;ldquo;Buildifier Executable&amp;rdquo; setting for the Bazel extension
(&lt;code>bazel.buildifierExecutable&lt;/code>).&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Disable the
&lt;a href="https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools">C/C++ (aka &amp;lsquo;cpptools&amp;rsquo;)&lt;/a>
extension (either completely, or in the current workspace).&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Add the following snippet to your VS Code user settings found in
.vscode/settings.json to enable autocomplete based on the
compile_commands.json file (see above).&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-json" data-lang="json">&lt;span style="display:flex;">&lt;span> &lt;span style="color:#4e9a06">&amp;#34;clangd.arguments&amp;#34;&lt;/span>&lt;span style="color:#a40000">:&lt;/span> &lt;span style="color:#000;font-weight:bold">[&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#4e9a06">&amp;#34;--compile-commands-dir=${workspaceFolder}/&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#4e9a06">&amp;#34;--completion-style=detailed&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#4e9a06">&amp;#34;--query-driver=**&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">]&lt;/span>&lt;span style="color:#a40000">,&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/li>
&lt;li>
&lt;p>For Python formatting, HEIR uses &lt;a href="https://github.com/google/pyink">pyink&lt;/a> for
autoformatting, which is a fork of the more commonly used
&lt;a href="https://github.com/psf/black">black&lt;/a> formatter with some patches to support
Google&amp;rsquo;s internal style guide. To use it in VSCode, install &lt;code>pyink&lt;/code> along with
other python utilities needed for HEIR: &lt;code>pip install -r requirements.txt&lt;/code> and
install the
&lt;a href="https://marketplace.visualstudio.com/items?itemName=ms-python.black-formatter">Black Formatter&lt;/a>
extension, then add the following to your VSCode user settings
(&lt;code>.vscode/settings.json&lt;/code>):&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-json" data-lang="json">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#4e9a06">&amp;#34;[python]&amp;#34;&lt;/span>&lt;span style="color:#a40000">:&lt;/span> &lt;span style="color:#000;font-weight:bold">{&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#204a87;font-weight:bold">&amp;#34;editor.defaultFormatter&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span> &lt;span style="color:#4e9a06">&amp;#34;ms-python.black-formatter&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#000;font-weight:bold">}&lt;/span>&lt;span style="color:#a40000">,&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#4e9a06">&amp;#34;black-formatter.path&amp;#34;&lt;/span>&lt;span style="color:#a40000">:&lt;/span> &lt;span style="color:#000;font-weight:bold">[&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#4e9a06">&amp;#34;path/to/pyink&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#000;font-weight:bold">]&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;/li>
&lt;li>
&lt;p>It might be necessary to add the path to your buildifier to VSCode, though it
should be auto-detected.&lt;/p>
&lt;ul>
&lt;li>Open the heir folder in VSCode&lt;/li>
&lt;li>Go to &amp;lsquo;Settings&amp;rsquo; and set it on the &amp;lsquo;Workspace&amp;rsquo;&lt;/li>
&lt;li>Search for &amp;ldquo;Bazel Buildifier Executable&amp;rdquo;&lt;/li>
&lt;li>Once you find it, write &lt;code>[home-directory]/bin/buildifier&lt;/code> for your specific
[home-directory].&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ul>
&lt;h3 id="building-testing-running-and-debugging-with-vscode">Building, Testing, Running and Debugging with VSCode&lt;/h3>
&lt;h4 id="building">Building&lt;/h4>
&lt;ol>
&lt;li>Open the &amp;ldquo;Explorer&amp;rdquo; (File Overview) in the left panel.&lt;/li>
&lt;li>Find &amp;ldquo;Bazel Build Targets&amp;rdquo; towards the bottom of the &amp;ldquo;Explorer&amp;rdquo; panel and
click the dropdown button.&lt;/li>
&lt;li>Unfold the heir folder&lt;/li>
&lt;li>Right-click on &amp;ldquo;//tools&amp;rdquo; and click the &amp;ldquo;Build Package Recursively&amp;rdquo; option&lt;/li>
&lt;/ol>
&lt;h4 id="testing">Testing&lt;/h4>
&lt;ol>
&lt;li>Open the &amp;ldquo;Explorer&amp;rdquo; (File Overview) in the left panel.&lt;/li>
&lt;li>Find &amp;ldquo;Bazel Build Targets&amp;rdquo; towards the bottom of the &amp;ldquo;Explorer&amp;rdquo; panel and
click the dropdown button.&lt;/li>
&lt;li>Unfold the heir folder&lt;/li>
&lt;li>Right-click on &amp;ldquo;//test&amp;rdquo; and click the &amp;ldquo;Test Package Recursively&amp;rdquo; option&lt;/li>
&lt;/ol>
&lt;h4 id="running-and-debugging">Running and Debugging&lt;/h4>
&lt;ol>
&lt;li>
&lt;p>Create a &lt;code>launch.json&lt;/code> file in the &lt;code>.vscode&lt;/code> folder, changing the &lt;code>&amp;quot;name&amp;quot;&lt;/code>
and &lt;code>&amp;quot;args&amp;quot;&lt;/code> as required:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-json" data-lang="json">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#000;font-weight:bold">{&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#204a87;font-weight:bold">&amp;#34;version&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span> &lt;span style="color:#4e9a06">&amp;#34;0.2.0&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#204a87;font-weight:bold">&amp;#34;configurations&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span> &lt;span style="color:#000;font-weight:bold">[&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">{&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#204a87;font-weight:bold">&amp;#34;name&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span> &lt;span style="color:#4e9a06">&amp;#34;Debug Secret-&amp;gt;BGV&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#204a87;font-weight:bold">&amp;#34;preLaunchTask&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span> &lt;span style="color:#4e9a06">&amp;#34;build&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#204a87;font-weight:bold">&amp;#34;type&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span> &lt;span style="color:#4e9a06">&amp;#34;lldb&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#204a87;font-weight:bold">&amp;#34;request&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span> &lt;span style="color:#4e9a06">&amp;#34;launch&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#204a87;font-weight:bold">&amp;#34;program&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span> &lt;span style="color:#4e9a06">&amp;#34;${workspaceFolder}/bazel-bin/tools/heir-opt&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#204a87;font-weight:bold">&amp;#34;args&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span> &lt;span style="color:#000;font-weight:bold">[&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#4e9a06">&amp;#34;--secret-to-bgv&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#4e9a06">&amp;#34;--debug&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#4e9a06">&amp;#34;${workspaceFolder}/tests/secret_to_bgv/ops.mlir&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">],&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#204a87;font-weight:bold">&amp;#34;relativePathBase&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span> &lt;span style="color:#4e9a06">&amp;#34;${workspaceFolder}&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#204a87;font-weight:bold">&amp;#34;sourceMap&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span> &lt;span style="color:#000;font-weight:bold">{&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#204a87;font-weight:bold">&amp;#34;proc/self/cwd&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span> &lt;span style="color:#4e9a06">&amp;#34;${workspaceFolder}&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#204a87;font-weight:bold">&amp;#34;/proc/self/cwd&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">:&lt;/span> &lt;span style="color:#4e9a06">&amp;#34;${workspaceFolder}&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">}&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">},&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">]&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#000;font-weight:bold">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>You can add as many different configurations as necessary.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Add Breakpoints to your program as desired.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>Open the Run/Debug panel on the left, select the desired configuration and
run/debug it.&lt;/p>
&lt;/li>
&lt;/ol>
&lt;ul>
&lt;li>Note that you might have to hit &amp;ldquo;Enter&amp;rdquo; to proceed past the Bazel build. It
might take several seconds between hitting &amp;ldquo;Enter&amp;rdquo; and the debug terminal
opening.&lt;/li>
&lt;/ul>
&lt;h2 id="vimneovim">Vim/Neovim&lt;/h2>
&lt;h3 id="misc-config">Misc config&lt;/h3>
&lt;p>Filetype detection&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-vim" data-lang="vim">&lt;span style="display:flex;">&lt;span># &lt;span style="color:#000">ftdetect&lt;/span>/&lt;span style="color:#000">mlir&lt;/span>.&lt;span style="color:#000">vim&lt;/span>&lt;span style="color:#a40000">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#a40000">&lt;/span>&lt;span style="color:#000">au&lt;/span> &lt;span style="color:#000">BufRead&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span>&lt;span style="color:#000">BufNewFile&lt;/span> *.&lt;span style="color:#000">mlir&lt;/span> &lt;span style="color:#000">setfiletype&lt;/span> &lt;span style="color:#000">mlir&lt;/span>&lt;span style="color:#a40000">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;a href="https://heir.dev/docs/development/bazel/#build-file-formatting">Buildifier&lt;/a> integration&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-vim" data-lang="vim">&lt;span style="display:flex;">&lt;span># &lt;span style="color:#000">ftplugin&lt;/span>/&lt;span style="color:#000">bzl&lt;/span>.&lt;span style="color:#000">vim&lt;/span>&lt;span style="color:#a40000">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#a40000">&lt;/span>&lt;span style="color:#000">augroup&lt;/span> &lt;span style="color:#000">AutoFormat&lt;/span>&lt;span style="color:#a40000">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#a40000">&lt;/span> &lt;span style="color:#000">autocmd&lt;/span>&lt;span style="color:#000;font-weight:bold">!&lt;/span>&lt;span style="color:#a40000">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#a40000">&lt;/span> &lt;span style="color:#000">autocmd&lt;/span> &lt;span style="color:#000">BufWritePre&lt;/span> &lt;span style="color:#000">Neoformat&lt;/span> &lt;span style="color:#000">buildifier&lt;/span>&lt;span style="color:#a40000">
&lt;/span>&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#a40000">&lt;/span>&lt;span style="color:#000">augroup&lt;/span> &lt;span style="color:#000">END&lt;/span>&lt;span style="color:#a40000">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>LSP configuration (Neovim, using
&lt;a href="https://github.com/neovim/nvim-lspconfig">nvim-lspconfig&lt;/a>)&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-lua" data-lang="lua">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#000">nvim_lsp&lt;/span>&lt;span style="color:#000;font-weight:bold">[&lt;/span>&lt;span style="color:#4e9a06">&amp;#34;mlir_lsp_server&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">].&lt;/span>&lt;span style="color:#000">setup&lt;/span> &lt;span style="color:#000;font-weight:bold">{&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000">on_attach&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#000">on_attach&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000">capabilities&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#000">capabilities&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000">cmd&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#000;font-weight:bold">{&lt;/span> &lt;span style="color:#4e9a06">&amp;#34;heir-lsp&amp;#34;&lt;/span> &lt;span style="color:#000;font-weight:bold">},&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#000;font-weight:bold">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Tree-sitter configuration for relevant project languages&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-lua" data-lang="lua">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#000">require&lt;/span>&lt;span style="color:#000;font-weight:bold">(&lt;/span>&lt;span style="color:#4e9a06">&amp;#39;nvim-treesitter.configs&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">).&lt;/span>&lt;span style="color:#000">setup&lt;/span> &lt;span style="color:#000;font-weight:bold">{&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000">ensure_installed&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#000;font-weight:bold">{&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#4e9a06">&amp;#34;markdown_inline&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#8f5902;font-style:italic">-- for markdown in tablegen&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#4e9a06">&amp;#34;mlir&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#4e9a06">&amp;#34;tablegen&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#4e9a06">&amp;#34;verilog&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#8f5902;font-style:italic">-- for yosys&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">},&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#8f5902;font-style:italic">-- &amp;lt;... other config options ...&amp;gt;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#000;font-weight:bold">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Telescope-alternate config (quickly jump between cc, header, and tablegen files)&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-lua" data-lang="lua">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#000">require&lt;/span>&lt;span style="color:#000;font-weight:bold">(&lt;/span>&lt;span style="color:#4e9a06">&amp;#39;telescope-alternate&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">).&lt;/span>&lt;span style="color:#000">setup&lt;/span>&lt;span style="color:#000;font-weight:bold">({&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000">mappings&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#000;font-weight:bold">{&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">{&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000">pattern&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;**/(.*).h&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000">targets&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#000;font-weight:bold">{&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">{&lt;/span> &lt;span style="color:#000">template&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;**/[1].cc&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#000">label&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;cc&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#000">enable_new&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#204a87;font-weight:bold">false&lt;/span> &lt;span style="color:#000;font-weight:bold">},&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">{&lt;/span> &lt;span style="color:#000">template&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;**/[1].cpp&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#000">label&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;cpp&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#000">enable_new&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#204a87;font-weight:bold">false&lt;/span> &lt;span style="color:#000;font-weight:bold">},&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">{&lt;/span> &lt;span style="color:#000">template&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;**/[1]Test.cc&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#000">label&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;cc Test&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#000">enable_new&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#204a87;font-weight:bold">false&lt;/span> &lt;span style="color:#000;font-weight:bold">},&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">{&lt;/span> &lt;span style="color:#000">template&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;**/[1]Test.cpp&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#000">label&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;cpp Test&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#000">enable_new&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#204a87;font-weight:bold">false&lt;/span> &lt;span style="color:#000;font-weight:bold">},&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">{&lt;/span> &lt;span style="color:#000">template&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;**/[1].td&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#000">label&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;tablegen&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#000">enable_new&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#204a87;font-weight:bold">false&lt;/span> &lt;span style="color:#000;font-weight:bold">},&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">}&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">},&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">{&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000">pattern&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;**/(.*).cc&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000">targets&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#000;font-weight:bold">{&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">{&lt;/span> &lt;span style="color:#000">template&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;**/[1].h&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#000">label&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;header&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#000">enable_new&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#204a87;font-weight:bold">false&lt;/span> &lt;span style="color:#000;font-weight:bold">},&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">{&lt;/span> &lt;span style="color:#000">template&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;**/[1].cpp&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#000">label&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;cpp&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#000">enable_new&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#204a87;font-weight:bold">false&lt;/span> &lt;span style="color:#000;font-weight:bold">},&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">{&lt;/span> &lt;span style="color:#000">template&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;**/[1]Test.cc&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#000">label&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;cc Test&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#000">enable_new&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#204a87;font-weight:bold">false&lt;/span> &lt;span style="color:#000;font-weight:bold">},&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">{&lt;/span> &lt;span style="color:#000">template&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;**/[1]Test.cpp&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#000">label&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;cpp Test&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#000">enable_new&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#204a87;font-weight:bold">false&lt;/span> &lt;span style="color:#000;font-weight:bold">},&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">{&lt;/span> &lt;span style="color:#000">template&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;**/[1].td&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#000">label&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;tablegen&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#000">enable_new&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#204a87;font-weight:bold">false&lt;/span> &lt;span style="color:#000;font-weight:bold">},&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">}&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">},&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">{&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000">pattern&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;**/(.*).cpp&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000">targets&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#000;font-weight:bold">{&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">{&lt;/span> &lt;span style="color:#000">template&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;**/[1].h&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#000">label&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;header&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#000">enable_new&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#204a87;font-weight:bold">false&lt;/span> &lt;span style="color:#000;font-weight:bold">},&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">{&lt;/span> &lt;span style="color:#000">template&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;**/[1].cc&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#000">label&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;cc&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#000">enable_new&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#204a87;font-weight:bold">false&lt;/span> &lt;span style="color:#000;font-weight:bold">},&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">{&lt;/span> &lt;span style="color:#000">template&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;**/[1]Test.cc&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#000">label&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;test&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#000">enable_new&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#204a87;font-weight:bold">false&lt;/span> &lt;span style="color:#000;font-weight:bold">},&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">{&lt;/span> &lt;span style="color:#000">template&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;**/[1]Test.cpp&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#000">label&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;test&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#000">enable_new&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#204a87;font-weight:bold">false&lt;/span> &lt;span style="color:#000;font-weight:bold">},&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">{&lt;/span> &lt;span style="color:#000">template&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;**/[1].td&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#000">label&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;tablegen&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#000">enable_new&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#204a87;font-weight:bold">false&lt;/span> &lt;span style="color:#000;font-weight:bold">},&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">}&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">},&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">{&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000">pattern&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;**/(.*).td&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000">targets&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#000;font-weight:bold">{&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">{&lt;/span> &lt;span style="color:#000">template&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;**/[1].h&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#000">label&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;header&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#000">enable_new&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#204a87;font-weight:bold">false&lt;/span> &lt;span style="color:#000;font-weight:bold">},&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">{&lt;/span> &lt;span style="color:#000">template&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;**/[1].cc&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#000">label&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;cc&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#000">enable_new&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#204a87;font-weight:bold">false&lt;/span> &lt;span style="color:#000;font-weight:bold">},&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">{&lt;/span> &lt;span style="color:#000">template&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;**/[1].cpp&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#000">label&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;cpp&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#000">enable_new&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#204a87;font-weight:bold">false&lt;/span> &lt;span style="color:#000;font-weight:bold">},&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">}&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">},&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">{&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000">pattern&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;(.*)Test.(.*)&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000">targets&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#000;font-weight:bold">{&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">{&lt;/span> &lt;span style="color:#000">template&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;**/[1].[2]&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#000">label&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;implementation&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#000">enable_new&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#204a87;font-weight:bold">false&lt;/span> &lt;span style="color:#000;font-weight:bold">},&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">}&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">},&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">},&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000">open_only_one_with&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;vertical_split&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#000;font-weight:bold">})&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h3 id="useful-mappings">Useful mappings&lt;/h3>
&lt;p>Navigate to the bazel build target for current file&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-lua" data-lang="lua">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#000">vim.keymap&lt;/span>&lt;span style="color:#000;font-weight:bold">.&lt;/span>&lt;span style="color:#000">set&lt;/span>&lt;span style="color:#000;font-weight:bold">(&lt;/span>&lt;span style="color:#4e9a06">&amp;#39;n&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;&amp;lt;leader&amp;gt;eb&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#204a87;font-weight:bold">function&lt;/span>&lt;span style="color:#000;font-weight:bold">()&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#8f5902;font-style:italic">-- expand(&amp;#34;%:p:h&amp;#34;) gets the current filepath&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#204a87;font-weight:bold">local&lt;/span> &lt;span style="color:#000">buildfile&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#000">vim.fn&lt;/span>&lt;span style="color:#000;font-weight:bold">.&lt;/span>&lt;span style="color:#000">expand&lt;/span>&lt;span style="color:#000;font-weight:bold">(&lt;/span>&lt;span style="color:#4e9a06">&amp;#34;%:p:h&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">)&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">..&lt;/span> &lt;span style="color:#4e9a06">&amp;#34;/BUILD&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#8f5902;font-style:italic">-- expand(&amp;#34;%:t&amp;#34;) gets the current filename with suffix.&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#204a87;font-weight:bold">local&lt;/span> &lt;span style="color:#000">target&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#000">vim.fn&lt;/span>&lt;span style="color:#000;font-weight:bold">.&lt;/span>&lt;span style="color:#000">expand&lt;/span>&lt;span style="color:#000;font-weight:bold">(&lt;/span>&lt;span style="color:#4e9a06">&amp;#34;%:t&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">)&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000">vim.api&lt;/span>&lt;span style="color:#000;font-weight:bold">.&lt;/span>&lt;span style="color:#000">nvim_command&lt;/span>&lt;span style="color:#000;font-weight:bold">(&lt;/span>&lt;span style="color:#4e9a06">&amp;#34;botright vsplit &amp;#34;&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">..&lt;/span> &lt;span style="color:#000">buildfile&lt;/span>&lt;span style="color:#000;font-weight:bold">)&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000">vim.cmd&lt;/span>&lt;span style="color:#000;font-weight:bold">(&lt;/span>&lt;span style="color:#4e9a06">&amp;#34;normal /&amp;#34;&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">..&lt;/span> &lt;span style="color:#000">target&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">..&lt;/span> &lt;span style="color:#000">vim.api&lt;/span>&lt;span style="color:#000;font-weight:bold">.&lt;/span>&lt;span style="color:#000">nvim_replace_termcodes&lt;/span>&lt;span style="color:#000;font-weight:bold">(&lt;/span>&lt;span style="color:#4e9a06">&amp;#34;&amp;lt;CR&amp;gt;&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#204a87;font-weight:bold">true&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#204a87;font-weight:bold">true&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#204a87;font-weight:bold">true&lt;/span>&lt;span style="color:#000;font-weight:bold">))&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000">vim.cmd&lt;/span>&lt;span style="color:#000;font-weight:bold">(&lt;/span>&lt;span style="color:#4e9a06">&amp;#34;normal zz&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">)&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#204a87;font-weight:bold">end&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000;font-weight:bold">{&lt;/span> &lt;span style="color:#000">noremap&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#204a87;font-weight:bold">true&lt;/span> &lt;span style="color:#000;font-weight:bold">})&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Set include guards according to HEIR style guide.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-lua" data-lang="lua">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#204a87;font-weight:bold">local&lt;/span> &lt;span style="color:#204a87;font-weight:bold">function&lt;/span> &lt;span style="color:#000">build_include_guard&lt;/span>&lt;span style="color:#000;font-weight:bold">()&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#8f5902;font-style:italic">-- project relative filepath&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#204a87;font-weight:bold">local&lt;/span> &lt;span style="color:#000">abs_path&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#000">vim.fn&lt;/span>&lt;span style="color:#000;font-weight:bold">.&lt;/span>&lt;span style="color:#000">expand&lt;/span>&lt;span style="color:#000;font-weight:bold">(&lt;/span>&lt;span style="color:#4e9a06">&amp;#34;%&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">)&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#204a87;font-weight:bold">local&lt;/span> &lt;span style="color:#000">rel_path&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#000">vim.fn&lt;/span>&lt;span style="color:#000;font-weight:bold">.&lt;/span>&lt;span style="color:#000">fnamemodify&lt;/span>&lt;span style="color:#000;font-weight:bold">(&lt;/span>&lt;span style="color:#000">abs_path&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#4e9a06">&amp;#34;:~:.&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">)&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#8f5902;font-style:italic">-- screaming case&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#204a87;font-weight:bold">local&lt;/span> &lt;span style="color:#000">upper&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#000">string.upper&lt;/span>&lt;span style="color:#000;font-weight:bold">(&lt;/span>&lt;span style="color:#000">rel_path&lt;/span>&lt;span style="color:#000;font-weight:bold">)&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#8f5902;font-style:italic">-- underscore separated&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#204a87;font-weight:bold">local&lt;/span> &lt;span style="color:#000">underscored&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#000">string.gsub&lt;/span>&lt;span style="color:#000;font-weight:bold">(&lt;/span>&lt;span style="color:#000">upper&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#4e9a06">&amp;#34;[./]&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#4e9a06">&amp;#34;_&amp;#34;&lt;/span>&lt;span style="color:#000;font-weight:bold">)&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#8f5902;font-style:italic">-- trailing underscore&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#204a87;font-weight:bold">return&lt;/span> &lt;span style="color:#000">underscored&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">..&lt;/span> &lt;span style="color:#4e9a06">&amp;#34;_&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#204a87;font-weight:bold">end&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#8f5902;font-style:italic">-- mnemonic: fi = fix include (guard)&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#000">vim.keymap&lt;/span>&lt;span style="color:#000;font-weight:bold">.&lt;/span>&lt;span style="color:#000">set&lt;/span>&lt;span style="color:#000;font-weight:bold">(&lt;/span>&lt;span style="color:#4e9a06">&amp;#39;n&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#4e9a06">&amp;#39;&amp;lt;leader&amp;gt;fi&amp;#39;&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#204a87;font-weight:bold">function&lt;/span>&lt;span style="color:#000;font-weight:bold">()&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#204a87;font-weight:bold">local&lt;/span> &lt;span style="color:#000">buf&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#000">vim.api&lt;/span>&lt;span style="color:#000;font-weight:bold">.&lt;/span>&lt;span style="color:#000">nvim_get_current_buf&lt;/span>&lt;span style="color:#000;font-weight:bold">()&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#204a87;font-weight:bold">local&lt;/span> &lt;span style="color:#000">include_guard&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#000">build_include_guard&lt;/span>&lt;span style="color:#000;font-weight:bold">()&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#204a87;font-weight:bold">local&lt;/span> &lt;span style="color:#000">ifndef&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#34;#ifndef &amp;#34;&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">..&lt;/span> &lt;span style="color:#000">include_guard&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#204a87;font-weight:bold">local&lt;/span> &lt;span style="color:#000">define&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#34;#define &amp;#34;&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">..&lt;/span> &lt;span style="color:#000">include_guard&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#204a87;font-weight:bold">local&lt;/span> &lt;span style="color:#000">endif&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#4e9a06">&amp;#34;#endif // &amp;#34;&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">..&lt;/span> &lt;span style="color:#000">include_guard&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000">vim.api&lt;/span>&lt;span style="color:#000;font-weight:bold">.&lt;/span>&lt;span style="color:#000">nvim_buf_set_lines&lt;/span>&lt;span style="color:#000;font-weight:bold">(&lt;/span>&lt;span style="color:#000">buf&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#0000cf;font-weight:bold">0&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#0000cf;font-weight:bold">2&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#204a87;font-weight:bold">false&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#000;font-weight:bold">{&lt;/span> &lt;span style="color:#000">ifndef&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#000">define&lt;/span> &lt;span style="color:#000;font-weight:bold">})&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> &lt;span style="color:#000">vim.api&lt;/span>&lt;span style="color:#000;font-weight:bold">.&lt;/span>&lt;span style="color:#000">nvim_buf_set_lines&lt;/span>&lt;span style="color:#000;font-weight:bold">(&lt;/span>&lt;span style="color:#000">buf&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">-&lt;/span>&lt;span style="color:#0000cf;font-weight:bold">2&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">-&lt;/span>&lt;span style="color:#0000cf;font-weight:bold">1&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#204a87;font-weight:bold">false&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#000;font-weight:bold">{&lt;/span> &lt;span style="color:#000">endif&lt;/span> &lt;span style="color:#000;font-weight:bold">})&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>&lt;span style="color:#204a87;font-weight:bold">end&lt;/span>&lt;span style="color:#000;font-weight:bold">,&lt;/span> &lt;span style="color:#000;font-weight:bold">{&lt;/span> &lt;span style="color:#000">noremap&lt;/span> &lt;span style="color:#ce5c00;font-weight:bold">=&lt;/span> &lt;span style="color:#204a87;font-weight:bold">true&lt;/span> &lt;span style="color:#000;font-weight:bold">})&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;!-- mdformat global-off --></description></item></channel></rss>