mirror of
1
0
Fork 0

Update plugins from upstream.

This commit is contained in:
Kurtis Moxley 2022-08-13 01:17:13 +08:00
parent 66b93f5a84
commit be700b9c7f
59 changed files with 4092 additions and 2098 deletions

View File

@ -0,0 +1,37 @@
" Author: 0xHyoga <0xHyoga@gmx.com>
" Description: Report starknet-compile errors in cairo code
call ale#Set('cairo_starknet_executable', 'starknet-compile')
call ale#Set('cairo_starknet_options', '')
function! ale_linters#cairo#starknet#Handle(buffer, lines) abort
" Error always on the first line
" e.g ex01.cairo:20:6: Could not find module 'contracts.utils.ex00_base'. Searched in the following paths:
let l:pattern = '\v\.cairo:(\d+):(\d+):+ (.*)'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
\ 'lnum': str2nr(l:match[1]),
\ 'col': str2nr(l:match[2]),
\ 'type': 'E',
\ 'text': l:match[3],
\})
endfor
return l:output
endfunction
function! ale_linters#cairo#starknet#GetCommand(buffer) abort
let l:executable = ale#Var(a:buffer, 'cairo_starknet_executable')
return l:executable . ale#Pad(ale#Var(a:buffer, 'cairo_starknet_options')) . ' %s'
endfunction
call ale#linter#Define('cairo', {
\ 'name': 'starknet',
\ 'executable': {b -> ale#Var(b, 'cairo_starknet_executable')},
\ 'command': function('ale_linters#cairo#starknet#GetCommand'),
\ 'callback': 'ale_linters#cairo#starknet#Handle',
\ 'output_stream': 'stderr',
\})

View File

@ -4,15 +4,16 @@
call ale#Set('dart_analyze_executable', 'dart')
function! ale_linters#dart#dart_analyze#Handle(buffer, lines) abort
let l:pattern = '\v^ ([a-z]+) - (.+):(\d+):(\d+) - (.+) - (.+)$'
let l:pattern = '\v([a-z]+) - (.+):(\d+):(\d+) - (.+) - (.+)$'
let l:output = []
for l:match in ale#util#GetMatches(a:lines, l:pattern)
let [l:type, l:filename, l:lnum, l:col, l:message, l:code] = l:match[1:6]
call add(l:output, {
\ 'type': l:match[1] is# 'error' ? 'E' : 'W',
\ 'text': l:match[6] . ': ' . l:match[5],
\ 'lnum': str2nr(l:match[3]),
\ 'col': str2nr(l:match[4]),
\ 'type': l:type is# 'error' ? 'E' : l:type is# 'info' ? 'I' : 'W',
\ 'text': l:code . ': ' . l:message,
\ 'lnum': str2nr(l:lnum),
\ 'col': str2nr(l:col),
\})
endfor
@ -22,7 +23,7 @@ endfunction
call ale#linter#Define('dart', {
\ 'name': 'dart_analyze',
\ 'executable': {b -> ale#Var(b, 'dart_analyze_executable')},
\ 'command': '%e analyze %s',
\ 'command': '%e analyze --fatal-infos %s',
\ 'callback': 'ale_linters#dart#dart_analyze#Handle',
\ 'lint_file': 1,
\})

View File

@ -0,0 +1,24 @@
" Description: SCA2D linter for OpenSCAD files
call ale#Set('openscad_sca2d_executable', 'sca2d')
call ale#Set('openscad_sca2d_options', '')
function! ale_linters#openscad#sca2d#GetExecutable(buffer) abort
return ale#Var(a:buffer, 'openscad_sca2d_executable')
endfunction
function! ale_linters#openscad#sca2d#GetCommand(buffer) abort
let l:executable = ale_linters#openscad#sca2d#GetExecutable(a:buffer)
let l:options = ale#Var(a:buffer, 'openscad_sca2d_options')
return ale#Escape(l:executable) . ale#Pad(l:options) . ' %s'
endfunction
call ale#linter#Define('openscad', {
\ 'name': 'SCA2D',
\ 'aliases': ['sca2d'],
\ 'executable': function('ale_linters#openscad#sca2d#GetExecutable'),
\ 'command': function('ale_linters#openscad#sca2d#GetCommand'),
\ 'callback': 'ale#handlers#openscad#SCA2D_callback',
\ 'lint_file': 1,
\ })

View File

@ -1,6 +1,7 @@
" Author: bretello <bretello@distruzione.org>
call ale#Set('yaml_actionlint_executable', 'actionlint')
call ale#Set('yaml_actionlint_options', '')
call ale#linter#Define('yaml', {
\ 'name': 'actionlint',

View File

