Giter Club home page Giter Club logo

compile.nvim's Introduction

compile.nvim

This is quite similar to Emacs' compile-mode although much simpler.

compile.nvim allows you to specify specific commands/lua functions to compile, run and test software in your favorite language.

To learn more install the plugin and inspect its global table:

:lua print(vim.inspect(Compile))

Configuring

--- These are the default options! feel free to just use an empty table here, or just override the ones you need
require 'compile'.setup{
    save_on_compile = false,
    comp_window_height = 20,
    bindings = {
        build = '<C-c><C-b>',
        run   = '<C-c><C-c>',
        test  = '<C-c><C-t>',
    },
    language_commands = {},
}

Language Commands

These are the commands that will be searched for the 3 actions the plugin provides:

  • run: build and run
  • build: only build
  • test: build and run test

The command is either a string or a lua function, if it is a function it is run and its return type (must be a string) is used as a command. The plugin has the following search order for its compile_command:

  1. Buffer local: b:compile_cmd_X='my command' where X is either run, build or test
  2. Plugin table: This is the language_commands table, this should be your preferred method of setting commands
  3. Global: g:compile_cmd_X='my command' where X is either run, build or test

Advanced Example

local get_comp_cmd_c = function(sub_cmd)
    local cmd = 'make'
    -- Use neovim's API to explore filesystem and discover
    -- the type of project, this is just a lua function feel
    -- free to do as you wish. Here we will assume a simple Makefile
    -- as an example
    cmd = ('%s %s'):format(cmd, sub_cmd)
    return cmd
end

require 'compile'.setup {
    language_commands = {
        ['odin'] = {
            build = 'odin build .',
            run = 'odin run .',
            test = 'odin test .',
        },
        ['zig'] = {
            build = 'zig build',
            run = 'zig build run',
            test = 'zig build test',
        },
        ['c'] = {
            build = function() return get_comp_cmd_c('all') end,
            run = function() return get_comp_cmd_c('run') end,
            test = function() return get_comp_cmd_c('test') end,
        },
    },
}

compile.nvim's People

Contributors

marcs-feh avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.