Adding a skel for plasma workspace

This commit is contained in:
2020-06-14 06:03:42 +05:30
parent add7d3ce93
commit b67551a674
531 changed files with 105507 additions and 0 deletions
@@ -0,0 +1,18 @@
.DS_Store
.project
doc
distribution/
.sourcescribe_index
*.swp
*.swo
*.pyc
cscope.out
*~
# symlinks created for pathogen
/ftplugin
/doc
# Distribution files
# */sparkup
# */sparkup.py
@@ -0,0 +1,48 @@
# Makefile for sparkup distribution
# TODO: this should use a separate build dir to copy SPARKUP_PY into.
# SPARKUP_PY should not reside in the Vim runtime dir (getting not updated via Git!)
SPARKUP_PY=sparkup.py
VERSION=`date '+%Y%m%d'`
README=README.md
.PHONY: all textmate vim textmate-dist vim-dist plugins plugins-pre generic all-dist
all: plugins
plugins-pre:
mkdir -p distribution
plugins: plugins-pre all-dist
textmate-dist: textmate
cd TextMate && zip -9r ../distribution/sparkup-textmate-${VERSION}.zip . && cd ..
vim-dist: vim
cd vim && zip -9r ../distribution/sparkup-vim-${VERSION}.zip . && cd ..
generic-dist: generic
cd generic && zip -9r ../distribution/sparkup-generic-${VERSION}.zip . && cd ..
all-dist:
zip -9r distribution/sparkup-${VERSION}.zip generic vim textmate README.md -x */sparkup-readme.txt
cp distribution/sparkup-${VERSION}.zip distribution/sparkup-latest.zip
generic:
cat ${SPARKUP_PY} > generic/sparkup
chmod +x generic/sparkup
#cp ${README} generic/sparkup-readme.txt
textmate:
#cp ${README} TextMate/sparkup-readme.txt
vim: vim/doc/sparkup.txt
# create pathogen friendly structure
vim-pathogen: vim ftplugin doc
ftplugin doc:
ln -s vim/$@
# Add asterisks to title, so it gets matched by `:helptags`
vim/doc/sparkup.txt: ${README}
mkdir -p $(@D)
sed '1s/.*/*\0*/' $< > $@
+175
View File
@@ -0,0 +1,175 @@
Sparkup
=======
**Sparkup lets you write HTML code faster.** Don't believe us?
[See it in action!](http://www.youtube.com/watch?v=Jw3jipcenKc)
Fixed by Zhao:
This is a fork of original version. This version support both python 2 and 3.
You can write HTML in a CSS-like syntax, and have Sparkup handle the expansion to full HTML
code. It is meant to help you write long HTML blocks in your text editor by letting you
type less characters than needed.
Sparkup is written in Python, and requires Python 2.5 or newer (2.5 is preinstalled in
Mac OS X Leopard). Sparkup also offers integration into common text editors. Support for VIM
and TextMate are currently included.
A short screencast is available here:
[http://www.youtube.com/watch?v=Jw3jipcenKc](http://www.youtube.com/watch?v=Jw3jipcenKc)
Usage and installation
----------------------
You may download Sparkup from GitHub. [Download the latest version here](http://github.com/rstacruz/sparkup/downloads).
- **TextMate**: Simply double-click on the `Sparkup.tmbundle` package in Finder. This
will install it automatically. In TextMate, open an HTML file (or set the document type to
HTML) type in something (e.g., `#header > h1`), then press `Ctrl` + `E`. Pressing `Tab`
will cycle through empty elements.
- **VIM**: See the `vim/README.txt` file for installation. In VIM,
create or open an HTML file (or set the filetype to ``html``), type in something (e.g.
`#header > h1`), then press `<C-E>` whilst in **insert mode** to expand to HTML.
Pressing `<C-n>` will cycle through empty elements. Variables specified in
`vim/README.txt` can be used to customise key mappings, and to add **normal mode** mappings
as well.
- **Others/command line use**: You may put `sparkup` in your `$PATH` somewhere. You may then
invoke it by typing `echo "(input here)" | sparkup`, or `sparkup --help` for a list of commands.
Credits
-------
Sparkup is written by Rico Sta. Cruz and is released under the MIT license.
This project is inspired by [Zen Coding](http://code.google.com/p/zen-coding/) of
[Vadim Makeev](http://pepelsbey.net). The Zen HTML syntax is forward-compatible with Sparkup
(anything that Zen HTML can parse, Sparkup can too).
The following people have contributed code to the project:
- Guillermo O. Freschi (Tordek @ GitHub)
Bugfixes to the parsing system
- Eric Van Dewoestine (ervandew @ GitHub)
Improvements to the VIM plugin
Examples
--------
**`div`** expands to:
```html
<div></div>
```
**`div#header`** expands to:
```html
<div id="header"></div>
```
**`div.align-left#header`** expands to:
```html
<div id="header" class="align-left"></div>
```
**`div#header + div#footer`** expands to:
```html
<div id="header"></div>
<div id="footer"></div>
```
**`#menu > ul`** expands to:
```html
<div id="menu">
<ul></ul>
</div>
```
**`#menu > h3 + ul`** expands to:
```html
<div id="menu">
<h3></h3>
<ul></ul>
</div>
```
**`#header > h1{Welcome to our site}`** expands to:
```html
<div id="header">
<h1>Welcome to our site</h1>
</div>
```
**`a[href=index.html]{Home}`** expands to:
```html
<a href="index.html">Home</a>
```
**`ul > li*3`** expands to:
```html
<ul>
<li></li>
<li></li>
<li></li>
</ul>
```
**`ul > li.item-$*3`** expands to:
```html
<ul>
<li class="item-1"></li>
<li class="item-2"></li>
<li class="item-3"></li>
</ul>
```
**`ul > li.item-$*3 > strong`** expands to:
```html
<ul>
<li class="item-1"><strong></strong></li>
<li class="item-2"><strong></strong></li>
<li class="item-3"><strong></strong></li>
</ul>
```
**`table > tr*2 > td.name + td*3`** expands to:
```html
<table>
<tr>
<td class="name"></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td class="name"></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
```
**`#header > ul > li < p{Footer}`** expands to:
```html
<!-- The < symbol goes back up the parent; i.e., the opposite of >. -->
<div id="header">
<ul>
<li></li>
</ul>
<p>Footer</p>
</div>
```
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>beforeRunningCommand</key>
<string>nop</string>
<key>command</key>
<string>#!/usr/bin/env python2
import sys; import os; sys.path.append(os.getenv('TM_BUNDLE_SUPPORT')); import sparkup
# You may change these options to your liking.
# Those starting with # are comments (disabled).
options = {
'textmate': True,
'no-last-newline': True,
'indent-tabs': False,
#'start-guide-format': 'Begin %s',
#'end-guide-format': 'End %s',
}
sparkup.Router().start(options=options)</string>
<key>fallbackInput</key>
<string>line</string>
<key>input</key>
<string>selection</string>
<key>keyEquivalent</key>
<string>^e</string>
<key>name</key>
<string>Sparkup expand</string>
<key>output</key>
<string>insertAsSnippet</string>
<key>uuid</key>
<string>73A48D2B-D843-42A1-A288-0D1A6380043B</string>
</dict>
</plist>
@@ -0,0 +1 @@
../../../sparkup.py
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Sparkup</string>
<key>ordering</key>
<array>
<string>AA687F82-BF47-477C-A832-D3671736EA81</string>
</array>
<key>uuid</key>
<string>0CDE6908-2EF0-4E86-A9C1-5AC12E320414</string>
</dict>
</plist>
@@ -0,0 +1 @@
au BufNewFile,BufRead *.hbs set filetype=html
@@ -0,0 +1,22 @@
Copyright (c) 2009, Rico Sta. Cruz.
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.
+184
View File
@@ -0,0 +1,184 @@
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
import sys
import sparkup
class SparkupTest:
options = {
'textmate': True,
'no-last-newline': True,
'post-tag-guides': True,
}
options = {
'default': {'textmate': True, 'no-last-newline': True, 'post-tag-guides': True},
'guides': {'textmate': True, 'no-last-newline': True, 'post-tag-guides': True, 'start-guide-format': 'Begin %s'},
'namespaced-elements': {'textmate': True, 'no-last-newline': True, 'post-tag-guides': True, 'namespaced-elements': True }
}
cases = {
'Simple test': {
'options': 'default',
'input': 'div',
'output': '<div>$1</div>$0'
},
'Class test': {
'input': 'div.lol',
'output': '<div class="lol">$1</div><!-- /.lol -->$0'
},
'ID and class test': {
'input': 'div.class#id',
'output': '<div class="class" id="id">$1</div><!-- /#id -->$0'
},
'ID and class test 2': {
'input': 'div#id.class',
'output': '<div class="class" id="id">$1</div><!-- /#id -->$0'
},
'Attributes test': {
'input': 'div#id.class[style=color:blue]',
'output': '<div style="color:blue" class="class" id="id">$1</div><!-- /#id -->$0'
},
'Multiple attributes test': {
'input': 'div[align=center][style=color:blue][rel=none]',
'output': '<div align="center" style="color:blue" rel="none">$1</div>$0'
},
'Multiple class test': {
'input': 'div.c1.c2.c3',
'output': '<div class="c1 c2 c3">$1</div><!-- /.c1.c2.c3 -->$0'
},
'Shortcut test': {
'input': 'input:button',
'output': '<input type="button" class="button" value="$1" name="$2">$0'
},
'Shortcut synonym test': {
'input': 'button',
'output': '<button>$1</button>$0',
},
'Child test': {
'input': 'div>ul>li',
'output': "<div>\n <ul>\n <li>$1</li>\n </ul>\n</div>$0"
},
'Sibling test': {
'input': 'div#x + ul+ h3.class',
'output': '<div id="x">$1</div><!-- /#x -->\n<ul>$2</ul>\n<h3 class="class">$3</h3>$0'
},
'Child + sibling test': {
'input': 'div > ul > li + span',
'output': '<div>\n <ul>\n <li>$1</li>\n <span>$2</span>\n </ul>\n</div>$0'
},
'Multiplier test 1': {
'input': 'ul > li*3',
'output': '<ul>\n <li>$1</li>\n <li>$2</li>\n <li>$3</li>\n</ul>$0'
},
'Multiplier test 2': {
'input': 'ul > li.item-$*3',
'output': '<ul>\n <li class="item-1">$1</li>\n <li class="item-2">$2</li>\n <li class="item-3">$3</li>\n</ul>$0'
},
'Multiplier test 3': {
'input': 'ul > li.item-$*3 > a',
'output': '<ul>\n <li class="item-1">\n <a href="$1">$2</a>\n </li>\n <li class="item-2">\n <a href="$3">$4</a>\n </li>\n <li class="item-3">\n <a href="$5">$6</a>\n </li>\n</ul>$0'
},
'Ampersand test': {
'input': 'td > tr.row-$*3 > td.cell-&*2',
'output': '<td>\n <tr class="row-1">\n <td class="cell-1">$1</td>\n <td class="cell-2">$2</td>\n </tr>\n <tr class="row-2">\n <td class="cell-3">$3</td>\n <td class="cell-4">$4</td>\n </tr>\n <tr class="row-3">\n <td class="cell-5">$5</td>\n <td class="cell-6">$6</td>\n </tr>\n</td>$0'
},
'Menu test': {
'input': 'ul#menu > li*3 > a > span',
'output': '<ul id="menu">\n <li>\n <a href="$1">\n <span>$2</span>\n </a>\n </li>\n <li>\n <a href="$3">\n <span>$4</span>\n </a>\n </li>\n <li>\n <a href="$5">\n <span>$6</span>\n </a>\n </li>\n</ul>$0'
},
'Back test': {
'input': 'ul#menu > li*3 > a < < div',
'output': '<ul id="menu">\n <li>\n <a href="$1">$2</a>\n </li>\n <li>\n <a href="$3">$4</a>\n </li>\n <li>\n <a href="$5">$6</a>\n </li>\n</ul>\n<div>$7</div>$0'
},
'Expand test': {
'input': 'p#menu > table+ + ul',
'output': '<p id="menu">\n <table>\n <tr>\n <td>$1</td>\n </tr>\n </table>\n <ul>$2</ul>\n</p>$0'
},
'Text with dot test': {
'input': 'p { text.com }',
'output': '<p> text.com </p>$0'
},
'Attribute with dot test': {
'input': 'p [attrib=text.com]',
'output': '<p attrib="text.com">$1</p>$0'
},
'PHP tag test': {
'input': 'php',
'output': '<?php\n $1\n?>$0',
},
'Eruby tag test': {
'input': 'erb:p',
'output': '<%= %>$0',
},
'ERB block test': {
'input': 'erb:b',
'output': '<% $2 %>\n $1\n<% end %>$0'
},
'Tag name case (#49)': {
'input': 'groupId{foobar}',
'output': '<groupId>foobar</groupId>$0'
},
'Nested curly braces test': {
'input': 'p{{{ title }}}',
'output': '<p>{{ title }}</p>$0'
},
'Nested curly braces test (#54)': {
'input': 'html>head>title{${title}}',
'output': '<html>\n <head>\n <title>${title}</title>\n </head>\n</html>$0'
},
'HTML component element with dash test': {
'input': 'my-html-component',
'output': '<my-html-component>$1</my-html-component>$0'
},
'XML namespaced element': {
'options': 'namespaced-elements',
'input': 'namespaced-ul',
'output': '<namespaced:ul>$1</namespaced:ul>$0'
},
# Add: text test, broken test, multi-attribute tests, indentation test, start and end comments test
}
def run(self):
"""Run Forrest run!"""
failures = 0
print("Test results:")
for name, case in self.cases.iteritems():
try:
options_key = case['options']
except:
options_key = 'default'
try:
options = self.options[options_key]
except:
options = self.options['default']
# Output buffer
r = sparkup.Router()
input = case['input']
output = r.start(options=options, str=input, ret=True)
del r
# Did it work?
result = output == case['output']
if result:
result_str = " OK "
else:
result_str = "FAIL"
print(" - %-30s [%s]" % (name, result_str))
if not result:
failures += 1
print("= %s" % input.replace("\n", "\n= "))
print("Actual output (condensed):")
print(" | '%s'" % output.replace("\n", r"\n").replace('"', '\"'))
print("Actual output:")
print(" | %s" % output.replace("\n", "\n | "))
print("Expected:")
print(" | %s" % case['output'].replace("\n", "\ n| "))
return failures
if __name__ == '__main__':
s = SparkupTest()
sys.exit(s.run())
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,69 @@
Installation
------------
With Pathogen
^^^^^^^^^^^^^
If you are using tpope's vim-pathogen, install as follows:
cd ~/.vim/bundle ; git clone https://github.com/rstacruz/sparkup.git
cd sparkup
make vim-pathogen
With Vundle
^^^^^^^^^^^
If using Vundle, you can specify Sparkup as a bundle and installation will happen
automatically. Add this to your Vim configuration:
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
and run the standard installation command for Vundle:
:PluginInstall
Manual installation
^^^^^^^^^^^^^^^^^^^
1. Copy the contents of vim/ftplugin/ to your ~/.vim/ftplugin directory.
(Assuming your current dir is sparkup/vim/)
$ cp -R ftplugin ~/.vim/
2. Copy the sparkup.py file to your ~/.vim directory
(Assuming your current dir is sparkup/vim/)
$ cp ../sparkup.py ~/.vim/
Configuration
-------------
Customise the Sparkup's configuration within Vim by specifying some or all of the following
as variables within your Vim configuration using the ``let`` directive.
g:sparkup (Default: 'sparkup') -
Location of the sparkup executable. You shouldn't need to change this
setting if you used the install option above.
g:sparkupArgs (Default: '--no-last-newline') -
Additional args passed to sparkup.
g:sparkupExecuteMapping (Default: '<c-e>') -
Mapping used to execute sparkup within insert mode.
g:sparkupNextMapping (Default: '<c-n>') -
Mapping used to jump to the next empty tag/attribute within insert mode.
g:sparkupMaps (Default: 1) -
Set up automatic mappings for Sparkup. If set to 0, this can be
used to disable creation of any mappings, which is useful if
full customisation is required.
g:sparkupMapsNormal (Default: 0) -
Set up mappings for normal mode within Vim. The same execute and next
mappings configured above will apply to normal mode if this option is
set.
@@ -0,0 +1 @@
../../../sparkup.py
@@ -0,0 +1,129 @@
" Sparkup
" Installation:
" Copy the contents of vim/ftplugin/ to your ~/.vim/ftplugin directory:
"
" $ cp -R vim/ftplugin ~/.vim/ftplugin/
"
" or use one of the automated methods specified in the README.txt file.
"
" Configuration:
" g:sparkup (Default: 'sparkup') -
" Location of the sparkup executable. You shouldn't need to change this
" setting if you used the install option above.
"
" g:sparkupArgs (Default: '--no-last-newline') -
" Additional args passed to sparkup.
"
" g:sparkupExecuteMapping (Default: '<c-e>') -
" Mapping used to execute sparkup within insert mode.
"
" g:sparkupNextMapping (Default: '<c-n>') -
" Mapping used to jump to the next empty tag/attribute within insert mode.
"
" g:sparkupMaps (Default: 1) -
" Set up automatic mappings for Sparkup. If set to 0, this can be
" used to disable creation of any mappings, which is useful if
" full customisation is required.
"
" g:sparkupMapsNormal (Default: 0) -
" Set up mappings for normal mode within Vim. The same execute and next
" mappings configured above will apply to normal mode if this option is
" set.
if !exists('g:sparkupExecuteMapping')
let g:sparkupExecuteMapping = '<c-e>'
endif
if !exists('g:sparkupNextMapping')
let g:sparkupNextMapping = '<c-n>'
endif
if !exists('g:sparkupMaps')
let g:sparkupMaps = 1
endif
if !exists('g:sparkupMapsNormal')
let g:sparkupMapsNormal = 0
endif
inoremap <buffer> <Plug>SparkupExecute <c-g>u<Esc>:call <SID>Sparkup()<cr>
inoremap <buffer> <Plug>SparkupNext <c-g>u<Esc>:call <SID>SparkupNext()<cr>
if g:sparkupMaps
if ! hasmapto('<Plug>SparkupExecute', 'i')
exec 'imap <buffer> ' . g:sparkupExecuteMapping . ' <Plug>SparkupExecute'
endif
if ! hasmapto('<Plug>SparkupNext', 'i')
exec 'imap <buffer> ' . g:sparkupNextMapping . ' <Plug>SparkupNext'
endif
if g:sparkupMapsNormal
if ! hasmapto('<Plug>SparkupExecute', 'n')
exec 'nnoremap <buffer> ' . g:sparkupExecuteMapping . ' :call <SID>Sparkup()<cr>'
endif
if ! hasmapto('<Plug>SparkupNext', 'n')
exec 'nnoremap <buffer> ' . g:sparkupNextMapping . ' :call <SID>SparkupNext()<cr>'
endif
endif
endif
if exists('*s:Sparkup')
finish
endif
function! s:Sparkup()
if !exists('s:sparkup')
let s:sparkup = exists('g:sparkup') ? g:sparkup : 'sparkup'
if !executable(s:sparkup)
" If g:sparkup is not configured (and/or not found in $PATH),
" look for sparkup.vim in Vim's runtimepath.
" XXX: quite expensive for a Pathogen-like environment (where &rtp is huge)
let paths = substitute(escape(&runtimepath, ' '), '\(,\|$\)', '/**\1', 'g')
let s:sparkup = fnamemodify(findfile('sparkup.py', paths), ':p')
if !filereadable(s:sparkup)
echohl WarningMsg
echom 'Warning: could not find sparkup/sparkup.py on your path or in your vim runtime path.'
echohl None
unlet s:sparkup
return
endif
endif
let s:sparkup = '"' . s:sparkup . '"'
" Workaround for windows, where the Python file cannot be executed via shebang
if has('win32') || has('win64')
let s:sparkup = 'python ' . s:sparkup
endif
endif
" Build arguments list (not cached, g:sparkupArgs might change, also
" &filetype, &expandtab etc)
let sparkupArgs = exists('g:sparkupArgs') ? g:sparkupArgs : '--no-last-newline'
" Pass '--xml' option, if 'xml' is used as filetype (default: none/'html')
" NOTE: &filetype can contain multiple values, e.g. 'smarty.html'
if index(split(&filetype, '\.'), 'xml') >= 0
let sparkupArgs .= ' --xml'
endif
" If the user's settings are to indent with tabs, do so!
" TODO textmate version of this functionality
if !&expandtab
let sparkupArgs .= ' --indent-tabs'
endif
let sparkupCmd = s:sparkup . printf(' %s --indent-spaces=%s', sparkupArgs, &shiftwidth)
exec '.!' . sparkupCmd
call s:SparkupNext()
endfunction
function! s:SparkupNext()
" 1: empty tag, 2: empty attribute, 3: empty line
let n = search('><\/\|\(""\)\|\(^\s*$\)', 'Wp')
if n == 3
startinsert!
else
let p = getpos(".")
let p[2] = p[2] + 1
call setpos(".", p)
startinsert
endif
endfunction
@@ -0,0 +1 @@
html
@@ -0,0 +1 @@
html
+1
View File
@@ -0,0 +1 @@
html