@ -133,11 +133,13 @@ let s:should_complete_map = {
\ 'typescript': '\v[a-zA-Z$_][a-zA-Z$_0-9]*$|\.$|''$|"$',
\ 'rust': '\v[a-zA-Z$_][a-zA-Z$_0-9]*$|\.$|::$',
\ 'cpp': '\v[a-zA-Z$_][a-zA-Z$_0-9]*$|\.$|::$|-\>$',
\ 'c': '\v[a-zA-Z$_][a-zA-Z$_0-9]*$|\.$|-\>$',
\}
" Regular expressions for finding the start column to replace with completion.
let s:omni_start_map = {
\ '<default>': '\v[a-zA-Z$_][a-zA-Z$_0-9]*$',
\ 'racket': '\k\+',
\}
" A map of exact characters for triggering LSP completions. Do not forget to
@ -147,6 +149,7 @@ let s:trigger_character_map = {
\ 'typescript': ['.', '''', '"'],
\ 'rust': ['.', '::'],
\ 'cpp': ['.', '::', '->'],
\ 'c': ['.', '->'],
\}
function! s:GetFiletypeValue(map, filetype) abort

View File

@ -78,6 +78,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['dhall'],
\ 'description': 'Standard code formatter for the Dhall language and removing dead code',
\ },
\ 'dune': {
\ 'function': 'ale#fixers#dune#Fix',
\ 'suggested_filetypes': ['dune'],
\ 'description': 'Fix dune files with dune format',
\ },
\ 'fecs': {
\ 'function': 'ale#fixers#fecs#Fix',
\ 'suggested_filetypes': ['javascript', 'css', 'html'],
@ -136,6 +141,11 @@ let s:default_registry = {
\ 'description': 'Apply prettier-eslint to a file.',
\ 'aliases': ['prettier-eslint'],
\ },
\ 'pyflyby': {
\ 'function': 'ale#fixers#pyflyby#Fix',
\ 'suggested_filetypes': ['python'],
\ 'description': 'Tidy Python imports with pyflyby.',
\ },
\ 'importjs': {
\ 'function': 'ale#fixers#importjs#Fix',
\ 'suggested_filetypes': ['javascript'],
@ -226,6 +236,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['php'],
\ 'description': 'Fix PHP files with php-cs-fixer.',
\ },
\ 'pint': {
\ 'function': 'ale#fixers#pint#Fix',
\ 'suggested_filetypes': ['php'],
\ 'description': 'Fix PHP files with Laravel Pint.',
\ },
\ 'astyle': {
\ 'function': 'ale#fixers#astyle#Fix',
\ 'suggested_filetypes': ['c', 'cpp'],

View File

@ -0,0 +1,16 @@
" Author: Albert Peschar <albert@peschar.net>
" Description: Fix files with dune format.
call ale#Set('ocaml_dune_executable', 'dune')
call ale#Set('ocaml_dune_options', '')
function! ale#fixers#dune#Fix(buffer) abort
let l:executable = ale#Var(a:buffer, 'ocaml_dune_executable')
let l:options = ale#Var(a:buffer, 'ocaml_dune_options')
return {
\ 'command': ale#Escape(l:executable)
\ . ' format'
\ . (empty(l:options) ? '' : ' ' . l:options),
\}
endfunction

View File

@ -0,0 +1,25 @@
" Author: Michael Dyrynda <michael@dyrynda.com.au>
" Description: Fixing files with Laravel Pint.
call ale#Set('php_pint_executable', 'pint')
call ale#Set('php_pint_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('php_pint_options', '')
function! ale#fixers#pint#GetExecutable(buffer) abort
return ale#path#FindExecutable(a:buffer, 'php_pint', [
\ 'vendor/bin/pint',
\ 'pint'
\])
endfunction
function! ale#fixers#pint#Fix(buffer) abort
let l:executable = ale#fixers#pint#GetExecutable(a:buffer)
return {
\ 'command': ale#Escape(l:executable)
\ . ' ' . ale#Var(a:buffer, 'php_pint_options')
\ . ' %t',
\ 'read_temporary_file': 1,
\}
endfunction

View File

@ -0,0 +1,41 @@
" Author: infokiller <joweill@icloud.com>
" Description: Tidy imports using pyflyby's tidy-import script
" https://github.com/deshaw/pyflyby
call ale#Set('python_pyflyby_executable', 'tidy-imports')
call ale#Set('python_pyflyby_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('python_pyflyby_options', '')
call ale#Set('python_pyflyby_auto_pipenv', 0)
call ale#Set('python_pyflyby_auto_poetry', 0)
function! ale#fixers#pyflyby#GetExecutable(buffer) abort
if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_pyflyby_auto_pipenv'))
\ && ale#python#PipenvPresent(a:buffer)
return 'pipenv'
endif
if (ale#Var(a:buffer, 'python_auto_poetry') || ale#Var(a:buffer, 'python_pyflyby_auto_poetry'))
\ && ale#python#PoetryPresent(a:buffer)
return 'poetry'
endif
return ale#python#FindExecutable(a:buffer, 'python_pyflyby', ['tidy-imports'])
endfunction
function! ale#fixers#pyflyby#Fix(buffer) abort
" let l:executable = ale#fixers#pyflyby#GetExecutable(a:buffer)
let l:executable = ale#fixers#pyflyby#GetExecutable(a:buffer)
let l:cmd = [ale#Escape(l:executable)]
if l:executable =~? 'pipenv\|poetry$'
call extend(l:cmd, ['run', 'tidy-imports'])
endif
let l:options = ale#Var(a:buffer, 'python_pyflyby_options')
if !empty(l:options)
call add(l:cmd, l:options)
endif
return {'command': join(l:cmd, ' ')}
endfunction

View File

@ -5,27 +5,13 @@ scriptencoding utf-8
call ale#Set('sh_shfmt_executable', 'shfmt')
call ale#Set('sh_shfmt_options', '')
function! s:DefaultOption(buffer) abort
if getbufvar(a:buffer, '&expandtab') == 0
" Tab is used by default
return ''
endif
let l:tabsize = getbufvar(a:buffer, '&shiftwidth')
if l:tabsize == 0
let l:tabsize = getbufvar(a:buffer, '&tabstop')
endif
return ' -i ' . l:tabsize
endfunction
function! ale#fixers#shfmt#Fix(buffer) abort
let l:executable = ale#Var(a:buffer, 'sh_shfmt_executable')
let l:options = ale#Var(a:buffer, 'sh_shfmt_options')
return {
\ 'command': ale#Escape(l:executable)
\ . (empty(l:options) ? s:DefaultOption(a:buffer) : ' ' . l:options)
\ . ' -filename=%s'
\ . (empty(l:options) ? '' : ' ' . l:options)
\}
endfunction

View File

@ -106,18 +106,20 @@ function! s:NvimPrepareWindowContent(lines) abort
let l:width += 2
let l:height += 2
let l:hor = g:ale_floating_window_border[0]
let l:top = g:ale_floating_window_border[1]
let l:top_left = g:ale_floating_window_border[2]
let l:top_right = g:ale_floating_window_border[3]
let l:bottom_right = g:ale_floating_window_border[4]
let l:bottom_left = g:ale_floating_window_border[5]
let l:left = get(g:ale_floating_window_border, 0, '|')
let l:top = get(g:ale_floating_window_border, 1, '-')
let l:top_left = get(g:ale_floating_window_border, 2, '+')
let l:top_right = get(g:ale_floating_window_border, 3, '+')
let l:bottom_right = get(g:ale_floating_window_border, 4, '+')
let l:bottom_left = get(g:ale_floating_window_border, 5, '+')
let l:right = get(g:ale_floating_window_border, 6, l:left)
let l:bottom = get(g:ale_floating_window_border, 7, l:top)
let l:lines = [l:top_left . repeat(l:top, l:width - 2) . l:top_right]
for l:line in a:lines
let l:line_width = strchars(l:line)
let l:lines = add(l:lines, l:hor . l:line . repeat(' ', l:width - l:line_width - 2). l:hor)
let l:lines = add(l:lines, l:left . l:line . repeat(' ', l:width - l:line_width - 2). l:right)
endfor
" Truncate the lines
@ -125,7 +127,7 @@ function! s:NvimPrepareWindowContent(lines) abort
let l:lines = l:lines[0:l:max_height]
endif
let l:lines = add(l:lines, l:bottom_left . repeat(l:top, l:width - 2) . l:bottom_right)
let l:lines = add(l:lines, l:bottom_left . repeat(l:bottom, l:width - 2) . l:bottom_right)
return [l:lines, l:width, l:height]
endfunction
@ -158,14 +160,14 @@ function! s:VimCreate(options) abort
\ 'padding': [0, 1, 0, 1],
\ 'border': [],
\ 'borderchars': empty(g:ale_floating_window_border) ? [' '] : [
\ g:ale_floating_window_border[1],
\ g:ale_floating_window_border[0],
\ g:ale_floating_window_border[1],
\ g:ale_floating_window_border[0],
\ g:ale_floating_window_border[2],
\ g:ale_floating_window_border[3],
\ g:ale_floating_window_border[4],
\ g:ale_floating_window_border[5],
\ get(g:ale_floating_window_border, 1, '-'),
\ get(g:ale_floating_window_border, 6, '|'),
\ get(g:ale_floating_window_border, 7, '-'),
\ get(g:ale_floating_window_border, 0, '|'),
\ get(g:ale_floating_window_border, 2, '+'),
\ get(g:ale_floating_window_border, 3, '+'),
\ get(g:ale_floating_window_border, 4, '+'),
\ get(g:ale_floating_window_border, 5, '+'),
\ ],
\ 'moved': 'any',
\ })

View File

@ -1,5 +1,17 @@
function! ale#handlers#actionlint#GetCommand(buffer) abort
return '%e --no-color --oneline %t'
let l:options = ale#Var(a:buffer, 'yaml_actionlint_options')
" automatically add --no-color option if not defined
if l:options !~# '--no-color'
let l:options .= ' --no-color'
endif
" automatically add --oneline option if not defined
if l:options !~# '--oneline'
let l:options .= ' --oneline'
endif
return '%e ' . l:options . ' %t'
endfunction
function! ale#handlers#actionlint#Handle(buffer, lines) abort

View File

@ -0,0 +1,73 @@
scriptencoding utf-8LE
" Description: This file defines a handler function for linting OpenSCAD files
" with SCA2D
function! ale#handlers#openscad#SCA2D_callback(buffer, lines) abort
" Example output::
" foo.scad:3:1: W2001: Variable `unused` overwritten within scope.
" foo.scad:1:1: F0001: Cannot read file due to syntax error:
" - No terminal matches '}' in the current parser context, at line 1 col 36
let l:filename_re = '^\([^:]*\):'
let l:linenum_re = '\([0-9]*\):'
let l:colnum_re = '\([0-9]*\):'
let l:err_id = '\([IWEFU][0-9]\+\):'
let l:err_msg = '\(.*\)'
let l:pattern = filename_re .
\ linenum_re .
\ colnum_re .
\ ' ' .
\ err_id .
\ ' ' .
\ err_msg
let l:result = []
let l:idx = 0
for l:line in a:lines
let l:matches = matchlist(line, pattern)
if len(matches) > 0
" option: Info, Warning, Error, Fatal, Unknown
if index(['I', 'W'], matches[4][0]) >= 0
let l:type = 'W'
else
let l:type = 'E'
endif
let l:lnum = matches[2]
let l:col = matches[3]
let l:text = matches[5]
" Better locations for some syntax errors
if matches[4][0] is# 'F'
let l:syntax_error_re = '^\(.*\), at line \([0-9]\+\) col \([0-9]\+\)$'
let l:next_line = a:lines[idx+1]
let l:syn_err_matches = matchlist(l:next_line, l:syntax_error_re)
if len(syn_err_matches) > 0
let l:text = l:text . l:syn_err_matches[1]
let l:lnum = l:syn_err_matches[2]
let l:col = l:syn_err_matches[3]
else
let l:text = l:next_line
endif
endif
let l:element = {
\ 'lnum': str2nr(l:lnum),
\ 'col': str2nr(l:col),
\ 'text': l:text,
\ 'detail': l:matches[4] . ': ' . l:text,
\ 'filename': fnamemodify(matches[1], ':p'),
\ 'type': l:type
\ }
call add(l:result, l:element)
endif
let l:idx += 1
endfor
return result
endfun

View File

@ -250,10 +250,16 @@ function! ale#job#Start(command, options) abort
if has_key(a:options, 'out_cb')
let l:job_options.out_cb = function('s:VimOutputCallback')
else
" prevent buffering of output and excessive polling in case close_cb is set
let l:job_options.out_cb = {->0}
endif
if has_key(a:options, 'err_cb')
let l:job_options.err_cb = function('s:VimErrorCallback')
else
" prevent buffering of output and excessive polling in case close_cb is set
let l:job_options.err_cb = {->0}
endif
if has_key(a:options, 'exit_cb')

View File

@ -0,0 +1,15 @@
===============================================================================
ALE Cairo Integration *ale-cairo-options*
===============================================================================
starknet *ale-cairo-starknet*
g:ale_cairo_starknet_executable *g:ale_cairo_starknet_executable*
*b:ale_cairo_starknet_executable*
Default: `'starknet-compile'`
Overrides the starknet-compile binary after installing the cairo-language.
For more information read 'https://starknet.io/docs/quickstart.html'

View File

@ -156,8 +156,7 @@ environments.
1. Vim 8.0.0027 on Linux via GitHub Actions.
2. Vim 8.2.4693 on Linux via GitHub Actions.
3. NeoVim 0.2.0 on Linux via GitHub Actions.
4. NeoVim 0.4.4 on Linux via GitHub Actions.
5. NeoVim 0.6.1 on Linux via GitHub Actions.
4. NeoVim 0.7.0 on Linux via GitHub Actions.
6. Vim 8 (stable builds) on Windows via AppVeyor.
If you are developing ALE code on Linux, Mac OSX, or BSD, you can run ALEs

View File

@ -134,7 +134,7 @@ g:ale_haskell_hlint_options g:ale_haskell_hlint_options
hls *ale-haskell-hls*
g:ale_haskell_hls_executable *g:ale_haskell_hls_executable*
*b:ale_haskell_his_executable*
*b:ale_haskell_hls_executable*
Type: |String|
Default: `'haskell-language-server-wrapper'`

View File

@ -2,6 +2,26 @@
ALE OCaml Integration *ale-ocaml-options*
===============================================================================
dune *ale-ocaml-dune*
Dune is a build system for OCaml projects. The `dune format` command is
supported for automatically formatting `dune` and `dune-project` files.
g:ale_ocaml_dune_executable *g:ale_ocaml_dune_executable*
*b:ale_ocaml_dune_executable*
Type: |String|
Default: `'dune'`
This variable can be set to pass the path to dune.
g:ale_ocaml_dune_options *g:ale_ocaml_dune_options*
*b:ale_ocaml_dune_options*
Type: |String|
Default: `''`
This variable can be set to pass additional options to the dune fixer.
===============================================================================
merlin *ale-ocaml-merlin*

View File

@ -0,0 +1,25 @@
===============================================================================
ALE OpenSCAD Integration *ale-openscad-options*
===============================================================================
sca2d *ale-openscad-sca2d*
g:ale_openscad_sca2d_executable *g:ale_openscad_sca2d_executable*
*b:ale_openscad_sca2d_executable*
Type: |String|
Default: `'sca2d'`
See |ale-integrations-local-executables|
g:ale_openscad_sca2d_options *g:ale_openscad_sca2d_options*
*b:ale_openscad_sca2d_options*
Type: |String|
Default: `''`
This variable can be set to pass options to sca2d.
===============================================================================
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:

View File

@ -272,6 +272,33 @@ g:ale_php_php_executable *g:ale_php_php_executable*
This variable sets the executable used for php.
===============================================================================
pint *ale-php-pint*
g:ale_php_pint_executable *g:ale_php_pint_executable*
*b:ale_php_pint_executable*
Type: |String|
Default: `'pint'`
This variable sets the executable used for pint.
g:ale_php_pint_options *g:ale_php_pint_options*
*b:ale_php_pint_options*
Type: |String|
Default: `''`
This variable can be set to pass additional options to pint.
g:ale_php_pint_use_global *g:ale_php_pint_use_global*
*b:ale_php_pint_use_global*
Type: |Boolean|
Default: `get(g:, 'ale_use_global_executables', 0)`
See |ale-integrations-local-executables|
===============================================================================
tlint *ale-php-tlint*

View File

@ -268,8 +268,8 @@ g:ale_python_flake8_change_directory *g:ale_python_flake8_change_directory*
Default: `'project'`
If set to `project`, ALE will switch to the project root before checking file.
If set to `file`, ALE will switch to directory the Python file being
checked with `flake8` is in before checking it.
If set to `file`, ALE will first switch to the directory containing the
Python file being checked with `flake8` before checking it.
You can turn it off with `off` option if you want to control the directory
Python is executed from yourself.
@ -708,6 +708,52 @@ g:ale_python_pyflakes_auto_poetry *g:ale_python_pyflakes_auto_poetry*
if true. This is overridden by a manually-set executable.
===============================================================================
pyflyby *ale-python-pyflyby*
g:ale_python_pyflyby_executable *g:ale_python_pyflyby_executable*
*b:ale_python_pyflyby_executable*
Type: |String|
Default: `'tidy-imports'`
See |ale-integrations-local-executables|
g:ale_python_pyflyby_options *g:ale_python_pyflyby_options*
*b:ale_python_pyflyby_options*
Type: |String|
Default: `''`
This variable can be changed to add command-line arguments to the pyflyby
tidy-imports invocation.
g:ale_python_pyflyby_use_global *g:ale_python_pyflyby_use_global*
*b:ale_python_pyflyby_use_global*
Type: |Number|
Default: `get(g:, 'ale_use_global_executables', 0)`
See |ale-integrations-local-executables|
g:ale_python_pyflyby_auto_pipenv *g:ale_python_pyflyby_auto_pipenv*
*b:ale_python_pyflyby_auto_pipenv*
Type: |Number|
Default: `0`
Detect whether the file is inside a pipenv, and set the executable to `pipenv`
if true. This is overridden by a manually-set executable.
g:ale_python_pyflyby_auto_poetry *g:ale_python_pyflyby_auto_poetry*
*b:ale_python_pyflyby_auto_poetry*
Type: |Number|
Default: `0`
Detect whether the file is inside a poetry, and set the executable to `poetry`
if true. This is overridden by a manually-set executable.
===============================================================================
pylama *ale-python-pylama*

View File

@ -95,6 +95,8 @@ Notes:
* `flawfinder`
* `gcc` (`cc`)
* `uncrustify`
* Cairo
* `starknet`
* Chef
* `cookstyle`
* `foodcritic`!!
@ -384,6 +386,7 @@ Notes:
* `clangd`
* `uncrustify`
* OCaml
* `dune`
* `merlin` (see |ale-ocaml-merlin|)
* `ocamlformat`
* `ocamllsp`
@ -393,6 +396,8 @@ Notes:
* `ibm_validator`
* `prettier`
* `yamllint`
* OpenSCAD
* `SCA2D`
* Packer
* `packer-fmt-fixer`
* Pascal
@ -417,6 +422,7 @@ Notes:
* `phpcs`
* `phpmd`
* `phpstan`
* `pint`
* `psalm`!!
* `tlint`
* PO
@ -466,6 +472,7 @@ Notes:
* `pycodestyle`
* `pydocstyle`
* `pyflakes`
* `pyflyby`
* `pylama`!!
* `pylint`!!
* `pylsp`

View File

@ -32,6 +32,20 @@ g:ale_yaml_actionlint_executable *g:ale_yaml_actionlint_executable*
This variable can be set to change the path to actionlint.
g:ale_yaml_actionlint_options *g:ale_yaml_actionlint_options*
*b:ale_yaml_actionlint_options*
Type: |String|
Default: `''`
This variable can be set to add extra options to actionlint executable.
For example, to disable running `shellcheck` and `pyflakes` external commands,
you may want to set:
>
let g:ale_yaml_actionlint_options = '-shellcheck= -pyflakes='
<
Please note that passing `-format` as option is not supported at the moment.
===============================================================================
circleci *ale-yaml-circleci*

View File

@ -676,7 +676,8 @@ Hover information can be displayed in the preview window instead by setting
When using Neovim or Vim with |popupwin|, if |g:ale_hover_to_floating_preview|
or |g:ale_floating_preview| is set to 1, the hover information will show in a
floating window. And |g:ale_floating_window_border| for the border setting.
floating window. The borders of the floating preview window can be customized
by setting |g:ale_floating_window_border|.
For Vim 8.1+ terminals, mouse hovering is disabled by default. Enabling
|balloonexpr| commands in terminals can cause scrolling issues in terminals,
@ -1236,14 +1237,19 @@ g:ale_floating_preview *g:ale_floating_preview*
g:ale_floating_window_border *g:ale_floating_window_border*
Type: |List|
Default: `['|', '-', '+', '+', '+', '+']`
Default: `['|', '-', '+', '+', '+', '+', '|', '-']`
When set to `[]`, window borders are disabled. The elements in the list set
the horizontal, top, top-left, top-right, bottom-right and bottom-left
border characters, respectively.
the the characters for the left side, top, top-left corner, top-right
corner, bottom-right corner, bottom-left corner, right side, and bottom of
the floating window, respectively.
If the terminal supports Unicode, you might try setting the value to
` ['│', '─', '╭', '╮', '╯', '╰']`, to make it look nicer.
` ['│', '─', '╭', '╮', '╯', '╰', '│', '─']`, to make it look nicer.
NOTE: For compatibility with previous versions, if the list does not have
elements for the right side and bottom, the left side and top will be used
instead.
g:ale_history_enabled *g:ale_history_enabled*
@ -2769,6 +2775,8 @@ documented in additional help files.
cspell................................|ale-c-cspell|
flawfinder............................|ale-c-flawfinder|
uncrustify............................|ale-c-uncrustify|
cairo...................................|ale-cairo-options|
starknet..............................|ale-cairo-starknet|
chef....................................|ale-chef-options|
cookstyle.............................|ale-chef-cookstyle|
foodcritic............................|ale-chef-foodcritic|
@ -3033,6 +3041,7 @@ documented in additional help files.
clangd................................|ale-objcpp-clangd|
uncrustify............................|ale-objcpp-uncrustify|
ocaml...................................|ale-ocaml-options|
dune..................................|ale-ocaml-dune|
merlin................................|ale-ocaml-merlin|
ocamllsp..............................|ale-ocaml-ocamllsp|
ols...................................|ale-ocaml-ols|
@ -3042,6 +3051,8 @@ documented in additional help files.
ibm_validator.........................|ale-openapi-ibm-validator|
prettier..............................|ale-openapi-prettier|
yamllint..............................|ale-openapi-yamllint|
openscad................................|ale-openscad-options|
sca2d.................................|ale-openscad-sca2d|
packer..................................|ale-packer-options|
packer-fmt-fixer......................|ale-packer-fmt-fixer|
pascal..................................|ale-pascal-options|
@ -3065,6 +3076,7 @@ documented in additional help files.
psalm.................................|ale-php-psalm|
php-cs-fixer..........................|ale-php-php-cs-fixer|
php...................................|ale-php-php|
pint..................................|ale-php-pint|
tlint.................................|ale-php-tlint|
intelephense..........................|ale-php-intelephense|
po......................................|ale-po-options|
@ -3111,6 +3123,7 @@ documented in additional help files.
pycodestyle...........................|ale-python-pycodestyle|
pydocstyle............................|ale-python-pydocstyle|
pyflakes..............................|ale-python-pyflakes|
pyflyby...............................|ale-python-pyflyby|
pylama................................|ale-python-pylama|
pylint................................|ale-python-pylint|
pylsp.................................|ale-python-pylsp|

View File

@ -152,10 +152,11 @@ let g:ale_hover_to_floating_preview = get(g:, 'ale_hover_to_floating_preview', 0
" Detail uses floating windows in Neovim
let g:ale_detail_to_floating_preview = get(g:, 'ale_detail_to_floating_preview', 0)
" Border setting for floating preview windows in Neovim
" The element in the list presents - horizontal, top, top-left, top-right,
" bottom-right and bottom-left
let g:ale_floating_window_border = get(g:, 'ale_floating_window_border', ['|', '-', '+', '+', '+', '+'])
" Border setting for floating preview windows
" The elements in the list set the characters for the left, top, top-left,
" top-right, bottom-right, bottom-left, right, and bottom of the border
" respectively
let g:ale_floating_window_border = get(g:, 'ale_floating_window_border', ['|', '-', '+', '+', '+', '+', '|', '-'])
" This flag can be set to 0 to disable warnings for trailing whitespace
let g:ale_warn_about_trailing_whitespace = get(g:, 'ale_warn_about_trailing_whitespace', 1)

View File

@ -32,6 +32,7 @@ class Source(Base):
'rust': r'(\.|::)\w*$',
'typescript': r'(\.|\'|")\w*$',
'cpp': r'(\.|::|->)\w*$',
'c': r'(\.|->)\w*$',
}
# Returns an integer for the start position, as with omnifunc.

View File

@ -104,6 +104,8 @@ formatting.
* [flawfinder](https://www.dwheeler.com/flawfinder/)
* [gcc](https://gcc.gnu.org/)
* [uncrustify](https://github.com/uncrustify/uncrustify)
* Cairo
* [starknet](https://starknet.io/docs)
* Chef
* [cookstyle](https://docs.chef.io/cookstyle.html)
* [foodcritic](http://www.foodcritic.io/) :floppy_disk:
@ -393,6 +395,7 @@ formatting.
* [clangd](https://clang.llvm.org/extra/clangd.html)
* [uncrustify](https://github.com/uncrustify/uncrustify)
* OCaml
* [dune](https://dune.build/)
* [merlin](https://github.com/the-lambda-church/merlin) see `:help ale-ocaml-merlin` for configuration instructions
* [ocamlformat](https://github.com/ocaml-ppx/ocamlformat)
* [ocamllsp](https://github.com/ocaml/ocaml-lsp)
@ -402,6 +405,8 @@ formatting.
* [ibm_validator](https://github.com/IBM/openapi-validator)
* [prettier](https://github.com/prettier/prettier)
* [yamllint](https://yamllint.readthedocs.io/)
* OpenSCAD
* [SCA2D](https://gitlab.com/bath_open_instrumentation_group/sca2d) :floppy_disk:
* Packer (HCL)
* [packer-fmt-fixer](https://github.com/hashicorp/packer)
* Pascal
@ -420,12 +425,13 @@ formatting.
* [langserver](https://github.com/felixfbecker/php-language-server)
* [phan](https://github.com/phan/phan) see `:help ale-php-phan` to instructions
* [php -l](https://secure.php.net/)
* [php-cs-fixer](http://cs.sensiolabs.org/)
* [php-cs-fixer](https://cs.symfony.com)
* [phpactor](https://github.com/phpactor/phpactor)
* [phpcbf](https://github.com/squizlabs/PHP_CodeSniffer)
* [phpcs](https://github.com/squizlabs/PHP_CodeSniffer)
* [phpmd](https://phpmd.org)
* [phpstan](https://github.com/phpstan/phpstan)
* [pint](https://github.com/laravel/pint) :beer:
* [psalm](https://getpsalm.org) :floppy_disk:
* [tlint](https://github.com/tightenco/tlint)
* PO
@ -475,6 +481,7 @@ formatting.
* [pycodestyle](https://github.com/PyCQA/pycodestyle) :warning:
* [pydocstyle](https://www.pydocstyle.org/) :warning:
* [pyflakes](https://github.com/PyCQA/pyflakes)
* [pyflyby](https://github.com/deshaw/pyflyby) :warning:
* [pylama](https://github.com/klen/pylama) :floppy_disk:
* [pylint](https://www.pylint.org/) :floppy_disk:
* [pylsp](https://github.com/python-lsp/python-lsp-server) :warning:

View File

@ -0,0 +1,6 @@
# Ignore generated tags
/doc/tags
dist.bat
*.zip
tags
*.sw[a-p]

View File

@ -0,0 +1,27 @@
Copyright (c) 2001-2013, Jeff Lanzarotta
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
* Neither the name of the {organization} nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -0,0 +1,99 @@
bufexplorer
===========
BufExplorer Plugin for Vim
With bufexplorer, you can quickly and easily switch between buffers by using the one of the default public interfaces:
`\<Leader\>be` normal open
`\<Leader\>bt` toggle open / close
`\<Leader\>bs` force horizontal split open
`\<Leader\>bv` force vertical split open
Once the bufexplorer window is open you can use the normal movement keys (hjkl) to move around and then use `<Enter>` or `<Left-Mouse-Click>` to select the buffer you would like to open. If you would like to have the selected buffer opened in a new tab, simply press either `<Shift-Enter>` or `t`. Please note that when opening a buffer in a tab, that if the buffer is already in another tab, bufexplorer can switch to that tab automatically for you if you would like. More about that in the supplied VIM help.
Bufexplorer also offers various options including:
- Display the list of buffers in various sort orders including:
- Most Recently Used (MRU) which is the default
- Buffer number
- File name
- File extension
- Full file path name
- Delete buffer from list
For more about options, sort orders, configuration options, etc. please see the supplied VIM help.
## vim.org
This plugin can also be found at http://www.vim.org/scripts/script.php?script_id=42.
## Installation
### Manually
1. If you do not want to use one of the the bundle handlers, you can take the
zip file from vim.org and unzip it and copy the plugin to your vimfiles\plugin
directory and the txt file to your vimfiles\doc directory. If you do that,
make sure you generate the help by executing
`:helptag <your runtime directory>/doc`
Once help tags have been generated, you can view the manual with
`:help bufexplorer`.
### Vundle (https://github.com/gmarik/Vundle.vim)
1. Add the following configuration to your `.vimrc`.
Plugin 'jlanzarotta/bufexplorer'
2. Install with `:BundleInstall`.
### NeoBundle (https://github.com/Shougo/neobundle.vim)
1. Add the following configuration to your `.vimrc`.
NeoBundle 'jlanzarotta/bufexplorer'
2. Install with `:NeoBundleInstall`.
### Plug (https://github.com/junegunn/vim-plug)
1. Add the following configuration to your `.vimrc`.
Plug 'jlanzarotta/bufexplorer'
2. Install with `:PlugInstall`.
### Pathogen
1. Install with the following command.
git clone https://github.com/jlanzarotta/bufexplorer.git ~/.vim/bundle/bufexplorer.vim
## License
Copyright (c) 2001-2022, Jeff Lanzarotta
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
* Neither the name of the {organization} nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -1,7 +1,7 @@
*bufexplorer.txt* Buffer Explorer Last Change: 03 Nov 2014
*bufexplorer.txt* Buffer Explorer Last Change: 02 May 2022
Buffer Explorer *buffer-explorer* *bufexplorer*
Version 7.4.6
Version 7.4.24
Plugin for easily exploring (or browsing) Vim|:buffers|.
@ -41,22 +41,24 @@ To install:
USAGE *bufexplorer-usage*
To start exploring in the current window, use: >
\be or :BufExplorer or Your custom key mapping
<Leader>be or :BufExplorer or Your custom key mapping
To toggle bufexplorer on or off in the current window, use: >
<Leader>bt or :ToggleBufExplorer or Your custom key mapping
To start exploring in a newly split horizontal window, use: >
\bs or :BufExplorerHorizontalSplit or Your custom key mapping
<Leader>bs or :BufExplorerHorizontalSplit or Your custom key mapping
To start exploring in a newly split vertical window, use: >
\bv or :BufExplorerVerticalSplit or Your custom key mapping
<Leader>bv or :BufExplorerVerticalSplit or Your custom key mapping
If you would like to use something other than '\', you may simply change the
leader (see |mapleader|).
If you would like to use something other than the default leader key - '\' -
you may simply change the leader (see |mapleader|).
When \bs or \bv is issued, bufexplorer opens in either a horizonally or
vertically split window. By issusing either of these commands, the user is
telling bufexplorer that they want to split the window and have bufexplorer
show the buffer they are about to select (from the bufexplorer windows) in the
newly split window. When \be is issued, bufexplorer opens the bufexplorer
contents in the current window and the buffer the user selects is opened in
the current window.
When <Leader>bs or <Leader>bv is issued, bufexplorer opens in either a
horizontally or vertically split window. By issuing either of these commands,
the user is telling bufexplorer that they want to split the window and have
bufexplorer show the buffer they are about to select (from the bufexplorer
windows) in the newly split window. When <Leader>be is issued, bufexplorer
opens the bufexplorer contents in the current window and the buffer the user
selects is opened in the current window.
Note: If the current buffer is modified when bufexplorer started, the current
window is always split and the new bufexplorer is displayed in that new
@ -70,18 +72,20 @@ Commands to use once exploring:
<leftmouse> Opens the buffer that is under the cursor into the current
window.
<shift-enter> Opens the buffer that is under the cursor in another tab.
a Toggles whether you are taken to the active window when
selecting a buffer or not.
b Fast buffer switching with b<any bufnum>.
B Works in association with the|ShowTabBuffer|option. If
|ShowTabBuffer|is set to 1, this toggles if BufExplorer is to
B Works in association with the |ShowTabBuffer| option. If
|ShowTabBuffer| is set to 1, this toggles if BufExplorer is to
only store the most recent tab for this buffer or not.
d |:delete|the buffer under the cursor from the list. The
d |:delete| the buffer under the cursor from the list. The
buffer's 'buflisted' is cleared. This allows for the buffer to
be displayed again using the 'show unlisted' command.
D |:wipeout|the buffer under the cursor from the list. When a
buffers is wiped, it will not be shown when unlisted buffer are
D |:wipeout| the buffer under the cursor from the list. When a
buffer is wiped, it will not be shown when unlisted buffers are
displayed.
f Toggles whether you are taken to the active window when
selecting a buffer or not.
F Open selected buffer in another window above the current.
f Open selected buffer in another window below the current.
o Opens the buffer that is under the cursor into the current
window.
p Toggles the showing of a split filename/pathname.
@ -97,12 +101,14 @@ Commands to use once exploring:
t Opens the buffer that is under the cursor in another tab.
T Toggles to show only buffers for this tab or not.
u Toggles the showing of "unlisted" buffers.
V Open the selected buffer in another window on the left of the current.
v Open the selected buffer in another window on the right of the current.
Once invoked, Buffer Explorer displays a sorted list (MRU is the default
sort method) of all the buffers that are currently opened. You are then
able to move the cursor to the line containing the buffer's name you are
wanting to act upon. Once you have selected the buffer you would like,
you can then either open it, close it(delete), resort the list, reverse
you can then either open it, close it (delete), resort the list, reverse
the sort, quit exploring and so on...
===============================================================================
@ -119,17 +125,18 @@ WINDOW LAYOUT *bufexplorer-windowlayout*
| | | | +-- Current Line #.
| | | +-- Relative/Full Path
| | +-- Buffer Name.
| +-- Buffer Attributes. See|:buffers|for more information.
+-- Buffer Number. See|:buffers|for more information.
| +-- Buffer Attributes. See |:buffers| for more information.
+-- Buffer Number. See |:buffers| for more information.
===============================================================================
CUSTOMIZATION *bufexplorer-customization*
If you do not like the default key mappings of \be, \bs, and \bv, you can
override bufexplorer's default mappings by setting up something like the
following in your vimrc file:
If you do not like the default key mappings of <Leader>be, <Leader>bs, and
<Leader>bv, you can override bufexplorer's default mappings by setting up
something like the following in your vimrc file:
nnoremap <silent> <F11> :BufExplorer<CR>
nnoremap <silent> <s-F11> :ToggleBufExplorer<CR>
nnoremap <silent> <m-F11> :BufExplorerHorizontalSplit<CR>
nnoremap <silent> <c-F11> :BufExplorerVerticalSplit<CR>
@ -193,13 +200,13 @@ directory, use: >
The default is to show absolute paths.
*g:bufExplorerShowTabBuffer*
To control weither or not to show buffers on for the specific tab or not, use: >
To control whether or not to show buffers on for the specific tab or not, use: >
let g:bufExplorerShowTabBuffer=0 " No.
let g:bufExplorerShowTabBuffer=1 " Yes.
The default is not to show.
*g:bufExplorerShowUnlisted*
To control whether to show unlisted buffer or not, use: >
To control whether to show unlisted buffers or not, use: >
let g:bufExplorerShowUnlisted=0 " Do not show unlisted buffers.
let g:bufExplorerShowUnlisted=1 " Show unlisted buffers.
The default is to NOT show unlisted buffers.
@ -242,14 +249,90 @@ current window, use: >
The default is to use the global &splitright.
*g:bufExplorerSplitVertSize*
To control the size of the new vertical split window. use: >
let g:bufExplorerVertSize=n " New split window is n columns wide.
let g:bufExplorerVertSize=0 " New split windows size set by Vim.
To control the size of the new vertical split window, use: >
let g:bufExplorerSplitVertSize=n " New split window is n columns wide.
let g:bufExplorerSplitVertSize=0 " New split windows size set by Vim.
The default is 0, so that the size is set by Vim.
*g:bufExplorerVersionWarn*
To control whether to warning about Vim version or not, use: >
let g:bufExplorerVersionWarn=1 " Warn if version conflict.
let g:bufExplorerVersionWarn=0 " Do not warn if version conflict.
The default is 1.
===============================================================================
CHANGE LOG *bufexplorer-changelog*
7.4.23 January 23, 2022
- Merged in changes from benoit-pierre that fixes an error thrown when vim
is in read-only mode.
- Merged in changes from tartansandal that implements the use of an
independent variable to track window splitting since s:splitMode != ''
no longer implies that a split was triggered.
7.4.22 January 5,2022
- Merged in change from nadean that fixed an issue that if you use either
split mode, you could no longer use the regular non-split mode. This was
because the split mode set s:splitMode and that variable was never reset
to "" to allow you run without split mode.
7.4.21 December 8, 2018
- Merged in changes from adelarsq that introduced ryanoasis/vim-devicons
support. If the global g:loaded_webdevicons has been set, bufexplorer
will now load the associated dev icons for each buffer.
7.4.20 January 18, 2017
- Thanks to jpflouret for supplying code that can remove the warning
messages if you using this plugin on an older version of Vim. The
global variable is g:bufExplorerVersionWarn.
7.4.19 September 18, 2017
- Merged all changes from github back into this version and tried to sync
to the correct version number.
7.4.18 - Github.
7.4.17 - Github.
7.4.16 August 14, 2017
- Thanks to Yubo Su for the patch that adds 'f, F, V, and v' commands.
With this change, the original 'f' command was remapped to 'a'.
The set of commands that can be used during exploring are:
F - Open selected buffer in another window above the current.
f - Open selected buffer in another window below the current.
V - Open the selected buffer in another window on the left of the
current.
v - Open the selected buffer in another window on the right of the
current.
7.4.15 May 01, 2017
- Finally applied the patch submitted by justfalter. This patch is a
backward-compatible fix for the "invalid tab range" bug.
7.4.14 April 10, 2017
- As suggested by adelarsq way back on January 5th, 2016, a filetype has
been added. There is now 'filetype=bufexplorer'.
7.4.13 March 08, 2017
- Thanks to devakivamsi for pointing out that even though bufexplorer
turns off line numbers by default within its own window, this did not
work correctly when using WinManager. This has now been corrected.
7.4.12 September 30, 2016
- Thanks again to Martin Vuille for several more fixes related to making
bufexplorer more tab-friendly.
7.4.11 September, 20, 2016
- Thanks to Martin Vuille for reworking the per-tab buffer listing code.
Fix for g:bufExplorerShowTabBuffer is not working correctly and other
"gliches" when the ShotTabBuffer option is enabled. For example old
code would not correctly handle adding/deleting a tab that wasn't the
highest-numbered tab.
7.4.10 August 26, 2016
- Thanks to buddylindsey for fixing a misspelling in the docs.
7.4.9 April 01, 2016
- Thanks to ivegotasthma for supplying a patch to fix a major issue with
plugin performance when lots of buffers are open.
- Thanks to ershov for the patch to fix grouping of files in ambiguous
sort modes.
- Thanks to PhilRunninger for changing documentation to use <Leader>, in
place of '\'.
7.4.8 January 27, 2015
- Thanks to Marius Gedminas for fixing up the documentation and correcting
various typos.
7.4.7 January 20, 2015
- Thanks goes out to Phil Runninger for added the ability to toggle the
bufexplorer list on and off using the :ToggleBufExplorer command, the
map <Leader>bt, and the function ToggleBufExplorer().
7.4.6 November 03, 2014
- Not sure how, but the file format was converted to Dos instead of Unix.
I converted the file back to Unix.
@ -275,7 +358,7 @@ CHANGE LOG *bufexplorer-changelog*
- First update related to Vim 7.4.
- Changed license text.
- Fixed issue with 'hidden'. If 'hidden' is set, make sure that
g:bufExplorerFindActive is set to 0. Otherwise, when using /bs or /bv,
g:bufExplorerFindActive is set to 0. Otherwise, when using \bs or \bv,
and selecting a buffer, the original buffer will be switched to instead
of being opened in the newly created windows.
- Added new 'b' mapping when the bufExplorer window is opened. When 'b'
@ -332,7 +415,7 @@ CHANGE LOG *bufexplorer-changelog*
fixes. Overall, I am hopeful that I not forgotten or lost a feature.
- Thanks to Tim Johnson for testing out this new version.
- I have hopefully allowed for better mapping of the main public
methods as is explained in the|bufexplorer-customization|section
methods as is explained in the |bufexplorer-customization| section
of the documentation.
- Add new 'B', 'o', and 'S' key mappings.
7.2.8 November 08, 2010
@ -503,7 +586,7 @@ CHANGE LOG *bufexplorer-changelog*
- Dave Eggum has made some 'significant' updates to this latest
version:
* Added BufExplorerGetAltBuf() global function to be used in the
users rulerformat.
user's rulerformat.
* Added g:bufExplorerSplitRight option.
* Added g:bufExplorerShowRelativePath option with mapping.
* Added current line highlighting.
@ -630,7 +713,7 @@ CHANGE LOG *bufexplorer-changelog*
- Thanks to Andre Pang for the original patch/idea to get bufexplorer
to work in insertmode/modeless mode (evim).
- Added Initialize and Cleanup autocommands to handle commands that
need to be performed when starting or leaving bufexplorer.
need to be performed when starting or leaving bufexplorer.
6.0.15 February 20, 2002
- Srinath Avadhanulax added a patch for winmanager.vim.
6.0.14 February 19, 2002
@ -692,7 +775,7 @@ TODO *bufexplorer-todo*
===============================================================================
CREDITS *bufexplorer-credits*
Author: Jeff Lanzarotta <delux256-vim at yahoo dot com>
Author: Jeff Lanzarotta <delux256-vim at outlook dot com>
Credit must go out to Bram Moolenaar and all the Vim developers for
making the world's best editor (IMHO). I also want to thank everyone who
@ -702,7 +785,7 @@ won't list names.
===============================================================================
COPYRIGHT *bufexplorer-copyright*
Copyright (c) 2001-2014, Jeff Lanzarotta
Copyright (c) 2001-2022, Jeff Lanzarotta
All rights reserved.
Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
"=============================================================================
" Copyright: Copyright (c) 2001-2014, Jeff Lanzarotta
"============================================================================
" Copyright: Copyright (c) 2001-2022, Jeff Lanzarotta
" All rights reserved.
"
" Redistribution and use in source and binary forms, with or
@ -35,8 +35,8 @@
" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
" Name Of File: bufexplorer.vim
" Description: Buffer Explorer Vim Plugin
" Maintainer: Jeff Lanzarotta (delux256-vim at yahoo dot com)
" Last Changed: Monday, 03 November 2014
" Maintainer: Jeff Lanzarotta (my name at gmail dot com)
" Last Changed: Thursday, 02 May 2022
" Version: See g:bufexplorer_version for version number.
" Usage: This file should reside in the plugin directory and be
" automatically sourced.
@ -44,6 +44,7 @@
" You may use the default keymappings of
"
" <Leader>be - Opens BufExplorer
" <Leader>bt - Toggles BufExplorer open or closed
" <Leader>bs - Opens horizontally split window BufExplorer
" <Leader>bv - Opens vertically split window BufExplorer
"
@ -51,12 +52,14 @@
" in your vimrc file, for example:
"
" nnoremap <silent> <F11> :BufExplorer<CR>
" nnoremap <silent> <s-F11> :ToggleBufExplorer<CR>
" nnoremap <silent> <m-F11> :BufExplorerHorizontalSplit<CR>
" nnoremap <silent> <c-F11> :BufExplorerVerticalSplit<CR>
"
" Or you can use
"
" ":BufExplorer" - Opens BufExplorer
" ":ToggleBufExplorer" - Opens/Closes BufExplorer
" ":BufExplorerHorizontalSplit" - Opens horizontally window BufExplorer
" ":BufExplorerVerticalSplit" - Opens vertically split window BufExplorer
"
@ -64,26 +67,45 @@
" History: See supplied documentation.
"=============================================================================
" Plugin Code {{{1
" Exit quickly if already running or when 'compatible' is set. {{{2
" Exit quickly if already running or when 'compatible' is set. {{{1
if exists("g:bufexplorer_version") || &cp
finish
endif
"2}}}
"1}}}
" Version number
let g:bufexplorer_version = "7.4.6"
let g:bufexplorer_version = "7.4.24"
" Plugin Code {{{1
" Check for Vim version {{{2
if !exists("g:bufExplorerVersionWarn")
let g:bufExplorerVersionWarn = 1
endif
if v:version < 700
echohl WarningMsg
echo "Sorry, bufexplorer ".g:bufexplorer_version." required Vim 7.0 and greater."
echohl None
if g:bufExplorerVersionWarn
echohl WarningMsg
echo "Sorry, bufexplorer ".g:bufexplorer_version." required Vim 7.0 or greater."
echohl None
endif
finish
endif
" Check to see if the version of Vim has the correct patch applied, if not, do
" not used <nowait>.
if v:version > 703 || v:version == 703 && has('patch1261') && has('patch1264')
" We are good to go.
else
if g:bufExplorerVersionWarn
echohl WarningMsg
echo "Sorry, bufexplorer ".g:bufexplorer_version." required Vim 7.3 or greater with patch1261 and patch1264."
echohl None
endif
finish
endif
" Create commands {{{2
command! BufExplorer :call BufExplorer()
command! ToggleBufExplorer :call ToggleBufExplorer()
command! BufExplorerHorizontalSplit :call BufExplorerHorizontalSplit()
command! BufExplorerVerticalSplit :call BufExplorerVerticalSplit()
@ -103,14 +125,14 @@ function! s:Set(var, default)
endfunction
" Script variables {{{2
let s:MRU_Exclude_List = ["[BufExplorer]","__MRU_Files__"]
let s:MRU_Exclude_List = ["[BufExplorer]","__MRU_Files__","[Buf\ List]"]
let s:MRUList = []
let s:name = '[BufExplorer]'
let s:originBuffer = 0
let s:running = 0
let s:sort_by = ["number", "name", "fullpath", "mru", "extension"]
let s:splitMode = ""
let s:tabSpace = []
let s:didSplit = 0
let s:types = {"fullname": ':p', "path": ':p:h', "relativename": ':~:.', "relativepath": ':~:.:h', "shortname": ':t'}
" Setup the autocommands that handle the MRUList and other stuff. {{{2
@ -128,8 +150,6 @@ function! s:Setup()
autocmd BufDelete * call s:DeactivateBuffer(0)
autocmd BufWinEnter \[BufExplorer\] call s:Initialize()
autocmd BufWinLeave \[BufExplorer\] call s:Cleanup()
autocmd TabEnter * call s:TabEnter()
autocmd SessionLoadPost * call s:Reset()
augroup END
endfunction
@ -139,82 +159,128 @@ function! s:Reset()
" command line are picked up correctly.
let s:MRUList = range(1, bufnr('$'))
" Initialize one tab space array, ignore zero-based tabpagenr since all
" tabpagenr's start at 1. -1 signifies this is the first time we are
" referencing this tabpagenr.
"
" If Vim has been loaded with mksession, then it is possible for more tabs
" to exist. So use tabpagenr() to determine how large to make the array. If
" there are 4 tabs, there should be 5 elements in this array.
"
" Each element will hold a CSV list of buffers viewed in that tab. So on
" the 3rd tab, if there user has viewed 4 different buffers in that tab, the
" value would be:
" echo s:tabSpace[3]
" [4, 9, 1, 10]
" echo s:tabSpace
" [[-1], [-1], [-1], [4, 9, 1, 10], [-1]]
let s:tabSpace = []
let i = 0
" Initialize the association of buffers to tabs for any buffers
" that have been created prior to now, e.g., files specified as
" vim command line arguments
call s:CatalogBuffers()
endfunction
while(tabpagenr('$') > 0 && i <= tabpagenr('$'))
call add(s:tabSpace, [-1])
let i = i + 1
endwhile
" CatalogBuffers {{{2
" Create tab associations for any existing buffers
function! s:CatalogBuffers()
let ct = tabpagenr()
for tab in range(1, tabpagenr('$'))
silent execute 'normal! ' . tab . 'gt'
for buf in tabpagebuflist()
call s:UpdateTabBufData(buf)
endfor
endfor
silent execute 'normal! ' . ct . 'gt'
endfunction
" AssociatedTab {{{2
" Return the number of the tab associated with the specified buffer.
" If the buffer is associated with more than one tab, the first one
" found is returned. If the buffer is not associated with any tabs,
" -1 is returned.
function! s:AssociatedTab(bufnr)
for tab in range(1, tabpagenr('$'))
let list = gettabvar(tab, 'bufexp_buf_list', [])
let idx = index(list, a:bufnr)
if idx != -1
return tab
endif
endfor
return -1
endfunction
" RemoveBufFromOtherTabs {{{2
" Remove the specified buffer from the buffer lists of all tabs
" except the current tab.
function! s:RemoveBufFromOtherTabs(bufnr)
for tab in range(1, tabpagenr('$'))
if tab == tabpagenr()
continue
endif
let list = gettabvar(tab, 'bufexp_buf_list', [])
let idx = index(list, a:bufnr)
if idx == -1
continue
endif
call remove(list, idx)
call settabvar(tab, 'bufexp_buf_list', list)
endfor
endfunction
" AddBufToCurrentTab {{{2
" Add the specified buffer to the list of buffers associated
" with the current tab
function! s:AddBufToCurrentTab(bufnr)
if index(t:bufexp_buf_list, a:bufnr) == -1
call add(t:bufexp_buf_list, a:bufnr)
endif
endfunction
" IsInCurrentTab {{{2
" Returns whether the specified buffer is associated
" with the current tab
function! s:IsInCurrentTab(bufnr)
" It shouldn't happen that the list of buffers is
" not defined but if it does, play it safe and
" include the buffer
if !exists('t:bufexp_buf_list')
return 1
endif
return (index(t:bufexp_buf_list, a:bufnr) != -1)
endfunction
" UpdateTabBufData {{{2
" Update the tab buffer data for the specified buffer
"
" The current tab's list is updated. If a buffer is only
" allowed to be associated with one tab, it is removed
" from the lists of any other tabs with which it may have
" been associated.
"
" The associations between tabs and buffers are maintained
" in separate lists for each tab, which are stored in tab-
" specific variables 't:bufexp_buf_list'.
function! s:UpdateTabBufData(bufnr)
" The first time we add a tab, Vim uses the current buffer
" as its starting page even though we are about to edit a
" new page, and another BufEnter for the new page is triggered
" later. Use this first BufEnter to initialize the list of
" buffers, but don't add the buffer number to the list if
" it is already associated with another tab
"
" Unfortunately, this doesn't work right when the first
" buffer opened in the tab should be associated with it,
" such as when 'tab split +buffer N' is used
if !exists("t:bufexp_buf_list")
let t:bufexp_buf_list = []
if s:AssociatedTab(a:bufnr) != -1
return
endif
endif
call s:AddBufToCurrentTab(a:bufnr)
if g:bufExplorerOnlyOneTab
call s:RemoveBufFromOtherTabs(a:bufnr)
endif
endfunction
" ActivateBuffer {{{2
function! s:ActivateBuffer()
" Verify the current tabpage exists in the
" current s:tabSpace array. This can be missing
" entries when restoring sessions.
let i = 0
while( tabpagenr('$') > 0 && i <= tabpagenr() )
" Number: 0
" String: 1
" Funcref: 2
" List: 3
" Dictionary: 4
" Float: 5
if type(get(s:tabSpace, i)) == 0
call add(s:tabSpace, [-1])
endif
let i = i + 1
endwhile
let _bufnr = bufnr("%")
let list = get(s:tabSpace, tabpagenr(), [-1])
if !empty(list) && list[0] == '-1'
" The first time we add a tab, Vim uses the current buffer
" as it's starting page. Even though we are about to
" edit a new page (BufEnter is triggered after), so
" remove the -1 entry indicating we have covered this case.
let list = []
call add(list, _bufnr)
let s:tabSpace[tabpagenr()] = list
elseif empty(list) || index(list, _bufnr) == -1
" Add new buffer to this tab's buffer list.
call add(list, _bufnr)
let s:tabSpace[tabpagenr()] = list
if g:bufExplorerOnlyOneTab == 1
" If a buffer can only be available in 1 tab page ensure this
" buffer is not present in any other tabs
let tabidx = 1
while tabidx < len(s:tabSpace)
if tabidx != tabpagenr()
let bufidx = index(s:tabSpace[tabidx], _bufnr)
if bufidx != -1
call remove(s:tabSpace[tabidx], bufidx)
endif
endif
let tabidx = tabidx + 1
endwhile
endif
endif
call s:UpdateTabBufData(_bufnr)
call s:MRUPush(_bufnr)
endfunction
@ -224,14 +290,6 @@ function! s:DeactivateBuffer(remove)
call s:MRUPop(_bufnr)
endfunction
" TabEnter {{{2
function! s:TabEnter()
" Make s:tabSpace 1-based
if empty(s:tabSpace) || len(s:tabSpace) < (tabpagenr() + 1)
call add(s:tabSpace, [-1])
endif
endfunction
" MRUPop {{{2
function! s:MRUPop(bufnr)
call filter(s:MRUList, 'v:val != '.a:bufnr)
@ -255,7 +313,7 @@ endfunction
" ShouldIgnore {{{2
function! s:ShouldIgnore(buf)
" Ignore temporary buffers with buftype set.
if empty(getbufvar(a:buf, "&buftype") == 0)
if empty(getbufvar(a:buf, "&buftype")) == 0
return 1
endif
@ -280,26 +338,7 @@ endfunction
" Initialize {{{2
function! s:Initialize()
let s:_insertmode = &insertmode
set noinsertmode
let s:_showcmd = &showcmd
set noshowcmd
let s:_cpo = &cpo
set cpo&vim
let s:_report = &report
let &report = 10000
setlocal nonumber
setlocal foldcolumn=0
setlocal nofoldenable
setlocal cursorline
setlocal nospell
setlocal nobuflisted
call s:SetLocalSettings()
let s:running = 1
endfunction
@ -323,20 +362,55 @@ function! s:Cleanup()
let s:running = 0
let s:splitMode = ""
let s:didSplit = 0
delmarks!
endfunction
" SetLocalSettings {{{2
function! s:SetLocalSettings()
let s:_insertmode = &insertmode
set noinsertmode
let s:_showcmd = &showcmd
set noshowcmd
let s:_cpo = &cpo
set cpo&vim
let s:_report = &report
let &report = 10000
setlocal nonumber
setlocal foldcolumn=0
setlocal nofoldenable
setlocal cursorline
setlocal nospell
setlocal nobuflisted
setlocal filetype=bufexplorer
endfunction
" BufExplorerHorizontalSplit {{{2
function! BufExplorerHorizontalSplit()
let s:splitMode = "sp"
execute "BufExplorer"
let s:splitMode = ""
endfunction
" BufExplorerVerticalSplit {{{2
function! BufExplorerVerticalSplit()
let s:splitMode = "vsp"
execute "BufExplorer"
let s:splitMode = ""
endfunction
" ToggleBufExplorer {{{2
function! ToggleBufExplorer()
if exists("s:running") && s:running == 1 && bufname(winbufnr(0)) == s:name
call s:Close()
else
call BufExplorer()
endif
endfunction
" BufExplorer {{{2
@ -381,6 +455,9 @@ function! BufExplorer()
" Restore the original settings.
let [&splitbelow, &splitright] = [_splitbelow, _splitright]
" Remember that a split was triggered
let s:didSplit = 1
endif
if !exists("b:displayMode") || b:displayMode != "winmanager"
@ -403,6 +480,7 @@ function! s:DisplayBufferList()
" the buffer using CTRL-^.
setlocal buftype=nofile
setlocal modifiable
setlocal noreadonly
setlocal noswapfile
setlocal nowrap
@ -431,28 +509,31 @@ function! s:MapKeys()
nnoremap <buffer> <silent> <tab> :call <SID>SelectBuffer()<CR>
endif
nnoremap <script> <silent> <buffer> <2-leftmouse> :call <SID>SelectBuffer()<CR>
nnoremap <script> <silent> <buffer> <CR> :call <SID>SelectBuffer()<CR>
nnoremap <script> <silent> <buffer> <F1> :call <SID>ToggleHelp()<CR>
nnoremap <script> <silent> <buffer> <s-cr> :call <SID>SelectBuffer("tab")<CR>
nnoremap <script> <silent> <buffer> B :call <SID>ToggleOnlyOneTab()<CR>
nnoremap <script> <silent> <buffer> b :call <SID>SelectBuffer("ask")<CR>
nnoremap <script> <silent> <buffer> d :call <SID>RemoveBuffer("delete")<CR>
xnoremap <script> <silent> <buffer> d :call <SID>RemoveBuffer("delete")<CR>
nnoremap <script> <silent> <buffer> D :call <SID>RemoveBuffer("wipe")<CR>
xnoremap <script> <silent> <buffer> D :call <SID>RemoveBuffer("wipe")<CR>
nnoremap <script> <silent> <buffer> f :call <SID>ToggleFindActive()<CR>
nnoremap <script> <silent> <buffer> m :call <SID>MRUListShow()<CR>
nnoremap <script> <silent> <buffer> o :call <SID>SelectBuffer()<CR>
nnoremap <script> <silent> <buffer> p :call <SID>ToggleSplitOutPathName()<CR>
nnoremap <script> <silent> <buffer> q :call <SID>Close()<CR>
nnoremap <script> <silent> <buffer> r :call <SID>SortReverse()<CR>
nnoremap <script> <silent> <buffer> R :call <SID>ToggleShowRelativePath()<CR>
nnoremap <script> <silent> <buffer> s :call <SID>SortSelect()<CR>
nnoremap <script> <silent> <buffer> S :call <SID>ReverseSortSelect()<CR>
nnoremap <script> <silent> <buffer> t :call <SID>SelectBuffer("tab")<CR>
nnoremap <script> <silent> <buffer> T :call <SID>ToggleShowTabBuffer()<CR>
nnoremap <script> <silent> <buffer> u :call <SID>ToggleShowUnlisted()<CR>
nnoremap <script> <silent> <nowait> <buffer> <2-leftmouse> :call <SID>SelectBuffer()<CR>
nnoremap <script> <silent> <nowait> <buffer> <CR> :call <SID>SelectBuffer()<CR>
nnoremap <script> <silent> <nowait> <buffer> <F1> :call <SID>ToggleHelp()<CR>
nnoremap <script> <silent> <nowait> <buffer> <s-cr> :call <SID>SelectBuffer("tab")<CR>
nnoremap <script> <silent> <nowait> <buffer> a :call <SID>ToggleFindActive()<CR>
nnoremap <script> <silent> <nowait> <buffer> b :call <SID>SelectBuffer("ask")<CR>
nnoremap <script> <silent> <nowait> <buffer> d :call <SID>RemoveBuffer("delete")<CR>
xnoremap <script> <silent> <nowait> <buffer> d :call <SID>RemoveBuffer("delete")<CR>
nnoremap <script> <silent> <nowait> <buffer> D :call <SID>RemoveBuffer("wipe")<CR>
xnoremap <script> <silent> <nowait> <buffer> D :call <SID>RemoveBuffer("wipe")<CR>
nnoremap <script> <silent> <nowait> <buffer> f :call <SID>SelectBuffer("split", "sb")<CR>
nnoremap <script> <silent> <nowait> <buffer> F :call <SID>SelectBuffer("split", "st")<CR>
nnoremap <script> <silent> <nowait> <buffer> m :call <SID>MRUListShow()<CR>
nnoremap <script> <silent> <nowait> <buffer> o :call <SID>SelectBuffer()<CR>
nnoremap <script> <silent> <nowait> <buffer> p :call <SID>ToggleSplitOutPathName()<CR>
nnoremap <script> <silent> <nowait> <buffer> q :call <SID>Close()<CR>
nnoremap <script> <silent> <nowait> <buffer> r :call <SID>SortReverse()<CR>
nnoremap <script> <silent> <nowait> <buffer> R :call <SID>ToggleShowRelativePath()<CR>
nnoremap <script> <silent> <nowait> <buffer> s :call <SID>SortSelect()<CR>
nnoremap <script> <silent> <nowait> <buffer> S :call <SID>ReverseSortSelect()<CR>
nnoremap <script> <silent> <nowait> <buffer> t :call <SID>SelectBuffer("tab")<CR>
nnoremap <script> <silent> <nowait> <buffer> T :call <SID>ToggleShowTabBuffer()<CR>
nnoremap <script> <silent> <nowait> <buffer> u :call <SID>ToggleShowUnlisted()<CR>
nnoremap <script> <silent> <nowait> <buffer> v :call <SID>SelectBuffer("split", "vr")<CR>
nnoremap <script> <silent> <nowait> <buffer> V :call <SID>SelectBuffer("split", "vl")<CR>
for k in ["G", "n", "N", "L", "M", "H"]
execute "nnoremap <buffer> <silent>" k ":keepjumps normal!" k."<CR>"
@ -558,11 +639,14 @@ function! s:CreateHelp()
call add(header, '" <F1> : toggle this help')
call add(header, '" <enter> or o or Mouse-Double-Click : open buffer under cursor')
call add(header, '" <shift-enter> or t : open buffer in another tab')
call add(header, '" a : toggle find active buffer')
call add(header, '" b : Fast buffer switching with b<any bufnum>')
call add(header, '" B : toggle if to save/use recent tab or not')
call add(header, '" d : delete buffer')
call add(header, '" D : wipe buffer')
call add(header, '" f : toggle find active buffer')
call add(header, '" p : toggle spliting of file and path name')
call add(header, '" F : open buffer in another window above the current')
call add(header, '" f : open buffer in another window below the current')
call add(header, '" p : toggle splitting of file and path name')
call add(header, '" q : quit')
call add(header, '" r : reverse sort')
call add(header, '" R : toggle showing relative or full paths')
@ -570,6 +654,8 @@ function! s:CreateHelp()
call add(header, '" S : reverse cycle thru "sort by" fields')
call add(header, '" T : toggle if to show only buffers for this tab or not')
call add(header, '" u : toggle showing unlisted buffers')
call add(header, '" V : open buffer in another window on the left of the current')
call add(header, '" v : open buffer in another window on the right of the current')
else
call add(header, '" Press <F1> for Help')
endif
@ -667,24 +753,17 @@ function! s:BuildBufferList()
endif
" Are we to show only buffer(s) for this tab?
if g:bufExplorerShowTabBuffer
let show_buffer = 0
for bufnr in s:tabSpace[tabpagenr()]
if buf.attributes =~ '^\s*'.bufnr.'\>'
" Only buffers shown on the current tabpagenr
let show_buffer = 1
break
endif
endfor
if show_buffer == 0
continue
endif
if g:bufExplorerShowTabBuffer && (!s:IsInCurrentTab(str2nr(buf.attributes)))
continue
endif
let line = buf.attributes." "
if exists("g:loaded_webdevicons")
let line .= WebDevIconsGetFileTypeSymbol(buf.shortname)
let line .= " "
endif
" Are we to split the path and file name?
if g:bufExplorerSplitOutPathName
let type = (g:bufExplorerShowRelativePath) ? "relativepath" : "path"
@ -763,20 +842,27 @@ function! s:SelectBuffer(...)
return s:Close()
endif
" Are we suppose to open the selected buffer in a tab?
" Get the tab number where this bufer is located in.
let tabNbr = s:GetTabNbr(_bufNbr)
" Are we supposed to open the selected buffer in a tab?
if (a:0 == 1) && (a:1 == "tab")
" Yes, we are to open the selected buffer in a tab.
" Restore [BufExplorer] buffer.
execute "keepjumps silent buffer!".s:originBuffer
" Get the tab nmber where this bufer is located in.
let tabNbr = s:GetTabNbr(_bufNbr)
execute "silent buffer!".s:originBuffer
" Was the tab found?
if tabNbr == 0
" _bufNbr is not opened in any tabs. Open a new tab with the selected buffer in it.
execute "999tab split +buffer" . _bufNbr
" _bufNbr is not opened in any tabs. Open a new tab with the
" selected buffer in it.
if v:version > 704 || ( v:version == 704 && has('patch2237') )
" new syntax for last tab as of 7.4.2237
execute "$tab split +buffer" . _bufNbr
else
execute "999tab split +buffer" . _bufNbr
endif
" Workaround for the issue mentioned in UpdateTabBufData.
call s:UpdateTabBufData(_bufNbr)
else
" The _bufNbr is already opened in a tab, go to that tab.
execute tabNbr . "tabnext"
@ -784,9 +870,42 @@ function! s:SelectBuffer(...)
" Focus window.
execute s:GetWinNbr(tabNbr, _bufNbr) . "wincmd w"
endif
else
" No, the user did not ask to open the selected buffer in a tab.
" Are we supposed to open the selected buffer in a split?
elseif (a:0 == 2) && (a:1 == "split")
if g:bufExplorerFindActive
call s:Close()
endif
" Was the tab found?
if tabNbr != 0
" Yes, the buffer is located in a tab. Go to that tab instead of
" opening split
execute tabNbr . "tabnext"
else
"Nope, the buffer is not in a tab, open it accordingly
let _bufName = expand("#"._bufNbr.":p")
if (a:2 == "vl")
execute _bufName ?
\ "vert topleft sb ".escape(_bufName, " ") :
\ "vert topleft sb "._bufNbr
elseif (a:2 == "vr")
execute _bufName ?
\ "vert belowright sb ".escape(_bufName, " ") :
\ "vert belowright sb "._bufNbr
elseif (a:2 == "st")
execute _bufName ?
\ "topleft sb ".escape(_bufName, " ") :
\ "topleft sb "._bufNbr
else " = sb
execute _bufName ?
\ "belowright sb ".escape(_bufName, " ") :
\ "belowright sb "._bufNbr
endif
endif
" Switch to selected buffer
execute "keepalt silent b!" _bufNbr
" Default, open in current window
else
" Are we suppose to move to the tab where the active buffer is?
if exists("g:bufExplorerChgWin")
execute g:bufExplorerChgWin."wincmd w"
@ -795,9 +914,6 @@ function! s:SelectBuffer(...)
call s:Close()
endif
" Get the tab number where this buffer is located in.
let tabNbr = s:GetTabNbr(_bufNbr)
" Was the tab found?
if tabNbr != 0
" Yes, the buffer is located in a tab. Go to that tab number.
@ -811,7 +927,7 @@ function! s:SelectBuffer(...)
endif
" Switch to the selected buffer.
execute "keepalt keepjumps silent b!" _bufNbr
execute "keepjumps keepalt silent b!" _bufNbr
endif
" Make the buffer 'listed' again.
@ -847,11 +963,7 @@ function! s:RemoveBuffer(mode)
return
endif
" Do not allow this buffer to be deleted if it is the last one.
if len(s:MRUList) == 1
call s:Error("Sorry, you are not allowed to delete the last buffer")
return
endif
let mode = a:mode
" These commands are to temporarily suspend the activity of winmanager.
if exists("b:displayMode") && b:displayMode == "winmanager"
@ -861,13 +973,27 @@ function! s:RemoveBuffer(mode)
let _bufNbr = str2nr(getline('.'))
if getbufvar(_bufNbr, '&modified') == 1
call s:Error("Sorry, no write since last change for buffer "._bufNbr.", unable to delete")
return
else
" Okay, everything is good, delete or wipe the buffer.
call s:DeleteBuffer(_bufNbr, a:mode)
" Calling confirm() requires Vim built with dialog option
if !has("dialog_con") && !has("dialog_gui")
call s:Error("Sorry, no write since last change for buffer "._bufNbr.", unable to delete")
return
endif
let answer = confirm('No write since last change for buffer '._bufNbr.'. Delete anyway?', "&Yes\n&No", 2)
if a:mode == "delete" && answer == 1
let mode = "force_delete"
elseif a:mode == "wipe" && answer == 1
let mode = "force_wipe"
else
return
endif
endif
" Okay, everything is good, delete or wipe the buffer.
call s:DeleteBuffer(_bufNbr, mode)
" Reactivate winmanager autocommand activity.
if exists("b:displayMode") && b:displayMode == "winmanager"
call WinManagerForceReSize("BufExplorer")
@ -882,6 +1008,10 @@ function! s:DeleteBuffer(buf, mode)
" Wipe/Delete buffer from Vim.
if a:mode == "wipe"
execute "silent bwipe" a:buf
elseif a:mode == "force_wipe"
execute "silent bwipe!" a:buf
elseif a:mode == "force_delete"
execute "silent bdelete!" a:buf
else
execute "silent bdelete" a:buf
endif
@ -898,13 +1028,23 @@ function! s:DeleteBuffer(buf, mode)
endtry
endfunction
" ListedAndCurrentTab {{{2
" Returns whether the specified buffer is both listed and associated
" with the current tab
function! s:ListedAndCurrentTab(buf)
return buflisted(a:buf) && s:IsInCurrentTab(a:buf)
endfunction
" Close {{{2
function! s:Close()
" Get only the listed buffers.
let listed = filter(copy(s:MRUList), "buflisted(v:val)")
" Get only the listed buffers associated with the current tab
let listed = filter(copy(s:MRUList), "s:ListedAndCurrentTab(v:val)")
if len(listed) == 0
let listed = filter(range(1, bufnr('$')), "s:ListedAndCurrentTab(v:val)")
endif
" If we needed to split the main window, close the split one.
if s:splitMode != "" && bufwinnr(s:originBuffer) != -1
if s:didSplit == 1 && bufwinnr(s:originBuffer) != -1
execute "wincmd c"
endif
@ -914,7 +1054,7 @@ function! s:Close()
" buffers.
execute "enew"
else
" Since there are buffers left to switch to, swith to the previous and
" Since there are buffers left to switch to, switch to the previous and
" then the current.
for b in reverse(listed[0:1])
execute "keepjumps silent b ".b
@ -1041,6 +1181,9 @@ function! s:SortListing()
" Easiest case.
execute sort 'n'
elseif g:bufExplorerSortBy == "name"
" Sort by full path first
execute sort 'ir /\zs\f\+\ze\s\+line/'
if g:bufExplorerSplitOutPathName
execute sort 'ir /\d.\{7}\zs\f\+\ze/'
else
@ -1054,6 +1197,16 @@ function! s:SortListing()
execute sort 'ir /\zs\f\+\ze\s\+line/'
elseif g:bufExplorerSortBy == "extension"
" Sort by full path...
execute sort 'ir /\zs\f\+\ze\s\+line/'
" Sort by name...
if g:bufExplorerSplitOutPathName
" Sort twice - first on the file name then on the path.
execute sort 'ir /\d.\{7}\zs\f\+\ze/'
endif
" Sort by extension.
execute sort 'ir /\.\zs\w\+\ze\s/'
elseif g:bufExplorerSortBy == "mru"
let l = getline(s:firstBufferLine, "$")
@ -1139,6 +1292,7 @@ call s:Set("g:bufExplorerMaxHeight", 25) " Handles dynamic resizing of the windo
" or by winmanager.
function! BufExplorer_Start()
let b:displayMode = "winmanager"
call s:SetLocalSettings()
call BufExplorer()
endfunction
@ -1150,6 +1304,7 @@ endfunction
" Handles dynamic refreshing of the window.
function! BufExplorer_Refresh()
let b:displayMode = "winmanager"
call s:SetLocalSettings()
call BufExplorer()
endfunction
@ -1180,7 +1335,7 @@ function! BufExplorer_ReSize()
call setpos(".", pres)
endfunction
" Default values {{{1
" Default values {{{2
call s:Set("g:bufExplorerDisableDefaultKeyMapping", 0) " Do not disable default key mappings.
call s:Set("g:bufExplorerDefaultHelp", 1) " Show default help?
call s:Set("g:bufExplorerDetailedHelp", 0) " Show detailed help?
@ -1198,13 +1353,16 @@ call s:Set("g:bufExplorerSplitOutPathName", 1) " Split out path and fil
call s:Set("g:bufExplorerSplitRight", &splitright) " Should vertical splits be on the right or left of current window?
call s:Set("g:bufExplorerSplitVertSize", 0) " Height for a vertical split. If <=0, default Vim size is used.
call s:Set("g:bufExplorerSplitHorzSize", 0) " Height for a horizontal split. If <=0, default Vim size is used.
"1}}}
" Default key mapping {{{1
" Default key mapping {{{2
if !hasmapto('BufExplorer') && g:bufExplorerDisableDefaultKeyMapping == 0
nnoremap <script> <silent> <unique> <Leader>be :BufExplorer<CR>
endif
if !hasmapto('ToggleBufExplorer') && g:bufExplorerDisableDefaultKeyMapping == 0
nnoremap <script> <silent> <unique> <Leader>bt :ToggleBufExplorer<CR>
endif
if !hasmapto('BufExplorerHorizontalSplit') && g:bufExplorerDisableDefaultKeyMapping == 0
nnoremap <script> <silent> <unique> <Leader>bs :BufExplorerHorizontalSplit<CR>
endif

View File

@ -330,6 +330,10 @@ fu! s:Open()
endf
fu! s:Close()
if has('patch-9.0.0115') && exists('s:cmdheight')
let &cmdheight = s:cmdheight
unlet s:cmdheight
en
cal s:async_glob_abort(0)
cal s:buffunc(0)
if winnr('$') == 1
@ -2845,6 +2849,11 @@ fu! ctrlp#init(type, ...)
if shouldExitSingle && s:ExitIfSingleCandidate()
retu 0
en
if has('patch-9.0.0115') && &cmdheight == 0
let s:cmdheight = &cmdheight
set cmdheight=1
en
cal s:BuildPrompt(1)
if s:keyloop | cal s:KeyLoop() | en
retu 1

View File

@ -368,7 +368,7 @@ endfunction " }}}2
function! s:ApplyConfig(config) abort " Set the buffer options {{{1
" Only process normal buffers (do not treat help files as '.txt' files)
if !empty(&buftype)
if index(['', 'acwrite'], &buftype) == -1
return
endif

View File

@ -0,0 +1,11 @@
all : gist-vim.zip
remove-zip:
-rm -f doc/tags
-rm -f gist-vim.zip
gist-vim.zip: remove-zip
zip -r gist-vim.zip autoload plugin doc README.mkd
release: gist-vim.zip
vimup update-script gist.vim

View File

@ -2,7 +2,7 @@
This is a vimscript for creating gists (http://gist.github.com).
For the latest version please see https://github.com/mattn/vim-gist.
For the latest version please see https://github.com/mattn/gist-vim.
## Usage:
@ -87,10 +87,6 @@ For the latest version please see https://github.com/mattn/vim-gist.
:Gist -l mattn
- Specify the number of gists listed:
:Gist -l -n 100
- List everyone's gists.
:Gist -la
@ -107,14 +103,14 @@ For the latest version please see https://github.com/mattn/vim-gist.
- Useful mappings on the gist-listing buffer:
- Both `o` or `Enter` open the gist file in a new buffer, and close the
vim-gist listing one.
gist-vim listing one.
- `b` opens the gist file in a browser; this is necessary because
`Shift-Enter` (as was originally) only works for GUI vim.
- `y` copies the contents of the selected gist to the clipboard, and
closes the vim-gist buffer.
closes the gist-vim buffer.
- `p` pastes the contents of the selected gist to the buffer from where
vim-gist was called, and closes the vim-gist buffer.
- Hitting `Escape` or `Tab` at the vim-gist buffer closes it.
gist-vim was called, and closes the gist-vim buffer.
- Hitting `Escape` or `Tab` at the gist-vim buffer closes it.
- Gist listing has fixed-length columns now, more amenable to eye inspection.
Every line on the gist-listing buffer contains the gist id, name and
@ -192,10 +188,6 @@ You need to either set global git config:
$ git config --global github.user Username
If you want to list more than 30 gists per page (maximum is 100):
let g:gist_per_page_limit = 100
## License:
Copyright 2010 by Yasuhiro Matsumoto
@ -245,7 +237,7 @@ If you want to use latest one:
Add the following lines to your `.vimrc`.
Bundle 'mattn/webapi-vim'
Bundle 'mattn/vim-gist'
Bundle 'mattn/gist-vim'
Now restart Vim and run `:BundleInstall`.
@ -253,7 +245,7 @@ Now restart Vim and run `:BundleInstall`.
Add the following line to your `.vimrc`.
NeoBundle 'mattn/vim-gist', {'depends': 'mattn/webapi-vim'}
NeoBundle 'mattn/gist-vim', {'depends': 'mattn/webapi-vim'}
## Requirements:
@ -270,15 +262,15 @@ First, you need to set your GitHub username in git's global configuration:
$ git config --global github.user <username>
Then vim-gist will ask for your password in order to create an access
token. If you have two-factor authentication enabled, vim-gist will also
Then gist-vim will ask for your password in order to create an access
token. If you have two-factor authentication enabled, gist-vim will also
prompt you to enter the two-factor key you receive.
NOTE:
If you want you can set it directly to `g:github_user` and `g:gist_token`.
Whichever type of authentication you use, your GitHub password will not be
stored, only a OAuth access token produced specifically for vim-gist. The
stored, only a OAuth access token produced specifically for gist-vim. The
token is stored in `~/.gist-vim`. If you stop using the plugin, you can
easily remove this file. To revoke the associated GitHub token, go to the
list of ["Authorized applications" on GitHub's "Account Settings"

View File

@ -3,7 +3,7 @@
" Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
" Last Change: 10-Oct-2016.
" Version: 7.3
" WebPage: http://github.com/mattn/vim-gist
" WebPage: http://github.com/mattn/gist-vim
" License: BSD
let s:save_cpo = &cpoptions
@ -134,7 +134,7 @@ function! s:truncate(str, num)
let str = substitute(str, mx_first, '\2', '')
endwhile
while width + 1 <= a:num
let ret .= ' '
let ret .= " "
let width = width + 1
endwhile
return ret
@ -160,7 +160,7 @@ function! s:format_gist(gist) abort
let desc = substitute(desc, ' ', ' ', 'g')
" Display a nice formatted (and truncated if needed) table of gists on screen
" Calculate field lengths for gist-listing formatting on screen
redir =>a |exe 'sil sign place buffer='.bufnr('')|redir end
redir =>a |exe "sil sign place buffer=".bufnr('')|redir end
let signlist = split(a, '\n')
let width = winwidth(0) - ((&number||&relativenumber) ? &numberwidth : 0) - &foldcolumn - (len(signlist) > 2 ? 2 : 0)
let idlen = 33
@ -171,7 +171,7 @@ endfunction
" Note: A colon in the file name has side effects on Windows due to NTFS Alternate Data Streams; avoid it.
let s:bufprefix = 'gist' . (has('unix') ? ':' : '_')
function! s:GistList(gistls, page, pagelimit) abort
function! s:GistList(gistls, page) abort
if a:gistls ==# '-all'
let url = g:gist_api_url.'gists/public'
elseif get(g:, 'gist_show_privates', 0) && a:gistls ==# 'starred'
@ -196,11 +196,9 @@ function! s:GistList(gistls, page, pagelimit) abort
exec 'silent noautocmd split' s:bufprefix.a:gistls
endif
endif
let url = url . '?per_page=' . a:pagelimit
if a:page > 1
let oldlines = getline(0, line('$'))
let url = url . '&page=' . a:page
let url = url . '?page=' . a:page
endif
setlocal modifiable
@ -216,7 +214,7 @@ function! s:GistList(gistls, page, pagelimit) abort
echohl ErrorMsg | echomsg v:errmsg | echohl None
return
endif
let res = webapi#http#get(url, '', { 'Authorization': auth })
let res = webapi#http#get(url, '', { "Authorization": auth })
if v:shell_error != 0
bw!
redraw
@ -332,7 +330,7 @@ function! gist#list(user, ...) abort
if len(auth) == 0
return []
endif
let res = webapi#http#get(url, '', { 'Authorization': auth })
let res = webapi#http#get(url, '', { "Authorization": auth })
return webapi#json#decode(res.content)
endfunction
@ -341,7 +339,7 @@ function! s:GistGetFileName(gistid) abort
if len(auth) == 0
return ''
endif
let res = webapi#http#get(g:gist_api_url.'gists/'.a:gistid, '', { 'Authorization': auth })
let res = webapi#http#get(g:gist_api_url.'gists/'.a:gistid, '', { "Authorization": auth })
let gist = webapi#json#decode(res.content)
if has_key(gist, 'files')
return sort(keys(gist.files))[0]
@ -354,7 +352,7 @@ function! s:GistDetectFiletype(gistid) abort
if len(auth) == 0
return ''
endif
let res = webapi#http#get(g:gist_api_url.'gists/'.a:gistid, '', { 'Authorization': auth })
let res = webapi#http#get(g:gist_api_url.'gists/'.a:gistid, '', { "Authorization": auth })
let gist = webapi#json#decode(res.content)
let filename = sort(keys(gist.files))[0]
let ext = fnamemodify(filename, ':e')
@ -382,7 +380,7 @@ endfunction
function! s:GistGet(gistid, clipboard) abort
redraw | echon 'Getting gist... '
let res = webapi#http#get(g:gist_api_url.'gists/'.a:gistid, '', { 'Authorization': s:GistGetAuthHeader() })
let res = webapi#http#get(g:gist_api_url.'gists/'.a:gistid, '', { "Authorization": s:GistGetAuthHeader() })
if res.status =~# '^2'
try
let gist = webapi#json#decode(res.content)
@ -461,10 +459,10 @@ function! s:GistGet(gistid, clipboard) abort
let content = gist.files[filename].content
call setline(1, split(content, "\n"))
let b:gist = {
\ 'filename': filename,
\ 'id': gist.id,
\ 'description': gist.description,
\ 'private': gist.public =~# 'true',
\ "filename": filename,
\ "id": gist.id,
\ "description": gist.description,
\ "private": gist.public =~ 'true',
\}
catch
let &undolevels = old_undolevels
@ -529,16 +527,16 @@ function! s:GistListAction(mode) abort
return
endif
if line =~# '^more\.\.\.$'
call s:GistList(b:gistls, b:page+1, g:gist_per_page_limit)
call s:GistList(b:gistls, b:page+1)
return
endif
endfunction
function! s:GistUpdate(content, gistid, gistnm, desc) abort
let gist = { 'id': a:gistid, 'files' : {}, 'description': '','public': function('webapi#json#true') }
let gist = { "id": a:gistid, "files" : {}, "description": "","public": function('webapi#json#true') }
if exists('b:gist')
if has_key(b:gist, 'filename') && len(a:gistnm) > 0
let gist.files[b:gist.filename] = { 'content': '', 'filename': b:gist.filename }
let gist.files[b:gist.filename] = { "content": '', "filename": b:gist.filename }
let b:gist.filename = a:gistnm
endif
if has_key(b:gist, 'private') && b:gist.private | let gist['public'] = function('webapi#json#false') | endif
@ -562,25 +560,25 @@ function! s:GistUpdate(content, gistid, gistnm, desc) abort
if a:desc !=# ' '
let gist['description'] = a:desc
else
let res = webapi#http#get(g:gist_api_url.'gists/'.a:gistid, '', { 'Authorization': auth })
let res = webapi#http#get(g:gist_api_url.'gists/'.a:gistid, '', { "Authorization": auth })
if res.status =~# '^2'
let old_gist = webapi#json#decode(res.content)
let gist['description'] = old_gist.description
endif
endif
let gist.files[filename] = { 'content': a:content, 'filename': filename }
let gist.files[filename] = { "content": a:content, "filename": filename }
redraw | echon 'Updating gist... '
let res = webapi#http#post(g:gist_api_url.'gists/' . a:gistid,
\ webapi#json#encode(gist), {
\ 'Authorization': auth,
\ 'Content-Type': 'application/json',
\ "Authorization": auth,
\ "Content-Type": "application/json",
\})
if res.status =~# '^2'
let obj = webapi#json#decode(res.content)
let loc = obj['html_url']
let b:gist = {'id': a:gistid, 'filename': filename}
let b:gist = {"id": a:gistid, "filename": filename}
setlocal nomodified
redraw | echomsg 'Done: '.loc
else
@ -600,8 +598,8 @@ function! s:GistDelete(gistid) abort
redraw | echon 'Deleting gist... '
let res = webapi#http#post(g:gist_api_url.'gists/'.a:gistid, '', {
\ 'Authorization': auth,
\ 'Content-Type': 'application/json',
\ "Authorization": auth,
\ "Content-Type": "application/json",
\}, 'DELETE')
if res.status =~# '^2'
if exists('b:gist')
@ -653,13 +651,13 @@ endfunction
" GistID: 123123
"
function! s:GistPost(content, private, desc, anonymous) abort
let gist = { 'files' : {}, 'description': '','public': function('webapi#json#true') }
let gist = { "files" : {}, "description": "","public": function('webapi#json#true') }
if a:desc !=# ' ' | let gist['description'] = a:desc | endif
if a:private | let gist['public'] = function('webapi#json#false') | endif
let filename = s:get_current_filename(1)
let gist.files[filename] = { 'content': a:content, 'filename': filename }
let gist.files[filename] = { "content": a:content, "filename": filename }
let header = {'Content-Type': 'application/json'}
let header = {"Content-Type": "application/json"}
if !a:anonymous
let auth = s:GistGetAuthHeader()
if len(auth) == 0
@ -676,10 +674,10 @@ function! s:GistPost(content, private, desc, anonymous) abort
let obj = webapi#json#decode(res.content)
let loc = obj['html_url']
let b:gist = {
\ 'filename': filename,
\ 'id': matchstr(loc, '[^/]\+$'),
\ 'description': gist['description'],
\ 'private': a:private,
\ "filename": filename,
\ "id": matchstr(loc, '[^/]\+$'),
\ "description": gist['description'],
\ "private": a:private,
\}
if s:update_GistID(b:gist['id'])
Gist -e
@ -697,7 +695,7 @@ function! s:GistPostBuffers(private, desc, anonymous) abort
let bn = bufnr('%')
let query = []
let gist = { 'files' : {}, 'description': '','public': function('webapi#json#true') }
let gist = { "files" : {}, "description": "","public": function('webapi#json#true') }
if a:desc !=# ' ' | let gist['description'] = a:desc | endif
if a:private | let gist['public'] = function('webapi#json#false') | endif
@ -710,12 +708,12 @@ function! s:GistPostBuffers(private, desc, anonymous) abort
silent! exec 'buffer!' bufnr
let content = join(getline(1, line('$')), "\n")
let filename = s:get_current_filename(index)
let gist.files[filename] = { 'content': content, 'filename': filename }
let gist.files[filename] = { "content": content, "filename": filename }
let index = index + 1
endfor
silent! exec 'buffer!' bn
let header = {'Content-Type': 'application/json'}
let header = {"Content-Type": "application/json"}
if !a:anonymous
let auth = s:GistGetAuthHeader()
if len(auth) == 0
@ -732,10 +730,10 @@ function! s:GistPostBuffers(private, desc, anonymous) abort
let obj = webapi#json#decode(res.content)
let loc = obj['html_url']
let b:gist = {
\ 'filename': filename,
\ 'id': matchstr(loc, '[^/]\+$'),
\ 'description': gist['description'],
\ 'private': a:private,
\ "filename": filename,
\ "id": matchstr(loc, '[^/]\+$'),
\ "description": gist['description'],
\ "private": a:private,
\}
if s:update_GistID(b:gist['id'])
Gist -e
@ -763,12 +761,10 @@ function! gist#Gist(count, bang, line1, line2, ...) abort
let editpost = 0
let anonymous = get(g:, 'gist_post_anonymous', 0)
let openbrowser = 0
let setpagelimit = 0
let pagelimit = g:gist_per_page_limit
let listmx = '^\%(-l\|--list\)\s*\([^\s]\+\)\?$'
let bufnamemx = '^' . s:bufprefix .'\(\zs[0-9a-f]\+\ze\|\zs[0-9a-f]\+\ze[/\\].*\)$'
if strlen(g:github_user) == 0 && anonymous == 0
echohl ErrorMsg | echomsg 'You have not configured a Github account. Read '':help gist-setup''.' | echohl None
echohl ErrorMsg | echomsg 'You have not configured a Github account. Read '':help gist-vim-setup''.' | echohl None
return
endif
if a:bang == '!'
@ -792,14 +788,6 @@ function! gist#Gist(count, bang, line1, line2, ...) abort
elseif arg =~# '^\(-G\|--gitclone\)$\C' && gistidbuf !=# '' && g:gist_api_url ==# 'https://api.github.com/' && has_key(b:, 'gist') && has_key(b:gist, 'id')
exe '!' printf('git clone git@github.com:%s', b:gist['id'])
return
elseif setpagelimit == 1
let setpagelimit = 0
let pagelimit = str2nr(arg)
if pagelimit < 1 || pagelimit > 100
echohl ErrorMsg | echomsg 'Page limit should be between 1 and 100: '.arg | echohl None
unlet args
return 0
endif
elseif arg =~# '^\(-la\|--listall\)$\C'
let gistls = '-all'
elseif arg =~# '^\(-ls\|--liststar\)$\C'
@ -840,7 +828,7 @@ function! gist#Gist(count, bang, line1, line2, ...) abort
echohl ErrorMsg | echomsg v:errmsg | echohl None
else
let gistid = gistidbuf
let res = webapi#http#post(g:gist_api_url.'gists/'.gistid.'/star', '', { 'Authorization': auth }, 'PUT')
let res = webapi#http#post(g:gist_api_url.'gists/'.gistid.'/star', '', { "Authorization": auth }, 'PUT')
if res.status =~# '^2'
echomsg 'Starred' gistid
else
@ -854,7 +842,7 @@ function! gist#Gist(count, bang, line1, line2, ...) abort
echohl ErrorMsg | echomsg v:errmsg | echohl None
else
let gistid = gistidbuf
let res = webapi#http#post(g:gist_api_url.'gists/'.gistid.'/star', '', { 'Authorization': auth }, 'DELETE')
let res = webapi#http#post(g:gist_api_url.'gists/'.gistid.'/star', '', { "Authorization": auth }, 'DELETE')
if res.status =~# '^2'
echomsg 'Unstarred' gistid
else
@ -869,7 +857,7 @@ function! gist#Gist(count, bang, line1, line2, ...) abort
return
else
let gistid = gistidbuf
let res = webapi#http#post(g:gist_api_url.'gists/'.gistid.'/fork', '', { 'Authorization': auth })
let res = webapi#http#post(g:gist_api_url.'gists/'.gistid.'/fork', '', { "Authorization": auth })
if res.status =~# '^2'
let obj = webapi#json#decode(res.content)
let gistid = obj['id']
@ -880,14 +868,6 @@ function! gist#Gist(count, bang, line1, line2, ...) abort
endif
elseif arg =~# '^\(-b\|--browser\)$\C'
let openbrowser = 1
elseif arg =~# '^\(-n\|--per-page\)$\C'
if len(gistls) > 0
let setpagelimit = 1
else
echohl ErrorMsg | echomsg 'Page limit can be set only for list commands'.arg | echohl None
unlet args
return 0
endif
elseif arg !~# '^-' && len(gistnm) == 0
if gistdesc !=# ' '
let gistdesc = matchstr(arg, '^\s*\zs.*\ze\s*$')
@ -924,7 +904,7 @@ function! gist#Gist(count, bang, line1, line2, ...) abort
endif
if len(gistls) > 0
call s:GistList(gistls, 1, pagelimit)
call s:GistList(gistls, 1)
elseif len(gistid) > 0 && editpost == 0 && deletepost == 0
call s:GistGet(gistid, clipboard)
else
@ -1006,12 +986,12 @@ function! s:GistGetAuthHeader() abort
let note_url = 'http://www.vim.org/scripts/script.php?script_id=2423'
let insecureSecret = printf('basic %s', webapi#base64#b64encode(g:github_user.':'.password))
let res = webapi#http#post(g:gist_api_url.'authorizations', webapi#json#encode({
\ 'scopes' : ['gist'],
\ 'note' : note,
\ 'note_url' : note_url,
\ "scopes" : ["gist"],
\ "note" : note,
\ "note_url" : note_url,
\}), {
\ 'Content-Type' : 'application/json',
\ 'Authorization' : insecureSecret,
\ "Content-Type" : "application/json",
\ "Authorization" : insecureSecret,
\})
let h = filter(res.header, 'stridx(v:val, "X-GitHub-OTP:") == 0')
if len(h)
@ -1021,13 +1001,13 @@ function! s:GistGetAuthHeader() abort
return ''
endif
let res = webapi#http#post(g:gist_api_url.'authorizations', webapi#json#encode({
\ 'scopes' : ['gist'],
\ 'note' : note,
\ 'note_url' : note_url,
\ "scopes" : ["gist"],
\ "note" : note,
\ "note_url" : note_url,
\}), {
\ 'Content-Type' : 'application/json',
\ 'Authorization' : insecureSecret,
\ 'X-GitHub-OTP' : otp,
\ "Content-Type" : "application/json",
\ "Authorization" : insecureSecret,
\ "X-GitHub-OTP" : otp,
\})
endif
let authorization = webapi#json#decode(res.content)
@ -1045,138 +1025,138 @@ function! s:GistGetAuthHeader() abort
endfunction
let s:extmap = extend({
\'.adb': 'ada',
\'.ahk': 'ahk',
\'.arc': 'arc',
\'.as': 'actionscript',
\'.asm': 'asm',
\'.asp': 'asp',
\'.aw': 'php',
\'.b': 'b',
\'.bat': 'bat',
\'.befunge': 'befunge',
\'.bmx': 'bmx',
\'.boo': 'boo',
\'.c-objdump': 'c-objdump',
\'.c': 'c',
\'.cfg': 'cfg',
\'.cfm': 'cfm',
\'.ck': 'ck',
\'.cl': 'cl',
\'.clj': 'clj',
\'.cmake': 'cmake',
\'.coffee': 'coffee',
\'.cpp': 'cpp',
\'.cppobjdump': 'cppobjdump',
\'.cs': 'csharp',
\'.css': 'css',
\'.cw': 'cw',
\'.d-objdump': 'd-objdump',
\'.d': 'd',
\'.darcspatch': 'darcspatch',
\'.diff': 'diff',
\'.duby': 'duby',
\'.dylan': 'dylan',
\'.e': 'e',
\'.ebuild': 'ebuild',
\'.eclass': 'eclass',
\'.el': 'lisp',
\'.erb': 'erb',
\'.erl': 'erlang',
\'.f90': 'f90',
\'.factor': 'factor',
\'.feature': 'feature',
\'.fs': 'fs',
\'.fy': 'fy',
\'.go': 'go',
\'.groovy': 'groovy',
\'.gs': 'gs',
\'.gsp': 'gsp',
\'.haml': 'haml',
\'.hs': 'haskell',
\'.html': 'html',
\'.hx': 'hx',
\'.ik': 'ik',
\'.ino': 'ino',
\'.io': 'io',
\'.j': 'j',
\'.java': 'java',
\'.js': 'javascript',
\'.json': 'json',
\'.jsp': 'jsp',
\'.kid': 'kid',
\'.lhs': 'lhs',
\'.lisp': 'lisp',
\'.ll': 'll',
\'.lua': 'lua',
\'.ly': 'ly',
\'.m': 'objc',
\'.mak': 'mak',
\'.man': 'man',
\'.mao': 'mao',
\'.matlab': 'matlab',
\'.md': 'markdown',
\'.minid': 'minid',
\'.ml': 'ml',
\'.moo': 'moo',
\'.mu': 'mu',
\'.mustache': 'mustache',
\'.mxt': 'mxt',
\'.myt': 'myt',
\'.n': 'n',
\'.nim': 'nim',
\'.nu': 'nu',
\'.numpy': 'numpy',
\'.objdump': 'objdump',
\'.ooc': 'ooc',
\'.parrot': 'parrot',
\'.pas': 'pas',
\'.pasm': 'pasm',
\'.pd': 'pd',
\'.phtml': 'phtml',
\'.pir': 'pir',
\'.pl': 'perl',
\'.po': 'po',
\'.py': 'python',
\'.pytb': 'pytb',
\'.pyx': 'pyx',
\'.r': 'r',
\'.raw': 'raw',
\'.rb': 'ruby',
\'.rhtml': 'rhtml',
\'.rkt': 'rkt',
\'.rs': 'rs',
\'.rst': 'rst',
\'.s': 's',
\'.sass': 'sass',
\'.sc': 'sc',
\'.scala': 'scala',
\'.scm': 'scheme',
\'.scpt': 'scpt',
\'.scss': 'scss',
\'.self': 'self',
\'.sh': 'sh',
\'.sml': 'sml',
\'.sql': 'sql',
\'.st': 'smalltalk',
\'.swift': 'swift',
\'.tcl': 'tcl',
\'.tcsh': 'tcsh',
\'.tex': 'tex',
\'.textile': 'textile',
\'.tpl': 'smarty',
\'.twig': 'twig',
\'.txt' : 'text',
\'.v': 'verilog',
\'.vala': 'vala',
\'.vb': 'vbnet',
\'.vhd': 'vhdl',
\'.vim': 'vim',
\'.weechatlog': 'weechatlog',
\'.xml': 'xml',
\'.xq': 'xquery',
\'.xs': 'xs',
\'.yml': 'yaml',
\".adb": "ada",
\".ahk": "ahk",
\".arc": "arc",
\".as": "actionscript",
\".asm": "asm",
\".asp": "asp",
\".aw": "php",
\".b": "b",
\".bat": "bat",
\".befunge": "befunge",
\".bmx": "bmx",
\".boo": "boo",
\".c-objdump": "c-objdump",
\".c": "c",
\".cfg": "cfg",
\".cfm": "cfm",
\".ck": "ck",
\".cl": "cl",
\".clj": "clj",
\".cmake": "cmake",
\".coffee": "coffee",
\".cpp": "cpp",
\".cppobjdump": "cppobjdump",
\".cs": "csharp",
\".css": "css",
\".cw": "cw",
\".d-objdump": "d-objdump",
\".d": "d",
\".darcspatch": "darcspatch",
\".diff": "diff",
\".duby": "duby",
\".dylan": "dylan",
\".e": "e",
\".ebuild": "ebuild",
\".eclass": "eclass",
\".el": "lisp",
\".erb": "erb",
\".erl": "erlang",
\".f90": "f90",
\".factor": "factor",
\".feature": "feature",
\".fs": "fs",
\".fy": "fy",
\".go": "go",
\".groovy": "groovy",
\".gs": "gs",
\".gsp": "gsp",
\".haml": "haml",
\".hs": "haskell",
\".html": "html",
\".hx": "hx",
\".ik": "ik",
\".ino": "ino",
\".io": "io",
\".j": "j",
\".java": "java",
\".js": "javascript",
\".json": "json",
\".jsp": "jsp",
\".kid": "kid",
\".lhs": "lhs",
\".lisp": "lisp",
\".ll": "ll",
\".lua": "lua",
\".ly": "ly",
\".m": "objc",
\".mak": "mak",
\".man": "man",
\".mao": "mao",
\".matlab": "matlab",
\".md": "markdown",
\".minid": "minid",
\".ml": "ml",
\".moo": "moo",
\".mu": "mu",
\".mustache": "mustache",
\".mxt": "mxt",
\".myt": "myt",
\".n": "n",
\".nim": "nim",
\".nu": "nu",
\".numpy": "numpy",
\".objdump": "objdump",
\".ooc": "ooc",
\".parrot": "parrot",
\".pas": "pas",
\".pasm": "pasm",
\".pd": "pd",
\".phtml": "phtml",
\".pir": "pir",
\".pl": "perl",
\".po": "po",
\".py": "python",
\".pytb": "pytb",
\".pyx": "pyx",
\".r": "r",
\".raw": "raw",
\".rb": "ruby",
\".rhtml": "rhtml",
\".rkt": "rkt",
\".rs": "rs",
\".rst": "rst",
\".s": "s",
\".sass": "sass",
\".sc": "sc",
\".scala": "scala",
\".scm": "scheme",
\".scpt": "scpt",
\".scss": "scss",
\".self": "self",
\".sh": "sh",
\".sml": "sml",
\".sql": "sql",
\".st": "smalltalk",
\".swift": "swift",
\".tcl": "tcl",
\".tcsh": "tcsh",
\".tex": "tex",
\".textile": "textile",
\".tpl": "smarty",
\".twig": "twig",
\".txt" : "text",
\".v": "verilog",
\".vala": "vala",
\".vb": "vbnet",
\".vhd": "vhdl",
\".vim": "vim",
\".weechatlog": "weechatlog",
\".xml": "xml",
\".xq": "xquery",
\".xs": "xs",
\".yml": "yaml",
\}, get(g:, 'gist_extmap', {}))
let &cpo = s:save_cpo

View File

@ -1,19 +1,19 @@
*Gist.vim* Vimscript for creating gists (http://gist.github.com)
Usage |vim-gist-usage|
Tips |vim-gist-tips|
License |vim-gist-license|
Install |vim-gist-install|
Requirements |vim-gist-requirements|
Setup |vim-gist-setup|
FAQ |vim-gist-faq|
Usage |gist-vim-usage|
Tips |gist-vim-tips|
License |gist-vim-license|
Install |gist-vim-install|
Requirements |gist-vim-requirements|
Setup |gist-vim-setup|
FAQ |gist-vim-faq|
This is a vimscript for creating gists (http://gist.github.com)
For the latest version please see https://github.com/mattn/vim-gist.
For the latest version please see https://github.com/mattn/gist-vim.
==============================================================================
USAGE *:Gist* *vim-gist-usage*
USAGE *:Gist* *gist-vim-usage*
- Post current buffer to gist, using default privacy option. >
@ -102,8 +102,6 @@ USAGE *:Gist* *vim-gist-usage*
:Gist -l
:Gist --list
:Gist -l -n 100
:Gist --list --per-page 100
<
- List gists from user "mattn". >
@ -122,15 +120,15 @@ USAGE *:Gist* *vim-gist-usage*
- While the gist list is visible, the following mappings apply:
- 'o' or 'Enter' will open the selected gist file in a new buffer
and close the vim-gist listing split.
and close the gist-vim listing split.
- 'b' will open the selected gist file in a browser. If you are in
GUI vim you can also achieve this by pressing 'Shift-Enter'.
- 'y' will copy the contents of the selected gist to the clipboard,
and close the vim-gist listing split.
and close the gist-vim listing split.
- 'p' will (copy and) paste the contents of the selected gist to the
buffer from which vim-gist was called, and close the vim-gist
buffer from which gist-vim was called, and close the gist-vim
listing split.
- 'Esc' will close the vim-gist listing split without performing any
- 'Esc' will close the gist-vim listing split without performing any
further action.
- Open the gist on browser after you post or update it.
@ -143,7 +141,7 @@ USAGE *:Gist* *vim-gist-usage*
:Gist!
<
==============================================================================
TIPS *vim-gist-tips*
TIPS *gist-vim-tips*
If you set "g:gist_clip_command", gist.vim will copy the gist code with option
"-c".
@ -203,10 +201,6 @@ If you want to open gist list/buffer as vertical split: >
let g:gist_list_vsplit = 1
If you want to list more than 30 gists per page (maximum is 100):
let g:gist_per_page_limit = 100
If you want to modify filetype for the file on github, or add mapping of
filetype/file-extension: >
@ -222,13 +216,13 @@ in your local file, then call >
:Gist
The vim-gist listing split lists gists ids, names (filenames) as well as
The gist-vim listing split lists gists ids, names (filenames) as well as
their description. This is done following a table layout, with fixed space
for each column. For offering quick browsing, vim-gist will truncate all
for each column. For offering quick browsing, gist-vim will truncate all
output exceeding the available horizontal space, assuring that every gist
listed only takes one line on the table. Although the gist id field width is
fixed internally, the user can define the length of the (file)name field on
the vim-gist listing. This can be done by the following declaration:
the gist-vim listing. This can be done by the following declaration:
let g:gist_namelength = 20
@ -247,7 +241,7 @@ All other values are treated as 1.
This variable's value is 1 by default.
==============================================================================
LICENSE *vim-gist-license*
LICENSE *gist-vim-license*
Copyright 2010 by Yasuhiro Matsumoto
@ -273,7 +267,7 @@ LICENSE *vim-gist-license*
OF THE POSSIBILITY OF SUCH DAMAGE.
==============================================================================
INSTALL *vim-gist-install*
INSTALL *gist-vim-install*
Copy following files into your plugin directory.
@ -281,7 +275,7 @@ rtp:
- autoload/gist.vim
- plugin/gist.vim
If you want to uninstall gist.vim, remember to also remove `~/.vim-gist`.
If you want to uninstall gist.vim, remember to also remove `~/.gist-vim`.
You need to install webapi-vim also:
@ -292,17 +286,17 @@ If you want to use latest one:
https://github.com/mattn/webapi-vim
==============================================================================
REQUIREMENTS *vim-gist-requirements*
REQUIREMENTS *gist-vim-requirements*
- curl command (http://curl.haxx.se/)
- webapi-vim (https://github.com/mattn/webapi-vim)
- and, if you want to use your git profile, the git command-line client.
==============================================================================
SETUP *vim-gist-setup*
SETUP *gist-vim-setup*
This plugin uses GitHub API v3. The authentication value is stored in `~/.vim-gist`.
vim-gist provides two ways to authenticate against the GitHub APIs.
This plugin uses GitHub API v3. The authentication value is stored in `~/.gist-vim`.
gist-vim provides two ways to authenticate against the GitHub APIs.
First, you need to set your GitHub username in global git config:
>
@ -318,7 +312,7 @@ If you have two-factor authentication enabled on GitHub, you'll see the message
"Must specify two-factor authentication OTP code." In this case, you need to
create a "Personal Access Token" on GitHub's "Account Settings" page
(https://github.com/settings/applications) and place it in a file
named ~/.vim-gist like this:
named ~/.gist-vim like this:
>
token xxxxx
<
@ -337,13 +331,13 @@ This is not secure at all, so strongly discouraged.
NOTE: the username is optional if you only send anonymous gists.
==============================================================================
FAQ *vim-gist-faq*
FAQ *gist-vim-faq*
Q. :Gist returns a Forbidden error
A. Try deleting ~/.vim-gist and authenticating again.
A. Try deleting ~/.gist-vim and authenticating again.
==============================================================================
THANKS *vim-gist-thanks*
THANKS *gist-vim-thanks*
AD7six
Bruno Bigras

View File

@ -0,0 +1,303 @@
script_name: Gist.vim
script_id: '2423'
script_type: utility
script_package: gist-vim.zip
script_version: '7.3'
required_vim_version: '7.0'
summary: vimscript for gist
detailed_description: |
This is vimscript for gist (http://gist.github.com)
Usage:
:Gist
post whole text to gist.
:'<,'>Gist
post selected text to gist.
:Gist -p
post whole text to gist with private.
if you got empty gist list, try :Gist --abandon
:Gist -a
post whole text to gist with anonymous.
:Gist -m
post multi buffer to gist.
:Gist -e
edit the gist. (should be work on gist buffer)
you can update the gist with :w command on gist buffer.
:Gist -e foo.js
edit the gist with name 'foo.js'. (should be work on gist buffer)
:Gist -d
delete the gist. (should be work on gist buffer)
authentication required.
:Gist -f
fork the gist. (should be work on gist buffer)
authentication required.
:Gist XXXXX
get gist XXXXX.
:Gist -c XXXXX.
get gist XXXXX and put to clipboard.
:Gist -l
list gists from mine.
:Gist -la
list gists from all.
Tips:
if set g:gist_clip_command, gist.vim will copy the gist code
with option '-c'.
# mac
let g:gist_clip_command = 'pbcopy'
# linux
let g:gist_clip_command = 'xclip -selection clipboard'
# others(cygwin?)
let g:gist_clip_command = 'putclip'
if you want to detect filetype from filename...
let g:gist_detect_filetype = 1
if you want to open browser after the post...
let g:gist_open_browser_after_post = 1
if you want to change the browser...
let g:gist_browser_command = 'w3m %URL%'
or
let g:gist_browser_command = 'opera %URL% &'
on windows, should work with original setting.
Require:
curl command (http://curl.haxx.se/)
and if you want to use profile of git, it require git command.
install_details: |
copy it to your plugin directory.
gist.vim leave cookie-jar file into runtimepath.
rtp:
plugin/gist.vim
cookies/github
See also: https://github.com/mattn/gist-vim/blob/master/README.mkd
versions:
- '7.3': |
This is an upgrade for Gist.vim: fixed many bugs. Added few list actions: yank, paste, open in browser.
- '7.2': |
This is an upgrade for Gist.vim: fixed many bugs.
- '7.1': |
This is an upgrade for Gist.vim: updated installation notes.
- '7.0': |
This is an upgrade for Gist.vim: fixed few bugs.
- '6.9': |
This is an upgrade for Gist.vim: fixed few bugs.
- '6.8': |
This is an upgrade for Gist.vim: changed authentication. removed password authentication. if you want to keep using password authentication, let gist_use_password_in_gitconfig to 1.
- '6.7': |
This is an upgrade for Gist.vim: fix behavior of g:gist_browser_command = ':OpenBrowser %URL%'.
- '6.6': |
This is an upgrade for Gist.vim: fixed detecting filetype.
- '6.5': |
This is an upgrade for Gist.vim: use webapi namespace. NOTE: please upgrade webapi-vim also.
- '6.4': |
This is an upgrade for Gist.vim: fixed updating with description.
- '6.3': |
This is an upgrade for Gist.vim: fixed typos.
- '6.2': |
This is an upgrade for Gist.vim: fixed some bugs.
- '6.1': |
This is an upgrade for Gist.vim: fixed opening browser.
- '6.0': |
This is an upgrade for Gist.vim: changed to use github APIs. Note to remove cookies directory if you used.
- '5.9': |
This is an upgrade for Gist.vim: add support anonymous post. fixed many bugs.
- '5.8': |
This is an upgrade for Gist.vim: add support for description. you can post description using -s option.
- '5.7': |
This is an upgrade for Gist.vim: post with filetype more cleverly.
- '5.6': |
This is an upgrade for Gist.vim: fix '--abandon'.
- '5.5': |
This is an upgrade for Gist.vim: fix: forgot to upload autoload/gist.vim.
- '5.4': |
This is an upgrade for Gist.vim: fix: does not work correctly with blockwize selection.
- '5.3': |
This is an upgrade for Gist.vim: upd: support autoload.
- '5.2': |
This is an upgrade for Gist.vim: add: support block-wise selection.
- '5.1': |
This is an upgrade for Gist.vim: fix: can't update privates.
- '5.0': |
This is an upgrade for Gist.vim: follow update of gist.github.com
- '4.9': |
fix: don't add new line after "Done: xxx".
fix: show WHY FAILED' when failed to post.
add: support for :OpenBrowser.
add: new option 'gist_curl_options'.
- '4.8': |
This is an upgrade for Gist.vim: fix: can't open private gist with ":Gist XXXXX".
- '4.7': |
This is an upgrade for Gist.vim: fix: filetype detection.
- '4.6': |
This is an upgrade for Gist.vim: fix: strange cookies folder.
- '4.5': |
This is an upgrade for Gist.vim: fix: use gist_clip_command for copying URL to clipboard. this fix strange behavior on Mac OSX.
- '4.4': |
This is an upgrade for Gist.vim: fix: gist is now only using https.
- '4.3': |
This is an upgrade for Gist.vim: add new option '-f' for fork.
- '4.2': |
This is an upgrade for Gist.vim: fixed code for login.
- '4.1': |
This is an upgrade for Gist.vim: fixed code cleanup.
- '4.0': |
This is an upgrade for Gist.vim: fixed deleting gist, listing privates.
- '3.9': |
This is an upgrade for Gist.vim: fixed :w handler in gist buffer.
- '3.8': |
This is an upgrade for Gist.vim: 'more...' on gist list.
- '3.7': |
This is an upgrade for Gist.vim: fix problem that break "gist list" window at twice.
- '3.6': |
This is an upgrade for Gist.vim: fix filetype detection for 'vimscript'.
- '3.5': |
This is an upgrade for Gist.vim: fix filetype detection.
- '3.4': |
This is an upgrade for Gist.vim: use '+' register on unix only if built with 'xterm_clipboard'. and some bug fixes.
- '3.3': |
This is an upgrade for Gist.vim: fix problem that append empty line when getting gist.
- '3.2': |
This is an upgrade for Gist.vim: added Gist header to recognize the gist. added script type header for Vimana.
- '3.1': |
This is an upgrade for Gist.vim: fix checking redirect url.
- '3.0': |
This is an upgrade for Gist.vim: fix for official changes(private button name was changed).
- '2.9': |
This is an upgrade for Gist.vim: fix for official changes(private button name was changed).
- '2.8': |
This is an upgrade for Gist.vim: be able to post multi buffer. currently updating or showing not supported. and ':Gist -d' delete the gist.
- '2.7': |
This is an upgrade for Gist.vim: be able to write the gist to local file with ':w foo.txt'.
- '2.6': |
This is an upgrade for Gist.vim: fixed problem that does not work 'Gist XXXX'.
- '2.5': |
This is an upgrade for Gist.vim: use existing buffer when open the list or gist.
- '2.4': |
This is an upgrade for Gist.vim: show error message when no any github settings.
- '2.3': |
This is an upgrade for Gist.vim: added :w BufWriteCmd for GistUpdate.
- '2.2': |
This is an upgrade for Gist.vim: fixed a bug for anonymous post. and new option '-a' for anonymous post.
- '2.1': |
This is an upgrade for Gist.vim: support changing gist filename.
- '2.0': |
This is an upgrade for Gist.vim: bugfix for listing gists in specified user.
- '1.9': |
This is an upgrade for Gist.vim: added support editing the gist. and bits bug fix.
- '1.8': |
This is an upgrade for Gist.vim: added new option g:gist_open_browser_after_post/g:gist_browser_command to open posted gist.
- '1.7': |
This is an upgrade for Gist.vim: now changed argument for putting clipboard as ':Gist -c XXXXX'.
- '1.6': |
This is an upgrade for Gist.vim: add gist's author in gist list.
- '1.5': |
This is an upgrade for Gist.vim: oops. bugfix for auto-detection.
- '1.4': |
This is an upgrade for Gist.vim: bugfix for auto-detection.
- '1.3': |
This is an upgrade for Gist.vim: more auto-detection for filetype.
- '1.2': |
This is an upgrade for Gist.vim: added new option for detect filetype from filename.
- '1.1': |
This is an upgrade for Gist.vim: calling StdinReadPost.
- '1.0': |
This is an upgrade for Gist.vim: treat literal "-" as part of username.
- '0.9': |
This is an upgrade for Gist.vim: added new option 'g:gist_clip_command' that copy the gist code.
# __END__
# vim: filetype=yaml

View File

@ -1,7 +1,7 @@
"=============================================================================
" File: gist.vim
" Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
" WebPage: http://github.com/mattn/vim-gist
" WebPage: http://github.com/mattn/gist-vim
" License: BSD
" GetLatestVimScripts: 2423 1 :AutoInstall: gist.vim
" script type: plugin
@ -12,13 +12,12 @@ endif
let g:loaded_gist_vim = 1
function! s:CompleteArgs(arg_lead,cmdline,cursor_pos)
return filter(copy(["-p", "-P", "-a", "-m", "-e", "-s", "-d", "+1", "-1", "-f", "-c", "-l", "-la", "-ls", "-b", "-n",
return filter(copy(["-p", "-P", "-a", "-m", "-e", "-s", "-d", "+1", "-1", "-f", "-c", "-l", "-la", "-ls", "-b",
\ "--listall", "--liststar", "--list", "--multibuffer", "--private", "--public", "--anonymous", "--description", "--clipboard",
\ "--rawurl", "--delete", "--edit", "--star", "--unstar", "--fork", "--browser", "--per-page"
\ "--rawurl", "--delete", "--edit", "--star", "--unstar", "--fork", "--browser"
\ ]), 'stridx(v:val, a:arg_lead)==0')
endfunction
let g:gist_per_page_limit = get(g:, 'gist_per_page_limit', 30)
command! -nargs=? -range=% -bang -complete=customlist,s:CompleteArgs Gist :call gist#Gist(<count>, "<bang>", <line1>, <line2>, <f-args>)
" vim:set et:

View File

@ -0,0 +1 @@
github: junegunn

View File

@ -0,0 +1,192 @@
This is a mirror of http://www.vim.org/scripts/script.php?script_id=521
Overview
The Most Recently Used (MRU) plugin provides an easy access to a list of
recently opened/edited files in Vim. This plugin automatically stores the
file names as you open/edit them in Vim.
This plugin will work on all the platforms where Vim is supported. This
plugin will work in both console and GUI Vim. This version of the MRU
plugin needs Vim 7.0 and above. If you are using an earlier version of
Vim, then you should use an older version of the MRU plugin.
The recently used filenames are stored in a file specified by the Vim
MRU_File variable.
The Github repository for the MRU plugin is available at:
http://github.com/yegappan/mru
Usage
To list and edit files from the MRU list, you can use the ":MRU" command.
The ":MRU" command displays the MRU file list in a temporary Vim window. If
the MRU window is already opened, then the MRU list displayed in the window
is refreshed.
If you are using GUI Vim, then the names of the recently edited files are
added to the "File->Recent Files" menu. You can select the name of a file
from this sub-menu to edit the file.
You can use the normal Vim commands to move around in the MRU window. You
cannot make changes in the MRU window.
You can select a file name to edit by pressing the <Enter> key or by double
clicking the left mouse button on a file name. The selected file will be
opened. If the file is already opened in a window, the cursor will be moved
to that window. Otherwise, the file is opened in the previous window. If the
previous window has a modified buffer or is the preview window or is used by
some other plugin, then the file is opened in a new window.
You can press the 'o' key to open the file name under the cursor in the
MRU window in a new window. You can also press <Shift-Enter> instead of 'o'
to open the file in a new window.
To open a file from the MRU window in read-only mode (view), press the 'v'
key.
To open a file from the MRU window in a new tab, press the 't' key. If the
file is already opened in a window in the current or in another tab, then
the cursor is moved to that tab. Otherwise, a new tab is opened.
You can open multiple files from the MRU window by specifying a count before
pressing '<Enter>' or 'v' or 'o' or 't'. You can also visually (using
linewise visual mode) select multiple filenames and invoke the commands to
open the files. Each selected file will be opened in a separate window or
tab.
You can press the 'u' key in the MRU window to update the file list. This is
useful if you keep the MRU window open always.
You can close the MRU window by pressing the 'q' key or the <Esc> key or
using one of the Vim window commands.
To display only files matching a pattern from the MRU list in the MRU
window, you can specify a pattern to the ":MRU" command. For example, to
display only file names matching "vim" in them, you can use the following
command ":MRU vim". When you specify a partial file name and only one
matching filename is found, then the ":MRU" command will edit that file.
The ":MRU" command supports command-line completion of file names from
the MRU list. You can enter a partial file name and then press <Tab>
or <Ctrl-D> to complete or list all the matching file names. Note that
after typing the ":MRU" command, you have to enter a space before completing
the file names with <Tab>.
When a file supplied to the ":MRU" command is not present in the MRU list,
but it is a readable file, then the file will be opened (even though it is
not present in the MRU list). This is useful if you want to open a file
present in the same directory as a file in the MRU list. You can use the
command-line completion of the ":MRU" command to complete the full path of a
file and then modify the path to open another file present in the same path.
Whenever the MRU list changes, the MRU file is updated with the latest MRU
list. When you have multiple instances of Vim running at the same time, the
latest MRU list will show up in all the instances of Vim.
The MRUFilename syntax group is used to highlight the file names in the MRU
window. By default, this syntax group is linked to the Identifier highlight
group. You can change the highlight group by adding the following line in
your .vimrc:
highlight link MRUFileName LineNr
The MRU buffer uses the 'mru file type. You can use this file type to add
custom auto commands, syntax highlighting, etc.
Configuration
By changing the following variables you can configure the behavior of this
plugin. Set the following variables in your .vimrc file using the 'let'
command.
The list of recently edited file names is stored in the file specified by the
MRU_File variable. The default setting for this variable is
$HOME/.vim_mru_files for Unix-like systems and $USERPROFILE/_vim_mru_files
for MS-Windows systems. You can change this variable to point to a file by
adding the following line to the .vimrc file:
let MRU_File = 'd:\myhome\_vim_mru_files'
By default, the plugin will remember the names of the last 100 used files.
As you edit more files, old file names will be removed from the MRU list.
You can set the 'MRU_Max_Entries' variable to remember more file names. For
example, to remember 1000 most recently used file names, you can use
let MRU_Max_Entries = 1000
By default, all the edited file names will be added to the MRU list. If you
want to exclude file names matching a list of patterns, you can set the
MRU_Exclude_Files variable to a list of Vim regular expressions. By default,
this variable is set to an empty string. For example, to not include files
in the temporary (/tmp, /var/tmp and d:\temp) directories, you can set the
MRU_Exclude_Files variable to
let MRU_Exclude_Files = '^/tmp/.*\|^/var/tmp/.*' " For Unix
let MRU_Exclude_Files = '^c:\\temp\\.*' " For MS-Windows
The specified pattern should be a Vim regular expression pattern.
If you want to add only file names matching a set of patterns to the MRU
list, then you can set the MRU_Include_Files variable. This variable should
be set to a Vim regular expression pattern. For example, to add only .c and
.h files to the MRU list, you can set this variable as below:
let MRU_Include_Files = '\.c$\|\.h$'
By default, MRU_Include_Files is set to an empty string and all the edited
filenames are added to the MRU list.
The default height of the MRU window is 8. You can set the MRU_Window_Height
variable to change the window height.
let MRU_Window_Height = 15
By default, when the :MRU command is invoked, the MRU list will be displayed
in a new window. Instead, if you want the MRU plugin to reuse the current
window, then you can set the 'MRU_Use_Current_Window' variable to one.
let MRU_Use_Current_Window = 1
The MRU plugin will reuse the current window. When a file name is selected,
the file is also opened in the current window.
When you select a file from the MRU window, the MRU window will be
automatically closed and the selected file will be opened in the previous
window. You can set the 'MRU_Auto_Close' variable to zero to keep the MRU
window open.
let MRU_Auto_Close = 0
If you don't use the "File->Recent Files" menu and want to disable it,
then you can set the 'MRU_Add_Menu' variable to zero. By default, the
menu is enabled.
let MRU_Add_Menu = 0
If too many file names are present in the MRU list, then updating the MRU
menu to list all the file names makes Vim slow. To avoid this, the
MRU_Max_Menu_Entries variable controls the number of file names to show in
the MRU menu. By default, this is set to 10. You can change this to show
more entries in the menu.
let MRU_Max_Menu_Entries = 20
If many file names are present in the MRU list, then the MRU menu is split
into sub-menus. Each sub-menu contains MRU_Max_Submenu_Entries file names.
The default setting for this is 10. You can change this to increase the
number of file names displayed in a single sub-menu:
let MRU_Max_Submenu_Entries = 15
In the MRU window, the filenames are displayed in two parts. The first part
contains the file name without the path and the second part contains the
full path to the file in parenthesis. This format is controlled by the
MRU_Filename_Format variable. If you prefer to change this to some other
format, then you can modify the MRU_Filename_Format variable. For example,
to display the full path without splitting it, you can set this variable
as shown below:
let MRU_Filename_Format={'formatter':'v:val', 'parser':'.*'}

File diff suppressed because it is too large Load Diff

View File

@ -90,7 +90,7 @@ vim -u NONE -c "helptags ~/.vim/pack/vendor/start/nerdtree/doc" -c q
After installing NERDTree, the best way to learn it is to turn on the Quick Help. Open NERDTree with the `:NERDTree` command, and press `?` to turn on the Quick Help, which will show you all the mappings and commands available in the NERDTree. Of course, your most complete source of information is the documentation: `:help NERDTree`.
## NERDTree Plugins
NERDTree can be extended with custom mappings and functions using its built-in API. The details of this API and are described in the included documentation. Several plugins have been written, and are available on Github for installation like any other plugin. The plugins in this list are maintained (or not) by their respective owners, and certain combinations may be incompatible.
NERDTree can be extended with custom mappings and functions using its built-in API. The details of this API are described in the included documentation. Several plugins have been written, and are available on Github for installation like any other plugin. The plugins in this list are maintained (or not) by their respective owners, and certain combinations may be incompatible.
* [Xuyuanp/nerdtree-git-plugin](https://github.com/Xuyuanp/nerdtree-git-plugin): Shows Git status flags for files and folders in NERDTree.
* [ryanoasis/vim-devicons](https://github.com/ryanoasis/vim-devicons): Adds filetype-specific icons to NERDTree files and folders,

View File

@ -907,3 +907,13 @@ version: "1.23"
MD5 checksum: c4d6e018cbbd3b286a9b1648b748c1f3
version: "1.23"
version: '1.28'
- Remove unnecessary executable flags from files
- Merge pull request #28 from gbence/master
- Fix error E1208 raised by vim >=8.2.3141
- Merge pull request #30 from stac47/fix_for_vim_8_2_3141
- Fix win_id format mismatch on vim7 or bellow
- Merge pull request #37 from moodoofish/master
- tlib#number#ConvertBase: support base > 36
SHA256 checksum: 666e632a1ebacebf6e774cdf5c541418343ce1a3949268685ebcb60e480b9f1d

View File

@ -1,17 +1,24 @@
" @Author: Tom Link (mailto:micathom AT gmail com?subject=[vim])
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Revision: 18
" @Revision: 26
function! tlib#number#ConvertBase(num, base, ...) "{{{3
let rtype = a:0 >= 1 ? a:1 : 'string'
if a:base > 36
throw 'tlib#number#ConvertBase: base > 36 is not supported'
endif
" TLogVAR a:num, a:base, rtype
if a:base == 32
let chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"
elseif a:base == 63 || a:base == 64
let chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
elseif a:base == 85
let chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+-;<=>?@^_`{|}~"
elseif a:base <= 62
let chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
else
throw 'tlib#number#ConvertBase: base is not supported'
endif
let rv = []
let num = 0.0 + a:num
let chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
while floor(num) > 0.0
let div = floor(num / a:base)
let num1 = float2nr(num - a:base * div)

View File

@ -73,7 +73,11 @@ endif
" Return vim code to jump back to the original window.
function! tlib#win#SetById(win_id) "{{{3
if a:win_id != g:tlib#win#null_id
let win_id = tlib#win#GetID()
if g:tlib#win#use_winid
let win_id = tlib#win#GetID()
else
let win_id = tlib#win#GetID().win_id
endif
call tlib#win#GotoID(a:win_id)
return printf('call tlib#win#GotoID(%s)', win_id)
" " TLogVAR a:winnr

View File

@ -1,8 +1,8 @@
" @Author: Tom Link (micathom AT gmail com?subject=[vim])
" @Created: 2007-04-10.
" @Last Change: 2019-04-09.
" @Last Change: 2022-07-21.
" @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
" @Revision: 836
" @Revision: 837
" @Website: http://www.vim.org/account/profile.php?user_id=4037
" GetLatestVimScripts: 1863 1 tlib.vim
" tlib.vim -- Some utility functions
@ -14,7 +14,7 @@ if v:version < 700 "{{{2
echoerr "tlib requires Vim >= 7"
finish
endif
let g:loaded_tlib = 127
let g:loaded_tlib = 128
let s:save_cpo = &cpo
set cpo&vim

File diff suppressed because it is too large Load Diff

View File

@ -157,6 +157,9 @@ plus |:grep|.
*:Gpedit*
:Gpedit [object] |:pedit| a |fugitive-object|.
*:Gdrop*
:Gdrop [object] |:drop| a |fugitive-object|.
*:Gread* *fugitive-:Gr*
:Gread [object] Empty the buffer and |:read| a |fugitive-object|.
When the argument is omitted, this is similar to
@ -165,12 +168,6 @@ plus |:grep|.
:{range}Gread [object] |:read| in a |fugitive-object| after {range}.
*:Gread!* *fugitive-:Gr!*
:Gread! [args] Empty the buffer and |:read| the output of a Git
command. For example, :Gread! show HEAD:%.
:{range}Gread! [args] |:read| the output of a Git command after {range}.
*:Gwrite* *fugitive-:Gw*
:Gwrite Write to the current file's path and stage the results.
When run in a work tree file, it is effectively git
@ -718,7 +715,7 @@ version.
*User_Fugitive*
Fugitive used to support `:autocmd User Fugitive` to run an autocommand after
loading any buffer belonging to a Git repository, but this is being phased
loading any buffer belonging to a Git repository, but this has been phased
out. Instead, one can leverage regular autocommand events like |BufNewFile|
and |BufReadPost|, and check !empty(FugitiveGitDir()) to confirm Fugitive has
found a repository. See also |fugitive-autocommands| for other, more

View File

@ -1,6 +1,6 @@
" fugitive.vim - A Git wrapper so awesome, it should be illegal
" Maintainer: Tim Pope <http://tpo.pe/>
" Version: 3.6
" Version: 3.7
" GetLatestVimScripts: 2975 1 :AutoInstall: fugitive.vim
if exists('g:loaded_fugitive')
@ -16,7 +16,7 @@ let s:bad_git_dir = '/$\|^fugitive:'
" Fugitive is active in the current buffer. Do not rely on this for direct
" filesystem access; use FugitiveFind('.git/whatever') instead.
function! FugitiveGitDir(...) abort
if v:version < 703
if v:version < 704
return ''
elseif !a:0 || type(a:1) == type(0) && a:1 < 0 || a:1 is# get(v:, 'true', -1)
if exists('g:fugitive_event')
@ -39,7 +39,7 @@ function! FugitiveGitDir(...) abort
elseif type(a:1) == type('')
return substitute(s:Slash(a:1), '/$', '', '')
elseif type(a:1) == type({})
return get(a:1, 'git_dir', '')
return get(a:1, 'fugitive_dir', get(a:1, 'git_dir', ''))
else
return ''
endif
@ -58,7 +58,7 @@ function! FugitiveReal(...) abort
if type(file) ==# type({})
let dir = FugitiveGitDir(file)
let tree = s:Tree(dir)
return FugitiveVimPath(empty(tree) ? dir : tree)
return s:VimSlash(empty(tree) ? dir : tree)
elseif file =~# '^\a\a\+:' || a:0 > 1
return call('fugitive#Real', [file] + a:000[1:-1])
elseif file =~# '^/\|^\a:\|^$'
@ -88,15 +88,14 @@ endfunction
" the inverse of FugitiveFind().
function! FugitiveParse(...) abort
let path = s:Slash(a:0 ? a:1 : @%)
if path !~# '^fugitive:'
if path !~# '^fugitive://'
return ['', '']
endif
let vals = matchlist(path, '\c^fugitive:\%(//\)\=\(.\{-\}\)\%(//\|::\)\(\x\{40,\}\|[0-3]\)\(/.*\)\=$')
if len(vals)
return [(vals[2] =~# '^.$' ? ':' : '') . vals[2] . substitute(vals[3], '^/', ':', ''), vals[1]]
let [rev, dir] = fugitive#Parse(path)
if !empty(dir)
return [rev, dir]
endif
let v:errmsg = 'fugitive: invalid Fugitive URL ' . path
throw v:errmsg
throw 'fugitive: invalid Fugitive URL ' . path
endfunction
" FugitiveGitVersion() queries the version of Git in use. Pass up to 3
@ -152,19 +151,6 @@ function! FugitiveShellCommand(...) abort
return call('fugitive#ShellCommand', a:000)
endfunction
" FugitivePrepare() is a deprecated alias for FugitiveShellCommand(). If you
" are using this in conjunction with system(), consider using
" FugitiveExecute() instead.
function! FugitivePrepare(...) abort
if !exists('s:did_prepare_warning')
let s:did_prepare_warning = 1
echohl WarningMsg
unsilent echomsg 'FugitivePrepare() has been superseded by FugitiveShellCommand()'
echohl NONE
endif
return call('fugitive#ShellCommand', a:000)
endfunction
" FugitiveConfig() get returns an opaque structure that can be passed to other
" FugitiveConfig functions in lieu of a Git directory. This can be faster
" when performing multiple config queries. Do not rely on the internal
@ -283,9 +269,21 @@ function! FugitiveStatusline(...) abort
return fugitive#Statusline()
endfunction
let s:resolved_git_dirs = {}
function! FugitiveActualDir(...) abort
let dir = call('FugitiveGitDir', a:000)
if empty(dir)
return ''
endif
if !has_key(s:resolved_git_dirs, dir)
let s:resolved_git_dirs[dir] = s:ResolveGitDir(dir)
endif
return empty(s:resolved_git_dirs[dir]) ? dir : s:resolved_git_dirs[dir]
endfunction
let s:commondirs = {}
function! FugitiveCommonDir(...) abort
let dir = FugitiveGitDir(a:0 ? a:1 : -1)
let dir = call('FugitiveActualDir', a:000)
if empty(dir)
return ''
endif
@ -327,6 +325,9 @@ function! FugitiveIsGitDir(...) abort
endfunction
function! s:ReadFile(path, line_count) abort
if v:version < 800 && !filereadable(a:path)
return []
endif
try
return readfile(a:path, 'b', a:line_count)
catch
@ -337,28 +338,28 @@ endfunction
let s:worktree_for_dir = {}
let s:dir_for_worktree = {}
function! s:Tree(path) abort
let dir = a:path
if dir =~# '/\.git$'
return len(dir) ==# 5 ? '/' : dir[0:-6]
elseif dir ==# ''
if a:path =~# '/\.git$'
return len(a:path) ==# 5 ? '/' : a:path[0:-6]
elseif a:path ==# ''
return ''
endif
let dir = FugitiveActualDir(a:path)
if !has_key(s:worktree_for_dir, dir)
let s:worktree_for_dir[dir] = ''
let ext_wtc_pat = 'v:val =~# "^\\s*worktreeConfig *= *\\%(true\\|yes\\|on\\|1\\) *$"'
let config = s:ReadFile(dir . '/config', 10)
let config = s:ReadFile(dir . '/config', 50)
if len(config)
let ext_wtc_config = filter(copy(config), ext_wtc_pat)
if len(ext_wtc_config) == 1 && filereadable(dir . '/config.worktree')
let config += s:ReadFile(dir . '/config.worktree', 10)
let config += s:ReadFile(dir . '/config.worktree', 50)
endif
else
let worktree = fnamemodify(FugitiveVimPath(get(s:ReadFile(dir . '/gitdir', 1), '0', '')), ':h')
if worktree ==# '.'
unlet! worktree
endif
if len(filter(s:ReadFile(FugitiveCommonDir(dir) . '/config', 10), ext_wtc_pat))
let config = s:ReadFile(dir . '/config.worktree', 10)
if len(filter(s:ReadFile(FugitiveCommonDir(dir) . '/config', 50), ext_wtc_pat))
let config = s:ReadFile(dir . '/config.worktree', 50)
endif
endif
if len(config)
@ -401,30 +402,42 @@ function! s:CeilingDirectories() abort
return s:ceiling_directories + get(g:, 'ceiling_directories', [s:Slash(fnamemodify(expand('~'), ':h'))])
endfunction
function! s:ResolveGitDir(git_dir) abort
let type = getftype(a:git_dir)
if type ==# 'dir' && FugitiveIsGitDir(a:git_dir)
return a:git_dir
elseif type ==# 'link' && FugitiveIsGitDir(a:git_dir)
return resolve(a:git_dir)
elseif type !=# ''
let line = get(s:ReadFile(a:git_dir, 1), 0, '')
let file_dir = s:Slash(FugitiveVimPath(matchstr(line, '^gitdir: \zs.*')))
if file_dir !~# '^/\|^\a:\|^$' && a:git_dir =~# '/\.git$' && FugitiveIsGitDir(a:git_dir[0:-5] . file_dir)
return simplify(a:git_dir[0:-5] . file_dir)
elseif file_dir =~# '^/\|^\a:' && FugitiveIsGitDir(file_dir)
return file_dir
endif
endif
return ''
endfunction
function! FugitiveExtractGitDir(path) abort
if type(a:path) ==# type({})
return get(a:path, 'git_dir', '')
return get(a:path, 'fugitive_dir', get(a:path, 'git_dir', ''))
elseif type(a:path) == type(0)
let path = s:Slash(a:path > 0 ? bufname(a:path) : bufname(''))
else
let path = s:Slash(a:path)
endif
if path =~# '^fugitive:'
return matchstr(path, '\C^fugitive:\%(//\)\=\zs.\{-\}\ze\%(//\|::\|$\)')
if path =~# '^fugitive://'
return fugitive#Parse(path)[1]
elseif empty(path)
return ''
else
let path = fnamemodify(path, ':p:h')
endif
let pre = substitute(matchstr(path, '^\a\a\+\ze:'), '^.', '\u&', '')
if len(pre) && exists('*' . pre . 'Real')
let path ={pre}Real(path)
endif
let path = s:Slash(path)
let root = resolve(path)
if root !=# path
silent! exe (haslocaldir() ? 'lcd' : exists(':tcd') && haslocaldir(-1) ? 'tcd' : 'cd') '.'
let path = {pre}Real(path)
endif
let root = s:Slash(fnamemodify(path, ':p:h'))
let previous = ""
let env_git_dir = len($GIT_DIR) ? s:Slash(simplify(fnamemodify(FugitiveVimPath($GIT_DIR), ':p:s?[\/]$??'))) : ''
call s:Tree(env_git_dir)
@ -439,20 +452,12 @@ function! FugitiveExtractGitDir(path) abort
return s:dir_for_worktree[root]
endif
let dir = substitute(root, '[\/]$', '', '') . '/.git'
let type = getftype(dir)
if type ==# 'dir' && FugitiveIsGitDir(dir)
return dir
elseif type ==# 'link' && FugitiveIsGitDir(dir)
return resolve(dir)
elseif type !=# ''
let line = get(s:ReadFile(dir, 1), 0, '')
let file_dir = s:Slash(FugitiveVimPath(matchstr(line, '^gitdir: \zs.*')))
if file_dir !~# '^/\|^\a:\|^$' && FugitiveIsGitDir(root . '/' . file_dir)
return simplify(root . '/' . file_dir)
elseif len(file_dir) && FugitiveIsGitDir(file_dir)
return file_dir
endif
let resolved = s:ResolveGitDir(dir)
if !empty(resolved)
let s:resolved_git_dirs[dir] = resolved
return dir is# resolved || s:Tree(resolved) is# 0 ? dir : resolved
elseif FugitiveIsGitDir(root)
let s:resolved_git_dirs[root] = root
return root
endif
let previous = root
@ -462,57 +467,56 @@ function! FugitiveExtractGitDir(path) abort
endfunction
function! FugitiveDetect(...) abort
if v:version < 703
if v:version < 704
return ''
endif
if exists('b:git_dir') && b:git_dir =~# '^$\|' . s:bad_git_dir
unlet b:git_dir
endif
if a:0 > 1 && a:2 is# 0 && !exists('#User#Fugitive')
return ''
endif
if !exists('b:git_dir')
let b:git_dir = FugitiveExtractGitDir(a:0 ? a:1 : bufnr(''))
endif
if empty(b:git_dir) || !exists('#User#Fugitive')
return ''
endif
if v:version >= 704 || (v:version == 703 && has('patch442'))
doautocmd <nomodeline> User Fugitive
elseif &modelines > 0
let modelines = &modelines
try
set modelines=0
doautocmd User Fugitive
finally
let &modelines = modelines
endtry
else
doautocmd User Fugitive
endif
return ''
endfunction
function! FugitiveVimPath(path) abort
if exists('+shellslash') && !&shellslash
return tr(a:path, '/', '\')
else
return a:path
endif
endfunction
function! FugitiveGitPath(path) abort
return s:Slash(a:path)
endfunction
if exists('+shellslash')
function! s:Slash(path) abort
return tr(a:path, '\', '/')
endfunction
function! s:VimSlash(path) abort
return tr(a:path, '\/', &shellslash ? '//' : '\\')
endfunction
function FugitiveVimPath(path) abort
return tr(a:path, '\/', &shellslash ? '//' : '\\')
endfunction
else
function! s:Slash(path) abort
return a:path
endfunction
function! s:VimSlash(path) abort
return a:path
endfunction
if has('win32unix') && filereadable('/git-bash.exe')
function! FugitiveVimPath(path) abort
return substitute(a:path, '^\(\a\):', '/\l\1', '')
endfunction
else
function! FugitiveVimPath(path) abort
return a:path
endfunction
endif
endif
function! s:ProjectionistDetect() abort
@ -545,9 +549,6 @@ command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#Complete Git exe
if exists(':Gstatus') != 2 && get(g:, 'fugitive_legacy_commands', 0)
exe 'command! -bang -bar -range=-1' s:addr_other 'Gstatus exe fugitive#Command(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
\ '|echohl WarningMSG|echomsg ":Gstatus is deprecated in favor of :Git (with no arguments)"|echohl NONE'
elseif exists(':Gstatus') != 2 && !exists('g:fugitive_legacy_commands')
exe 'command! -bang -bar -range=-1' s:addr_other 'Gstatus'
\ ' echoerr ":Gstatus has been removed in favor of :Git (with no arguments)"'
endif
for s:cmd in ['Commit', 'Revert', 'Merge', 'Rebase', 'Pull', 'Push', 'Fetch', 'Blame']
@ -555,9 +556,6 @@ for s:cmd in ['Commit', 'Revert', 'Merge', 'Rebase', 'Pull', 'Push', 'Fetch', 'B
exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#' . s:cmd . 'Complete G' . tolower(s:cmd)
\ 'echohl WarningMSG|echomsg ":G' . tolower(s:cmd) . ' is deprecated in favor of :Git ' . tolower(s:cmd) . '"|echohl NONE|'
\ 'exe fugitive#Command(<line1>, <count>, +"<range>", <bang>0, "<mods>", "' . tolower(s:cmd) . ' " . <q-args>)'
elseif exists(':G' . tolower(s:cmd)) != 2 && !exists('g:fugitive_legacy_commands')
exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#' . s:cmd . 'Complete G' . tolower(s:cmd)
\ 'echoerr ":G' . tolower(s:cmd) . ' has been removed in favor of :Git ' . tolower(s:cmd) . '"'
endif
endfor
unlet s:cmd
@ -568,13 +566,6 @@ exe "command! -bar -bang -nargs=? -complete=customlist,fugitive#CdComplete Glcd
exe 'command! -bang -nargs=? -range=-1' s:addr_wins '-complete=customlist,fugitive#GrepComplete Ggrep exe fugitive#GrepCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
exe 'command! -bang -nargs=? -range=-1' s:addr_wins '-complete=customlist,fugitive#GrepComplete Glgrep exe fugitive#GrepCommand(0, <count> > 0 ? <count> : 0, +"<range>", <bang>0, "<mods>", <q-args>)'
if exists(':Glog') != 2 && get(g:, 'fugitive_legacy_commands', 0)
exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#LogComplete Glog :exe fugitive#LogCommand(<line1>,<count>,+"<range>",<bang>0,"<mods>",<q-args>, "")'
\ '|echohl WarningMSG|echomsg ":Glog is deprecated in favor of :Gclog"|echohl NONE'
elseif exists(':Glog') != 2 && !exists('g:fugitive_legacy_commands')
exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#LogComplete Glog'
\ ' echoerr ":Glog has been removed in favor of :Gclog"'
endif
exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#LogComplete Gclog :exe fugitive#LogCommand(<line1>,<count>,+"<range>",<bang>0,"<mods>",<q-args>, "c")'
exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#LogComplete GcLog :exe fugitive#LogCommand(<line1>,<count>,+"<range>",<bang>0,"<mods>",<q-args>, "c")'
exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#LogComplete Gllog :exe fugitive#LogCommand(<line1>,<count>,+"<range>",<bang>0,"<mods>",<q-args>, "l")'
@ -582,10 +573,11 @@ exe 'command! -bang -nargs=? -range=-1 -complete=customlist,fugitive#LogComplete
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Ge exe fugitive#Open("edit<bang>", 0, "<mods>", <q-args>)'
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gedit exe fugitive#Open("edit<bang>", 0, "<mods>", <q-args>)'
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#ReadComplete Gpedit exe fugitive#Open("pedit", <bang>0, "<mods>", <q-args>)'
exe 'command! -bar -bang -nargs=* -range=-1' s:addr_other '-complete=customlist,fugitive#ReadComplete Gsplit exe fugitive#Open((<count> > 0 ? <count> : "").(<count> ? "split" : "edit"), <bang>0, "<mods>", <q-args>)'
exe 'command! -bar -bang -nargs=* -range=-1' s:addr_other '-complete=customlist,fugitive#ReadComplete Gvsplit exe fugitive#Open((<count> > 0 ? <count> : "").(<count> ? "vsplit" : "edit!"), <bang>0, "<mods>", <q-args>)'
exe 'command! -bar -bang -nargs=* -range=-1' s:addr_tabs '-complete=customlist,fugitive#ReadComplete Gtabedit exe fugitive#Open((<count> >= 0 ? <count> : "")."tabedit", <bang>0, "<mods>", <q-args>)'
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gpedit exe fugitive#Open("pedit", <bang>0, "<mods>", <q-args>)'
exe 'command! -bar -bang -nargs=* -range=-1' s:addr_other '-complete=customlist,fugitive#EditComplete Gsplit exe fugitive#Open((<count> > 0 ? <count> : "").(<count> ? "split" : "edit"), <bang>0, "<mods>", <q-args>)'
exe 'command! -bar -bang -nargs=* -range=-1' s:addr_other '-complete=customlist,fugitive#EditComplete Gvsplit exe fugitive#Open((<count> > 0 ? <count> : "").(<count> ? "vsplit" : "edit!"), <bang>0, "<mods>", <q-args>)'
exe 'command! -bar -bang -nargs=* -range=-1' s:addr_tabs '-complete=customlist,fugitive#EditComplete Gtabedit exe fugitive#Open((<count> >= 0 ? <count> : "")."tabedit", <bang>0, "<mods>", <q-args>)'
exe 'command! -bar -bang -nargs=* -complete=customlist,fugitive#EditComplete Gdrop exe fugitive#DropCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
if exists(':Gr') != 2
exe 'command! -bar -bang -nargs=* -range=-1 -complete=customlist,fugitive#ReadComplete Gr exe fugitive#ReadCommand(<line1>, <count>, +"<range>", <bang>0, "<mods>", <q-args>)'
@ -641,7 +633,7 @@ elseif exists(':Gbrowse') != 2 && !exists('g:fugitive_legacy_commands')
\ 'echoerr ":Gbrowse has been removed in favor of :GBrowse"'
endif
if v:version < 703
if v:version < 704
finish
endif
@ -665,8 +657,15 @@ let g:io_fugitive = {
augroup fugitive
autocmd!
autocmd BufNewFile,BufReadPost * call FugitiveDetect(+expand('<abuf>'), 0)
autocmd FileType netrw call FugitiveDetect(+expand('<abuf>'), 0)
autocmd BufNewFile,BufReadPost *
\ if exists('b:git_dir') && b:git_dir =~# '^$\|' . s:bad_git_dir |
\ unlet b:git_dir |
\ endif
autocmd FileType netrw
\ if exists('b:git_dir') && b:git_dir =~# '^$\|' . s:bad_git_dir |
\ unlet b:git_dir |
\ endif
autocmd BufFilePost * unlet! b:git_dir
autocmd FileType git
\ call fugitive#MapCfile()
@ -699,15 +698,15 @@ augroup fugitive
\ silent doautocmd BufNewFile |
\ endif
autocmd BufReadCmd fugitive://*//* nested exe fugitive#BufReadCmd() |
autocmd BufReadCmd fugitive://* nested exe fugitive#BufReadCmd() |
\ if &path =~# '^\.\%(,\|$\)' |
\ let &l:path = substitute(&path, '^\.,\=', '', '') |
\ endif
autocmd BufWriteCmd fugitive://*//[0-3]/* nested exe fugitive#BufWriteCmd()
autocmd FileReadCmd fugitive://*//* nested exe fugitive#FileReadCmd()
autocmd FileWriteCmd fugitive://*//[0-3]/* nested exe fugitive#FileWriteCmd()
autocmd BufWriteCmd fugitive://* nested exe fugitive#BufWriteCmd()
autocmd FileReadCmd fugitive://* nested exe fugitive#FileReadCmd()
autocmd FileWriteCmd fugitive://* nested exe fugitive#FileWriteCmd()
if exists('##SourceCmd')
autocmd SourceCmd fugitive://*//* nested exe fugitive#SourceCmd()
autocmd SourceCmd fugitive://* nested exe fugitive#SourceCmd()
endif
autocmd User Flags call Hoist('buffer', function('FugitiveStatusline'))
@ -715,14 +714,15 @@ augroup fugitive
autocmd User ProjectionistDetect call s:ProjectionistDetect()
augroup END
nmap <script><silent> <Plug>fugitive:y<C-G> :<C-U>call setreg(v:register, fugitive#Object(@%))<CR>
nmap <script> <Plug>fugitive: <Nop>
if get(g:, 'fugitive_no_maps')
finish
endif
let s:nowait = v:version >= 704 ? '<nowait>' : ''
function! s:Map(mode, lhs, rhs, flags) abort
let flags = a:flags . (a:rhs =~# '<Plug>' ? '' : '<script>')
let flags = a:flags . (a:rhs =~# '<Plug>' ? '' : '<script>') . '<nowait>'
let head = a:lhs
let tail = ''
let keys = get(g:, a:mode.'remap', {})
@ -740,11 +740,9 @@ function! s:Map(mode, lhs, rhs, flags) abort
endwhile
endif
if empty(mapcheck(head.tail, a:mode))
exe a:mode.'map' s:nowait flags head.tail a:rhs
exe a:mode.'map' flags head.tail a:rhs
endif
endfunction
call s:Map('c', '<C-R><C-G>', 'fnameescape(fugitive#Object(@%))', '<expr>')
call s:Map('n', 'y<C-G>', ':<C-U>call setreg(v:register, fugitive#Object(@%))<CR>', '<silent>')
nmap <script><silent> <Plug>fugitive:y<C-G> :<C-U>call setreg(v:register, fugitive#Object(@%))<CR>
nmap <script> <Plug>fugitive: <Nop>

View File

@ -162,7 +162,7 @@ function! s:common_prefix(a, b)
return -1
endif
for i in range(len)
if a:a[i:i] != a:b[i:i]
if a:a[i:i] !=# a:b[i:i]
return i - 1
endif
endfor

View File

@ -24,7 +24,8 @@ syntax sync fromstart
" syntax case ignore
syntax case match
syntax match jsNoise /[:,;]/
syntax match jsNoise /[:;]/
syntax match jsNoise /,/ skipwhite skipempty nextgroup=@jsExpression
syntax match jsDot /\./ skipwhite skipempty nextgroup=jsObjectProp,jsFuncCall,jsPrototype,jsTaggedTemplate
syntax match jsObjectProp contained /\<\K\k*/
syntax match jsFuncCall /\<\K\k*\ze\s*(/
@ -33,7 +34,8 @@ syntax match jsParensError /[)}\]]/
" Program Keywords
syntax keyword jsStorageClass const var let skipwhite skipempty nextgroup=jsDestructuringBlock,jsDestructuringArray,jsVariableDef
syntax match jsVariableDef contained /\<\K\k*/ skipwhite skipempty nextgroup=jsFlowDefinition
syntax keyword jsOperatorKeyword delete instanceof typeof void new in of skipwhite skipempty nextgroup=@jsExpression
syntax keyword jsOperatorKeyword delete instanceof typeof void new in skipwhite skipempty nextgroup=@jsExpression
syntax keyword jsOf of skipwhite skipempty nextgroup=@jsExpression
syntax match jsOperator "[-!|&+<>=%/*~^]" skipwhite skipempty nextgroup=@jsExpression
syntax match jsOperator /::/ skipwhite skipempty nextgroup=@jsExpression
syntax keyword jsBooleanTrue true
@ -99,7 +101,8 @@ syntax keyword jsStatement contained break continue skipwhite skipempty next
syntax keyword jsConditional if skipwhite skipempty nextgroup=jsParenIfElse
syntax keyword jsConditional else skipwhite skipempty nextgroup=jsCommentIfElse,jsIfElseBlock
syntax keyword jsConditional switch skipwhite skipempty nextgroup=jsParenSwitch
syntax keyword jsRepeat while for skipwhite skipempty nextgroup=jsParenRepeat,jsForAwait
syntax keyword jsWhile while skipwhite skipempty nextgroup=jsParenWhile
syntax keyword jsFor for skipwhite skipempty nextgroup=jsParenFor,jsForAwait
syntax keyword jsDo do skipwhite skipempty nextgroup=jsRepeatBlock
syntax region jsSwitchCase contained matchgroup=jsLabel start=/\<\%(case\|default\)\>/ end=/:\@=/ contains=@jsExpression,jsLabel skipwhite skipempty nextgroup=jsSwitchColon keepend
syntax keyword jsTry try skipwhite skipempty nextgroup=jsTryCatchBlock
@ -135,19 +138,20 @@ syntax keyword jsHtmlEvents onblur onclick oncontextmenu ondblclick onfocus
" Code blocks
syntax region jsBracket matchgroup=jsBrackets start=/\[/ end=/\]/ contains=@jsExpression,jsSpreadExpression extend fold
syntax region jsParen matchgroup=jsParens start=/(/ end=/)/ contains=@jsExpression extend fold nextgroup=jsFlowDefinition
syntax region jsParenDecorator contained matchgroup=jsParensDecorator start=/(/ end=/)/ contains=@jsAll extend fold
syntax region jsParenIfElse contained matchgroup=jsParensIfElse start=/(/ end=/)/ contains=@jsAll skipwhite skipempty nextgroup=jsCommentIfElse,jsIfElseBlock,jsReturn extend fold
syntax region jsParenRepeat contained matchgroup=jsParensRepeat start=/(/ end=/)/ contains=@jsAll skipwhite skipempty nextgroup=jsCommentRepeat,jsRepeatBlock,jsReturn extend fold
syntax region jsParenSwitch contained matchgroup=jsParensSwitch start=/(/ end=/)/ contains=@jsAll skipwhite skipempty nextgroup=jsSwitchBlock extend fold
syntax region jsParenDecorator contained matchgroup=jsParensDecorator start=/(/ end=/)/ contains=@jsExpression extend fold
syntax region jsParenIfElse contained matchgroup=jsParensIfElse start=/(/ end=/)/ contains=@jsExpression skipwhite skipempty nextgroup=jsCommentIfElse,jsIfElseBlock,jsReturn extend fold
syntax region jsParenWhile contained matchgroup=jsParensWhile start=/(/ end=/)/ contains=@jsExpression skipwhite skipempty nextgroup=jsCommentRepeat,jsRepeatBlock,jsReturn extend fold
syntax region jsParenFor contained matchgroup=jsParensFor start=/(/ end=/)/ contains=@jsExpression,jsStorageClass,jsOf skipwhite skipempty nextgroup=jsCommentRepeat,jsRepeatBlock,jsReturn extend fold
syntax region jsParenSwitch contained matchgroup=jsParensSwitch start=/(/ end=/)/ contains=@jsExpression skipwhite skipempty nextgroup=jsSwitchBlock extend fold
syntax region jsParenCatch contained matchgroup=jsParensCatch start=/(/ end=/)/ skipwhite skipempty nextgroup=jsTryCatchBlock extend fold
syntax region jsFuncArgs contained matchgroup=jsFuncParens start=/(/ end=/)/ contains=jsFuncArgCommas,jsComment,jsFuncArgExpression,jsDestructuringBlock,jsDestructuringArray,jsRestExpression,jsFlowArgumentDef skipwhite skipempty nextgroup=jsCommentFunction,jsFuncBlock,jsFlowReturn extend fold
syntax region jsClassBlock contained matchgroup=jsClassBraces start=/{/ end=/}/ contains=jsClassFuncName,jsClassMethodType,jsArrowFunction,jsArrowFuncArgs,jsComment,jsGenerator,jsDecorator,jsClassProperty,jsClassPropertyComputed,jsClassStringKey,jsAsyncKeyword,jsNoise extend fold
syntax region jsFuncBlock contained matchgroup=jsFuncBraces start=/{/ end=/}/ contains=@jsAll,jsBlock extend fold
syntax region jsIfElseBlock contained matchgroup=jsIfElseBraces start=/{/ end=/}/ contains=@jsAll,jsBlock extend fold
syntax region jsTryCatchBlock contained matchgroup=jsTryCatchBraces start=/{/ end=/}/ contains=@jsAll,jsBlock skipwhite skipempty nextgroup=jsCatch,jsFinally extend fold
syntax region jsFinallyBlock contained matchgroup=jsFinallyBraces start=/{/ end=/}/ contains=@jsAll,jsBlock extend fold
syntax region jsSwitchBlock contained matchgroup=jsSwitchBraces start=/{/ end=/}/ contains=@jsAll,jsBlock,jsSwitchCase extend fold
syntax region jsRepeatBlock contained matchgroup=jsRepeatBraces start=/{/ end=/}/ contains=@jsAll,jsBlock extend fold
syntax region jsFuncBlock contained matchgroup=jsFuncBraces start=/{/ end=/}/ contains=@jsAll extend fold
syntax region jsIfElseBlock contained matchgroup=jsIfElseBraces start=/{/ end=/}/ contains=@jsAll extend fold
syntax region jsTryCatchBlock contained matchgroup=jsTryCatchBraces start=/{/ end=/}/ contains=@jsAll skipwhite skipempty nextgroup=jsCatch,jsFinally extend fold
syntax region jsFinallyBlock contained matchgroup=jsFinallyBraces start=/{/ end=/}/ contains=@jsAll extend fold
syntax region jsSwitchBlock contained matchgroup=jsSwitchBraces start=/{/ end=/}/ contains=@jsAll,jsSwitchCase extend fold
syntax region jsRepeatBlock contained matchgroup=jsRepeatBraces start=/{/ end=/}/ contains=@jsAll extend fold
syntax region jsDestructuringBlock contained matchgroup=jsDestructuringBraces start=/{/ end=/}/ contains=jsDestructuringProperty,jsDestructuringAssignment,jsDestructuringNoise,jsDestructuringPropertyComputed,jsSpreadExpression,jsComment nextgroup=jsFlowDefinition extend fold
syntax region jsDestructuringArray contained matchgroup=jsDestructuringBraces start=/\[/ end=/\]/ contains=jsDestructuringPropertyValue,jsDestructuringNoise,jsDestructuringProperty,jsSpreadExpression,jsDestructuringBlock,jsDestructuringArray,jsComment nextgroup=jsFlowDefinition extend fold
syntax region jsObject contained matchgroup=jsObjectBraces start=/{/ end=/}/ contains=jsObjectKey,jsObjectKeyString,jsObjectKeyComputed,jsObjectShorthandProp,jsObjectSeparator,jsObjectFuncName,jsObjectMethodType,jsGenerator,jsComment,jsObjectStringKey,jsSpreadExpression,jsDecorator,jsAsyncKeyword,jsTemplateString extend fold
@ -165,7 +169,7 @@ syntax match jsFuncName contained /\<\K\k*/ skipwhite skipempty ne
syntax region jsFuncArgExpression contained matchgroup=jsFuncArgOperator start=/=/ end=/[,)]\@=/ contains=@jsExpression extend
syntax match jsFuncArgCommas contained ','
syntax keyword jsArguments contained arguments
syntax keyword jsForAwait contained await skipwhite skipempty nextgroup=jsParenRepeat
syntax keyword jsForAwait contained await skipwhite skipempty nextgroup=jsParenFor
" Matches a single keyword argument with no parens
syntax match jsArrowFuncArgs /\<\K\k*\ze\s*=>/ skipwhite contains=jsFuncArgs skipwhite skipempty nextgroup=jsArrowFunction extend
@ -233,7 +237,7 @@ if exists("javascript_plugin_flow")
endif
syntax cluster jsExpression contains=jsBracket,jsParen,jsObject,jsTernaryIf,jsTaggedTemplate,jsTemplateString,jsString,jsRegexpString,jsNumber,jsFloat,jsOperator,jsOperatorKeyword,jsBooleanTrue,jsBooleanFalse,jsNull,jsFunction,jsArrowFunction,jsGlobalObjects,jsExceptions,jsFutureKeys,jsDomErrNo,jsDomNodeConsts,jsHtmlEvents,jsFuncCall,jsUndefined,jsNan,jsPrototype,jsBuiltins,jsNoise,jsClassDefinition,jsArrowFunction,jsArrowFuncArgs,jsParensError,jsComment,jsArguments,jsThis,jsSuper,jsDo,jsForAwait,jsAsyncKeyword,jsStatement,jsDot
syntax cluster jsAll contains=@jsExpression,jsStorageClass,jsConditional,jsRepeat,jsReturn,jsException,jsTry,jsNoise,jsBlockLabel
syntax cluster jsAll contains=@jsExpression,jsStorageClass,jsConditional,jsWhile,jsFor,jsReturn,jsException,jsTry,jsNoise,jsBlockLabel,jsBlock
" Define the default highlighting.
" For version 5.7 and earlier: only when not done already
@ -248,6 +252,8 @@ if version >= 508 || !exists("did_javascript_syn_inits")
HiLink jsComment Comment
HiLink jsEnvComment PreProc
HiLink jsParensIfElse jsParens
HiLink jsParensWhile jsParensRepeat
HiLink jsParensFor jsParensRepeat
HiLink jsParensRepeat jsParens
HiLink jsParensSwitch jsParens
HiLink jsParensCatch jsParens
@ -273,6 +279,8 @@ if version >= 508 || !exists("did_javascript_syn_inits")
HiLink jsBranch Conditional
HiLink jsLabel Label
HiLink jsReturn Statement
HiLink jsWhile jsRepeat
HiLink jsFor jsRepeat
HiLink jsRepeat Repeat
HiLink jsDo Repeat
HiLink jsStatement Statement

View File

@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2015 - 2020 Greg Dietsche
Copyright (c) 2015 - 2017 Greg Dietsche
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -1,4 +1,4 @@
# vim-lastplace v3.2.1
# vim-lastplace v3.1.1
Intelligently reopen files at your last edit position. By default git,
svn, and mercurial commit messages are ignored because you
@ -14,23 +14,12 @@ Advantages over the snippets that can be found around the net include:
* Opens folds if the last edit position is inside a fold.
* Works properly with new file templates and scripts that jump to a specific line in them.
## Installation
### Vim 8 & Beyond:
You can install vim-lastplace as a vim plugin without any additional tools
## Installation
You can use [pathogen.vim](https://github.com/tpope/vim-pathogen) or other plugin managers to install and use vim-lastplace.
```bash
mkdir -p ~/.vim/pack/plugins/start
rm -rf ~/.vim/pack/plugins/start/vim-lastplace
git clone --depth=1 https://github.com/farmergreg/vim-lastplace.git ~/.vim/pack/plugins/start/vim-lastplace
```
### Pathogen:
You can also use [pathogen.vim](https://github.com/tpope/vim-pathogen) or other plugin managers to install and use vim-lastplace.
cd ~/.vim/bundle
git clone git://github.com/farmergreg/vim-lastplace.git
```bash
cd ~/.vim/bundle
git clone git://github.com/farmergreg/vim-lastplace.git
```
### Preventing Conflicts:
Depending on which Vim package you're using, Vim may be preconfigured with
last-edit-position logic that doesn't work quite as well as vim-lastplace.
If so, you may want to disable that in favor of vim-lastplace. For example,
@ -43,24 +32,18 @@ You can configure what file types to ignore by setting
g:lastplace_ignore in your vimrc. This is a comma separated list.
By default it is set to:
```vim
let g:lastplace_ignore = "gitcommit,gitrebase,svn,hgcommit"
````
let g:lastplace_ignore = "gitcommit,gitrebase,svn,hgcommit"
You can configure buffer types to ignore by setting
g:lastplace_ignore_buftype in your vimrc. This is a comma separated list.
By default it is set to:
```vim
let g:lastplace_ignore_buftype = "quickfix,nofile,help"
```
let g:lastplace_ignore_buftype = "quickfix,nofile,help"
Closed folds are automatically opened when jumping to the last edit position. If you
Folds are automatically opened when jumping to the last edit position. If you
do not like this behavior you can disable it by putting this in your vimrc:
```vim
let g:lastplace_open_folds = 0
```
let g:lastplace_open_folds = 0
## Miscellaneous
This plugin is complete and stable. Please do not be afraid to try it even
@ -70,10 +53,6 @@ a bug, please submit a pull request that fixes whatever problem you're having.
## Version History
vim-lastplace uses [semver](http://semver.org/) to manage version numbers.
### 3.2.1
- Re-center screen when opening folds
- Documentation fixes and updates
### 3.1.1
- Add 'nofile' and 'help' to lastplace_ignore_buftype. (Issue [#14](https://github.com/farmergreg/vim-lastplace/issues/14))
- Do not jump when a new file is created (Issue [#15](https://github.com/farmergreg/vim-lastplace/issues/15), [#16](https://github.com/farmergreg/vim-lastplace/issues/16))

View File

@ -2,7 +2,7 @@
Author: Gregory L. Dietsche <https://www.gregd.org/>
License: MIT
Version: 3.2.1
Version: 3.1.1
INTRODUCTION *vim-lastplace-introduction*
@ -23,7 +23,7 @@ By default it is set to:
let g:lastplace_ignore_buftype = "quickfix,nofile,help"
Closed folds are automatically opened when jumping to the last edit position. If you
Folds are automatically opened when jumping to the last edit position. If you
do not like this behavior you can disable it by putting this in your vimrc:
let g:lastplace_open_folds = 0

View File

@ -4,7 +4,7 @@
" Author: Gregory L. Dietsche <vim@gregd.org>
" Licence: MIT
" Website: https://www.gregd.org/
" Version: 3.2.1
" Version: 3.1.1
" ============================================================================
if exists("b:loaded_lastplace_plugin") || &cp
@ -76,5 +76,5 @@ endf
augroup lastplace_plugin
autocmd!
autocmd BufRead * call s:lastplace()
autocmd BufWinEnter * call s:lastplace()
augroup END

View File

@ -197,22 +197,27 @@ function! rhubarb#Request(path, ...) abort
if exists('*FugitiveExecute') && v:version >= 800
try
if has_key(options, 'callback')
return FugitiveExecute({'argv': args}, { r -> r.exit_status || r.stdout ==# [''] ? '' : options.callback(json_decode(join(r.stdout, ' '))) })
return FugitiveExecute({'argv': args},
\ { r -> r.exit_status || r.stdout ==# [''] ? '' : call(options.callback, [json_decode(join(r.stdout, ' '))] + get(options, 'callback_args', [])) })
endif
let raw = join(FugitiveExecute({'argv': args}).stdout, ' ')
return empty(raw) ? raw : json_decode(raw)
if empty(raw)
throw 'rhubarb: bug? empty response from ' . path
else
return json_decode(raw)
endif
catch /^fugitive:/
endtry
endif
let raw = system(join(map(copy(args), 's:shellesc(v:val)'), ' '))
silent let raw = system(join(map(copy(args), 's:shellesc(v:val)'), ' '))
if has_key(options, 'callback')
if !v:shell_error && !empty(raw)
call options.callback(rhubarb#JsonDecode(raw))
call call(options.callback, [rhubarb#JsonDecode(raw)] + get(options, 'callback_args', []))
endif
return {}
endif
if raw ==# ''
return raw
if empty(raw)
throw 'rhubarb: bug? empty response from ' . path
else
return rhubarb#JsonDecode(raw)
endif
@ -244,6 +249,21 @@ endfunction
" Section: Issues
function! s:CompleteAddIssues(response, prefix) abort
for issue in get(a:response, 'items', [])
call complete_add({
\ 'word': a:prefix . issue.number,
\ 'abbr': '#' . issue.number,
\ 'menu': issue.title,
\ 'info': substitute(empty(issue.body) ? "\n" : issue.body,'\r','','g'),
\ })
endfor
if !has_key(a:response, 'message')
return
endif
throw 'rhubarb: ' . a:response.message
endfunction
let s:reference = '\<\%(\c\%(clos\|resolv\|referenc\)e[sd]\=\|\cfix\%(e[sd]\)\=\)\>'
function! rhubarb#Complete(findstart, base) abort
if a:findstart
@ -261,20 +281,12 @@ function! rhubarb#Complete(findstart, base) abort
let prefix = s:repo_homepage().'/issues/'
let query = a:base
endif
let response = rhubarb#RepoSearch('issues', 'state:open '.query)
if type(response) != type({})
call s:throw('unknown error')
elseif has_key(response, 'message')
call s:throw(response.message)
else
let issues = get(response, 'items', [])
endif
return map(issues, '{"word": prefix.v:val.number, "abbr": "#".v:val.number, "menu": v:val.title, "info": substitute(empty(v:val.body) ? "\n" : v:val.body,"\\r","","g")}')
let response = rhubarb#RepoSearch('issues', 'state:open ' . query)
call s:CompleteAddIssues(response, prefix)
endif
catch /^rhubarb:.*is not a GitHub repository/
return []
catch /^\%(fugitive\|rhubarb\):/
echoerr v:errmsg
echoerr v:exception
endtry
endfunction
@ -295,13 +307,14 @@ function! rhubarb#FugitiveUrl(...) abort
return ''
endif
let path = substitute(opts.path, '^/', '', '')
if path =~# '^\.git/refs/heads/'
return root . '/commits/' . path[16:-1]
elseif path =~# '^\.git/refs/tags/'
return root . '/releases/tag/' . path[15:-1]
elseif path =~# '^\.git/refs/remotes/[^/]\+/.'
return root . '/commits/' . matchstr(path,'remotes/[^/]\+/\zs.*')
elseif path =~# '^\.git\>'
let ref = matchstr(opts.path, '^/\=\.git/\zsrefs/.*')
if ref =~# '^refs/heads/'
return root . '/commits/' . ref[11:-1]
elseif ref =~# '^refs/tags/'
return root . '/releases/tag/' . ref[10:-1]
elseif ref =~# '^refs/remotes/[^/]\+/.'
return root . '/commits/' . matchstr(ref,'remotes/[^/]\+/\zs.*')
elseif opts.path =~# '^/\=\.git\>'
return root
endif
let commit = opts.commit

View File

@ -0,0 +1,728 @@
*SnipMate.txt* Plugin for using TextMate-style snippets in Vim.
SnipMate *snippet* *snippets* *SnipMate*
1. Description |SnipMate-description|
2. Usage |SnipMate-usage|
3. Interface and Settings |SnipMate-interface| |SnipMate-settings|
4. Snippets |SnipMate-snippets|
- Snippet files |SnipMate-snippet-files|
- Snippet syntax |SnipMate-syntax|
5. Snippet sources |SnipMate-snippet-sources|
6. Disadvantages to TextMate |SnipMate-disadvantages|
7. Contact |SnipMate-contact|
8. License |SnipMate-license|
For Vim version 7.0 or later.
This plugin only works if 'compatible' is not set.
{Vi does not have any of these features.}
SnipMate depends on vim-addon-mw-utils and tlib.
==============================================================================
DESCRIPTION *SnipMate-description*
SnipMate implements snippet features in Vim. A snippet is like a template,
reducing repetitive insertion of pieces of text. Snippets can contain
placeholders for modifying the text if necessary or interpolated code for
evaluation. For example, in C, typing "for" then pushing <Tab> could expand
to: >
for (i = 0; i < count; i++) {
/* code */
}
SnipMate is inspired by TextMate's snippet features.
==============================================================================
USAGE *SnipMate-usage*
Every snippet consists of an expansion and a trigger. Typing a trigger into
your buffer and then hitting your trigger key (<Tab> by default, see
|SnipMate-mappings|) will replace the trigger with the expansion text.
The expansion text can optionally include tab stops. When it does, upon
expansion of the snippet, the cursor is placed at the first one, and the user
can jump between each tab stop. Each of these tab stops can be represented by
default placeholder text. If such a placeholder is provided, then the text of
the placeholder can be repeated in the snippet at specified mirrors. Any edits
to the placeholder are instantly updated at every mirror.
SnipMate allows multiple snippets to use the same trigger. When triggered,
a list of all snippets with that trigger is provided and prompts for which
snippet to use.
*SnipMate-scopes*
SnipMate searches for snippets inside a directory named "snippets" inside each
entry in 'runtimepath'. Which files are loaded depends on 'filetype' and
'syntax'; see |SnipMate-syntax| for more information. Snippets are loaded and
refreshed automatically on demand.
Note: SnipMate does not ship with any snippets. In order to use it, the user
must either write their own snippets or obtain some from a repository like
https://github.com/honza/vim-snippets
==============================================================================
INTERFACE AND SETTINGS *SnipMate-interface* *SnipMate-settings*
*SnipMate-commands*
Commands~
*:SnipMateOpenSnippetFiles*
:SnipMateOpenSnippetFiles Opens a list of all valid snippet locations
based on the current scope |SnipMate-scopes|.
Only existing files and non-existing .snippets
files will be shown, with the existing files
shown first.
:SnipMateLoadScope[!] scope [scope ...]
Load snippets from additional scopes. Without
[!] the additional scopes are loaded only in
the current buffer. For example >
:SnipMateLoadScopes rails
< will load all rails.snippets in the current
buffer.
*SnipMate-options*
Options~
g:snips_author A variable used in some snippets in place of
the author's (your) name. Similar to
$TM_FULLNAME in TextMate. For example, >
snippet name
`g:snips_author`
< creates a snippet "name" that expands to your
name.
g:snipMate This |Dictionary| contains other SnipMate
options. In short add >
let g:snipMate = {}
< to your .vimrc before setting other SnipMate
options.
g:snipMate.scope_aliases A |Dictionary| associating certain filetypes
with other scopes |SnipMate-scopes|. The
entries consist of a filetype as the key and
a comma-separated list of aliases as the
value. For example, >
let g:snipMate.scope_aliases = {}
let g:snipMate.scope_aliases['ruby']
\ = 'ruby,ruby-rails'
< tells SnipMate that "ruby-rails" snippets in
addition to "ruby" snippets should be loaded
when editing files with 'filetype' set to
"ruby" or contains "ruby" as an entry in the
case of dotted filetypes. A buffer local
variant b:snipMate_scope_aliases is merged
with the global variant.
g:snipMate_no_default_aliases Note: This has been renamed to the following.
g:snipMate.no_default_aliases
When set to 1, prevents SnipMate from loading
default scope aliases. The defaults are:
Filetype Alias ~
cpp c
cu c
eruby eruby-rails,html
html javascript
mxml actionscript
objc c
php php,html,javascript
ur html,javascript
xhtml html
Individual defaults can be disabled by setting
them to an empty value: >
let g:snipMate.scope_aliases.php = ''
< will disable the default PHP alias.
Note: Setting this option does not disable
scope aliases entirely, only those made by
SnipMate itself. Any scope aliases created by
the user or someone else will still be in
effect.
g:snipMate.snippet_version
The snippet parser version to use. The
possible values are:
0 Use the older parser
1 Use the newer parser
If unset, SnipMate defaults to version 0. The
value of this option is also used for all
.snippet files. See |SnipMate-parser-versions|
for more information.
g:snipMate.override
As detailed below, when two snippets with the
same name and description are loaded, both are
kept and differentiated by the location of the
file they were in. When this option is enabled
(set to 1), the snippet originating in the
last loaded file is kept, similar to how Vim
maps and other settings work. Note: Load order
is determined by 'runtimepath'.
Duplicates are only dropped after reading one
snippet file. If multiple files contain a
snippet see always_choose_first
g:snipMate.always_choose_first
Always choose first snippet if there are
multiple left
g:snipMate.description_in_completion
If set to 1 (default is 0), snippet
descriptions will be included in the popup
menu used for snippet completion, like with
<Plug>snipMateShow.
g:snipMate['no_match_completion_feedkeys_chars']
A string inserted when no match for a trigger
is found. By default a tab is inserted
according to 'expandtab', 'tabstop', and
'softtabstop'. Set it to the empty string to
prevent anything from being inserted.
*SnipMate-mappings*
Mappings~
The mappings SnipMate uses can be customized with the |:map| commands. For
example, to change the key that triggers snippets and moves to the next
tab stop, >
:imap <C-J> <Plug>snipMateNextOrTrigger
:smap <C-J> <Plug>snipMateNextOrTrigger
Note: The noremap variants of the map commands must NOT be used.
The list of possible <Plug> mappings is as follows:
<Plug>snipMateNextOrTrigger Default: <Tab> Mode: Insert, Select
Jumps to the next tab stop or, if none exists,
try to expand a snippet. Use in both insert
and select modes.
<Plug>snipMateTrigger Default: unmapped Mode: Insert
Try to expand a snippet regardless of any
existing snippet expansion. If done within an
expanded snippet, the outer snippet's tab
stops are lost, unless expansion failed.
<Plug>snipMateBack Default: <S-Tab> Mode: Insert, Select
Jump to the previous tab stop, if it exists.
Use in both insert and select modes.
<Plug>snipMateShow Default: <C-R><Tab> Mode: Insert
Show all available snippets (that start with
the previous text, if it exists). Use in
insert mode.
<Plug>snipMateVisual Default: <Tab> Mode: Visual
See |SnipMate-visual|.
Additionally, <CR> is mapped in visual mode in .snippets files for retabbing
snippets.
==============================================================================
SNIPPETS *SnipMate-snippets*
*SnipMate-snippet-files*
Snippet Files ~
Note: SnipMate does not ship with any snippets.
SnipMate looks inside of each entry of 'rtp' (or |SnipMate-snippet-sources|)
for a directory named /snippets/. Based on the 'filetype' and 'syntax'
settings (dotted filetypes are parsed), the following files are read for
snippets: >
.../snippets/<scope>.snippets
.../snippets/<scope>_<name>.snippets
.../snippets/<scope>/<name>.snippets
.../snippets/<scope>/<trigger>.snippet
.../snippets/<scope>/<trigger>/<description>.snippet
where <scope> is a scope or 'filetype' or 'syntax', <name> is an arbitrary
name, <trigger> is the trigger for a snippet, and <description> is
a description used for |SnipMate-multisnip|. Snippets in the `_` scope (for
example `.../snippets/_.snippets`) are loaded for all filetypes.
A .snippet file defines a single snippet with the trigger (and description)
determined by the filename. The entire contents of the file are used as the
snippet expansion text.
Multiple snippets can be defined in *.snippets files. Each snippet definition
looks something like: >
snippet trigger optional description
expanded text
more expanded text
< *SnipMate-multisnip*
The description is optional. If it is left out, the description "default" is
used. When two snippets in the same scope have the same name and the same
description, SnipMate will try to preserve both. The g:snipMate.override
option disables this, in favor of keeping the last-loaded snippet. This can be
overridden on a per-snippet basis by defining the snippet with a bang (!): >
snippet! trigger optional description
expanded text
more expanded text
Two bangs will remove the trigger entirely from SnipMate's lookup. In this
case any snippet text is unused.
Note: Hard tabs in the expansion text are required. When the snippet is
expanded in the text and 'expandtab' is set, each tab will be replaced with
spaces based on 'softtabstop' if nonzero or 'shiftwidth' otherwise.
SnipMate currently provides two versions for the snippet parser. The
differences between them can be found at |SnipMate-parser-versions|. Which
version parser the snippets in a file should be used with can be specified
with a version line, e.g.: >
version 1
Specification of a version applies to the snippets following it. Multiple
version specifications can appear in a single file to intermix version 0 and
version 1 snippets. The default is determined by the
g:snipMate.snippet_version option. |SnipMate-options|
Comments can be made in .snippets files by starting a line with a # character.
However these can't be used inside of snippet definitions: >
# this is a correct comment
snippet trigger
expanded text
snippet another_trigger
# this isn't a comment!
expanded text
This should hopefully be clear with the included syntax highlighting.
*SnipMate-extends*
Borrowing from UltiSnips, .snippets files can also contain an extends
directive, for example: >
extends html, javascript, css
will tell SnipMate to also read html, javascript, and css snippets.
SNIPPET SYNTAX *snippet-syntax* *SnipMate-syntax*
As mentioned above, there are two versions of the snippet parser. They are
selected by the g:snipMate.snippet_version option (|SnipMate-options|) or the
version directive in .snippets files. Differences will be mentioned throughout
with a summary at |SnipMate-parser-versions|.
Anywhere in a snippet, a backslash escapes the character following it,
regardless of whether that character is special or not. That is, '\a' will
always result in an 'a' in the output. A single backslash can be output by
using '\\'.
*SnipMate-tabstops*
Tab stops~
When triggering a snippet, SnipMate will by default jump to the very end of
the snippet text. This can be changed through the use of tab stops: $1, $2,
and so on. After expansion, SnipMate will jump to the first tab stop. From
then on, the <Plug>snipMateNextOrTrigger map will jump to the next higher
numbered tabs top.
In the case of an ambiguity, for example if a stop occurs just before
a literal number, braces may be placed around the stop number to resolve it:
${3}79 is the third tab stop followed by the string "79".
NOTE: In the version 0 snippet parser, the braces are mandatory.
*SnipMate-zero-tabstop*
SnipMate will always stop at the special zero tab stop $0. Once it jumps to
the zero tab stop, snippet expansion is finished. If the zero tab stop is not
present in a definition, it will be put at the end.
For example, to place the cursor first on the id of a <div> tag, then on its
class, and finally end editing its contents: >
snippet div
<div id="$1" class="$2">
$0
</div>
< *SnipMate-placeholders*
In addition to being simply a location, each tab stop contains a placeholder,
or some default text. The placeholder can be specified for every tab stop
(including the zero tab stop) with a colon after the stop ID, as in
${1:default text}. The braces are required only when specifying a placeholder.
Once a tab stop with a placeholder is reached, the placeholder will be
selected in |Select-mode|. For example, >
snippet div
<div id="${1:id}" class="${2:class}">
$0
</div>
Finally, placeholders can contain mirrors and evaluations (detailed below)
and, in version 1 of the snippet parser, even entire other tab stops. If the
placeholder is edited, then these nested tab stops are removed and skipped
entirely.
NOTE: Version 1 of the snippet parser must be used! See
|SnipMate-parser-versions|.
For example, >
snippet div
<div${1: id="${2:id}"}${3: class="${4:class}"}>
$0
</div>
When expanded, this snippet selects the entirety of the id attribute. If this
stop is edited, then the second tab stop is removed and the third tab stop
becomes the next one. If the first tab stop is left unedited, then SnipMate
jumps to the second tab stop. This allows the user to use a single div snippet
that can be used for instances where the id or class attributes are desired
and those where they are not.
*SnipMate-mirrors*
Mirrors~
A mirror is simply a copy of a tab stop's text, updated as the tab stop is
edited. These look like a tab stop without a placeholder; $1 for example. In
the event that no placeholder is specified for a certain tab stop--say $1--the
first instance becomes the tab stop and the rest become mirrors.
Additionally, in version 1 of the parser, substitutions similar to
|:substitute| can be performed. For instance ${1/foo/bar/g} will replace all
instances of "foo" in the $1 mirror with "bar". This uses |substitute()|
behind the scenes.
Note: Just like with tab stops, braces can be used to avoid ambiguities: ${1}2
is a mirror of the first tab stop followed by a 2. Version 0 of the snippet
parser offers no way to resolve such ambiguities. Version 0 also requires that
a tabstop have a placeholder before its mirrors work.
As an example, >
snippet for
for ($1 = ${2:start}; ${1:i} < ${3:end}; $1${4:++}) {
${0:/* code */}
}
< *SnipMate-eval*
Expression Evaluation~
Snippets can contain Vim script expressions that are evaluated as the snippet
is expanded. Expressions are specified inside backticks: >
snippet date
`strftime("%Y-%m-%d")`
If the expression results in any Vim error, the error will be displayed (or
found in :messages) and the result of the expression will be the empty string.
Filename([{expr}] [, {defaultText}]) *SnipMate-Filename()*
Since the current filename is used often in snippets, a default function
has been defined for it in SnipMate.vim, appropriately called Filename().
With no arguments, the default filename without an extension is returned;
the first argument specifies what to place before or after the filename,
and the second argument supplies the default text to be used if the file
has not been named. "$1" in the first argument is replaced with the filename;
if you only want the filename to be returned, the first argument can be left
blank. Examples: >
snippet filename
`Filename()`
snippet filename_with_default
`Filename('', 'name')`
snippet filename_foo
`Filename('$1_foo')`
The first example returns the filename if it the file has been named, and an
empty string if it hasn't. The second returns the filename if it's been named,
and "name" if it hasn't. The third returns the filename followed by "_foo" if
it has been named, and an empty string if it hasn't.
*SnipMate-visual*
The VISUAL Stop~
While tab stops have numeric IDs, a special one exists with the ID 'VISUAL'.
When a snippet is expanded, if any text had been grabbed with the
snipMateVisual mapping (see |SnipMate-mappings|), all instances of the VISUAL
stop will be replaced with it. Both transformations as well as a default
placeholder can be used with the VISUAL stop.
Note: Both $VISUAL and ${VISUAL} are valid in version 1 of the snippet parser.
In version 0, only {VISUAL} is valid (without the $), and neither
transformations nor a default placeholder can be used.
Example: >
snippet div
<div>
${0:${VISUAL:<!-- content -->}}
</div>
<
*SnipMate-parser-versions*
Parser Versions~
SnipMate provides two versions for its snippet parser. Version 0 is the legacy
regex based version and is updated sparingly. Version 1 is the revamped
version with new features. Any newly developed features will likely only be
available to version 1 users.
Which version is used is determined by version directives in snippet files
(|SnipMate-snippet-files|) and by the g:snipMate.snippet_version option
(|SnipMate-options|).
A complete list of current differences is as follows:
- Version 0 does not support nested placeholders such as ${1:"${2:foo}"} at
all.
- Backslash escaping is guaranteed to work in version 1. In certain edge cases
this may not work in version 0.
- Certain syntactic errors, such as a missing closing brace for a tabstop, are
more gracefully handled in version 1. In most cases, the parser will either
discard the error or, as in the previous example, end an item at the end of
line. Version 0 may not be predictable in this regard.
- Braces are not mandatory in version 1. SnipMate will determine which
instance of a stop ID to use based on the presence of a placeholder, or
whichever instance occurs first. Braces can therefore be used to
disambiguate between stop 12, $12, and stop 1 followed by a 2: ${1}2. In
other words, version 0 makes a distinction between a mirror and a stop while
version 1 resolves the differences for you.
- Placeholders are not mandatory to enable mirror support in version 1.
- Version 0 uses the confusing syntax {VISUAL} to refer to visual content.
Version 1 treats it as just another stop ID, so both $VISUAL and ${VISUAL}
work. Plus version 1 allows a default value in case no visual selection has
been made.
- Transformations similar to |:substitute| can be preformed on any mirror,
including visual content.
*SnipMate-deprecate*
Deprecation~
The legacy parser, version 0, is deprecated. It is currently still the default
parser, but that will be changing. NOTE that switching which parser you use
could require changes to your snippets--see the previous section.
To continue using the old parser, set g:snipMate.snippet_version (see
|SnipMate-options|) to 0 in your |vimrc|.
Setting g:snipMate.snippet_version to either 0 or 1 will remove the start up
message. One way this can be done--to use the new parser--is as follows:
>
let g:snipMate = { 'snippet_version' : 1 }
<
==============================================================================
SNIPPET SOURCES *SnipMate-snippet-sources*
SnipMate is configurable.
plugin/SnipMate.vim assigns a couple important keys: >
" default implementation collecting snippets by handlers
let g:SnipMate['get_snippets'] = SnipMate#GetSnippets
" default handler:
let g:SnipMateSources['default'] = SnipMate#DefaultPool
You can override both of those settings.
You can see that the default set of snippets is determined by Vim's 'rtp'.
Example 1:~
autoload/SnipMate_python_demo.vim shows how you can register additional
sources such as creating snippets on the fly representing python function
definitions found in the current file.
Example 2:~
Add to your ~/.vimrc: For each new snippet add a second version ending in _
adding folding markers >
let g:commentChar = {
\ 'vim': '"',
\ 'c': '//',
\ 'cpp': '//',
\ 'sh': '#',
\ 'python': '#'
\ }
" url https://github.com/garbas/vim-snipmate/issues/49
fun! AddFolding(text)
return substitute(a:text,'\n'," ".g:commentChar[&ft]." {{{\n",1)."\n".g:commentChar[&ft]." }}}"
endf
fun! SnippetsWithFolding(scopes, trigger, result)
" hacky: temporarely remove this function to prevent infinite recursion:
call remove(g:SnipMateSources, 'with_folding')
" get list of snippets:
let result = SnipMate#GetSnippets(a:scopes, substitute(a:trigger,'_\(\*\)\?$','\1',''))
let g:SnipMateSources['with_folding'] = funcref#Function('SnippetsWithFolding')
" add folding:
for k in keys(result)
let a:result[k.'_'] = map(result[k],'AddFolding(v:val)')
endfor
endf
" force setting default:
runtime plugin/SnipMate.vim
" add our own source
let g:SnipMateSources['with_folding'] = funcref#Function('SnippetsWithFolding')
See |SnipMate-syntax| for more details about all possible relative locations
to 'rtp' can be found in.
==============================================================================
KNOWN ISSUES *SnipMate-known-issues*
SnipMate.vim currently has the following disadvantages to TextMate's snippets:
- Placeholders cannot span multiple lines.
- Activating snippets in different scopes of the same file is
not possible.
- Vim formatting with fo=t or fo=a can mess up SnipMate.
Perhaps some of these features will be added in a later release.
==============================================================================
CHANGELOG *SnipMate-changelog*
0.89 - 2016-05-29
-----------------
* Various regex updates to legacy parser
* Addition of double bang syntax to completely remove a snippet from lookup
* Group various SnipMate autocommands
* Support setting 'shiftwidth' to 0
* Parser now operates linewise, adding some flexibility
* Mirror substitutions are more literal
* Mirror length is calculated correctly when substitutions occur
0.88 - 2015-04-04
-----------------
* Implement simple caching
* Remove expansion guards
* Add `:SnipMateLoadScope` command and buffer-local scope aliases
* Load `<scope>_*.snippets` files
* Use CursorMoved autocmd events entirely
* The nested branch has been merged
* A new snippet parser has been added. The g:snipmate.version as well as
version lines in snippet files determines which is used
* The new parser supports tab stops placed within placeholders,
substitutions, non-consecutive stop numbers, and fewer ambiguities
* The stop jumping code has been updated
* Tests have been added for the jumping code and the new parser
* The override branch has been merged
* The g:snipMate.override option is added. When enabled, if two snippets
share the same name, the later-loaded one is kept and the other discarded
* Override behavior can be enabled on a per-snippet basis with a bang (!) in
the snippet file
* Otherwise, SnipMate tries to preserve all snippets loaded
* Fix bug with mirrors in the first column
* Fix bug with tabs in indents
<http://github.com/garbas/vim-snipmate/issues/143>
* Fix bug with mirrors in placeholders
* Fix reading single snippet files
* Fix the use of the visual map at the end of a line
* Fix expansion of stops containing only the zero tab stop
* Remove select mode mappings
* Indent visual placeholder expansions and remove extraneous lines
<http://github.com/garbas/vim-snipmate/issues/177>
<http://github.com/garbas/vim-snipmate/issues/178>
0.87 - 2014-01-04
-----------------
* Stop indenting empty lines when expanding snippets
* Support extends keyword in .snippets files
* Fix visual placeholder support
* Add zero tabstop support
* Support negative 'softtabstop'
* Add g:snipMate_no_default_aliases option
* Add <Plug>snipMateTrigger for triggering an expansion inside a snippet
* Add snipMate#CanBeTriggered() function
0.86 - 2013-06-15
-----------------
* Use more idiomatic <Plug> maps
* Remove most select mode mappings
* Fix disappearing variables bug (hpesoj)
* Fix cursor position bug when a variable is on the same line as the stop
* Fix undo point creation causing problems with Supertab
* Fix bug where SnipMate would use a typed trigger as a regular expression
0.85 - 2013-04-03
-----------------
* Allow trigger key customization
* Enable undoing of snippet expansion
* Support backslash escaping in snippets
* Add support for {VISUAL}
* Expand filetype extension with scope_aliases
* Add expansion guards
* Enable per-buffer expansion of snippets
* Fix 'cpo' compatibility
* Update supertab compatibility
* Enable customization of various things through g:SnipMate
* Disable spelling in snippet files
* Highlight trigger names in .snippets files
* Update many snippets
* Separate sample snippets into separate repository
0.84
----
* Unreleased version by Michael Sanders, available on his GitHub,
<https://github.com/msanders/snipmate.vim>
0.83 - 2009-07-13
-----------------
* Last release done by Michael Sanders, available at
<http://www.vim.org/scripts/script.php?script_id=2540>
==============================================================================
CONTACT *SnipMate-contact* *SnipMate-author*
SnipMate is currently maintained by:
- Rok Garbas
- Marc Weber (marco-oweber@gmx.de)
- Adnan Zafar
For bug reports, issues, or questions, check out the Issues page on GitHub:
https://github.com/garbas/vim-snipmate/issues
The original author, Michael Sanders, can be reached at:
msanders42+snipmate <at> gmail <dot> com
==============================================================================
LICENSE *SnipMate-license*
SnipMate is released under the MIT license:
Copyright 2009-2010 Michael Sanders. All rights reserved.
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.
==============================================================================
vim:tw=78:ts=8:ft=help:norl: