Home

Awesome

compiler-explorer.nvim

License: MIT

Compile your code and explore assembly from Neovim using the compiler-explorer REST API. Supercharged by vim.ui, vim.notify and vim.diagnostic.

FeaturesDependenciesInstallCommandsConfiguration

Demo

Preview This is what the interface looks like using the vim.ui provided by dressing.nvim with the fzf-lua backend and the vim.notify provided by nvim-notify.

Features

Dependencies

You can verify these dependencies by running :checkhealth compiler-explorer

<details> <summary>Recommended</summary> <br> <a href="https://github.com/stevearc/dressing.nvim">dressing.nvim</a> or another plugin that overrides <code>vim.ui</code> </details> <details> <summary>Optional</summary> <br> <a href="https://github.com/rcarriga/nvim-notify">nvim-notify</a> or another plugin that overrides <code>vim.notify</code> </details>

Installation

packer

require('packer').startup(function()
  use {'krady21/compiler-explorer.nvim'}
end

paq

require("paq") {
  {'krady21/compiler-explorer.nvim'};
}

vim-plug

Plug 'krady21/compiler-explorer.nvim'

Commands

The suggested way to use compiler-explorer.nvim is through the vim commands provided. You can refer to :h compiler-explorer-commands or the table below:

CommandDescriptionCalled from
:CECompileCompile the source code in the current buffer and dump assembly output to a new window. Also accepts a visual selection.source code buffer
:CECompileLiveSame as :CECompile, but it will also try to recompile the source code every time the buffer is saved.source code buffer
:CEFormatFormat the source code.source code buffer
:CEAddLibraryAdd a library to be used by future calls of :CECompile.source code buffer
:CELoadExampleLoad an existing code example to a new tab.any buffer
:CEOpenWebsiteOpen the website using the source code and compilers from previous :CECompile calls.any buffer
:CEDeleteCacheClear the json cache where the compilers and languages are stored.any buffer
:CEShowTooltipShow information about a specific instruction under cursor.assembly buffer
:CEGotoLabelJump to the label definition under cursor.assembly buffer
<details> <summary>Examples</summary> </details>

Configuration

compiler-explorer.nvim works out of the box without configuration. If you want to change some of its options (like using a local instance of compiler-explorer), you can do so through the setup() function.

<details> <summary>Default options</summary>
require("compiler-explorer").setup({
  url = "https://godbolt.org",
  infer_lang = true, -- Try to infer possible language based on file extension.
  line_match = {
    highlight = false, -- highlight the matching line(s) in the other buffer.
    jump = false, -- move the cursor in the other buffer to the first matching line.
  },
  open_qflist = false, --  Open qflist after compilation if there are diagnostics.
  split = "split", -- How to split the window after the second compile (split/vsplit).
  compiler_flags = "", -- Default flags passed to the compiler.
  job_timeout_ms = 25000, -- Timeout for libuv job in milliseconds.
  languages = { -- Language specific default compiler/flags
    --c = {
    --  compiler = "g121",
    --  compiler_flags = "-O2 -Wall",
    --},
  },
})
</details>

API Coverage:

You can find the full API docs here.

Related projects

Inspiration