Skip to content

Small plugin to support running your custom build commands from neovim

Notifications You must be signed in to change notification settings

castlele/build.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

build.nvim

build allows you to run your build commands from neovim like with default make.

WIP: Add here gif usage example

Usage

To start using build plugin use command :Build generate and in newely created build file add your configuration. In conf object use keys as commands' names and values as commands to run:

---@param cmd string
---@return string
local function runTestsCommand(cmd)
   local runner = "./run_tests.sh \"%s\""
   return string.format(runner, cmd)
end

---@return string
local function getCurrentFileName()
   local filePath = vim.fn.expand("%")
   local pathComponents = vim.fn.split(filePath, "/")
   local file = pathComponents[#pathComponents]
   local fileName = vim.fn.split(file, "%.")

   return fileName[#fileName]
end

conf = {
   install = "sudo luarocks make",
   remove = "sudo luarocks remove cluautils",
   currentTest = runTestsCommand(getCurrentFileName()),
   allTest = runTestsCommand("*"),
   threadTest = [[
      bear -- make build
      make test_thread
   ]] .. runTestsCommand("cthread*"),
   memoryTest = [[
      bear -- make build
   ]] .. runTestsCommand("cmemory*"),
   oopTest = runTestsCommand("oop"),
   stringTest = runTestsCommand("string_utils*"),
   jsonTest = runTestsCommand("json*"),
   fmTest = runTestsCommand("file_manager*"),
   tableTest = runTestsCommand("table_utils*"),
   hashmapTest = runTestsCommand("*hashmap*"),
   linkedlistTest = runTestsCommand("linkedlist*"),
}

As you can see, your commands can return either string representation of terminal command or a function to run! Strings will run in toggleterm while functions will just run.

After saving build file you can use all your declared commands like this: :Build <your_command_name>.

You can edit your configuration file with :Build edit command.

Installation

Prerequisites:

  1. cluautils library. Library with different lua tools.

    Can be installed with luarocks: luarocks install cluautils

  2. akinsho/toggleterm plugin. Manages running commands.

  3. One of the search engines:


Install plugin with your favourite plugin manager like this:

require("lazy").setup {
    {
        "castlele/build.nvim",
        opts = true,
    },
}

Configuration

To enable plugin you have to run setup method:

require("build").setup()

With no arguments provided build plugin will use default settings:

require("build").setup {
    buildFileName = "build.lua",
    engineConfig = {
        type = "minipick", -- can fallback to telescope
        keymap = "<leader>B",
    },
}

About

Small plugin to support running your custom build commands from neovim

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages