Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Mythos-404/xmake.nvim

Open more actions menu

Repository files navigation

| English | 简体中文 |

Xmake.nvim

🎐 Features

  • Lightning-fast startup speed of 1-3ms (tested on Dell G15 5515 with ArchLinux)
  • Automatically generates compile_commands.json for lsp when saving xmake.lua
  • Provides a run command, so no need to open an extra window to run a target
  • The lua-lsp binding is provided so you can happily write xmake.lua files

🏗 Installation

lazy.nvim
{
    "Mythos-404/xmake.nvim",
    version = "^3",
    lazy = true,
    event = "BufReadPost",
    config = true,
}
mini.deps
add("Mythos-404/xmake.nvim")

Requirements

💡 Commands

  • Xmake[!] run <target|all|@> [args] Run target
  • Xmake[!] debug <target|all|@> [args] Debug target
  • Xmake[!] build <target|all|@> Build target
  • Xmake[!] clean <target|all|@> Clean target
  • Xmake mode <mode> Set build mode
  • Xmake arch <arch> Set target architecture
  • Xmake plat <plat> Set target platform
  • Xmake toolchain <toolchain> Set toolchain

Tip

  • ! will call clean before executing the command
  • @ executes the last run target
  • all will use xmake's --all option to run
  • args are command line arguments passed to the target

⚙️ Default Settings

Default Settings
{
    -- Configuration when saving `xmake.lua`
    on_save = {
        -- Reload project information
        reload_project_info = true,
        -- Configuration for generating `compile_commands.json`
        lsp_compile_commands = {
            enable = true,
            -- Directory name (relative path) for output file
            output_dir = "build",
        },
    },

    -- Lsp related configuration
    lsp = {
        enable = true,
        language = "en", ---@type "en"|"zh-cn"
    },

    -- Debugger related configuration
    debuger = {
        -- Checks the project's build mode, and if it’s not among the modes below,
        -- it will automatically switch to `debug` mode for build/run,
        -- and then switch back to the original build mode
        rulus = { "debug", "releasedbg" },
        -- Dap configuration, please refer to Dap and the debugger's documentation
        dap = {
            name = "Xmake Debug",
            type = "codelldb",
            request = "launch",
            cwd = "${workspaceFolder}",
            console = "integratedTerminal",
            stopOnEntry = false,
            runInTerminal = true,
        },
    },

    -- Notification related settings
    notify = {
        -- Icons for completion
        icons = {
            error = "",
            successfully = "",
        },
        -- Icons for progress display
        spinner = { "", "", "", "", "", "", "", "", "", "" },
        -- Refresh rate for the progress bar
        refresh_rate_ms = 100,
    },

    -- Runner configuration
    runner = {
        -- Select which backend to use
        type = "toggleterm", ---@type "toggleterm"|"terminal"|"quickfix"|"snacks"

        config = {
            toggleterm = {
                direction = "float", ---@type "vertical"|"horizontal"|"tab"|"float"
                singleton = true,
                auto_scroll = true,
                close_on_success = false,
            },
            terminal = {
                name = "Runner Terminal",
                prefix_name = "[Xmake]: ",
                split_size = 15,
                split_direction = "horizontal", ---@type "vertical"|"horizontal"
                focus = true,
                focus_auto_insert = true,
                auto_resize = true,
                close_on_success = false,
            },
            quickfix = {
                show = "always", ---@type "always"|"only_on_error"
                size = 15,
                position = "botright", ---@type "vertical"|"horizontal"|"leftabove"|"aboveleft"|"rightbelow"|"belowright"|"topleft"|"botright"
                close_on_success = false,
            },
            snacks = {
                position = "float",
                interactive = true,
            },
        },
    },
    -- Executor configuration
    execute = {
        -- Select which backend to use
        type = "quickfix", ---@type "toggleterm"|"terminal"|"quickfix"|"snacks"

        config = {
            toggleterm = {
                direction = "float", ---@type "vertical"|"horizontal"|"tab"|"float"
                singleton = true,
                auto_scroll = true,
                close_on_success = true,
            },
            terminal = {
                name = "Executor Terminal",
                prefix_name = "[Xmake]: ",
                split_size = 15,
                split_direction = "horizontal", ---@type "vertical"|"horizontal"
                focus = false,
                focus_auto_insert = true,
                auto_resize = true,
                close_on_success = true,
            },
            quickfix = {
                show = "only_on_error", ---@type "always"|"only_on_error"
                size = 15,
                position = "botright", ---@type "vertical"|"horizontal"|"leftabove"|"aboveleft"|"rightbelow"|"belowright"|"topleft"|"botright"
                close_on_success = true,
            },
            snacks = {
                position = "float",
                interactive = true,
            },
        },
    },

    -- Enable development mode
    dev_debug = true,
}

✨ Usage with Other Plugins

To use with status line plugins like lualine.nvim, here's an example for lualine.nvim:

require("lualine").setup({
    sections = {
       lualine_y = {
            {
                function()
                    if not vim.g.loaded_xmake then return "" end
                    local Info = require("xmake.info")
                    if Info.mode.current == "" then return "" end
                    if Info.target.current == "" then return "Xmake: Not Select Target" end
                    return ("%s(%s)"):format(Info.target.current, Info.mode.current)
                end,
                cond = function()
                    return vim.o.columns > 100
                end,
            }
        }
    }
})

🎉 Other Projects

About

The xmake plugin for neovim provides a ui interface that allows you to configure xmake more efficiently.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Morty Proxy This is a proxified and sanitized view of the page, visit original site.