GithubHelp home page GithubHelp logo

susensio / shebang.nvim Goto Github PK

View Code? Open in Web Editor NEW

This project forked from samirettali/shebang.nvim

0.0 0.0 0.0 17 KB

A Neovim plugin that inserts a shebang line when editing a new file.

Lua 100.00%

shebang.nvim's Introduction

shebang.nvim

A simple Neovim plugin written in Lua that automatically inserts a shebang line when editing a new file and makes it executable.

Installation

Plug "susensio/shebang.nvim"
lua require("shebang").setup()
use {
    "susensio/shebang.nvim",
    config = function() require("shebang").setup() end
}

Usage

If a file extension is present, the pluggin works automatically. A manual user command is provided :Bang [<ext>] with an optional extension argument, usefull when editing previously created files or source files without extension.

-- Try to set shebang based on extension, or insert default shebang
:Bang

-- Force specific shebang by declaring extension
:Bang py

Customization

You can set custom shebangs or override defaults in setup with bins = { extension = binary }, using either a binary command (which will be resolved with /usr/bin/env) or a full path:

require("shebang").setup({
    bin = {
        ksh = "/usr/bin/ksh",
        py = "python3.11",
        scala = nil
    }
})

Default options are:

{
    bins = {
        awk = "awk",
        hs = "runhaskell",
        jl = "julia",
        lua = "lua",
        m = "octave",
        mak = "make",
        php = "php",
        pl = "perl",
        py = "python3",
        r = "Rscript",
        rb = "ruby",
        scala = "scala",
        sh = "bash",
        tcl = "tclsh",
        tk = "wish",
    },
    automatic = true,       -- insert shebang on new file
    command = true,         -- define Bang user command
    executable = true,      -- make file executable on exit
    default = "/bin/sh"     -- default shebang for `:Bang` without args
}

FAQ

Q: How does it differ from forked samirettali/shebang.nvim?

A: First, it only makes a file executable if the shebang is still present on exist. This prevent false positives. Second, a :Bang user command can manually add a shebang, helping with false negatives.

shebang.nvim's People

Contributors

samirettali avatar susensio 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.