Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork44
Neovim compiler for building and running your code without having to configure anything
License
Zeioth/compiler.nvim
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Neovim compiler for building and running your code without having to configure anything.
- Why
- Supported languages
- Required system dependencies
- How to install
- Commands
- Basic usage
- Creating a solution (optional)
- Build automation utilities (optional)
- Quick start
- FAQ
Those familiar with Visual Studio IDE will remember how convenient it was to just press a button and having your program compiled and running. I wanted to bring that same user experience to Neovim.
Some languages require you manually install their compilers in your machine, so compiler.nvim is able to call them.Please check here, as the packages will be different depending your operative system.
lazy.nvim package manager
{-- This plugin"Zeioth/compiler.nvim",cmd= {"CompilerOpen","CompilerToggleResults","CompilerRedo"},dependencies= {"stevearc/overseer.nvim","nvim-telescope/telescope.nvim"},opts= {},},{-- The task runner we use"stevearc/overseer.nvim",commit="6271cab7ccc4ca840faa93f54440ffae3a3918bd",cmd= {"CompilerOpen","CompilerToggleResults","CompilerRedo"},opts= {task_list= {direction="bottom",min_height=25,max_height=25,default_detail=1 }, },},-- Open compilervim.api.nvim_set_keymap('n','<F6>',"<cmd>CompilerOpen<cr>", {noremap=true,silent=true })-- Redo last selected optionvim.api.nvim_set_keymap('n','<S-F6>',"<cmd>CompilerStop<cr>"-- (Optional, to dispose all tasks before redo).."<cmd>CompilerRedo<cr>", {noremap=true,silent=true })-- Toggle compiler resultsvim.api.nvim_set_keymap('n','<S-F7>',"<cmd>CompilerToggleResults<cr>", {noremap=true,silent=true })
| Command | Description |
|---|---|
:CompilerOpen | Shows the adecuated compiler for your buffer's filetype. |
:CompilerToggleResults | Open or close the compiler results. |
:CompilerRedo | Redo the last selected option. |
:CompilerStop | Dispose all tasks. |
This is what happen when you selectbuild & run,build, orrun in the compiler:
compiler.nvim will look for the conventional entry point file for the current language you are using. To achieve this, it searches in your current working directory for the next files
| Language | Default entry point | Default output |
|---|---|---|
| asm x86-64 | ./main.asm | ./bin/program |
| c | ./main.c | ./bin/program |
| c++ | ./main.cpp | ./bin/program |
| c# | ./Program.cs | ./bin/Program.exe |
| dart | ./lib/main.dart | ./bin/main |
| elixir | ./mix.exs | ./_build/ |
| fortran | ./fpm | ./build/ |
| f# | see here | ./bin/ |
| gleam | ./build.toml | ./build |
| flutter | ./pubspec.yaml | ./build/ |
| go | ./main.go | ./bin/program |
| java | ./Main.java | ./bin/Main.class |
| javascript | ./src/index.js | |
| kotlin | ./Main.kt | ./bin/MainKt.class |
| lua | ./main.lua | |
| make | ./Makefile | |
| perl | ./main.pl | |
| python | ./main.py | ./bin/program |
| r | ./main.r | |
| ruby | ./main.rb | |
| rust | ./main.rs | ./bin/program |
| shell | ./main.sh | |
| swift | ./main.swift | ./bin/program |
| typescript | ./src/index.ts | |
| visual basic .net | see here | ./bin/ |
| zig | ./build.zig | ./zig-out/bin/build |
This is how the compilation results look after selectingBuild & run program in c
For more info see wiki - when to use every option
If you want to have more control, you can create a.solution.toml file in your working directory by using this template where every [entry] represents a program to compile
[HelloWorld]entry_point ="/path/to/my/entry_point_file/main.c"output ="/path/where/the/program/will/be/written/hello_world"arguments =""[SOLUTION]executable ="/program/to/execute/after/the/solution/has/compiled/my_program"
If any of these files exist in your current working directory, they will be automatically detected and displayed onCompiler.nvim:
| Build automation utility | File | More info |
|---|---|---|
| Make | ./Makefile | +info |
| CMake | ./CMakeLists.txt | +info |
| Gradle | ./build.gradle | +info |
| Maven | ./pom.xml | +info |
| NodeJS NPM | ./package.json | +info |
| Meson | ./meson.build | +info |
Create~/c-example/main.c and paste this code. Then do:cd ~/c-example/ to change the working directory to the project.
#include<stdio.h>intmain() {printf("Hello, World!\n");return0;}
Open the compiler and selectBuild and run. You will see the compilation results.
- I get errors when compiling: You have to
:cd /your/project/root_dirbefore callingCompiler.nvim. - How can I auto
:cdmy projects? Usethis fork of the pluginproject.nvim. - I don't have time to read: If you prefer you can tryNormalNvim which comes with the compiler pre-installed. Just open some code and hit F6!
- Do compiler.nvim support tests? Testing is not the responsability of a compiler. For that please install the pluginNeotest or similar.
- How can I add a language that is not supported yet? Fork the project, and go to the directory
/compiler/languages. Copyc.luaand rename it to any language you would like to add, for exampleruby.lua. Now modify the file the way you want. It is important you name the file as the filetype of the language you are implementing. Then please, submit a PR to this repo so everyone can benefit from it. - How can I change the way the compiler works? Same as the previous one.
- How can I add an automation build utility that is not supported yet? Fork the project, and go to the directory
/compiler/bau. Copymake.luaand rename it to the build automation utility you want to add, for examplemaven.lua. Now modify the file the way you want. Note that you will also have to modify/utilities-bau.luaand change the functionget_bau_opts()so it can parse the utility you want to add. Then please, submit a PR to this repo so everyone can benefit from it. - Is this plugin just a compiler, or can I run scripts too? Yes you can. But if your script receive arguments, we recommend you to use the terminal instead, because creating a
.solution.tomlfile just to be able to pass arguments to your simple shell script is probably a overkill, and not the right tool. - I'm a windows user, do I need to do something special? You have toenable WSL, and run nvim inside. Otherwise it would be impossible for you to install therequired dependencies.
- How can I disable notifications when compiling? Checkhere.
The workflow of game development is essentially very different from just compiling and running a program. It involve loading editing and running scenes. While there is no way for us to support it directly, here I offer you some tricks:
ToBuild and run a godot scene, use the commandgodot /my/scene.tscn on the terminal. This works really well: It's fast and simple.
The recommended way is to have 2 monitors, one with nvim and your code, and another one with your unity scenes to run the game. Unity hassome terminal commands, but working with them is quite a painful experience.
If you want to help me, please star this repository to increase the visibility of the project.
- Study adding support for justfiles/taskfiles.
- Better Windows compatibility when not using WSL: The commands
rm -rfandmkdir -ponly exist on unix. To support Windows without WSL we should run the equivalent powershell command when Windows is detected. - Aditionally, we will also have to compile for
asmwin64 architecture, if the detected OS is windows. - Aditionally, we will also have to add an option to compile for
Build for windows (flutter).
About
Neovim compiler for building and running your code without having to configure anything
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors7
Uh oh!
There was an error while loading.Please reload this page.

