Skip to content

Insert-Shebang-Plugin #114

@dase78

Description

@dase78

I am trying to get a shebang-plugin to run, no success:

local micro = import("micro")
local config = import("micro/config")

function insertShebang(bp)
    local buf = bp.Buf
    local success, err = pcall(function()
        if buf:LineCount() == 0 then
            buf:Insert(1, "#!/usr/bin/env bash\n")
        elseif buf:Line(1) ~= "#!/usr/bin/env bash" then
            buf:Insert(1, "#!/usr/bin/env bash\n")
        else
            micro.InfoBar():Message("Shebang already exists.")
        end
    end)

    if not success then
        micro.InfoBar():Error("Fehler: " .. err)
    end
end

function init()
    config.MakeCommand("bang", insertShebang, config.NoComplete)
    config.AddRuntimeFile("bang", config.RTHelp, "help/bang.md")
end

Has anyone already a simple Shebang-Plugin up his sleeve?

I also posted at the unofficial channel: https://github.com/Neko-Box-Coder/unofficial-plugin-channel/issues/10

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions