Full Code of ngmy/vim-rubocop for AI

master 1c57918086d2 cached
3 files
5.1 KB
1.7k tokens
1 requests
Download .txt
Repository: ngmy/vim-rubocop
Branch: master
Commit: 1c57918086d2
Files: 3
Total size: 5.1 KB

Directory structure:
gitextract_jagvczb3/

├── LICENSE
├── README.md
└── plugin/
    └── rubocop.vim

================================================
FILE CONTENTS
================================================

================================================
FILE: LICENSE
================================================
The MIT License (MIT)

Copyright (c) 2013 Yuta Nagamiya

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.



================================================
FILE: README.md
================================================
# Vim RuboCop

The **Vim RuboCop** plugin runs [RuboCop](https://github.com/bbatsov/rubocop) and displays the results in Vim.

## Requirements

Please note that the current version of the Vim RuboCop plugin requires RuboCop 0.12.0 or later.

## Installation

Obtain a copy of this plugin and place `rubocop.vim` in your Vim plugin directory.

## Usage

You can use the `:RuboCop` command to run RuboCop and display the results.

You can also use the `:RuboCop` command together with options. For example, `:RuboCop -l`, `:RuboCop -a` and so on.

### Configuration File

To run with the specified configuration file, add the following line to your `.vimrc` file:

```viml
let g:vimrubocop_config = '/path/to/rubocop.yml'
```

### Keyboard Shortcuts

Credit for Shortcuts: [Ack.vim](https://github.com/mileszs/ack.vim)

In the quickfix window, you can use:

    o    to open (same as enter)
    go   to preview file (open but maintain focus on ack.vim results)
    t    to open in new tab
    T    to open in new tab silently
    h    to open in horizontal split
    H    to open in horizontal split silently
    v    to open in vertical split
    gv   to open in vertical split silently
    q    to close the quickfix window

Additionally, the plugin registers `<Leader>ru` in normal mode
for triggering it easily. You can disable these default mappings by setting
`g:vimrubocop_keymap` in your `.vimrc` file, and then remap them differently.

For instance, to trigger RuboCop by pressing `<Leader>r` you can put the following in
your `.vimrc`:

```viml
let g:vimrubocop_keymap = 0
nmap <Leader>r :RuboCop<CR>
```

## License

The Vim RuboCop plugin is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).


================================================
FILE: plugin/rubocop.vim
================================================
" The "Vim RuboCop" plugin runs RuboCop and displays the results in Vim.
"
" Author:    Yuta Nagamiya
" URL:       https://github.com/ngmy/vim-rubocop
" Version:   0.4
" Copyright: Copyright (c) 2013 Yuta Nagamiya
" License:   MIT
" ----------------------------------------------------------------------------

if exists('g:loaded_vimrubocop') || &cp
  finish
endif
let g:loaded_vimrubocop = 1

let s:save_cpo = &cpo
set cpo&vim

if !exists('g:vimrubocop_rubocop_cmd')
  let g:vimrubocop_rubocop_cmd = 'rubocop '
endif

" Options
if !exists('g:vimrubocop_config')
  let g:vimrubocop_config = ''
endif

if !exists('g:vimrubocop_extra_args')
  let g:vimrubocop_extra_args = ''
endif

if !exists('g:vimrubocop_keymap')
  let g:vimrubocop_keymap = 1
endif

let s:rubocop_switches = ['-l', '--lint', '-R', '--rails', '-a', '--auto-correct']

function! s:RuboCopSwitches(...)
  return join(s:rubocop_switches, "\n")
endfunction

function! s:RuboCop(current_args)
  let l:extra_args     = g:vimrubocop_extra_args
  let l:filename       = @%
  let l:rubocop_cmd    = g:vimrubocop_rubocop_cmd
  let l:rubocop_opts   = ' '.a:current_args.' '.l:extra_args.' --format emacs'
  if g:vimrubocop_config != ''
    let l:rubocop_opts = ' '.l:rubocop_opts.' --config '.g:vimrubocop_config
  endif

  let l:rubocop_output  = system(l:rubocop_cmd.l:rubocop_opts.' '.l:filename)
  if !empty(matchstr(l:rubocop_opts, '--auto-correct\|-\<a\>'))
    "Reload file if using auto correct
    edit
  endif
  let l:rubocop_output  = substitute(l:rubocop_output, '\\"', "'", 'g')
  let l:rubocop_results = split(l:rubocop_output, "\n")
  cexpr l:rubocop_results
  copen
  " Shortcuts taken from Ack.vim - git://github.com/mileszs/ack.vim.git
  exec "nnoremap <silent> <buffer> q :ccl<CR>"
  exec "nnoremap <silent> <buffer> t <C-W><CR><C-W>T"
  exec "nnoremap <silent> <buffer> T <C-W><CR><C-W>TgT<C-W><C-W>"
  exec "nnoremap <silent> <buffer> o <CR>"
  exec "nnoremap <silent> <buffer> go <CR><C-W><C-W>"
  exec "nnoremap <silent> <buffer> h <C-W><CR><C-W>K"
  exec "nnoremap <silent> <buffer> H <C-W><CR><C-W>K<C-W>b"
  exec "nnoremap <silent> <buffer> v <C-W><CR><C-W>H<C-W>b<C-W>J<C-W>t"
  exec "nnoremap <silent> <buffer> gv <C-W><CR><C-W>H<C-W>b<C-W>J"
endfunction

command! -complete=custom,s:RuboCopSwitches -nargs=? RuboCop :call <SID>RuboCop(<q-args>)

" Shortcuts for RuboCop
if g:vimrubocop_keymap == 1
  nmap <Leader>ru :RuboCop<CR>
endif

let &cpo = s:save_cpo
Download .txt
gitextract_jagvczb3/

├── LICENSE
├── README.md
└── plugin/
    └── rubocop.vim
Condensed preview — 3 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (6K chars).
[
  {
    "path": "LICENSE",
    "chars": 1081,
    "preview": "The MIT License (MIT)\n\nCopyright (c) 2013 Yuta Nagamiya\n\nPermission is hereby granted, free of charge, to any person obt"
  },
  {
    "path": "README.md",
    "chars": 1744,
    "preview": "# Vim RuboCop\n\nThe **Vim RuboCop** plugin runs [RuboCop](https://github.com/bbatsov/rubocop) and displays the results in"
  },
  {
    "path": "plugin/rubocop.vim",
    "chars": 2445,
    "preview": "\" The \"Vim RuboCop\" plugin runs RuboCop and displays the results in Vim.\n\"\n\" Author:    Yuta Nagamiya\n\" URL:       https"
  }
]

About this extraction

This page contains the full source code of the ngmy/vim-rubocop GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 3 files (5.1 KB), approximately 1.7k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!