Git Product home page Git Product logo

vim-shellcheck's Introduction

vim-shellcheck

Vim wrapper for ShellCheck, a static analysis tool for shell scripts.

Commands

These commands are available in buffers with 'filetype' of sh.

:[range]ShellCheck[!] [args]

Run shellcheck for the current buffer using optional [args] and send any errors to the quickfix-window. Specify a [range] or use a visual selection to check only those lines, otherwise the entire buffer is checked. Call with a bang to automatically open the quickfix-window when errors are found.

:[range]LShellCheck[!] [args]

Run shellcheck for the current buffer using optional [args] and send any errors to a location-list-window. Specify a [range] or use a visual selection to check only those lines, otherwise the entire buffer is checked. Call with a bang to automatically open the location-list-window when errors are found.

QF Mappings

Open ShellCheck error definition on GitHub - gb

The gb command can be used quickfix or location list windows to open the ShellCheck error definition on GitHub. This command requires the Netrw plugin to be installed. If Netrw is not installed, the gb map prints the URL to the ShellCheck error definition on GitHub instead. This functionality is enabled when the window's w:quickfix_title attribute starts with one of the following:

  • :shellcheck -- created by compiler shellcheck | :make % or some other program
  • :ShellCheck -- created by the :ShellCheck command
  • :LShellCheck -- created by the :LShellCheck command

To disable this mapping:

let g:shellcheck_disable_mappings = 1

To setup a different map:

let g:shellcheck_disable_mappings = 1
autocmd FileType qf nmap <buffer> <silent> gB <Plug>(shellcheck-gb)

Note: The gb map will not be defined if one already exists.

Compiler

A ShellCheck :compiler is provided by Vim 8.2.1769 and newer for use as a 'makeprg'. To use it, run:

:compiler shellcheck
:make! %
:copen

Configuration

g:shellcheck_qf_open

Specifies how the quickfix-window is opened when :ShellCheck! is used. The default value is "botright copen 10".

g:shellcheck_ll_open

Specifies how the location-list-window is opened when :LShellCheck! is used. The default value is "lopen 10".

Installation

Use your favorite plugin manager, or use Vim's built-in package support:

mkdir -p ~/.vim/pack/shellcheck/start
cd ~/.vim/pack/shellcheck/start
git clone https://github.com/itspriddle/vim-shellcheck.git
vim -u NONE -c "helptags vim-shellcheck/doc" -c q

License

MIT License - see LICENSE in this repo.

vim-shellcheck's People

Contributors

itspriddle avatar konfekt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

vim-shellcheck's Issues

error| syntax error near unexpected token `(' #1799

Originally created shellcheck issue: koalaman/shellcheck#1799 .

  • My shellcheck version (shellcheck --version or "online"): 0.7.0
  • debian package version: 0.7.0-2
  • tried on shellcheck.net: OK, no error
  • tried with vim-shellcheck, as of git SHA 4346419: FAIL

Including report for direct reference:

  • Here's a snippet that shows the problem:

#!/bin/bash

shopt -s extglob;
for f in /etc/hosts/host\.!(mail)\.conf ; do
    echo "$f";
done;
  • Here's what shellcheck currently says:
    error| syntax error near unexpected token `('

  • Expected: No error

Plugin doesn't do anything when writing on openSUSE, but on MacOS it does

I found your fancy โค๏ธ vim-plugin and use it on MacOS and on openSUSE (both are my main workstation(s) and servers):

On MacOS it behaves like this:

  • ๐ŸŸฉ shellcheck on write (:w)
    grafik
  • ๐Ÿ›‘ shellcheck on demand (:Shellcheck!)
    grafik

And on openSUSE it only works on demand:

  • ๐Ÿ›‘ shellcheck on write (:w)
    (nothing happens at all!?)
  • ๐ŸŸฉ shellcheck on demand (:Shellcheck!)
    grafik

My vim on MacOS:

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Sep 24 2021 06:02:32)
macOS version - x86_64
Included patches: 1-3455
Compiled by Homebrew

My vim on OpenSUSE:

VIM - Vi IMproved 8.0 (2016 Sep 12)
Included patches: 1-1568
Compiled by 'http://www.opensuse.org/'

I tried it also with a more current vim on openSUSE (8.2.4375-lp153.721.1), but this didn't make it better in any wayโ€ฆ

shellcheck on write would be what I prefer. Can you @itspriddle please help what's wrong here? ๐Ÿคท๐Ÿปโ€โ™‚๏ธ Thanks a lot!

"gb" binding in quickfix buffer errors

I'm on Neovim and using gb on a quickfix error results in:

Error detected while processing function <SNR>145_gb:
line   14:
E117: Unknown function: netrw#CheckIfRemote
E116: Invalid arguments for function netrw#BrowseX

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.