This repository has been archived by the owner on Mar 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
adaa7e8
commit cc80dea
Showing
4 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Copyright 2019 Zandr Martin | ||
|
||
Redistribution and use in source and binary forms, with or without modification, | ||
are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
2. 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. | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
## vimlfmt | ||
|
||
A formatter for VimL code. | ||
|
||
### Status | ||
|
||
Very, very alpha. [Maybe abandoned?](#maybe-abandoned) Use at your own risk. | ||
|
||
### Usage | ||
|
||
See `vimlfmt --help`, but in general: | ||
|
||
vimlfmt < input.vim > output.vim | ||
|
||
### Formatting Options | ||
|
||
There aren't any. This formats VimL using two-space indents, tries to keep lines | ||
shorter than 80 columns, and uses six spaces (three indents) for continued | ||
lines. At this point in the project I do not want to add the complexity of | ||
formatting options (VimL is already complicated enough). | ||
|
||
### Limitations | ||
|
||
- Primarily, most commands are parsed as generic `ExCmd` nodes, which include | ||
the arguments as a single raw string literal, so no formatting is done. | ||
- There is no way to tell `vimlfmt` not to format part of a file. | ||
- If some portion of the code doesn't parse, no formatting is done at all. | ||
|
||
### Strategy | ||
|
||
This formatter parses the input VimL into an abstract syntax tree and then | ||
writes out every node of that tree. Other formatters I've looked at do more of | ||
an "in-place" style of formatting, so I'm not sure if the way vimlfmt works is | ||
optimal. | ||
|
||
### Maybe abandoned? | ||
|
||
Writing VimL isn't too bad (it's not great, but it's _mostly_ Ruby- or | ||
Python-like). Parsing and formatting VimL is a **nightmare**. Its unending | ||
inconsistency and unusual line continuation syntax make it much harder to format | ||
than other languages (as far as I can tell). | ||
|
||
There's still a lot to be done, but I'm pretty burned out on it for now. That | ||
said, contributions are welcome! Having some help would be quite motivational. | ||
It would be great if this project became something people could actually use. | ||
|
||
### License | ||
|
||
BSD 2-clause |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Copyright 2019 Zandr Martin | ||
|
||
Redistribution and use in source and binary forms, with or without modification, | ||
are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
2. 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. | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
## viml-parser-rs | ||
|
||
A parser for VimL, written in Rust. | ||
|
||
This started life as a direct port of [the vim-jp | ||
parser](https://github.com/vim-jp/vim-vimlparser) and grew from there. As of | ||
commit 4f09a92, output of this parser exactly matched output of the original for | ||
every .vim file in my ~/.config/nvim/ directory (45-50 plugins). Since that | ||
point, output no longer matches, because I have changed some behavior (e.g. this | ||
continues parsing after a top-level `finish`) and fixed some bugs. | ||
|
||
### Usage | ||
|
||
There are two exposed functions: `parse_lines()` and `parse_file()`. Both will | ||
return a `Node` enum, the specific variant of which identifies the node type, | ||
and contains an inner struct with data specific to that node. See the | ||
documentation for further details. | ||
|
||
### License | ||
|
||
BSD 2-clause |