Compile your code and explore assembly from Neovim using the
compiler-explorer REST API. Supercharged by vim.ui,
vim.notify and vim.diagnostic.
Features • Dependencies • Install • Commands • Configuration
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.
vim.loop.vim.ui.select or pass it as a vim
command parameter.You can verify these dependencies by running :checkhealth compiler-explorer
require('packer').startup(function()
use {'krady21/compiler-explorer.nvim'}
end
require("paq") {
{'krady21/compiler-explorer.nvim'};
}
Plug 'krady21/compiler-explorer.nvim'
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:
| Command | Description | Called from |
|---|---|---|
:CECompile |
Compile the source code in the current buffer and dump assembly output to a new window. Also accepts a visual selection. | source code buffer |
:CECompileLive |
Same as :CECompile, but it will also try to recompile the source code every time the buffer is saved. |
source code buffer |
:CEFormat |
Format the source code. | source code buffer |
:CEAddLibrary |
Add a library to be used by future calls of :CECompile. |
source code buffer |
:CELoadExample |
Load an existing code example to a new tab. | any buffer |
:CEOpenWebsite |
Open the website using the source code and compilers from previous :CECompile calls. |
any buffer |
:CEDeleteCache |
Clear the json cache where the compilers and languages are stored. | any buffer |
:CEShowTooltip |
Show information about a specific instruction under cursor. | assembly buffer |
:CEGotoLabel |
Jump to the label definition under cursor. | assembly buffer |
:CECompile will prompt the user to select the compiler and flags
interactively using vim.ui.select and vim.ui.input.:CECompile compiler=g121 flags=-O2 flags=-Wall specify the
compiler and flags as command arguments.':<,'>CECompile will compile a visual selection.:CECompile! will open the assembly output in a new window. Not adding
bang (!) will reuse the last assembly window.:CECompile inferLang=false do not infer possible language (based on file
extension). Will prompt user to select the language before selecting the
compiler.:CECompile binary=true show binary opcodes and address using virtual text.:CECompile intel=false use AT&T syntax instead of intel.:CECompileLive creates an autcommand that runs :CECompile every time
the buffer is saved (BufWritePost).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.
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",
--},
},
})
GET /api/languagesGET /api/compilers/<lang-id>GET /api/libraries/<lang-id>GET /api/shortlinkinfo/<link-id>POST /api/compiler/<compiler-id>/compileGET /api/formatsPOST /api/format/<formatter>GET /api/asm/<instruction-set>/<instruction>GET /source/builtin/listGET /source/builtin/load/<lang-id>/<example-id>GET /clientstate/<base64>You can find the full API docs here.