• Stars
    star
    144
  • Rank 255,530 (Top 6 %)
  • Language
    Vim Script
  • License
    Other
  • Created about 8 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

⚡ Vim Script Parser written in Go

Vim Script Parser written in Go

CI Status codecov Sourcegraph GoDoc

This repository is the fork of https://github.com/ynkdir/vim-vimlparser and it provides Go-ish interface with performance improvement.

The Fastest Vim Script Parser!

Benchmarks

$ pwd
/home/vim-jp/src/github.com/ynkdir/vim-vimlparser

$ git rev-parse HEAD
2fff43c58968a18bc01bc8304df68bde01af04d9

$ wc -l < autoload/vimlparser.vim
5195

$ time vim -u NONE -N --cmd "let &rtp .= ',' . getcwd()" --cmd "silent call vimlparser#test('autoload/vimlparser.vim')" -c ":q"
vim -u NONE -N --cmd "let &rtp .= ',' . getcwd()" --cmd  -c ":q"  48.88s user 0.05s system 99% cpu 48.942 total

$ python3 -V
Python 3.5.0

$ time python3 py/vimlparser.py autoload/vimlparser.vim > /dev/null
python3 py/vimlparser.py autoload/vimlparser.vim > /dev/null  4.17s user 0.04s system 99% cpu 4.236 total

$ pypy3 -V
Python 3.2.5 (b2091e973da69152b3f928bfaabd5d2347e6df46, Mar 04 2016, 07:08:30)
[PyPy 2.4.0 with GCC 5.3.0]

$ time pypy3 py/vimlparser.py autoload/vimlparser.vim > /dev/null
pypy3 py/vimlparser.py autoload/vimlparser.vim > /dev/null  2.63s user 0.06s system 99% cpu 2.694 total

$ node --version
v4.2.3

$ time node js/vimlparser.js autoload/vimlparser.vim > /dev/null
node js/vimlparser.js autoload/vimlparser.vim > /dev/null  0.77s user 0.04s system 125% cpu 0.644 total

$ go get github.com/vim-jp/go-vimlparser/cmd/vimlparser
$ time vimlparser autoload/vimlparser.vim > /dev/null
vimlparser autoload/vimlparser.vim > /dev/null  0.25s user 0.03s system 114% cpu 0.244 total
Language Time (sec)
Vim script 48.88s
Python3 4.17s
pypy3 2.63s
node 0.77s
Go 0.25s

Note that, in addition to the Go lang speed, I added performance improvement for Go implementation.

Rich interface compared to other implementation

go-vimlparser is written in Go which is typed language and I added Go-ish interface, so you can see each node fields. e.g. https://godoc.org/github.com/vim-jp/go-vimlparser/ast#Function

package doc
go-vimlparser GoDoc
go-vimlparser/ast GoDoc
go-vimlparser/token GoDoc

CLI tool

Installation

go get github.com/vim-jp/go-vimlparser/cmd/vimlparser

Usage

$ echo 'let x = 1' | vimlparser
(let = x 1)
$ vimlparser autoload/vimlparser.vim | head -n 5
; vim:set ts=8 sts=2 sw=2 tw=0 et:
;
; VimL parser - Vim Script Parser
;
; License: This file is placed in the public domain.

As a Lint Tool

You can use it to detect syntax error. It doesn't check much things compared to existing lint tool for Vim script, but it runs fast even if you pass lots of files to it.

