1
0
mirror of https://github.com/amix/vimrc synced 2025-06-23 06:35:01 +08:00

Updated plugins

This commit is contained in:
amix
2017-03-07 18:04:28 +01:00
parent fe46dfbbe6
commit ccb7854aa2
103 changed files with 1729 additions and 445 deletions

View File

@ -1,3 +1,14 @@
All files except:
ftdetect/vim-literate-coffeescript.vim
indent/litcoffee.vim
syntax/litcoffee.vim
test/test.coffee.md
test/test.litcoffee
test/test.png
Issued under WTFPL:
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
@ -13,3 +24,31 @@
0. You just DO WHAT THE FUCK YOU WANT TO.
These files issed under this license:
ftdetect/vim-literate-coffeescript.vim
indent/litcoffee.vim
syntax/litcoffee.vim
test/test.coffee.md
test/test.litcoffee
test/test.png
Copyright (c) 2013 Michael Smith
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.

View File

@ -337,23 +337,15 @@ It behaves very similar to `:make`, described [above](#compile-to-javascript).
## Literate CoffeeScript
Literate CoffeeScript syntax and indent support is provided by
[vim-literate-coffeescript]. The `Coffee` commands detect when they're running
on a litcoffee file and pass the `--literate` flag to their respective tools,
but at this time the commands are not automatically loaded when a litcoffee file
is opened.
Literate CoffeeScript syntax and indent support is now built in! The `Coffee`
commands detect when they're running on a litcoffee file and pass the
`--literate` flag to their respective tools.
[vim-literate-coffeescript]: https://github.com/mintplant/vim-literate-coffeescript
To load them, run
runtime ftplugin/coffee.vim
while inside a litcoffee buffer. To do this automatically, add
autocmd FileType litcoffee runtime ftplugin/coffee.vim
to your vimrc.
Literate CoffeeScript syntax and indent support was written by @mintplant
(Michael Smith). A standalone repo
[exists](https://github.com/jwhitley/vim-literate-coffeescript), but you'll
need to copy the `ftplugin/litcoffee.vim` file or set up an autocmd to get the
`Coffee` commands to be automatically loaded for litcoffee files.
## CoffeeScript in HTML

View File

@ -0,0 +1,8 @@
" Language: Literate CoffeeScript
" Maintainer: Michael Smith <michael@diglumi.com>
" URL: https://github.com/mintplant/vim-literate-coffeescript
" License: MIT
autocmd BufNewFile,BufRead *.litcoffee set filetype=litcoffee
autocmd BufNewFile,BufRead *.coffee.md set filetype=litcoffee

View File

@ -0,0 +1 @@
runtime ftplugin/coffee.vim

View File

@ -0,0 +1,22 @@
if exists('b:did_indent')
finish
endif
runtime! indent/coffee.vim
let b:did_indent = 1
setlocal indentexpr=GetLitCoffeeIndent()
if exists('*GetLitCoffeeIndent')
finish
endif
function GetLitCoffeeIndent()
if searchpair('^ \|\t', '', '$', 'bWnm') > 0
return GetCoffeeIndent(v:lnum)
else
return -1
endif
endfunc

View File

@ -32,7 +32,7 @@ hi def link coffeeConditional Conditional
syn match coffeeException /\<\%(try\|catch\|finally\)\>/ display
hi def link coffeeException Exception
syn match coffeeKeyword /\<\%(new\|in\|of\|by\|and\|or\|not\|is\|isnt\|class\|extends\|super\|do\|yield\|debugger\|import\|export\)\>/
syn match coffeeKeyword /\<\%(new\|in\|of\|by\|and\|or\|not\|is\|isnt\|class\|extends\|super\|do\|yield\|debugger\|import\|export\|await\)\>/
\ display
" The `own` keyword is only a keyword after `for`.
syn match coffeeKeyword /\<for\s\+own\>/ contained containedin=coffeeRepeat

View File

@ -0,0 +1,23 @@
" Language: Literate CoffeeScript
" Maintainer: Michael Smith <michael@diglumi.com>
" URL: https://github.com/mintplant/vim-literate-coffeescript
" License: MIT
if exists('b:current_syntax') && b:current_syntax == 'litcoffee'
finish
endif
syn include @markdown syntax/markdown.vim
syn include @coffee syntax/coffee.vim
" Partition the file into notCoffee and inlineCoffee. Each line will match
" exactly one of these regions. notCoffee matches with a zero-width
" look-behind.
syn region notCoffee start='^\%( \|\t\)\@<!' end='$' contains=@markdown
syn region inlineCoffee start='^ \|\t' end='$' contains=@coffee
" We defined notCoffee as a region so we can highlight every element in it
" that doesn't have it's own explicit rule.
highlight default link notCoffee Comment
let b:current_syntax = "litcoffee"

View File

@ -0,0 +1,117 @@
The **Scope** class regulates lexical scoping within CoffeeScript. As you
generate code, you create a tree of scopes in the same shape as the nested
function bodies. Each scope knows about the variables declared within it,
and has a reference to its parent enclosing scope. In this way, we know which
variables are new and need to be declared with `var`, and which are shared
with external scopes.
Import the helpers we plan to use.
{extend, last} = require './helpers'
exports.Scope = class Scope
The `root` is the top-level **Scope** object for a given file.
@root: null
Initialize a scope with its parent, for lookups up the chain,
as well as a reference to the **Block** node it belongs to, which is
where it should declare its variables, and a reference to the function that
it belongs to.
constructor: (@parent, @expressions, @method) ->
@variables = [{name: 'arguments', type: 'arguments'}]
@positions = {}
Scope.root = this unless @parent
Adds a new variable or overrides an existing one.
add: (name, type, immediate) ->
return @parent.add name, type, immediate if @shared and not immediate
if Object::hasOwnProperty.call @positions, name
@variables[@positions[name]].type = type
else
@positions[name] = @variables.push({name, type}) - 1
When `super` is called, we need to find the name of the current method we're
in, so that we know how to invoke the same method of the parent class. This
can get complicated if super is being called from an inner function.
`namedMethod` will walk up the scope tree until it either finds the first
function object that has a name filled in, or bottoms out.
namedMethod: ->
return @method if @method.name or !@parent
@parent.namedMethod()
Look up a variable name in lexical scope, and declare it if it does not
already exist.
find: (name) ->
return yes if @check name
@add name, 'var'
no
Reserve a variable name as originating from a function parameter for this
scope. No `var` required for internal references.
parameter: (name) ->
return if @shared and @parent.check name, yes
@add name, 'param'
Just check to see if a variable has already been declared, without reserving,
walks up to the root scope.
check: (name) ->
!!(@type(name) or @parent?.check(name))
Generate a temporary variable name at the given index.
temporary: (name, index) ->
if name.length > 1
'_' + name + if index > 1 then index - 1 else ''
else
'_' + (index + parseInt name, 36).toString(36).replace /\d/g, 'a'
Gets the type of a variable.
type: (name) ->
return v.type for v in @variables when v.name is name
null
If we need to store an intermediate result, find an available name for a
compiler-generated variable. `_var`, `_var2`, and so on...
freeVariable: (name, reserve=true) ->
index = 0
index++ while @check((temp = @temporary name, index))
@add temp, 'var', yes if reserve
temp
Ensure that an assignment is made at the top of this scope
(or at the top-level scope, if requested).
assign: (name, value) ->
@add name, {value, assigned: yes}, yes
@hasAssignments = yes
Does this scope have any declared variables?
hasDeclarations: ->
!!@declaredVariables().length
Return the list of variables first declared in this scope.
declaredVariables: ->
realVars = []
tempVars = []
for v in @variables when v.type is 'var'
(if v.name.charAt(0) is '_' then tempVars else realVars).push v.name
realVars.sort().concat tempVars.sort()
Return the list of assignments that are supposed to be made at the top
of this scope.
assignedVariables: ->
"#{v.name} = #{v.type.value}" for v in @variables when v.type.assigned

View File

@ -0,0 +1,117 @@
The **Scope** class regulates lexical scoping within CoffeeScript. As you
generate code, you create a tree of scopes in the same shape as the nested
function bodies. Each scope knows about the variables declared within it,
and has a reference to its parent enclosing scope. In this way, we know which
variables are new and need to be declared with `var`, and which are shared
with external scopes.
Import the helpers we plan to use.
{extend, last} = require './helpers'
exports.Scope = class Scope
The `root` is the top-level **Scope** object for a given file.
@root: null
Initialize a scope with its parent, for lookups up the chain,
as well as a reference to the **Block** node it belongs to, which is
where it should declare its variables, and a reference to the function that
it belongs to.
constructor: (@parent, @expressions, @method) ->
@variables = [{name: 'arguments', type: 'arguments'}]
@positions = {}
Scope.root = this unless @parent
Adds a new variable or overrides an existing one.
add: (name, type, immediate) ->
return @parent.add name, type, immediate if @shared and not immediate
if Object::hasOwnProperty.call @positions, name
@variables[@positions[name]].type = type
else
@positions[name] = @variables.push({name, type}) - 1
When `super` is called, we need to find the name of the current method we're
in, so that we know how to invoke the same method of the parent class. This
can get complicated if super is being called from an inner function.
`namedMethod` will walk up the scope tree until it either finds the first
function object that has a name filled in, or bottoms out.
namedMethod: ->
return @method if @method.name or !@parent
@parent.namedMethod()
Look up a variable name in lexical scope, and declare it if it does not
already exist.
find: (name) ->
return yes if @check name
@add name, 'var'
no
Reserve a variable name as originating from a function parameter for this
scope. No `var` required for internal references.
parameter: (name) ->
return if @shared and @parent.check name, yes
@add name, 'param'
Just check to see if a variable has already been declared, without reserving,
walks up to the root scope.
check: (name) ->
!!(@type(name) or @parent?.check(name))
Generate a temporary variable name at the given index.
temporary: (name, index) ->
if name.length > 1
'_' + name + if index > 1 then index - 1 else ''
else
'_' + (index + parseInt name, 36).toString(36).replace /\d/g, 'a'
Gets the type of a variable.
type: (name) ->
return v.type for v in @variables when v.name is name
null
If we need to store an intermediate result, find an available name for a
compiler-generated variable. `_var`, `_var2`, and so on...
freeVariable: (name, reserve=true) ->
index = 0
index++ while @check((temp = @temporary name, index))
@add temp, 'var', yes if reserve
temp
Ensure that an assignment is made at the top of this scope
(or at the top-level scope, if requested).
assign: (name, value) ->
@add name, {value, assigned: yes}, yes
@hasAssignments = yes
Does this scope have any declared variables?
hasDeclarations: ->
!!@declaredVariables().length
Return the list of variables first declared in this scope.
declaredVariables: ->
realVars = []
tempVars = []
for v in @variables when v.type is 'var'
(if v.name.charAt(0) is '_' then tempVars else realVars).push v.name
realVars.sort().concat tempVars.sort()
Return the list of assignments that are supposed to be made at the top
of this scope.
assignedVariables: ->
"#{v.name} = #{v.type.value}" for v in @variables when v.type.assigned