$ vimlparser **/*.vim > /dev/null
test/test_err_funcarg_duplicate.vim:1:20: vimlparser: E853: Duplicate argument name: b
test/test_err_funcarg_firstline.vim:1:14: vimlparser: E125: Illegal argument: firstline
test/test_err_funcarg_lastline.vim:1:14: vimlparser: E125: Illegal argument: lastline
test/test_err_funcarg.vim:1:44: vimlparser: E125: Illegal argument: a:bar
test/test_err_funcname.vim:11:10: vimlparser: E128: Function name must start with a capital or contain a colon: foo
test/test_err_toomanyarg.vim:1:9: vimlparser: E740: Too many arguments for function
test/test_err_varname.vim:1:5: vimlparser: E461: Illegal variable name: foo:bar
test/test_issue16_err_line_continuation_lnum2.vim:3:9: vimlparser: E488: Trailing characters: z
test/test_issue16_err_line_continuation_lnum.vim:2:9: vimlparser: E488: Trailing characters: z
test/test_neo_tnoremap.vim:1:1: vimlparser: E492: Not an editor command: tnoremap <Esc> <C-\><C-N>
test/test_noneo_tnoremap.vim:1:1: vimlparser: E492: Not an editor command: tnoremap <Esc> <C-\><C-N>
test/test_xxx_colonsharp.vim:2:6: vimlparser: unexpected token: :
test/test_xxx_err_funcarg_space_comma.vim:19:14: vimlparser: E475: Invalid argument: White space is not allowed before comma
" sample
command! LintVimLParser :silent cexpr system('vimlparser ' . expand('%') . ' > /dev/null')
augroup lint-vimlparser
  autocmd!
  autocmd BufWritePost *.vim LintVimLParser
augroup END

Credit

@ynkdir for https://github.com/ynkdir/vim-vimlparser

🐦 Author

Original Author: haya14busa (https://github.com/haya14busa)

Maintenance Author: vim-jp

More Repositories

1

vital.vim

A comprehensive Vim utility functions for Vim plugins
Vim Script
573
star
2

issues

有志で既知のバグや要望を検討・管理し、オフィシャルへの還元をしていきます。
JavaScript
341
star
3

vimdoc-ja

A project which translate Vim documents into Japanese.
Vim Script
333
star
4

vim-vimlparser

Vim script parser
Vim Script
161
star
5

vim-cpp

c or cpp syntax files
Vim Script
145
star
6

reading-vimrc

vimrc読書会まとめ
JavaScript
106
star
7

vim-jp.github.io

The website for vim-jp.org
JavaScript
92
star
8

vim-go-extra

Extra plugin for golang
Vim Script
90
star
9

vimdoc-ja-working

vimdoc-ja working repository
Vim Script
76
star
10

ekiden

vim-jp記事執筆企画「駅伝」の管理リポジトリ
Astro
51
star
11

syntax-vim-ex

An excellent Vim's syntax highlighting file for Vim script
Vim Script
49
star
12

vimconf

Obsoleted. Moved to https://github.com/vim-jp/vimconf.org
CSS
45
star
13

vimconf.org

An International Vim Conference
HTML
45
star
14

nvimdoc-ja

neovimヘルプの日本語翻訳です
Shell
42
star
15

vim-obsoleted

Please use vim/vim. Vim came to github.
C
32
star
16

autofmt

Text Formatting Plugin
Vim Script
28
star
17

slacklog-generator

Archive generator for Slack
Go
26
star
18

ctags

Use https://ctags.io instead (This was fork of http://ctags.sourceforge.net/)
C
26
star
19

lang-ja

Manage Japanese language files which distributed with vim.
Roff
21
star
20

icon

Icon storage for vim-jp
19
star
21

vital-complete

Completion for vital.vim
Vim Script
14
star
22

vim-ci

travis-ci stub project for Vim (deprecated)
Shell
14
star
23

slacklog

Archives of vim-jp.slack.com
12
star
24

redirects

Provide redirects for Vim binaries
HTML
11
star
25

vim-java

java syntax files
Vim Script
9
star
26

vimdoc-en

Vim Script
7
star
27

vim-sweep_trail

「Vim script テクニックバイブル〜Vim使いの魔法の杖」サンプルプラグイン
Vim Script
7
star
28

vim-streem

streem-lang syntax file for vim
Vim Script
6
star
29

ujihisa.vim-3

ujihisa.vim#3 -- an international Vim conference
Ruby
3
star
30

ujihisa.vim-2

ujihisa.vim #2
Ruby
3
star
31

vim-users-jp

Older contents on vim-users.jp
HTML
3
star
32

coc

3
star
33

debug.vim

so far jdb and gdb
2
star
34

vim-script-styleguide-sketch

1
star
35

sandbox

CSS
1
star
36

miv

C
1
star