Ajout des fichiers de configurations
This commit is contained in:
parent
e2d5ed2188
commit
382e583bb2
15 changed files with 5083 additions and 0 deletions
21
LICENSE.md
Normal file
21
LICENSE.md
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2017 Tomáš Iser
|
||||
|
||||
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.
|
120
autoload/airline/themes/codedark.vim
Normal file
120
autoload/airline/themes/codedark.vim
Normal file
|
@ -0,0 +1,120 @@
|
|||
" Vim Code Dark (airline theme)
|
||||
" https://github.com/tomasiser/vim-code-dark
|
||||
|
||||
scriptencoding utf-8
|
||||
|
||||
let g:airline#themes#codedark#palette = {}
|
||||
|
||||
" Terminal colors (base16):
|
||||
let s:cterm00 = "00"
|
||||
let s:cterm03 = "08"
|
||||
let s:cterm05 = "07"
|
||||
let s:cterm07 = "15"
|
||||
let s:cterm08 = "01"
|
||||
let s:cterm0A = "03"
|
||||
let s:cterm0B = "02"
|
||||
let s:cterm0C = "06"
|
||||
let s:cterm0D = "04"
|
||||
let s:cterm0E = "05"
|
||||
if exists('base16colorspace') && base16colorspace == "256"
|
||||
let s:cterm01 = "18"
|
||||
let s:cterm02 = "19"
|
||||
let s:cterm04 = "20"
|
||||
let s:cterm06 = "21"
|
||||
let s:cterm09 = "16"
|
||||
let s:cterm0F = "17"
|
||||
else
|
||||
let s:cterm01 = "00"
|
||||
let s:cterm02 = "08"
|
||||
let s:cterm04 = "07"
|
||||
let s:cterm06 = "07"
|
||||
let s:cterm09 = "06"
|
||||
let s:cterm0F = "03"
|
||||
endif
|
||||
|
||||
if &t_Co >= 256
|
||||
let g:codedark_term256=1
|
||||
elseif !exists("g:codedark_term256")
|
||||
let g:codedark_term256=0
|
||||
endif
|
||||
|
||||
let s:cdFront = {'gui': '#FFFFFF', 'cterm': (g:codedark_term256 ? '15' : s:cterm07)}
|
||||
let s:cdFrontGray = {'gui': '#D4D4D4', 'cterm': (g:codedark_term256 ? '188' : s:cterm05)}
|
||||
let s:cdBack = {'gui': '#1E1E1E', 'cterm': (g:codedark_term256 ? '234' : s:cterm00)}
|
||||
let s:cdSelection = {'gui': '#264F78', 'cterm': (g:codedark_term256 ? '24' : s:cterm01)}
|
||||
|
||||
let s:cdBlue = {'gui': '#0A7ACA', 'cterm': (g:codedark_term256 ? '32' : s:cterm0D)}
|
||||
let s:cdLightBlue = {'gui': '#5CB6F8', 'cterm': (g:codedark_term256 ? '75' : s:cterm0C)}
|
||||
let s:cdYellow = {'gui': '#FFAF00', 'cterm': (g:codedark_term256 ? '214' : s:cterm0A)}
|
||||
let s:cdRed = {'gui': '#F44747', 'cterm': (g:codedark_term256 ? '203' : s:cterm08)}
|
||||
|
||||
let s:cdDarkDarkDark = {'gui': '#262626', 'cterm': (g:codedark_term256 ? '235' : s:cterm01)}
|
||||
let s:cdDarkDark = {'gui': '#303030', 'cterm': (g:codedark_term256 ? '236' : s:cterm02)}
|
||||
let s:cdDark = {'gui': '#3C3C3C', 'cterm': (g:codedark_term256 ? '237' : s:cterm03)}
|
||||
|
||||
let s:Warning = [ s:cdRed.gui, s:cdDarkDark.gui, s:cdRed.cterm, s:cdDarkDark.cterm, 'none']
|
||||
|
||||
" Normal:
|
||||
|
||||
let s:N1 = [ s:cdFront.gui, s:cdBlue.gui, s:cdFront.cterm, s:cdBlue.cterm, 'none' ]
|
||||
let s:N2 = [ s:cdFront.gui, s:cdDarkDark.gui, s:cdFront.cterm, s:cdDarkDark.cterm, 'none' ]
|
||||
let s:N3 = [ s:cdFront.gui, s:cdDarkDarkDark.gui, s:cdFront.cterm, s:cdDarkDarkDark.cterm, 'none' ]
|
||||
let s:NM = [ s:cdFront.gui, s:cdDarkDarkDark.gui, s:cdFront.cterm, s:cdDarkDarkDark.cterm, 'none']
|
||||
|
||||
let g:airline#themes#codedark#palette.normal = airline#themes#generate_color_map(s:N1, s:N2, s:N3)
|
||||
let g:airline#themes#codedark#palette.normal_modified = { 'airline_c': s:NM }
|
||||
let g:airline#themes#codedark#palette.normal.airline_warning = s:Warning
|
||||
let g:airline#themes#codedark#palette.normal_modified.airline_warning = s:Warning
|
||||
|
||||
" Insert:
|
||||
|
||||
let s:I1 = [ s:cdBack.gui, s:cdYellow.gui, s:cdBack.cterm, s:cdYellow.cterm, 'none' ]
|
||||
let s:I2 = [ s:cdFront.gui, s:cdDarkDark.gui, s:cdFront.cterm, s:cdDarkDark.cterm, 'none' ]
|
||||
let s:I3 = [ s:cdFront.gui, s:cdDarkDarkDark.gui, s:cdFront.cterm, s:cdDarkDarkDark.cterm, 'none' ]
|
||||
let s:IM = [ s:cdFront.gui, s:cdDarkDarkDark.gui, s:cdFront.cterm, s:cdDarkDarkDark.cterm, 'none']
|
||||
|
||||
let g:airline#themes#codedark#palette.insert = airline#themes#generate_color_map(s:I1, s:I2, s:I3)
|
||||
let g:airline#themes#codedark#palette.insert_modified = { 'airline_c': s:IM }
|
||||
let g:airline#themes#codedark#palette.insert.airline_warning = s:Warning
|
||||
let g:airline#themes#codedark#palette.insert_modified.airline_warning = s:Warning
|
||||
|
||||
" Replace:
|
||||
|
||||
let s:R1 = [ s:cdBack.gui, s:cdYellow.gui, s:cdBack.cterm, s:cdYellow.cterm, 'none' ]
|
||||
let s:R2 = [ s:cdFront.gui, s:cdDarkDark.gui, s:cdFront.cterm, s:cdDarkDark.cterm, 'none' ]
|
||||
let s:R3 = [ s:cdFront.gui, s:cdDarkDarkDark.gui, s:cdFront.cterm, s:cdDarkDarkDark.cterm, 'none' ]
|
||||
let s:RM = [ s:cdFront.gui, s:cdDarkDarkDark.gui, s:cdFront.cterm, s:cdDarkDarkDark.cterm, 'none']
|
||||
|
||||
let g:airline#themes#codedark#palette.replace = airline#themes#generate_color_map(s:R1, s:R2, s:R3)
|
||||
let g:airline#themes#codedark#palette.replace_modified = { 'airline_c': s:RM }
|
||||
let g:airline#themes#codedark#palette.replace.airline_warning = s:Warning
|
||||
let g:airline#themes#codedark#palette.replace_modified.airline_warning = s:Warning
|
||||
|
||||
" Visual:
|
||||
|
||||
let s:V1 = [ s:cdLightBlue.gui, s:cdDark.gui, s:cdLightBlue.cterm, s:cdDark.cterm, 'none' ]
|
||||
let s:V2 = [ s:cdFront.gui, s:cdDarkDark.gui, s:cdFront.cterm, s:cdDarkDark.cterm, 'none' ]
|
||||
let s:V3 = [ s:cdFront.gui, s:cdDarkDarkDark.gui, s:cdFront.cterm, s:cdDarkDarkDark.cterm, 'none' ]
|
||||
let s:VM = [ s:cdFront.gui, s:cdDarkDarkDark.gui, s:cdFront.cterm, s:cdDarkDarkDark.cterm, 'none']
|
||||
|
||||
let g:airline#themes#codedark#palette.visual = airline#themes#generate_color_map(s:V1, s:V2, s:V3)
|
||||
let g:airline#themes#codedark#palette.visual_modified = { 'airline_c': s:VM }
|
||||
let g:airline#themes#codedark#palette.visual.airline_warning = s:Warning
|
||||
let g:airline#themes#codedark#palette.visual_modified.airline_warning = s:Warning
|
||||
|
||||
" Inactive:
|
||||
|
||||
let s:IA1 = [ s:cdFrontGray.gui, s:cdDark.gui, s:cdFrontGray.cterm, s:cdDark.cterm, 'none' ]
|
||||
let s:IA2 = [ s:cdFrontGray.gui, s:cdDarkDark.gui, s:cdFrontGray.cterm, s:cdDarkDark.cterm, 'none' ]
|
||||
let s:IA3 = [ s:cdFrontGray.gui, s:cdDarkDarkDark.gui, s:cdFrontGray.cterm, s:cdDarkDarkDark.cterm, 'none' ]
|
||||
let s:IAM = [ s:cdFrontGray.gui, s:cdDarkDarkDark.gui, s:cdFrontGray.cterm, s:cdDarkDarkDark.cterm, 'none' ]
|
||||
|
||||
let g:airline#themes#codedark#palette.inactive = airline#themes#generate_color_map(s:IA1, s:IA2, s:IA3)
|
||||
let g:airline#themes#codedark#palette.inactive_modified = { 'airline_c': s:IAM }
|
||||
|
||||
" Red accent for readonly:
|
||||
|
||||
let g:airline#themes#codedark#palette.accents = {
|
||||
\ 'red': [ s:cdRed.gui, '', s:cdRed.cterm, '' ]
|
||||
\ }
|
||||
|
1
autoload/codedark
Submodule
1
autoload/codedark
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 811fcff1526f330e87f3d7663fe60588b22e5dd8
|
264
autoload/pathogen.vim
Normal file
264
autoload/pathogen.vim
Normal file
|
@ -0,0 +1,264 @@
|
|||
" pathogen.vim - path option manipulation
|
||||
" Maintainer: Tim Pope <http://tpo.pe/>
|
||||
" Version: 2.4
|
||||
|
||||
" Install in ~/.vim/autoload (or ~\vimfiles\autoload).
|
||||
"
|
||||
" For management of individually installed plugins in ~/.vim/bundle (or
|
||||
" ~\vimfiles\bundle), adding `execute pathogen#infect()` to the top of your
|
||||
" .vimrc is the only other setup necessary.
|
||||
"
|
||||
" The API is documented inline below.
|
||||
|
||||
if exists("g:loaded_pathogen") || &cp
|
||||
finish
|
||||
endif
|
||||
let g:loaded_pathogen = 1
|
||||
|
||||
" Point of entry for basic default usage. Give a relative path to invoke
|
||||
" pathogen#interpose() or an absolute path to invoke pathogen#surround().
|
||||
" Curly braces are expanded with pathogen#expand(): "bundle/{}" finds all
|
||||
" subdirectories inside "bundle" inside all directories in the runtime path.
|
||||
" If no arguments are given, defaults "bundle/{}", and also "pack/{}/start/{}"
|
||||
" on versions of Vim without native package support.
|
||||
function! pathogen#infect(...) abort
|
||||
if a:0
|
||||
let paths = filter(reverse(copy(a:000)), 'type(v:val) == type("")')
|
||||
else
|
||||
let paths = ['bundle/{}', 'pack/{}/start/{}']
|
||||
endif
|
||||
if has('packages')
|
||||
call filter(paths, 'v:val !~# "^pack/[^/]*/start/[^/]*$"')
|
||||
endif
|
||||
let static = '^\%([$~\\/]\|\w:[\\/]\)[^{}*]*$'
|
||||
for path in filter(copy(paths), 'v:val =~# static')
|
||||
call pathogen#surround(path)
|
||||
endfor
|
||||
for path in filter(copy(paths), 'v:val !~# static')
|
||||
if path =~# '^\%([$~\\/]\|\w:[\\/]\)'
|
||||
call pathogen#surround(path)
|
||||
else
|
||||
call pathogen#interpose(path)
|
||||
endif
|
||||
endfor
|
||||
call pathogen#cycle_filetype()
|
||||
if pathogen#is_disabled($MYVIMRC)
|
||||
return 'finish'
|
||||
endif
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
" Split a path into a list.
|
||||
function! pathogen#split(path) abort
|
||||
if type(a:path) == type([]) | return a:path | endif
|
||||
if empty(a:path) | return [] | endif
|
||||
let split = split(a:path,'\\\@<!\%(\\\\\)*\zs,')
|
||||
return map(split,'substitute(v:val,''\\\([\\,]\)'',''\1'',"g")')
|
||||
endfunction
|
||||
|
||||
" Convert a list to a path.
|
||||
function! pathogen#join(...) abort
|
||||
if type(a:1) == type(1) && a:1
|
||||
let i = 1
|
||||
let space = ' '
|
||||
else
|
||||
let i = 0
|
||||
let space = ''
|
||||
endif
|
||||
let path = ""
|
||||
while i < a:0
|
||||
if type(a:000[i]) == type([])
|
||||
let list = a:000[i]
|
||||
let j = 0
|
||||
while j < len(list)
|
||||
let escaped = substitute(list[j],'[,'.space.']\|\\[\,'.space.']\@=','\\&','g')
|
||||
let path .= ',' . escaped
|
||||
let j += 1
|
||||
endwhile
|
||||
else
|
||||
let path .= "," . a:000[i]
|
||||
endif
|
||||
let i += 1
|
||||
endwhile
|
||||
return substitute(path,'^,','','')
|
||||
endfunction
|
||||
|
||||
" Convert a list to a path with escaped spaces for 'path', 'tag', etc.
|
||||
function! pathogen#legacyjoin(...) abort
|
||||
return call('pathogen#join',[1] + a:000)
|
||||
endfunction
|
||||
|
||||
" Turn filetype detection off and back on again if it was already enabled.
|
||||
function! pathogen#cycle_filetype() abort
|
||||
if exists('g:did_load_filetypes')
|
||||
filetype off
|
||||
filetype on
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Check if a bundle is disabled. A bundle is considered disabled if its
|
||||
" basename or full name is included in the list g:pathogen_blacklist or the
|
||||
" comma delimited environment variable $VIMBLACKLIST.
|
||||
function! pathogen#is_disabled(path) abort
|
||||
if a:path =~# '\~$'
|
||||
return 1
|
||||
endif
|
||||
let sep = pathogen#slash()
|
||||
let blacklist = get(g:, 'pathogen_blacklist', get(g:, 'pathogen_disabled', [])) + pathogen#split($VIMBLACKLIST)
|
||||
if !empty(blacklist)
|
||||
call map(blacklist, 'substitute(v:val, "[\\/]$", "", "")')
|
||||
endif
|
||||
return index(blacklist, fnamemodify(a:path, ':t')) != -1 || index(blacklist, a:path) != -1
|
||||
endfunction
|
||||
|
||||
" Prepend the given directory to the runtime path and append its corresponding
|
||||
" after directory. Curly braces are expanded with pathogen#expand().
|
||||
function! pathogen#surround(path) abort
|
||||
let sep = pathogen#slash()
|
||||
let rtp = pathogen#split(&rtp)
|
||||
let path = fnamemodify(a:path, ':s?[\\/]\=$??')
|
||||
let before = filter(pathogen#expand(path), '!pathogen#is_disabled(v:val)')
|
||||
let after = filter(reverse(pathogen#expand(path, sep.'after')), '!pathogen#is_disabled(v:val[0:-7])')
|
||||
call filter(rtp, 'index(before + after, v:val) == -1')
|
||||
let &rtp = pathogen#join(before, rtp, after)
|
||||
return &rtp
|
||||
endfunction
|
||||
|
||||
" For each directory in the runtime path, add a second entry with the given
|
||||
" argument appended. Curly braces are expanded with pathogen#expand().
|
||||
function! pathogen#interpose(name) abort
|
||||
let sep = pathogen#slash()
|
||||
let name = a:name
|
||||
if has_key(s:done_bundles, name)
|
||||
return ""
|
||||
endif
|
||||
let s:done_bundles[name] = 1
|
||||
let list = []
|
||||
for dir in pathogen#split(&rtp)
|
||||
if dir =~# '\<after$'
|
||||
let list += reverse(filter(pathogen#expand(dir[0:-6].name, sep.'after'), '!pathogen#is_disabled(v:val[0:-7])')) + [dir]
|
||||
else
|
||||
let list += [dir] + filter(pathogen#expand(dir.sep.name), '!pathogen#is_disabled(v:val)')
|
||||
endif
|
||||
endfor
|
||||
let &rtp = pathogen#join(pathogen#uniq(list))
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
let s:done_bundles = {}
|
||||
|
||||
" Invoke :helptags on all non-$VIM doc directories in runtimepath.
|
||||
function! pathogen#helptags() abort
|
||||
let sep = pathogen#slash()
|
||||
for glob in pathogen#split(&rtp)
|
||||
for dir in map(split(glob(glob), "\n"), 'v:val.sep."/doc/".sep')
|
||||
if (dir)[0 : strlen($VIMRUNTIME)] !=# $VIMRUNTIME.sep && filewritable(dir) == 2 && !empty(split(glob(dir.'*.txt'))) && (!filereadable(dir.'tags') || filewritable(dir.'tags'))
|
||||
silent! execute 'helptags' pathogen#fnameescape(dir)
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
command! -bar Helptags :call pathogen#helptags()
|
||||
|
||||
" Execute the given command. This is basically a backdoor for --remote-expr.
|
||||
function! pathogen#execute(...) abort
|
||||
for command in a:000
|
||||
execute command
|
||||
endfor
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
" Section: Unofficial
|
||||
|
||||
function! pathogen#is_absolute(path) abort
|
||||
return a:path =~# (has('win32') ? '^\%([\\/]\|\w:\)[\\/]\|^[~$]' : '^[/~$]')
|
||||
endfunction
|
||||
|
||||
" Given a string, returns all possible permutations of comma delimited braced
|
||||
" alternatives of that string. pathogen#expand('/{a,b}/{c,d}') yields
|
||||
" ['/a/c', '/a/d', '/b/c', '/b/d']. Empty braces are treated as a wildcard
|
||||
" and globbed. Actual globs are preserved.
|
||||
function! pathogen#expand(pattern, ...) abort
|
||||
let after = a:0 ? a:1 : ''
|
||||
let pattern = substitute(a:pattern, '^[~$][^\/]*', '\=expand(submatch(0))', '')
|
||||
if pattern =~# '{[^{}]\+}'
|
||||
let [pre, pat, post] = split(substitute(pattern, '\(.\{-\}\){\([^{}]\+\)}\(.*\)', "\\1\001\\2\001\\3", ''), "\001", 1)
|
||||
let found = map(split(pat, ',', 1), 'pre.v:val.post')
|
||||
let results = []
|
||||
for pattern in found
|
||||
call extend(results, pathogen#expand(pattern))
|
||||
endfor
|
||||
elseif pattern =~# '{}'
|
||||
let pat = matchstr(pattern, '^.*{}[^*]*\%($\|[\\/]\)')
|
||||
let post = pattern[strlen(pat) : -1]
|
||||
let results = map(split(glob(substitute(pat, '{}', '*', 'g')), "\n"), 'v:val.post')
|
||||
else
|
||||
let results = [pattern]
|
||||
endif
|
||||
let vf = pathogen#slash() . 'vimfiles'
|
||||
call map(results, 'v:val =~# "\\*" ? v:val.after : isdirectory(v:val.vf.after) ? v:val.vf.after : isdirectory(v:val.after) ? v:val.after : ""')
|
||||
return filter(results, '!empty(v:val)')
|
||||
endfunction
|
||||
|
||||
" \ on Windows unless shellslash is set, / everywhere else.
|
||||
function! pathogen#slash() abort
|
||||
return !exists("+shellslash") || &shellslash ? '/' : '\'
|
||||
endfunction
|
||||
|
||||
function! pathogen#separator() abort
|
||||
return pathogen#slash()
|
||||
endfunction
|
||||
|
||||
" Convenience wrapper around glob() which returns a list.
|
||||
function! pathogen#glob(pattern) abort
|
||||
let files = split(glob(a:pattern),"\n")
|
||||
return map(files,'substitute(v:val,"[".pathogen#slash()."/]$","","")')
|
||||
endfunction
|
||||
|
||||
" Like pathogen#glob(), only limit the results to directories.
|
||||
function! pathogen#glob_directories(pattern) abort
|
||||
return filter(pathogen#glob(a:pattern),'isdirectory(v:val)')
|
||||
endfunction
|
||||
|
||||
" Remove duplicates from a list.
|
||||
function! pathogen#uniq(list) abort
|
||||
let i = 0
|
||||
let seen = {}
|
||||
while i < len(a:list)
|
||||
if (a:list[i] ==# '' && exists('empty')) || has_key(seen,a:list[i])
|
||||
call remove(a:list,i)
|
||||
elseif a:list[i] ==# ''
|
||||
let i += 1
|
||||
let empty = 1
|
||||
else
|
||||
let seen[a:list[i]] = 1
|
||||
let i += 1
|
||||
endif
|
||||
endwhile
|
||||
return a:list
|
||||
endfunction
|
||||
|
||||
" Backport of fnameescape().
|
||||
function! pathogen#fnameescape(string) abort
|
||||
if exists('*fnameescape')
|
||||
return fnameescape(a:string)
|
||||
elseif a:string ==# '-'
|
||||
return '\-'
|
||||
else
|
||||
return substitute(escape(a:string," \t\n*?[{`$\\%#'\"|!<"),'^[+>]','\\&','')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Like findfile(), but hardcoded to use the runtimepath.
|
||||
function! pathogen#runtime_findfile(file,count) abort
|
||||
let rtp = pathogen#join(1,pathogen#split(&rtp))
|
||||
let file = findfile(a:file,rtp,a:count)
|
||||
if file ==# ''
|
||||
return ''
|
||||
else
|
||||
return fnamemodify(file,':p')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" vim:set et sw=2 foldmethod=expr foldexpr=getline(v\:lnum)=~'^\"\ Section\:'?'>1'\:getline(v\:lnum)=~#'^fu'?'a1'\:getline(v\:lnum)=~#'^endf'?'s1'\:'=':
|
2538
autoload/plug.vim
Normal file
2538
autoload/plug.vim
Normal file
File diff suppressed because it is too large
Load diff
18
base16/schemes/codedark/codedark.yaml
Normal file
18
base16/schemes/codedark/codedark.yaml
Normal file
|
@ -0,0 +1,18 @@
|
|||
scheme: "codedark"
|
||||
author: "Tomas Iser (https://github.com/tomasiser)"
|
||||
base00: "1E1E1E"
|
||||
base01: "262626"
|
||||
base02: "303030"
|
||||
base03: "3C3C3C"
|
||||
base04: "808080"
|
||||
base05: "D4D4D4"
|
||||
base06: "E9E9E9"
|
||||
base07: "FFFFFF"
|
||||
base08: "D16969"
|
||||
base09: "B5CEA8"
|
||||
base0A: "D7BA7D"
|
||||
base0B: "608B4E"
|
||||
base0C: "9CDCFE"
|
||||
base0D: "569CD6"
|
||||
base0E: "C586C0"
|
||||
base0F: "CE9178"
|
72
base16/templates/putty/putty/base16-codedark.reg
Normal file
72
base16/templates/putty/putty/base16-codedark.reg
Normal file
|
@ -0,0 +1,72 @@
|
|||
Windows Registry Editor Version 5.00
|
||||
|
||||
; Base16 codedark
|
||||
; schema by Tomas Iser (https://github.com/tomasiser)
|
||||
[HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\codedark]
|
||||
|
||||
; Default Foreground
|
||||
"Colour0"="212,212,212"
|
||||
|
||||
; Default Bold Foreground -- equals to non-bold
|
||||
"Colour1"="212,212,212"
|
||||
|
||||
; Default Background
|
||||
"Colour2"="30,30,30"
|
||||
|
||||
; Default Bold Background -- equals to non-bold
|
||||
"Colour3"="30,30,30"
|
||||
|
||||
; Cursor Text -- equals to default background
|
||||
"Colour4"="30,30,30"
|
||||
|
||||
; Cursor Colour -- equals to default foreground
|
||||
"Colour5"="212,212,212"
|
||||
|
||||
; ANSI Black
|
||||
"Colour6"="30,30,30"
|
||||
|
||||
; ANSI Black Bold
|
||||
"Colour7"="60,60,60"
|
||||
|
||||
; ANSI Red
|
||||
"Colour8"="209,105,105"
|
||||
|
||||
; ANSI Red Bold
|
||||
"Colour9"="181,206,168"
|
||||
|
||||
; ANSI Green
|
||||
"Colour10"="96,139,78"
|
||||
|
||||
; ANSI Green Bold
|
||||
"Colour11"="38,38,38"
|
||||
|
||||
; ANSI Yellow
|
||||
"Colour12"="215,186,125"
|
||||
|
||||
; ANSI Yellow Bold
|
||||
"Colour13"="48,48,48"
|
||||
|
||||
; ANSI Blue
|
||||
"Colour14"="86,156,214"
|
||||
|
||||
; ANSI Blue Bold
|
||||
"Colour15"="128,128,128"
|
||||
|
||||
; ANSI Magenta
|
||||
"Colour16"="197,134,192"
|
||||
|
||||
; ANSI Magenta Bold
|
||||
"Colour17"="233,233,233"
|
||||
|
||||
; ANSI Cyan
|
||||
"Colour18"="156,220,254"
|
||||
|
||||
; ANSI Cyan Bold
|
||||
"Colour19"="206,145,120"
|
||||
|
||||
; ANSI White
|
||||
"Colour20"="212,212,212"
|
||||
|
||||
; ANSI White Bold
|
||||
"Colour21"="255,255,255"
|
||||
|
123
base16/templates/shell/scripts/base16-codedark.sh
Normal file
123
base16/templates/shell/scripts/base16-codedark.sh
Normal file
|
@ -0,0 +1,123 @@
|
|||
#!/bin/sh
|
||||
# base16-shell (https://github.com/chriskempson/base16-shell)
|
||||
# Base16 Shell template by Chris Kempson (http://chriskempson.com)
|
||||
# codedark scheme by Tomas Iser (https://github.com/tomasiser)
|
||||
|
||||
# This script doesn't support linux console (use 'vconsole' template instead)
|
||||
if [ "${TERM%%-*}" = 'linux' ]; then
|
||||
return 2>/dev/null || exit 0
|
||||
fi
|
||||
|
||||
color00="1E/1E/1E" # Base 00 - Black
|
||||
color01="D1/69/69" # Base 08 - Red
|
||||
color02="60/8B/4E" # Base 0B - Green
|
||||
color03="D7/BA/7D" # Base 0A - Yellow
|
||||
color04="56/9C/D6" # Base 0D - Blue
|
||||
color05="C5/86/C0" # Base 0E - Magenta
|
||||
color06="9C/DC/FE" # Base 0C - Cyan
|
||||
color07="D4/D4/D4" # Base 05 - White
|
||||
color08="3C/3C/3C" # Base 03 - Bright Black
|
||||
color09=$color01 # Base 08 - Bright Red
|
||||
color10=$color02 # Base 0B - Bright Green
|
||||
color11=$color03 # Base 0A - Bright Yellow
|
||||
color12=$color04 # Base 0D - Bright Blue
|
||||
color13=$color05 # Base 0E - Bright Magenta
|
||||
color14=$color06 # Base 0C - Bright Cyan
|
||||
color15="FF/FF/FF" # Base 07 - Bright White
|
||||
color16="B5/CE/A8" # Base 09
|
||||
color17="CE/91/78" # Base 0F
|
||||
color18="26/26/26" # Base 01
|
||||
color19="30/30/30" # Base 02
|
||||
color20="80/80/80" # Base 04
|
||||
color21="E9/E9/E9" # Base 06
|
||||
color_foreground="D4/D4/D4" # Base 05
|
||||
color_background="1E/1E/1E" # Base 00
|
||||
color_cursor="D4/D4/D4" # Base 05
|
||||
|
||||
if [ -n "$TMUX" ]; then
|
||||
# Tell tmux to pass the escape sequences through
|
||||
# (Source: http://permalink.gmane.org/gmane.comp.terminal-emulators.tmux.user/1324)
|
||||
printf_template='\033Ptmux;\033\033]4;%d;rgb:%s\033\033\\\033\\'
|
||||
printf_template_var='\033Ptmux;\033\033]%d;rgb:%s\033\033\\\033\\'
|
||||
printf_template_custom='\033Ptmux;\033\033]%s%s\033\033\\\033\\'
|
||||
elif [ "${TERM%%-*}" = "screen" ]; then
|
||||
# GNU screen (screen, screen-256color, screen-256color-bce)
|
||||
printf_template='\033P\033]4;%d;rgb:%s\033\\'
|
||||
printf_template_var='\033P\033]%d;rgb:%s\033\\'
|
||||
printf_template_custom='\033P\033]%s%s\033\\'
|
||||
else
|
||||
printf_template='\033]4;%d;rgb:%s\033\\'
|
||||
printf_template_var='\033]%d;rgb:%s\033\\'
|
||||
printf_template_custom='\033]%s%s\033\\'
|
||||
fi
|
||||
|
||||
# 16 color space
|
||||
printf $printf_template 0 $color00
|
||||
printf $printf_template 1 $color01
|
||||
printf $printf_template 2 $color02
|
||||
printf $printf_template 3 $color03
|
||||
printf $printf_template 4 $color04
|
||||
printf $printf_template 5 $color05
|
||||
printf $printf_template 6 $color06
|
||||
printf $printf_template 7 $color07
|
||||
printf $printf_template 8 $color08
|
||||
printf $printf_template 9 $color09
|
||||
printf $printf_template 10 $color10
|
||||
printf $printf_template 11 $color11
|
||||
printf $printf_template 12 $color12
|
||||
printf $printf_template 13 $color13
|
||||
printf $printf_template 14 $color14
|
||||
printf $printf_template 15 $color15
|
||||
|
||||
# 256 color space
|
||||
printf $printf_template 16 $color16
|
||||
printf $printf_template 17 $color17
|
||||
printf $printf_template 18 $color18
|
||||
printf $printf_template 19 $color19
|
||||
printf $printf_template 20 $color20
|
||||
printf $printf_template 21 $color21
|
||||
|
||||
# foreground / background / cursor color
|
||||
if [ -n "$ITERM_SESSION_ID" ]; then
|
||||
# iTerm2 proprietary escape codes
|
||||
printf $printf_template_custom Pg D4D4D4 # forground
|
||||
printf $printf_template_custom Ph 1E1E1E # background
|
||||
printf $printf_template_custom Pi D4D4D4 # bold color
|
||||
printf $printf_template_custom Pj 303030 # selection color
|
||||
printf $printf_template_custom Pk D4D4D4 # selected text color
|
||||
printf $printf_template_custom Pl D4D4D4 # cursor
|
||||
printf $printf_template_custom Pm 1E1E1E # cursor text
|
||||
else
|
||||
printf $printf_template_var 10 $color_foreground
|
||||
printf $printf_template_var 11 $color_background
|
||||
printf $printf_template_custom 12 ";7" # cursor (reverse video)
|
||||
fi
|
||||
|
||||
# clean up
|
||||
unset printf_template
|
||||
unset printf_template_var
|
||||
unset color00
|
||||
unset color01
|
||||
unset color02
|
||||
unset color03
|
||||
unset color04
|
||||
unset color05
|
||||
unset color06
|
||||
unset color07
|
||||
unset color08
|
||||
unset color09
|
||||
unset color10
|
||||
unset color11
|
||||
unset color12
|
||||
unset color13
|
||||
unset color14
|
||||
unset color15
|
||||
unset color16
|
||||
unset color17
|
||||
unset color18
|
||||
unset color19
|
||||
unset color20
|
||||
unset color21
|
||||
unset color_foreground
|
||||
unset color_background
|
||||
unset color_cursor
|
1
bundle/vim-doge
Submodule
1
bundle/vim-doge
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 1aba70d1d2ff408045f8d57eec0b8103da5d2db9
|
358
colors/codedark.vim
Normal file
358
colors/codedark.vim
Normal file
|
@ -0,0 +1,358 @@
|
|||
" Vim Code Dark (color scheme)
|
||||
" https://github.com/tomasiser/vim-code-dark
|
||||
|
||||
scriptencoding utf-8
|
||||
|
||||
set background=dark
|
||||
hi clear
|
||||
if exists("syntax_on")
|
||||
syntax reset
|
||||
endif
|
||||
let g:colors_name="codedark"
|
||||
|
||||
" Highlighting function (inspiration from https://github.com/chriskempson/base16-vim)
|
||||
if &t_Co >= 256
|
||||
let g:codedark_term256=1
|
||||
elseif !exists("g:codedark_term256")
|
||||
let g:codedark_term256=0
|
||||
endif
|
||||
fun! <sid>hi(group, fg, bg, attr, sp)
|
||||
if !empty(a:fg)
|
||||
exec "hi " . a:group . " guifg=" . a:fg.gui . " ctermfg=" . (g:codedark_term256 ? a:fg.cterm256 : a:fg.cterm)
|
||||
endif
|
||||
if !empty(a:bg)
|
||||
exec "hi " . a:group . " guibg=" . a:bg.gui . " ctermbg=" . (g:codedark_term256 ? a:bg.cterm256 : a:bg.cterm)
|
||||
endif
|
||||
if a:attr != ""
|
||||
exec "hi " . a:group . " gui=" . a:attr . " cterm=" . a:attr
|
||||
endif
|
||||
if !empty(a:sp)
|
||||
exec "hi " . a:group . " guisp=" . a:sp.gui
|
||||
endif
|
||||
endfun
|
||||
|
||||
" ------------------
|
||||
" Color definitions:
|
||||
" ------------------
|
||||
|
||||
" Terminal colors (base16):
|
||||
let s:cterm00 = "00"
|
||||
let s:cterm03 = "08"
|
||||
let s:cterm05 = "07"
|
||||
let s:cterm07 = "15"
|
||||
let s:cterm08 = "01"
|
||||
let s:cterm0A = "03"
|
||||
let s:cterm0B = "02"
|
||||
let s:cterm0C = "06"
|
||||
let s:cterm0D = "04"
|
||||
let s:cterm0E = "05"
|
||||
if exists('base16colorspace') && base16colorspace == "256"
|
||||
let s:cterm01 = "18"
|
||||
let s:cterm02 = "19"
|
||||
let s:cterm04 = "20"
|
||||
let s:cterm06 = "21"
|
||||
let s:cterm09 = "16"
|
||||
let s:cterm0F = "17"
|
||||
else
|
||||
let s:cterm01 = "00"
|
||||
let s:cterm02 = "08"
|
||||
let s:cterm04 = "07"
|
||||
let s:cterm06 = "07"
|
||||
let s:cterm09 = "06"
|
||||
let s:cterm0F = "03"
|
||||
endif
|
||||
|
||||
" General appearance colors:
|
||||
" (some of them may be unused)
|
||||
|
||||
let s:cdNone = {'gui': 'NONE', 'cterm': 'NONE', 'cterm256': 'NONE'}
|
||||
let s:cdFront = {'gui': '#D4D4D4', 'cterm': s:cterm05, 'cterm256': '188'}
|
||||
let s:cdBack = {'gui': '#1E1E1E', 'cterm': s:cterm00, 'cterm256': '234'}
|
||||
|
||||
let s:cdTabCurrent = {'gui': '#1E1E1E', 'cterm': s:cterm00, 'cterm256': '234'}
|
||||
let s:cdTabOther = {'gui': '#2D2D2D', 'cterm': s:cterm01, 'cterm256': '236'}
|
||||
let s:cdTabOutside = {'gui': '#252526', 'cterm': s:cterm01, 'cterm256': '235'}
|
||||
|
||||
let s:cdLeftDark = {'gui': '#252526', 'cterm': s:cterm01, 'cterm256': '235'}
|
||||
let s:cdLeftMid = {'gui': '#373737', 'cterm': s:cterm03, 'cterm256': '237'}
|
||||
let s:cdLeftLight = {'gui': '#3F3F46', 'cterm': s:cterm03, 'cterm256': '238'}
|
||||
|
||||
let s:cdPopupFront = {'gui': '#BBBBBB', 'cterm': s:cterm06, 'cterm256': '250'}
|
||||
let s:cdPopupBack = {'gui': '#2D2D30', 'cterm': s:cterm01, 'cterm256': '236'}
|
||||
let s:cdPopupHighlightBlue = {'gui': '#073655', 'cterm': s:cterm0D, 'cterm256': '24'}
|
||||
let s:cdPopupHighlightGray = {'gui': '#3D3D40', 'cterm': s:cterm03, 'cterm256': '237'}
|
||||
|
||||
let s:cdSplitLight = {'gui': '#898989', 'cterm': s:cterm04, 'cterm256': '245'}
|
||||
let s:cdSplitDark = {'gui': '#444444', 'cterm': s:cterm03, 'cterm256': '238'}
|
||||
let s:cdSplitThumb = {'gui': '#424242', 'cterm': s:cterm04, 'cterm256': '238'}
|
||||
|
||||
let s:cdCursorDarkDark = {'gui': '#222222', 'cterm': s:cterm01, 'cterm256': '235'}
|
||||
let s:cdCursorDark = {'gui': '#51504F', 'cterm': s:cterm03, 'cterm256': '239'}
|
||||
let s:cdCursorLight = {'gui': '#AEAFAD', 'cterm': s:cterm04, 'cterm256': '145'}
|
||||
let s:cdSelection = {'gui': '#264F78', 'cterm': s:cterm03, 'cterm256': '24'}
|
||||
let s:cdLineNumber = {'gui': '#5A5A5A', 'cterm': s:cterm04, 'cterm256': '240'}
|
||||
|
||||
let s:cdDiffRedDark = {'gui': '#4B1818', 'cterm': s:cterm08, 'cterm256': '52'}
|
||||
let s:cdDiffRedLight = {'gui': '#6F1313', 'cterm': s:cterm08, 'cterm256': '52'}
|
||||
let s:cdDiffRedLightLight = {'gui': '#FB0101', 'cterm': s:cterm08, 'cterm256': '09'}
|
||||
let s:cdDiffGreenDark = {'gui': '#373D29', 'cterm': s:cterm0B, 'cterm256': '237'}
|
||||
let s:cdDiffGreenLight = {'gui': '#4B5632', 'cterm': s:cterm09, 'cterm256': '58'}
|
||||
|
||||
let s:cdSearchCurrent = {'gui': '#49545F', 'cterm': s:cterm09, 'cterm256': '236'}
|
||||
let s:cdSearch = {'gui': '#4C4E50', 'cterm': s:cterm0A, 'cterm256': '236'}
|
||||
|
||||
" Syntax colors:
|
||||
|
||||
if !exists("g:codedark_conservative")
|
||||
let g:codedark_conservative=0
|
||||
endif
|
||||
|
||||
let s:cdGray = {'gui': '#808080', 'cterm': s:cterm04, 'cterm256': '08'}
|
||||
let s:cdViolet = {'gui': '#646695', 'cterm': s:cterm04, 'cterm256': '60'}
|
||||
let s:cdBlue = {'gui': '#569CD6', 'cterm': s:cterm0D, 'cterm256': '75'}
|
||||
let s:cdDarkBlue = {'gui': '#223E55', 'cterm': s:cterm0D, 'cterm256': '73'}
|
||||
let s:cdLightBlue = {'gui': '#9CDCFE', 'cterm': s:cterm0C, 'cterm256': '117'}
|
||||
if g:codedark_conservative | let s:cdLightBlue = s:cdFront | endif
|
||||
let s:cdGreen = {'gui': '#608B4E', 'cterm': s:cterm0B, 'cterm256': '65'}
|
||||
let s:cdBlueGreen = {'gui': '#4EC9B0', 'cterm': s:cterm0F, 'cterm256': '43'}
|
||||
let s:cdLightGreen = {'gui': '#B5CEA8', 'cterm': s:cterm09, 'cterm256': '151'}
|
||||
let s:cdRed = {'gui': '#F44747', 'cterm': s:cterm08, 'cterm256': '203'}
|
||||
let s:cdOrange = {'gui': '#CE9178', 'cterm': s:cterm0F, 'cterm256': '173'}
|
||||
let s:cdLightRed = {'gui': '#D16969', 'cterm': s:cterm08, 'cterm256': '167'}
|
||||
if g:codedark_conservative | let s:cdLightRed = s:cdOrange | endif
|
||||
let s:cdYellowOrange = {'gui': '#D7BA7D', 'cterm': s:cterm0A, 'cterm256': '179'}
|
||||
let s:cdYellow = {'gui': '#DCDCAA', 'cterm': s:cterm0A, 'cterm256': '187'}
|
||||
if g:codedark_conservative | let s:cdYellow = s:cdFront | endif
|
||||
let s:cdPink = {'gui': '#C586C0', 'cterm': s:cterm0E, 'cterm256': '176'}
|
||||
if g:codedark_conservative | let s:cdPink = s:cdBlue | endif
|
||||
|
||||
" Vim editor colors
|
||||
" <sid>hi(GROUP, FOREGROUND, BACKGROUND, ATTRIBUTE, SPECIAL)
|
||||
call <sid>hi('Normal', s:cdFront, s:cdBack, 'none', {})
|
||||
call <sid>hi('ColorColumn', {}, s:cdCursorDarkDark, 'none', {})
|
||||
call <sid>hi('Cursor', s:cdCursorDark, s:cdCursorLight, 'none', {})
|
||||
call <sid>hi('CursorLine', {}, s:cdCursorDarkDark, 'none', {})
|
||||
call <sid>hi('CursorColumn', {}, s:cdCursorDarkDark, 'none', {})
|
||||
call <sid>hi('Directory', s:cdBlue, s:cdBack, 'none', {})
|
||||
call <sid>hi('DiffAdd', {}, s:cdDiffGreenDark, 'none', {})
|
||||
call <sid>hi('DiffChange', {}, s:cdDiffRedDark, 'none', {})
|
||||
call <sid>hi('DiffDelete', {}, s:cdDiffRedLight, 'none', {})
|
||||
call <sid>hi('DiffText', {}, s:cdDiffRedLight, 'none', {})
|
||||
call <sid>hi('EndOfBuffer', s:cdLineNumber, s:cdBack, 'none', {})
|
||||
call <sid>hi('ErrorMsg', s:cdRed, s:cdBack, 'none', {})
|
||||
call <sid>hi('VertSplit', s:cdSplitDark, s:cdBack, 'none', {})
|
||||
call <sid>hi('Folded', s:cdLeftLight, s:cdLeftDark, 'underline', {})
|
||||
call <sid>hi('FoldColumn', s:cdLineNumber, s:cdBack, 'none', {})
|
||||
call <sid>hi('SignColumn', {}, s:cdBack, 'none', {})
|
||||
call <sid>hi('IncSearch', s:cdNone, s:cdSearchCurrent, 'none', {})
|
||||
call <sid>hi('LineNr', s:cdLineNumber, s:cdBack, 'none', {})
|
||||
call <sid>hi('CursorLineNr', s:cdPopupFront, s:cdBack, 'none', {})
|
||||
call <sid>hi('MatchParen', s:cdNone, s:cdCursorDark, 'none', {})
|
||||
call <sid>hi('ModeMsg', s:cdFront, s:cdLeftDark, 'none', {})
|
||||
call <sid>hi('MoreMsg', s:cdFront, s:cdLeftDark, 'none', {})
|
||||
call <sid>hi('NonText', s:cdLineNumber, s:cdBack, 'none', {})
|
||||
call <sid>hi('Pmenu', s:cdPopupFront, s:cdPopupBack, 'none', {})
|
||||
call <sid>hi('PmenuSel', s:cdPopupFront, s:cdPopupHighlightBlue, 'none', {})
|
||||
call <sid>hi('PmenuSbar', {}, s:cdPopupHighlightGray, 'none', {})
|
||||
call <sid>hi('PmenuThumb', {}, s:cdPopupFront, 'none', {})
|
||||
call <sid>hi('Question', s:cdBlue, s:cdBack, 'none', {})
|
||||
call <sid>hi('Search', s:cdNone, s:cdSearch, 'none', {})
|
||||
call <sid>hi('SpecialKey', s:cdBlue, s:cdNone, 'none', {})
|
||||
call <sid>hi('SpellBad', s:cdNone, s:cdNone, 'undercurl', {})
|
||||
call <sid>hi('SpellCap', s:cdNone, s:cdNone, 'undercurl', {})
|
||||
call <sid>hi('SpellLocal', s:cdNone, s:cdNone, 'undercurl', {})
|
||||
call <sid>hi('StatusLine', s:cdFront, s:cdLeftMid, 'none', {})
|
||||
call <sid>hi('StatusLineNC', s:cdFront, s:cdLeftDark, 'none', {})
|
||||
call <sid>hi('TabLine', s:cdFront, s:cdTabOther, 'none', {})
|
||||
call <sid>hi('TabLineFill', s:cdFront, s:cdTabOutside, 'none', {})
|
||||
call <sid>hi('TabLineSel', s:cdFront, s:cdTabCurrent, 'none', {})
|
||||
call <sid>hi('Title', s:cdNone, s:cdNone, 'bold', {})
|
||||
call <sid>hi('Visual', s:cdNone, s:cdSelection, 'none', {})
|
||||
call <sid>hi('VisualNOS', s:cdNone, s:cdSelection, 'none', {})
|
||||
call <sid>hi('WarningMsg', s:cdOrange, s:cdBack, 'none', {})
|
||||
call <sid>hi('WildMenu', s:cdNone, s:cdSelection, 'none', {})
|
||||
|
||||
call <sid>hi('Comment', s:cdGreen, {}, 'none', {})
|
||||
|
||||
call <sid>hi('Constant', s:cdBlue, {}, 'none', {})
|
||||
call <sid>hi('String', s:cdOrange, {}, 'none', {})
|
||||
call <sid>hi('Character', s:cdOrange, {}, 'none', {})
|
||||
call <sid>hi('Number', s:cdLightGreen, {}, 'none', {})
|
||||
call <sid>hi('Boolean', s:cdBlue, {}, 'none', {})
|
||||
call <sid>hi('Float', s:cdLightGreen, {}, 'none', {})
|
||||
|
||||
call <sid>hi('Identifier', s:cdLightBlue, {}, 'none', {})
|
||||
call <sid>hi('Function', s:cdYellow, {}, 'none', {})
|
||||
|
||||
call <sid>hi('Statement', s:cdPink, {}, 'none', {})
|
||||
call <sid>hi('Conditional', s:cdPink, {}, 'none', {})
|
||||
call <sid>hi('Repeat', s:cdPink, {}, 'none', {})
|
||||
call <sid>hi('Label', s:cdPink, {}, 'none', {})
|
||||
call <sid>hi('Operator', s:cdFront, {}, 'none', {})
|
||||
call <sid>hi('Keyword', s:cdPink, {}, 'none', {})
|
||||
call <sid>hi('Exception', s:cdPink, {}, 'none', {})
|
||||
|
||||
call <sid>hi('PreProc', s:cdPink, {}, 'none', {})
|
||||
call <sid>hi('Include', s:cdPink, {}, 'none', {})
|
||||
call <sid>hi('Define', s:cdPink, {}, 'none', {})
|
||||
call <sid>hi('Macro', s:cdPink, {}, 'none', {})
|
||||
call <sid>hi('PreCondit', s:cdPink, {}, 'none', {})
|
||||
|
||||
call <sid>hi('Type', s:cdBlue, {}, 'none', {})
|
||||
call <sid>hi('StorageClass', s:cdBlue, {}, 'none', {})
|
||||
call <sid>hi('Structure', s:cdBlue, {}, 'none', {})
|
||||
call <sid>hi('Typedef', s:cdBlue, {}, 'none', {})
|
||||
|
||||
call <sid>hi('Special', s:cdFront, {}, 'none', {})
|
||||
call <sid>hi('SpecialChar', s:cdFront, {}, 'none', {})
|
||||
call <sid>hi('Tag', s:cdFront, {}, 'none', {})
|
||||
call <sid>hi('Delimiter', s:cdFront, {}, 'none', {})
|
||||
call <sid>hi('SpecialComment', s:cdGreen, {}, 'none', {})
|
||||
call <sid>hi('Debug', s:cdFront, {}, 'none', {})
|
||||
|
||||
call <sid>hi('Underlined', s:cdNone, {}, 'underline', {})
|
||||
call <sid>hi("Conceal", s:cdFront, s:cdBack, 'none', {})
|
||||
|
||||
call <sid>hi('Ignore', s:cdFront, {}, 'none', {})
|
||||
|
||||
call <sid>hi('Error', s:cdRed, s:cdBack, 'undercurl', s:cdRed)
|
||||
|
||||
call <sid>hi('Todo', s:cdNone, s:cdLeftMid, 'none', {})
|
||||
|
||||
" Markdown:
|
||||
call <sid>hi('markdownBold', s:cdBlue, {}, 'bold', {})
|
||||
call <sid>hi('markdownCode', s:cdOrange, {}, 'none', {})
|
||||
call <sid>hi('markdownRule', s:cdBlue, {}, 'bold', {})
|
||||
call <sid>hi('markdownCodeDelimiter', s:cdOrange, {}, 'none', {})
|
||||
call <sid>hi('markdownHeadingDelimiter', s:cdBlue, {}, 'none', {})
|
||||
call <sid>hi('markdownFootnote', s:cdOrange, {}, 'none', {})
|
||||
call <sid>hi('markdownFootnoteDefinition', s:cdOrange, {}, 'none', {})
|
||||
call <sid>hi('markdownUrl', s:cdLightBlue, {}, 'underline', {})
|
||||
call <sid>hi('markdownLinkText', s:cdOrange, {}, 'none', {})
|
||||
call <sid>hi('markdownEscape', s:cdYellowOrange, {}, 'none', {})
|
||||
|
||||
" JSON:
|
||||
call <sid>hi('jsonKeyword', s:cdLightBlue, {}, 'none', {})
|
||||
call <sid>hi('jsonEscape', s:cdYellowOrange, {}, 'none', {})
|
||||
call <sid>hi('jsonNull', s:cdBlue, {}, 'none', {})
|
||||
call <sid>hi('jsonBoolean', s:cdBlue, {}, 'none', {})
|
||||
|
||||
" HTML:
|
||||
call <sid>hi('htmlTag', s:cdGray, {}, 'none', {})
|
||||
call <sid>hi('htmlEndTag', s:cdGray, {}, 'none', {})
|
||||
call <sid>hi('htmlTagName', s:cdBlue, {}, 'none', {})
|
||||
call <sid>hi('htmlSpecialTagName', s:cdBlue, {}, 'none', {})
|
||||
call <sid>hi('htmlArg', s:cdLightBlue, {}, 'none', {})
|
||||
|
||||
" CSS:
|
||||
call <sid>hi('cssBraces', s:cdFront, {}, 'none', {})
|
||||
call <sid>hi('cssInclude', s:cdPink, {}, 'none', {})
|
||||
call <sid>hi('cssTagName', s:cdYellowOrange, {}, 'none', {})
|
||||
call <sid>hi('cssClassName', s:cdYellowOrange, {}, 'none', {})
|
||||
call <sid>hi('cssPseudoClass', s:cdYellowOrange, {}, 'none', {})
|
||||
call <sid>hi('cssPseudoClassId', s:cdYellowOrange, {}, 'none', {})
|
||||
call <sid>hi('cssPseudoClassLang', s:cdYellowOrange, {}, 'none', {})
|
||||
call <sid>hi('cssIdentifier', s:cdYellowOrange, {}, 'none', {})
|
||||
call <sid>hi('cssProp', s:cdLightBlue, {}, 'none', {})
|
||||
call <sid>hi('cssDefinition', s:cdLightBlue, {}, 'none', {})
|
||||
call <sid>hi('cssAttr', s:cdOrange, {}, 'none', {})
|
||||
call <sid>hi('cssAttrRegion', s:cdOrange, {}, 'none', {})
|
||||
call <sid>hi('cssColor', s:cdOrange, {}, 'none', {})
|
||||
call <sid>hi('cssFunction', s:cdOrange, {}, 'none', {})
|
||||
call <sid>hi('cssFunctionName', s:cdOrange, {}, 'none', {})
|
||||
call <sid>hi('cssVendor', s:cdOrange, {}, 'none', {})
|
||||
call <sid>hi('cssValueNumber', s:cdOrange, {}, 'none', {})
|
||||
call <sid>hi('cssValueLength', s:cdOrange, {}, 'none', {})
|
||||
call <sid>hi('cssUnitDecorators', s:cdOrange, {}, 'none', {})
|
||||
|
||||
" JavaScript:
|
||||
call <sid>hi('jsVariableDef', s:cdLightBlue, {}, 'none', {})
|
||||
call <sid>hi('jsFuncArgs', s:cdLightBlue, {}, 'none', {})
|
||||
call <sid>hi('jsRegexpString', s:cdLightRed, {}, 'none', {})
|
||||
call <sid>hi('jsThis', s:cdBlue, {}, 'none', {})
|
||||
call <sid>hi('jsDestructuringBlock', s:cdLightBlue, {}, 'none', {})
|
||||
call <sid>hi('jsObjectKey', s:cdLightBlue, {}, 'none', {})
|
||||
call <sid>hi('jsGlobalObjects', s:cdBlueGreen, {}, 'none', {})
|
||||
call <sid>hi('jsModuleKeyword', s:cdLightBlue, {}, 'none', {})
|
||||
call <sid>hi('jsClassDefinition', s:cdBlueGreen, {}, 'none', {})
|
||||
call <sid>hi('jsClassKeyword', s:cdBlue, {}, 'none', {})
|
||||
call <sid>hi('jsExtendsKeyword', s:cdBlue, {}, 'none', {})
|
||||
call <sid>hi('jsExportDefault', s:cdPink, {}, 'none', {})
|
||||
call <sid>hi('jsFuncCall', s:cdYellow, {}, 'none', {})
|
||||
call <sid>hi('jsObjectKey', s:cdYellow, {}, 'none', {})
|
||||
call <sid>hi('jsObjectValue', s:cdLightBlue, {}, 'none', {})
|
||||
call <sid>hi('jsParen', s:cdLightBlue, {}, 'none', {})
|
||||
|
||||
" XML:
|
||||
call <sid>hi('xmlTag', s:cdBlueGreen, {}, 'none', {})
|
||||
call <sid>hi('xmlTagName', s:cdBlueGreen, {}, 'none', {})
|
||||
call <sid>hi('xmlEndTag', s:cdBlueGreen, {}, 'none', {})
|
||||
|
||||
" Ruby:
|
||||
call <sid>hi('rubyClassNameTag', s:cdBlueGreen, {}, 'none', {})
|
||||
call <sid>hi('rubyClassName', s:cdBlueGreen, {}, 'none', {})
|
||||
call <sid>hi('rubyModuleName', s:cdBlueGreen, {}, 'none', {})
|
||||
call <sid>hi('rubyConstant', s:cdBlueGreen, {}, 'none', {})
|
||||
|
||||
" Golang:
|
||||
call <sid>hi('goPackage', s:cdBlue, {}, 'none', {})
|
||||
call <sid>hi('goImport', s:cdBlue, {}, 'none', {})
|
||||
call <sid>hi('goVar', s:cdBlue, {}, 'none', {})
|
||||
call <sid>hi('goConst', s:cdBlue, {}, 'none', {})
|
||||
call <sid>hi('goStatement', s:cdPink, {}, 'none', {})
|
||||
call <sid>hi('goType', s:cdBlue, {}, 'none', {})
|
||||
call <sid>hi('goSignedInts', s:cdBlue, {}, 'none', {})
|
||||
call <sid>hi('goUnsignedInts', s:cdBlue, {}, 'none', {})
|
||||
call <sid>hi('goFloats', s:cdBlue, {}, 'none', {})
|
||||
call <sid>hi('goComplexes', s:cdBlue, {}, 'none', {})
|
||||
call <sid>hi('goBuiltins', s:cdYellow, {}, 'none', {})
|
||||
call <sid>hi('goBoolean', s:cdBlue, {}, 'none', {})
|
||||
call <sid>hi('goPredefinedIdentifiers', s:cdBlue, {}, 'none', {})
|
||||
call <sid>hi('goTodo', s:cdGreen, {}, 'none', {})
|
||||
call <sid>hi('goDeclaration', s:cdBlue, {}, 'none', {})
|
||||
call <sid>hi('goDeclType', s:cdBlue, {}, 'none', {})
|
||||
call <sid>hi('goTypeDecl', s:cdBlue, {}, 'none', {})
|
||||
call <sid>hi('goTypeName', s:cdBlueGreen, {}, 'none', {})
|
||||
call <sid>hi('goVarAssign', s:cdLightBlue, {}, 'none', {})
|
||||
call <sid>hi('goVarDefs', s:cdLightBlue, {}, 'none', {})
|
||||
call <sid>hi('goReceiver', s:cdFront, {}, 'none', {})
|
||||
call <sid>hi('goReceiverType', s:cdDarkBlue, {}, 'none', {})
|
||||
call <sid>hi('goFunctionCall', s:cdYellow, {}, 'none', {})
|
||||
call <sid>hi('goMethodCall', s:cdYellow, {}, 'none', {})
|
||||
call <sid>hi('goSingleDecl', s:cdLightBlue, {}, 'none', {})
|
||||
|
||||
" Python:
|
||||
call <sid>hi('pythonStatement', s:cdBlue, {}, 'none', {})
|
||||
call <sid>hi('pythonOperator', s:cdBlue, {}, 'none', {})
|
||||
call <sid>hi('pythonException', s:cdPink, {}, 'none', {})
|
||||
call <sid>hi('pythonExClass', s:cdBlueGreen, {}, 'none', {})
|
||||
call <sid>hi('pythonBuiltinObj', s:cdLightBlue, {}, 'none', {})
|
||||
call <sid>hi('pythonBuiltinType', s:cdBlueGreen, {}, 'none', {})
|
||||
call <sid>hi('pythonBoolean', s:cdBlue, {}, 'none', {})
|
||||
call <sid>hi('pythonNone', s:cdBlue, {}, 'none', {})
|
||||
call <sid>hi('pythonTodo', s:cdBlue, {}, 'none', {})
|
||||
call <sid>hi('pythonClassVar', s:cdBlue, {}, 'none', {})
|
||||
call <sid>hi('pythonClassDef', s:cdBlueGreen, {}, 'none', {})
|
||||
|
||||
" TeX:
|
||||
call <sid>hi('texStatement', s:cdBlue, {}, 'none', {})
|
||||
call <sid>hi('texBeginEnd', s:cdYellow, {}, 'none', {})
|
||||
call <sid>hi('texBeginEndName', s:cdLightBlue, {}, 'none', {})
|
||||
call <sid>hi('texOption', s:cdLightBlue, {}, 'none', {})
|
||||
call <sid>hi('texBeginEndModifier', s:cdLightBlue, {}, 'none', {})
|
||||
call <sid>hi('texDocType', s:cdPink, {}, 'none', {})
|
||||
call <sid>hi('texDocTypeArgs', s:cdLightBlue, {}, 'none', {})
|
||||
|
||||
" Git:
|
||||
call <sid>hi('gitcommitHeader', s:cdGray, {}, 'none', {})
|
||||
call <sid>hi('gitcommitOnBranch', s:cdGray, {}, 'none', {})
|
||||
call <sid>hi('gitcommitBranch', s:cdPink, {}, 'none', {})
|
||||
call <sid>hi('gitcommitComment', s:cdGray, {}, 'none', {})
|
||||
call <sid>hi('gitcommitSelectedType', s:cdGreen, {}, 'none', {})
|
||||
call <sid>hi('gitcommitSelectedFile', s:cdGreen, {}, 'none', {})
|
||||
call <sid>hi('gitcommitDiscardedType', s:cdRed, {}, 'none', {})
|
||||
call <sid>hi('gitcommitDiscardedFile', s:cdRed, {}, 'none', {})
|
||||
call <sid>hi('gitcommitOverflow', s:cdRed, {}, 'none', {})
|
||||
call <sid>hi('gitcommitSummary', s:cdPink, {}, 'none', {})
|
||||
call <sid>hi('gitcommitBlank', s:cdPink, {}, 'none', {})
|
||||
|
673
plugin/auto-pairs.vim
Normal file
673
plugin/auto-pairs.vim
Normal file
|
@ -0,0 +1,673 @@
|
|||
" Insert or delete brackets, parens, quotes in pairs.
|
||||
" Maintainer: JiangMiao <jiangfriend@gmail.com>
|
||||
" Contributor: camthompson
|
||||
" Last Change: 2019-02-02
|
||||
" Version: 2.0.0
|
||||
" Homepage: http://www.vim.org/scripts/script.php?script_id=3599
|
||||
" Repository: https://github.com/jiangmiao/auto-pairs
|
||||
" License: MIT
|
||||
|
||||
if exists('g:AutoPairsLoaded') || &cp
|
||||
finish
|
||||
end
|
||||
let g:AutoPairsLoaded = 1
|
||||
|
||||
if !exists('g:AutoPairs')
|
||||
let g:AutoPairs = {'(':')', '[':']', '{':'}',"'":"'",'"':'"', '```':'```', '"""':'"""', "'''":"'''", "`":"`"}
|
||||
end
|
||||
|
||||
" default pairs base on filetype
|
||||
func! AutoPairsDefaultPairs()
|
||||
if exists('b:autopairs_defaultpairs')
|
||||
return b:autopairs_defaultpairs
|
||||
end
|
||||
let r = copy(g:AutoPairs)
|
||||
let allPairs = {
|
||||
\ 'vim': {'\v^\s*\zs"': ''},
|
||||
\ 'rust': {'\w\zs<': '>', '&\zs''': ''},
|
||||
\ 'php': {'<?': '?>//k]', '<?php': '?>//k]'}
|
||||
\ }
|
||||
for [filetype, pairs] in items(allPairs)
|
||||
if &filetype == filetype
|
||||
for [open, close] in items(pairs)
|
||||
let r[open] = close
|
||||
endfor
|
||||
end
|
||||
endfor
|
||||
let b:autopairs_defaultpairs = r
|
||||
return r
|
||||
endf
|
||||
|
||||
if !exists('g:AutoPairsMapBS')
|
||||
let g:AutoPairsMapBS = 1
|
||||
end
|
||||
|
||||
" Map <C-h> as the same BS
|
||||
if !exists('g:AutoPairsMapCh')
|
||||
let g:AutoPairsMapCh = 1
|
||||
end
|
||||
|
||||
if !exists('g:AutoPairsMapCR')
|
||||
let g:AutoPairsMapCR = 1
|
||||
end
|
||||
|
||||
if !exists('g:AutoPairsWildClosedPair')
|
||||
let g:AutoPairsWildClosedPair = ''
|
||||
end
|
||||
|
||||
if !exists('g:AutoPairsMapSpace')
|
||||
let g:AutoPairsMapSpace = 1
|
||||
end
|
||||
|
||||
if !exists('g:AutoPairsCenterLine')
|
||||
let g:AutoPairsCenterLine = 1
|
||||
end
|
||||
|
||||
if !exists('g:AutoPairsShortcutToggle')
|
||||
let g:AutoPairsShortcutToggle = '<M-p>'
|
||||
end
|
||||
|
||||
if !exists('g:AutoPairsShortcutFastWrap')
|
||||
let g:AutoPairsShortcutFastWrap = '<M-e>'
|
||||
end
|
||||
|
||||
if !exists('g:AutoPairsMoveCharacter')
|
||||
let g:AutoPairsMoveCharacter = "()[]{}\"'"
|
||||
end
|
||||
|
||||
if !exists('g:AutoPairsShortcutJump')
|
||||
let g:AutoPairsShortcutJump = '<M-n>'
|
||||
endif
|
||||
|
||||
" Fly mode will for closed pair to jump to closed pair instead of insert.
|
||||
" also support AutoPairsBackInsert to insert pairs where jumped.
|
||||
if !exists('g:AutoPairsFlyMode')
|
||||
let g:AutoPairsFlyMode = 0
|
||||
endif
|
||||
|
||||
" When skipping the closed pair, look at the current and
|
||||
" next line as well.
|
||||
if !exists('g:AutoPairsMultilineClose')
|
||||
let g:AutoPairsMultilineClose = 1
|
||||
endif
|
||||
|
||||
" Work with Fly Mode, insert pair where jumped
|
||||
if !exists('g:AutoPairsShortcutBackInsert')
|
||||
let g:AutoPairsShortcutBackInsert = '<M-b>'
|
||||
endif
|
||||
|
||||
if !exists('g:AutoPairsSmartQuotes')
|
||||
let g:AutoPairsSmartQuotes = 1
|
||||
endif
|
||||
|
||||
" 7.4.849 support <C-G>U to avoid breaking '.'
|
||||
" Issue talk: https://github.com/jiangmiao/auto-pairs/issues/3
|
||||
" Vim note: https://github.com/vim/vim/releases/tag/v7.4.849
|
||||
if v:version > 704 || v:version == 704 && has("patch849")
|
||||
let s:Go = "\<C-G>U"
|
||||
else
|
||||
let s:Go = ""
|
||||
endif
|
||||
|
||||
let s:Left = s:Go."\<LEFT>"
|
||||
let s:Right = s:Go."\<RIGHT>"
|
||||
|
||||
|
||||
|
||||
|
||||
" unicode len
|
||||
func! s:ulen(s)
|
||||
return len(split(a:s, '\zs'))
|
||||
endf
|
||||
|
||||
func! s:left(s)
|
||||
return repeat(s:Left, s:ulen(a:s))
|
||||
endf
|
||||
|
||||
func! s:right(s)
|
||||
return repeat(s:Right, s:ulen(a:s))
|
||||
endf
|
||||
|
||||
func! s:delete(s)
|
||||
return repeat("\<DEL>", s:ulen(a:s))
|
||||
endf
|
||||
|
||||
func! s:backspace(s)
|
||||
return repeat("\<BS>", s:ulen(a:s))
|
||||
endf
|
||||
|
||||
func! s:getline()
|
||||
let line = getline('.')
|
||||
let pos = col('.') - 1
|
||||
let before = strpart(line, 0, pos)
|
||||
let after = strpart(line, pos)
|
||||
let afterline = after
|
||||
if g:AutoPairsMultilineClose
|
||||
let n = line('$')
|
||||
let i = line('.')+1
|
||||
while i <= n
|
||||
let line = getline(i)
|
||||
let after = after.' '.line
|
||||
if !(line =~ '\v^\s*$')
|
||||
break
|
||||
end
|
||||
let i = i+1
|
||||
endwhile
|
||||
end
|
||||
return [before, after, afterline]
|
||||
endf
|
||||
|
||||
" split text to two part
|
||||
" returns [orig, text_before_open, open]
|
||||
func! s:matchend(text, open)
|
||||
let m = matchstr(a:text, '\V'.a:open.'\v$')
|
||||
if m == ""
|
||||
return []
|
||||
end
|
||||
return [a:text, strpart(a:text, 0, len(a:text)-len(m)), m]
|
||||
endf
|
||||
|
||||
" returns [orig, close, text_after_close]
|
||||
func! s:matchbegin(text, close)
|
||||
let m = matchstr(a:text, '^\V'.a:close)
|
||||
if m == ""
|
||||
return []
|
||||
end
|
||||
return [a:text, m, strpart(a:text, len(m), len(a:text)-len(m))]
|
||||
endf
|
||||
|
||||
" add or delete pairs base on g:AutoPairs
|
||||
" AutoPairsDefine(addPairs:dict[, removeOpenPairList:list])
|
||||
"
|
||||
" eg:
|
||||
" au FileType html let b:AutoPairs = AutoPairsDefine({'<!--' : '-->'}, ['{'])
|
||||
" add <!-- --> pair and remove '{' for html file
|
||||
func! AutoPairsDefine(pairs, ...)
|
||||
let r = AutoPairsDefaultPairs()
|
||||
if a:0 > 0
|
||||
for open in a:1
|
||||
unlet r[open]
|
||||
endfor
|
||||
end
|
||||
for [open, close] in items(a:pairs)
|
||||
let r[open] = close
|
||||
endfor
|
||||
return r
|
||||
endf
|
||||
|
||||
func! AutoPairsInsert(key)
|
||||
if !b:autopairs_enabled
|
||||
return a:key
|
||||
end
|
||||
|
||||
let b:autopairs_saved_pair = [a:key, getpos('.')]
|
||||
|
||||
let [before, after, afterline] = s:getline()
|
||||
|
||||
" Ignore auto close if prev character is \
|
||||
if before[-1:-1] == '\'
|
||||
return a:key
|
||||
end
|
||||
|
||||
" check open pairs
|
||||
for [open, close, opt] in b:AutoPairsList
|
||||
let ms = s:matchend(before.a:key, open)
|
||||
let m = matchstr(afterline, '^\v\s*\zs\V'.close)
|
||||
if len(ms) > 0
|
||||
" process the open pair
|
||||
|
||||
" remove inserted pair
|
||||
" eg: if the pairs include < > and <!-- -->
|
||||
" when <!-- is detected the inserted pair < > should be clean up
|
||||
let target = ms[1]
|
||||
let openPair = ms[2]
|
||||
if len(openPair) == 1 && m == openPair
|
||||
break
|
||||
end
|
||||
let bs = ''
|
||||
let del = ''
|
||||
while len(before) > len(target)
|
||||
let found = 0
|
||||
" delete pair
|
||||
for [o, c, opt] in b:AutoPairsList
|
||||
let os = s:matchend(before, o)
|
||||
if len(os) && len(os[1]) < len(target)
|
||||
" any text before openPair should not be deleted
|
||||
continue
|
||||
end
|
||||
let cs = s:matchbegin(afterline, c)
|
||||
if len(os) && len(cs)
|
||||
let found = 1
|
||||
let before = os[1]
|
||||
let afterline = cs[2]
|
||||
let bs = bs.s:backspace(os[2])
|
||||
let del = del.s:delete(cs[1])
|
||||
break
|
||||
end
|
||||
endfor
|
||||
if !found
|
||||
" delete charactor
|
||||
let ms = s:matchend(before, '\v.')
|
||||
if len(ms)
|
||||
let before = ms[1]
|
||||
let bs = bs.s:backspace(ms[2])
|
||||
end
|
||||
end
|
||||
endwhile
|
||||
return bs.del.openPair.close.s:left(close)
|
||||
end
|
||||
endfor
|
||||
|
||||
" check close pairs
|
||||
for [open, close, opt] in b:AutoPairsList
|
||||
if close == ''
|
||||
continue
|
||||
end
|
||||
if a:key == g:AutoPairsWildClosedPair || opt['mapclose'] && opt['key'] == a:key
|
||||
" the close pair is in the same line
|
||||
let m = matchstr(afterline, '^\v\s*\V'.close)
|
||||
if m != ''
|
||||
if before =~ '\V'.open.'\v\s*$' && m[0] =~ '\v\s'
|
||||
" remove the space we inserted if the text in pairs is blank
|
||||
return "\<DEL>".s:right(m[1:])
|
||||
else
|
||||
return s:right(m)
|
||||
end
|
||||
end
|
||||
let m = matchstr(after, '^\v\s*\zs\V'.close)
|
||||
if m != ''
|
||||
if a:key == g:AutoPairsWildClosedPair || opt['multiline']
|
||||
if b:autopairs_return_pos == line('.') && getline('.') =~ '\v^\s*$'
|
||||
normal! ddk$
|
||||
end
|
||||
call search(m, 'We')
|
||||
return "\<Right>"
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
endfor
|
||||
|
||||
|
||||
" Fly Mode, and the key is closed-pairs, search closed-pair and jump
|
||||
if g:AutoPairsFlyMode && a:key =~ '\v[\}\]\)]'
|
||||
if search(a:key, 'We')
|
||||
return "\<Right>"
|
||||
endif
|
||||
endif
|
||||
|
||||
return a:key
|
||||
endf
|
||||
|
||||
func! AutoPairsDelete()
|
||||
if !b:autopairs_enabled
|
||||
return "\<BS>"
|
||||
end
|
||||
|
||||
let [before, after, ig] = s:getline()
|
||||
for [open, close, opt] in b:AutoPairsList
|
||||
let b = matchstr(before, '\V'.open.'\v\s?$')
|
||||
let a = matchstr(after, '^\v\s*\V'.close)
|
||||
if b != '' && a != ''
|
||||
if b[-1:-1] == ' '
|
||||
if a[0] == ' '
|
||||
return "\<BS>\<DELETE>"
|
||||
else
|
||||
return "\<BS>"
|
||||
end
|
||||
end
|
||||
return s:backspace(b).s:delete(a)
|
||||
end
|
||||
endfor
|
||||
|
||||
return "\<BS>"
|
||||
" delete the pair foo[]| <BS> to foo
|
||||
for [open, close, opt] in b:AutoPairsList
|
||||
let m = s:matchend(before, '\V'.open.'\v\s*'.'\V'.close.'\v$')
|
||||
if len(m) > 0
|
||||
return s:backspace(m[2])
|
||||
end
|
||||
endfor
|
||||
return "\<BS>"
|
||||
endf
|
||||
|
||||
|
||||
" Fast wrap the word in brackets
|
||||
func! AutoPairsFastWrap()
|
||||
let c = @"
|
||||
normal! x
|
||||
let [before, after, ig] = s:getline()
|
||||
if after[0] =~ '\v[\{\[\(\<]'
|
||||
normal! %
|
||||
normal! p
|
||||
else
|
||||
for [open, close, opt] in b:AutoPairsList
|
||||
if close == ''
|
||||
continue
|
||||
end
|
||||
if after =~ '^\s*\V'.open
|
||||
call search(close, 'We')
|
||||
normal! p
|
||||
let @" = c
|
||||
return ""
|
||||
end
|
||||
endfor
|
||||
if after[1:1] =~ '\v\w'
|
||||
normal! e
|
||||
normal! p
|
||||
else
|
||||
normal! p
|
||||
end
|
||||
end
|
||||
let @" = c
|
||||
return ""
|
||||
endf
|
||||
|
||||
func! AutoPairsJump()
|
||||
call search('["\]'')}]','W')
|
||||
endf
|
||||
|
||||
func! AutoPairsMoveCharacter(key)
|
||||
let c = getline(".")[col(".")-1]
|
||||
let escaped_key = substitute(a:key, "'", "''", 'g')
|
||||
return "\<DEL>\<ESC>:call search("."'".escaped_key."'".")\<CR>a".c."\<LEFT>"
|
||||
endf
|
||||
|
||||
func! AutoPairsBackInsert()
|
||||
let pair = b:autopairs_saved_pair[0]
|
||||
let pos = b:autopairs_saved_pair[1]
|
||||
call setpos('.', pos)
|
||||
return pair
|
||||
endf
|
||||
|
||||
func! AutoPairsReturn()
|
||||
if b:autopairs_enabled == 0
|
||||
return ''
|
||||
end
|
||||
let b:autopairs_return_pos = 0
|
||||
let before = getline(line('.')-1)
|
||||
let [ig, ig, afterline] = s:getline()
|
||||
let cmd = ''
|
||||
for [open, close, opt] in b:AutoPairsList
|
||||
if close == ''
|
||||
continue
|
||||
end
|
||||
|
||||
if before =~ '\V'.open.'\v\s*$' && afterline =~ '^\s*\V'.close
|
||||
let b:autopairs_return_pos = line('.')
|
||||
if g:AutoPairsCenterLine && winline() * 3 >= winheight(0) * 2
|
||||
" Recenter before adding new line to avoid replacing line content
|
||||
let cmd = "zz"
|
||||
end
|
||||
|
||||
" If equalprg has been set, then avoid call =
|
||||
" https://github.com/jiangmiao/auto-pairs/issues/24
|
||||
if &equalprg != ''
|
||||
return "\<ESC>".cmd."O"
|
||||
endif
|
||||
|
||||
" conflict with javascript and coffee
|
||||
" javascript need indent new line
|
||||
" coffeescript forbid indent new line
|
||||
if &filetype == 'coffeescript' || &filetype == 'coffee'
|
||||
return "\<ESC>".cmd."k==o"
|
||||
else
|
||||
return "\<ESC>".cmd."=ko"
|
||||
endif
|
||||
end
|
||||
endfor
|
||||
return ''
|
||||
endf
|
||||
|
||||
func! AutoPairsSpace()
|
||||
if !b:autopairs_enabled
|
||||
return "\<SPACE>"
|
||||
end
|
||||
|
||||
let [before, after, ig] = s:getline()
|
||||
|
||||
for [open, close, opt] in b:AutoPairsList
|
||||
if close == ''
|
||||
continue
|
||||
end
|
||||
if before =~ '\V'.open.'\v$' && after =~ '^\V'.close
|
||||
if close =~ '\v^[''"`]$'
|
||||
return "\<SPACE>"
|
||||
else
|
||||
return "\<SPACE>\<SPACE>".s:Left
|
||||
end
|
||||
end
|
||||
endfor
|
||||
return "\<SPACE>"
|
||||
endf
|
||||
|
||||
func! AutoPairsMap(key)
|
||||
" | is special key which separate map command from text
|
||||
let key = a:key
|
||||
if key == '|'
|
||||
let key = '<BAR>'
|
||||
end
|
||||
let escaped_key = substitute(key, "'", "''", 'g')
|
||||
" use expr will cause search() doesn't work
|
||||
execute 'inoremap <buffer> <silent> '.key." <C-R>=AutoPairsInsert('".escaped_key."')<CR>"
|
||||
endf
|
||||
|
||||
func! AutoPairsToggle()
|
||||
if b:autopairs_enabled
|
||||
let b:autopairs_enabled = 0
|
||||
echo 'AutoPairs Disabled.'
|
||||
else
|
||||
let b:autopairs_enabled = 1
|
||||
echo 'AutoPairs Enabled.'
|
||||
end
|
||||
return ''
|
||||
endf
|
||||
|
||||
func! s:sortByLength(i1, i2)
|
||||
return len(a:i2[0])-len(a:i1[0])
|
||||
endf
|
||||
|
||||
func! AutoPairsInit()
|
||||
let b:autopairs_loaded = 1
|
||||
if !exists('b:autopairs_enabled')
|
||||
let b:autopairs_enabled = 1
|
||||
end
|
||||
|
||||
if !exists('b:AutoPairs')
|
||||
let b:AutoPairs = AutoPairsDefaultPairs()
|
||||
end
|
||||
|
||||
if !exists('b:AutoPairsMoveCharacter')
|
||||
let b:AutoPairsMoveCharacter = g:AutoPairsMoveCharacter
|
||||
end
|
||||
|
||||
let b:autopairs_return_pos = 0
|
||||
let b:autopairs_saved_pair = [0, 0]
|
||||
let b:AutoPairsList = []
|
||||
|
||||
" buffer level map pairs keys
|
||||
" n - do not map the first charactor of closed pair to close key
|
||||
" m - close key jumps through multi line
|
||||
" s - close key jumps only in the same line
|
||||
for [open, close] in items(b:AutoPairs)
|
||||
let o = open[-1:-1]
|
||||
let c = close[0]
|
||||
let opt = {'mapclose': 1, 'multiline':1}
|
||||
let opt['key'] = c
|
||||
if o == c
|
||||
let opt['multiline'] = 0
|
||||
end
|
||||
let m = matchlist(close, '\v(.*)//(.*)$')
|
||||
if len(m) > 0
|
||||
if m[2] =~ 'n'
|
||||
let opt['mapclose'] = 0
|
||||
end
|
||||
if m[2] =~ 'm'
|
||||
let opt['multiline'] = 1
|
||||
end
|
||||
if m[2] =~ 's'
|
||||
let opt['multiline'] = 0
|
||||
end
|
||||
let ks = matchlist(m[2], '\vk(.)')
|
||||
if len(ks) > 0
|
||||
let opt['key'] = ks[1]
|
||||
let c = opt['key']
|
||||
end
|
||||
let close = m[1]
|
||||
end
|
||||
call AutoPairsMap(o)
|
||||
if o != c && c != '' && opt['mapclose']
|
||||
call AutoPairsMap(c)
|
||||
end
|
||||
let b:AutoPairsList += [[open, close, opt]]
|
||||
endfor
|
||||
|
||||
" sort pairs by length, longer pair should have higher priority
|
||||
let b:AutoPairsList = sort(b:AutoPairsList, "s:sortByLength")
|
||||
|
||||
for item in b:AutoPairsList
|
||||
let [open, close, opt] = item
|
||||
if open == "'" && open == close
|
||||
let item[0] = '\v(^|\W)\zs'''
|
||||
end
|
||||
endfor
|
||||
|
||||
|
||||
for key in split(b:AutoPairsMoveCharacter, '\s*')
|
||||
let escaped_key = substitute(key, "'", "''", 'g')
|
||||
execute 'inoremap <silent> <buffer> <M-'.key."> <C-R>=AutoPairsMoveCharacter('".escaped_key."')<CR>"
|
||||
endfor
|
||||
|
||||
" Still use <buffer> level mapping for <BS> <SPACE>
|
||||
if g:AutoPairsMapBS
|
||||
" Use <C-R> instead of <expr> for issue #14 sometimes press BS output strange words
|
||||
execute 'inoremap <buffer> <silent> <BS> <C-R>=AutoPairsDelete()<CR>'
|
||||
end
|
||||
|
||||
if g:AutoPairsMapCh
|
||||
execute 'inoremap <buffer> <silent> <C-h> <C-R>=AutoPairsDelete()<CR>'
|
||||
endif
|
||||
|
||||
if g:AutoPairsMapSpace
|
||||
" Try to respect abbreviations on a <SPACE>
|
||||
let do_abbrev = ""
|
||||
if v:version == 703 && has("patch489") || v:version > 703
|
||||
let do_abbrev = "<C-]>"
|
||||
endif
|
||||
execute 'inoremap <buffer> <silent> <SPACE> '.do_abbrev.'<C-R>=AutoPairsSpace()<CR>'
|
||||
end
|
||||
|
||||
if g:AutoPairsShortcutFastWrap != ''
|
||||
execute 'inoremap <buffer> <silent> '.g:AutoPairsShortcutFastWrap.' <C-R>=AutoPairsFastWrap()<CR>'
|
||||
end
|
||||
|
||||
if g:AutoPairsShortcutBackInsert != ''
|
||||
execute 'inoremap <buffer> <silent> '.g:AutoPairsShortcutBackInsert.' <C-R>=AutoPairsBackInsert()<CR>'
|
||||
end
|
||||
|
||||
if g:AutoPairsShortcutToggle != ''
|
||||
" use <expr> to ensure showing the status when toggle
|
||||
execute 'inoremap <buffer> <silent> <expr> '.g:AutoPairsShortcutToggle.' AutoPairsToggle()'
|
||||
execute 'noremap <buffer> <silent> '.g:AutoPairsShortcutToggle.' :call AutoPairsToggle()<CR>'
|
||||
end
|
||||
|
||||
if g:AutoPairsShortcutJump != ''
|
||||
execute 'inoremap <buffer> <silent> ' . g:AutoPairsShortcutJump. ' <ESC>:call AutoPairsJump()<CR>a'
|
||||
execute 'noremap <buffer> <silent> ' . g:AutoPairsShortcutJump. ' :call AutoPairsJump()<CR>'
|
||||
end
|
||||
|
||||
if &keymap != ''
|
||||
let l:imsearch = &imsearch
|
||||
let l:iminsert = &iminsert
|
||||
let l:imdisable = &imdisable
|
||||
execute 'setlocal keymap=' . &keymap
|
||||
execute 'setlocal imsearch=' . l:imsearch
|
||||
execute 'setlocal iminsert=' . l:iminsert
|
||||
if l:imdisable
|
||||
execute 'setlocal imdisable'
|
||||
else
|
||||
execute 'setlocal noimdisable'
|
||||
end
|
||||
end
|
||||
|
||||
endf
|
||||
|
||||
func! s:ExpandMap(map)
|
||||
let map = a:map
|
||||
let map = substitute(map, '\(<Plug>\w\+\)', '\=maparg(submatch(1), "i")', 'g')
|
||||
let map = substitute(map, '\(<Plug>([^)]*)\)', '\=maparg(submatch(1), "i")', 'g')
|
||||
return map
|
||||
endf
|
||||
|
||||
func! AutoPairsTryInit()
|
||||
if exists('b:autopairs_loaded')
|
||||
return
|
||||
end
|
||||
|
||||
" for auto-pairs starts with 'a', so the priority is higher than supertab and vim-endwise
|
||||
"
|
||||
" vim-endwise doesn't support <Plug>AutoPairsReturn
|
||||
" when use <Plug>AutoPairsReturn will cause <Plug> isn't expanded
|
||||
"
|
||||
" supertab doesn't support <SID>AutoPairsReturn
|
||||
" when use <SID>AutoPairsReturn will cause Duplicated <CR>
|
||||
"
|
||||
" and when load after vim-endwise will cause unexpected endwise inserted.
|
||||
" so always load AutoPairs at last
|
||||
|
||||
" Buffer level keys mapping
|
||||
" comptible with other plugin
|
||||
if g:AutoPairsMapCR
|
||||
if v:version == 703 && has('patch32') || v:version > 703
|
||||
" VIM 7.3 supports advancer maparg which could get <expr> info
|
||||
" then auto-pairs could remap <CR> in any case.
|
||||
let info = maparg('<CR>', 'i', 0, 1)
|
||||
if empty(info)
|
||||
let old_cr = '<CR>'
|
||||
let is_expr = 0
|
||||
else
|
||||
let old_cr = info['rhs']
|
||||
let old_cr = s:ExpandMap(old_cr)
|
||||
let old_cr = substitute(old_cr, '<SID>', '<SNR>' . info['sid'] . '_', 'g')
|
||||
let is_expr = info['expr']
|
||||
let wrapper_name = '<SID>AutoPairsOldCRWrapper73'
|
||||
endif
|
||||
else
|
||||
" VIM version less than 7.3
|
||||
" the mapping's <expr> info is lost, so guess it is expr or not, it's
|
||||
" not accurate.
|
||||
let old_cr = maparg('<CR>', 'i')
|
||||
if old_cr == ''
|
||||
let old_cr = '<CR>'
|
||||
let is_expr = 0
|
||||
else
|
||||
let old_cr = s:ExpandMap(old_cr)
|
||||
" old_cr contain (, I guess the old cr is in expr mode
|
||||
let is_expr = old_cr =~ '\V(' && toupper(old_cr) !~ '\V<C-R>'
|
||||
|
||||
" The old_cr start with " it must be in expr mode
|
||||
let is_expr = is_expr || old_cr =~ '\v^"'
|
||||
let wrapper_name = '<SID>AutoPairsOldCRWrapper'
|
||||
end
|
||||
end
|
||||
|
||||
if old_cr !~ 'AutoPairsReturn'
|
||||
if is_expr
|
||||
" remap <expr> to `name` to avoid mix expr and non-expr mode
|
||||
execute 'inoremap <buffer> <expr> <script> '. wrapper_name . ' ' . old_cr
|
||||
let old_cr = wrapper_name
|
||||
end
|
||||
" Always silent mapping
|
||||
execute 'inoremap <script> <buffer> <silent> <CR> '.old_cr.'<SID>AutoPairsReturn'
|
||||
end
|
||||
endif
|
||||
call AutoPairsInit()
|
||||
endf
|
||||
|
||||
" Always silent the command
|
||||
inoremap <silent> <SID>AutoPairsReturn <C-R>=AutoPairsReturn()<CR>
|
||||
imap <script> <Plug>AutoPairsReturn <SID>AutoPairsReturn
|
||||
|
||||
|
||||
au BufEnter * :call AutoPairsTryInit()
|
212
plugin/endwise.vim
Normal file
212
plugin/endwise.vim
Normal file
|
@ -0,0 +1,212 @@
|
|||
" Location: plugin/endwise.vim
|
||||
" Author: Tim Pope <http://tpo.pe/>
|
||||
" Version: 1.2
|
||||
" License: Same as Vim itself. See :help license
|
||||
" GetLatestVimScripts: 2386 1 :AutoInstall: endwise.vim
|
||||
|
||||
if exists("g:loaded_endwise") || &cp
|
||||
finish
|
||||
endif
|
||||
let g:loaded_endwise = 1
|
||||
|
||||
augroup endwise " {{{1
|
||||
autocmd!
|
||||
autocmd FileType lua
|
||||
\ let b:endwise_addition = 'end' |
|
||||
\ let b:endwise_words = 'function,do,then' |
|
||||
\ let b:endwise_pattern = '^\s*\zs\%(\%(local\s\+\)\=function\)\>\%(.*\<end\>\)\@!\|\<\%(then\|do\)\ze\s*$' |
|
||||
\ let b:endwise_syngroups = 'luaFunction,luaStatement,luaCond'
|
||||
autocmd FileType elixir
|
||||
\ let b:endwise_addition = 'end' |
|
||||
\ let b:endwise_words = 'do,fn' |
|
||||
\ let b:endwise_pattern = '.*[^.:@$]\zs\<\%(do\(:\)\@!\|fn\)\>\ze\%(.*[^.:@$]\<end\>\)\@!' |
|
||||
\ let b:endwise_syngroups = 'elixirBlockDefinition'
|
||||
autocmd FileType ruby
|
||||
\ let b:endwise_addition = 'end' |
|
||||
\ let b:endwise_words = 'module,class,def,if,unless,case,while,until,begin,do' |
|
||||
\ let b:endwise_pattern = '^\(.*=\)\?\s*\%(private\s\+\|protected\s\+\|public\s\+\|module_function\s\+\)*\zs\%(module\|class\|def\|if\|unless\|case\|while\|until\|for\|\|begin\)\>\%(.*[^.:@$]\<end\>\)\@!\|\<do\ze\%(\s*|.*|\)\=\s*$' |
|
||||
\ let b:endwise_syngroups = 'rubyModule,rubyClass,rubyDefine,rubyControl,rubyConditional,rubyRepeat'
|
||||
autocmd FileType crystal
|
||||
\ let b:endwise_addition = 'end' |
|
||||
\ let b:endwise_words = 'module,class,lib,macro,struct,union,enum,def,if,unless,ifdef,case,while,until,for,begin,do' |
|
||||
\ let b:endwise_pattern = '^\(.*=\)\?\s*\%(private\s\+\|protected\s\+\|public\s\+\|abstract\s\+\)*\zs\%(module\|class\|lib\|macro\|struct\|union\|enum\|def\|if\|unless\|ifdef\|case\|while\|until\|for\|begin\)\>\%(.*[^.:@$]\<end\>\)\@!\|\<do\ze\%(\s*|.*|\)\=\s*$' |
|
||||
\ let b:endwise_syngroups = 'crystalModule,crystalClass,crystalLib,crystalMacro,crystalStruct,crystalEnum,crystalDefine,crystalConditional,crystalRepeat,crystalControl'
|
||||
autocmd FileType sh,zsh
|
||||
\ let b:endwise_addition = '\=submatch(0)=="then" ? "fi" : submatch(0)=="case" ? "esac" : "done"' |
|
||||
\ let b:endwise_words = 'then,case,do' |
|
||||
\ let b:endwise_pattern = '\%(^\s*\zscase\>\ze\|\zs\<\%(do\|then\)\ze\s*$\)' |
|
||||
\ let b:endwise_syngroups = 'shConditional,shLoop,shIf,shFor,shRepeat,shCaseEsac,zshConditional,zshRepeat,zshDelimiter'
|
||||
autocmd FileType vb,vbnet,aspvbs
|
||||
\ let b:endwise_addition = 'End &' |
|
||||
\ let b:endwise_words = 'Function,Sub,Class,Module,Enum,Namespace' |
|
||||
\ let b:endwise_pattern = '\%(\<End\>.*\)\@<!\<&\>' |
|
||||
\ let b:endwise_syngroups = 'vbStatement,vbnetStorage,vbnetProcedure,vbnet.*Words,AspVBSStatement'
|
||||
autocmd FileType vim
|
||||
\ let b:endwise_addition = '\=submatch(0)=~"aug\\%[roup]" ? submatch(0) . " END" : "end" . submatch(0)' |
|
||||
\ let b:endwise_words = 'fu\%[nction],wh\%[ile],if,for,try,aug\%[roup]\%(\s\+\cEND\)\@!' |
|
||||
\ let b:endwise_end_pattern = '\%(end\%(fu\%[nction]\|wh\%[hile]\|if\|for\|try\)\)\|aug\%[roup]\%(\s\+\cEND\)' |
|
||||
\ let b:endwise_syngroups = 'vimFuncKey,vimNotFunc,vimCommand,vimAugroupKey,vimAugroup,vimAugroupError'
|
||||
autocmd FileType c,cpp,xdefaults,haskell
|
||||
\ let b:endwise_addition = '#endif' |
|
||||
\ let b:endwise_words = 'if,ifdef,ifndef' |
|
||||
\ let b:endwise_pattern = '^\s*#\%(if\|ifdef\|ifndef\)\>' |
|
||||
\ let b:endwise_syngroups = 'cPreCondit,cPreConditMatch,cCppInWrapper,xdefaultsPreProc'
|
||||
autocmd FileType objc
|
||||
\ let b:endwise_addition = '@end' |
|
||||
\ let b:endwise_words = 'interface,implementation' |
|
||||
\ let b:endwise_pattern = '^\s*@\%(interface\|implementation\)\>' |
|
||||
\ let b:endwise_syngroups = 'objcObjDef'
|
||||
autocmd FileType make
|
||||
\ let b:endwise_addition = '\="end" . submatch(0)' |
|
||||
\ let b:endwise_words = 'ifdef,ifndef,ifeq,ifneq,define' |
|
||||
\ let b:endwise_pattern = '^\s*\(d\zsef\zeine\|\zsif\zen\=\(def\|eq\)\)\>' |
|
||||
\ let b:endwise_syngroups = 'makePreCondit,makeDefine'
|
||||
autocmd FileType verilog
|
||||
\ let b:endwise_addition = '\="end" . submatch(0)' |
|
||||
\ let b:endwise_words = 'begin,module,case,function,primitive,specify,task' |
|
||||
\ let b:endwise_pattern = '\<\%(\zs\zebegin\|module\|case\|function\|primitive\|specify\|task\)\>.*$' |
|
||||
\ let b:endwise_syngroups = 'verilogConditional,verilogLabel,verilogStatement'
|
||||
autocmd FileType matlab
|
||||
\ let b:endwise_addition = 'end' |
|
||||
\ let b:endwise_words = 'function,if,for' |
|
||||
\ let b:endwise_syngroups = 'matlabStatement,matlabFunction,matlabConditional,matlabRepeat'
|
||||
autocmd FileType htmldjango
|
||||
\ let b:endwise_addition = '{% end& %}' |
|
||||
\ let b:endwise_words = 'autoescape,block,blocktrans,cache,comment,filter,for,if,ifchanged,ifequal,ifnotequal,language,spaceless,verbatim,with' |
|
||||
\ let b:endwise_syngroups = 'djangoTagBlock,djangoStatement'
|
||||
autocmd FileType htmljinja,jinja.html
|
||||
\ let b:endwise_addition = '{% end& %}' |
|
||||
\ let b:endwise_words = 'autoescape,block,cache,call,filter,for,if,macro,raw,set,trans,with' |
|
||||
\ let b:endwise_syngroups = 'jinjaTagBlock,jinjaStatement'
|
||||
autocmd FileType snippets
|
||||
\ let b:endwise_addition = 'endsnippet' |
|
||||
\ let b:endwise_words = 'snippet' |
|
||||
\ let b:endwise_syngroups = 'snipSnippet,snipSnippetHeader,snipSnippetHeaderKeyword'
|
||||
autocmd FileType * call s:abbrev()
|
||||
augroup END " }}}1
|
||||
|
||||
function! s:abbrev()
|
||||
if exists('g:endwise_abbreviations')
|
||||
for word in split(get(b:, 'endwise_words', ''), ',')
|
||||
execute 'iabbrev <buffer><script>' word word.'<CR><SID>DiscretionaryEnd<Space><C-U><BS>'
|
||||
endfor
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:teardownMappings()
|
||||
inoremap <buffer> <C-X><CR> <C-X><CR>
|
||||
inoremap <buffer> <CR> <CR>
|
||||
endfunction
|
||||
|
||||
" Functions {{{1
|
||||
|
||||
function! EndwiseDiscretionary()
|
||||
return <SID>crend(0)
|
||||
endfunction
|
||||
|
||||
function! EndwiseAlways()
|
||||
return <SID>crend(1)
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
|
||||
" Maps {{{1
|
||||
|
||||
if empty(maparg("<Plug>DiscretionaryEnd"))
|
||||
inoremap <silent> <SID>DiscretionaryEnd <C-R>=<SID>crend(0)<CR>
|
||||
inoremap <silent> <SID>AlwaysEnd <C-R>=<SID>crend(1)<CR>
|
||||
imap <script> <Plug>DiscretionaryEnd <SID>DiscretionaryEnd
|
||||
imap <script> <Plug>AlwaysEnd <SID>AlwaysEnd
|
||||
endif
|
||||
|
||||
if !exists('g:endwise_no_mappings')
|
||||
if maparg('<CR>','i') =~# '<C-R>=.*crend(.)<CR>\|<\%(Plug\|SNR\|SID\)>.*End'
|
||||
" Already mapped
|
||||
elseif maparg('<CR>','i') =~? '<cr>'
|
||||
exe "imap <script> <C-X><CR> ".maparg('<CR>','i')."<SID>AlwaysEnd"
|
||||
exe "imap <silent> <script> <CR> ".maparg('<CR>','i')."<SID>DiscretionaryEnd"
|
||||
elseif maparg('<CR>','i') =~# '<Plug>\w\+CR'
|
||||
exe "imap <C-X><CR> ".maparg('<CR>', 'i')."<Plug>AlwaysEnd"
|
||||
exe "imap <silent> <CR> ".maparg('<CR>', 'i')."<Plug>DiscretionaryEnd"
|
||||
else
|
||||
imap <script> <C-X><CR> <CR><SID>AlwaysEnd
|
||||
imap <CR> <CR><Plug>DiscretionaryEnd
|
||||
endif
|
||||
autocmd endwise CmdwinEnter * call s:teardownMappings()
|
||||
endif
|
||||
|
||||
" }}}1
|
||||
|
||||
" Code {{{1
|
||||
|
||||
function! s:mysearchpair(beginpat,endpat,synidpat)
|
||||
let s:lastline = line('.')
|
||||
call s:synid()
|
||||
let line = searchpair(a:beginpat,'',a:endpat,'Wn','<SID>synid() !~# "^'.substitute(a:synidpat,'\\','\\\\','g').'$"',line('.')+50)
|
||||
return line
|
||||
endfunction
|
||||
|
||||
function! s:crend(always)
|
||||
let n = ""
|
||||
if !exists("b:endwise_addition") || !exists("b:endwise_words") || !exists("b:endwise_syngroups")
|
||||
return n
|
||||
endif
|
||||
let synids = join(map(split(b:endwise_syngroups, ','), 'hlID(v:val)'), ',')
|
||||
let wordchoice = '\%('.substitute(b:endwise_words,',','\\|','g').'\)'
|
||||
if exists("b:endwise_pattern")
|
||||
let beginpat = substitute(b:endwise_pattern,'&',substitute(wordchoice,'\\','\\&','g'),'g')
|
||||
else
|
||||
let beginpat = '\<'.wordchoice.'\>'
|
||||
endif
|
||||
let lnum = line('.') - 1
|
||||
let space = matchstr(getline(lnum),'^\s*')
|
||||
let col = match(getline(lnum),beginpat) + 1
|
||||
let word = matchstr(getline(lnum),beginpat)
|
||||
let endword = substitute(word,'.*',b:endwise_addition,'')
|
||||
let y = n.endword."\<C-O>O"
|
||||
if exists("b:endwise_end_pattern")
|
||||
let endpat = '\w\@<!'.substitute(word, '.*', substitute(b:endwise_end_pattern, '\\', '\\\\', 'g'), '').'\w\@!'
|
||||
elseif b:endwise_addition[0:1] ==# '\='
|
||||
let endpat = '\w\@<!'.endword.'\w\@!'
|
||||
else
|
||||
let endpat = '\w\@<!'.substitute('\w\+', '.*', b:endwise_addition, '').'\w\@!'
|
||||
endif
|
||||
let synidpat = '\%('.substitute(synids,',','\\|','g').'\)'
|
||||
if a:always
|
||||
return y
|
||||
elseif col <= 0 || synID(lnum,col,1) !~ '^'.synidpat.'$'
|
||||
return n
|
||||
elseif getline('.') !~# '^\s*#\=$'
|
||||
return n
|
||||
endif
|
||||
let line = s:mysearchpair(beginpat,endpat,synidpat)
|
||||
" even is false if no end was found, or if the end found was less
|
||||
" indented than the current line
|
||||
let even = strlen(matchstr(getline(line),'^\s*')) >= strlen(space)
|
||||
if line == 0
|
||||
let even = 0
|
||||
endif
|
||||
if !even && line == line('.') + 1
|
||||
return y
|
||||
endif
|
||||
if even
|
||||
return n
|
||||
endif
|
||||
return y
|
||||
endfunction
|
||||
|
||||
function! s:synid()
|
||||
" Checking this helps to force things to stay in sync
|
||||
while s:lastline < line('.')
|
||||
let s = synID(s:lastline,indent(s:lastline)+1,1)
|
||||
let s:lastline = nextnonblank(s:lastline + 1)
|
||||
endwhile
|
||||
|
||||
let s = synID(line('.'),col('.'),1)
|
||||
let s:lastline = line('.')
|
||||
return s
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
|
||||
" vim:set sw=2 sts=2:
|
571
plugin/ragtag.vim
Normal file
571
plugin/ragtag.vim
Normal file
|
@ -0,0 +1,571 @@
|
|||
" ragtag.vim - Ghetto XML/HTML mappings (formerly allml.vim)
|
||||
" Author: Tim Pope <http://tpo.pe/>
|
||||
" Version: 2.0
|
||||
" GetLatestVimScripts: 1896 1 :AutoInstall: ragtag.vim
|
||||
|
||||
if exists("g:loaded_ragtag") || &cp || v:version < 700
|
||||
finish
|
||||
endif
|
||||
let g:loaded_ragtag = 1
|
||||
|
||||
if !exists('g:html_indent_inctags')
|
||||
let g:html_indent_inctags = 'body,head,html,tbody,p,li,dt,dd'
|
||||
endif
|
||||
if !exists('g:html_indent_autotags')
|
||||
let g:html_indent_autotags = 'wbr'
|
||||
endif
|
||||
if !exists('g:html_indent_script1')
|
||||
let g:html_indent_script1 = 'inc'
|
||||
endif
|
||||
if !exists('g:html_indent_style1')
|
||||
let g:html_indent_style1 = 'inc'
|
||||
endif
|
||||
|
||||
augroup ragtag
|
||||
autocmd!
|
||||
autocmd BufReadPost * if ! did_filetype() && getline(1)." ".getline(2).
|
||||
\ " ".getline(3) =~? '<\%(!DOCTYPE \)\=html\>' | setf html | endif
|
||||
autocmd FileType *html*,wml,jsp,gsp,mustache,smarty call s:Init()
|
||||
autocmd FileType php,asp*,cf,mason,eruby,liquid,jst,eelixir call s:Init()
|
||||
autocmd FileType xml,xslt,xsd,docbk call s:Init()
|
||||
autocmd FileType javascript.jsx,jsx,javascriptreact,handlebars call s:Init()
|
||||
autocmd FileType typescript.tsx,tsx,typescriptreact call s:Init()
|
||||
autocmd InsertLeave * call s:Leave()
|
||||
autocmd CursorHold * if exists("b:loaded_ragtag") | call s:Leave() | endif
|
||||
augroup END
|
||||
|
||||
inoremap <silent> <Plug>ragtagHtmlComplete <C-R>=<SID>htmlEn()<CR><C-X><C-O><C-P><C-R>=<SID>htmlDis()<CR><C-N>
|
||||
|
||||
" Public interface, for if you have your own filetypes to activate on
|
||||
function! RagtagInit()
|
||||
call s:Init()
|
||||
endfunction
|
||||
|
||||
function! AllmlInit()
|
||||
call s:Init()
|
||||
endfunction
|
||||
|
||||
function! s:isFiletype(ft)
|
||||
return index(split(&filetype, '\.'), a:ft) >= 0
|
||||
endfunction
|
||||
|
||||
function! s:Init()
|
||||
let b:loaded_ragtag = 1
|
||||
if s:subtype() == "xml"
|
||||
imap <script> <buffer> <C-X>! <?xml version="1.0" encoding="<C-R>=toupper(<SID>charset())<CR>"?>
|
||||
elseif s:subtype() == "xhtml"
|
||||
imap <script> <buffer> <C-X>! <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
else
|
||||
imap <script> <buffer> <C-X>! <!DOCTYPE html>
|
||||
endif
|
||||
|
||||
if empty(&l:define)
|
||||
let &l:define = '\<id=["'']\='
|
||||
let b:undo_ftplugin = get(b:, 'undo_ftplugin', 'exe') . '|setl def='
|
||||
endif
|
||||
|
||||
imap <silent> <buffer> <C-X># <C-R>=<SID>charsetTag()<CR>
|
||||
inoremap <silent> <buffer> <SID>HtmlComplete <C-R>=<SID>htmlEn()<CR><C-X><C-O><C-P><C-R>=<SID>htmlDis()<CR><C-N>
|
||||
imap <buffer> <C-X>H <SID>HtmlComplete
|
||||
inoremap <silent> <buffer> <C-X>$ <C-R>=<SID>javascriptIncludeTag()<CR>
|
||||
inoremap <silent> <buffer> <C-X>@ <C-R>=<SID>stylesheetTag()<CR>
|
||||
inoremap <silent> <buffer> <C-X><Space> <Esc>ciW<Lt><C-R>"<C-R>=<SID>tagextras()<CR>></<C-R>"><Esc>F<i
|
||||
inoremap <silent> <buffer> <C-X><CR> <Esc>ciW<Lt><C-R>"<C-R>=<SID>tagextras()<CR>><CR></<C-R>"><Esc>O
|
||||
if exists("&omnifunc")
|
||||
inoremap <silent> <buffer> <C-X>/ <Lt>/<C-R>=<SID>htmlEn()<CR><C-X><C-O><C-R>=<SID>htmlDis()<CR><C-R>=<SID>reindent()<CR>
|
||||
if exists(":XMLns")
|
||||
XMLns xhtml10s
|
||||
endif
|
||||
else
|
||||
inoremap <silent> <buffer> <C-X>/ <Lt>/><Left>
|
||||
endif
|
||||
let b:surround_{char2nr("p")} = "<p>\n\t\r\n</p>"
|
||||
let b:surround_{char2nr("d")} = "<div\1div: \r^[^ ]\r &\1>\n\t\r\n</div>"
|
||||
imap <buffer> <C-X><C-_> <C-X>/
|
||||
imap <buffer> <SID>ragtagOopen <C-X><Lt><Space>
|
||||
imap <buffer> <SID>ragtagOclose <Space><C-X>><Left><Left>
|
||||
if s:isFiletype('php')
|
||||
inoremap <buffer> <C-X><Lt> <?php
|
||||
inoremap <buffer> <C-X>> ?>
|
||||
inoremap <buffer> <SID>ragtagOopen <?php<Space>echo<Space>
|
||||
let b:surround_45 = "<?php \r ?>"
|
||||
let b:surround_61 = "<?php echo \r ?>"
|
||||
elseif s:isFiletype('htmltt') || s:isFiletype('tt2html')
|
||||
inoremap <buffer> <C-X><Lt> [%
|
||||
inoremap <buffer> <C-X>> %]
|
||||
let b:surround_45 = "[% \r %]"
|
||||
let b:surround_61 = "[% \r %]"
|
||||
if !exists("b:surround_101")
|
||||
let b:surround_101 = "[% \r %]\n[% END %]"
|
||||
endif
|
||||
elseif s:isFiletype('mustache')
|
||||
inoremap <buffer> <SID>ragtagOopen {{<Space>
|
||||
inoremap <buffer> <SID>ragtagOclose <Space>}}<Left><Left>
|
||||
inoremap <buffer> <C-X><Lt> {{
|
||||
inoremap <buffer> <C-X>> }}
|
||||
let b:surround_45 = "{{ \r }}"
|
||||
let b:surround_61 = "{{ \r }}"
|
||||
elseif s:isFiletype('django') || s:isFiletype('htmldjango') || s:isFiletype('liquid') || s:isFiletype('htmljinja')
|
||||
inoremap <buffer> <SID>ragtagOopen {{<Space>
|
||||
inoremap <buffer> <SID>ragtagOclose <Space>}}<Left><Left>
|
||||
inoremap <buffer> <C-X><Lt> {%
|
||||
inoremap <buffer> <C-X>> %}
|
||||
let b:surround_45 = "{% \r %}"
|
||||
let b:surround_61 = "{{ \r }}"
|
||||
elseif s:isFiletype('mason')
|
||||
inoremap <buffer> <SID>ragtagOopen <&<Space>
|
||||
inoremap <buffer> <SID>ragtagOclose <Space>&><Left><Left>
|
||||
inoremap <buffer> <C-X><Lt> <%
|
||||
inoremap <buffer> <C-X>> %>
|
||||
let b:surround_45 = "<% \r %>"
|
||||
let b:surround_61 = "<& \r &>"
|
||||
elseif s:isFiletype('cf')
|
||||
inoremap <buffer> <SID>ragtagOopen <cfoutput>
|
||||
inoremap <buffer> <SID>ragtagOclose </cfoutput><Left><C-Left><Left>
|
||||
inoremap <buffer> <C-X><Lt> <cf
|
||||
inoremap <buffer> <C-X>> >
|
||||
let b:surround_45 = "<cf\r>"
|
||||
let b:surround_61 = "<cfoutput>\r</cfoutput>"
|
||||
elseif s:isFiletype('smarty')
|
||||
inoremap <buffer> <SID>ragtagOopen {
|
||||
inoremap <buffer> <SID>ragtagOclose }
|
||||
inoremap <buffer> <C-X><Lt> {
|
||||
inoremap <buffer> <C-X>> }
|
||||
let b:surround_45 = "{\r}"
|
||||
let b:surround_61 = "{\r}"
|
||||
elseif s:isFiletype('handlebars')
|
||||
inoremap <buffer> <SID>ragtagOopen {{
|
||||
inoremap <buffer> <SID>ragtagOclose }}
|
||||
inoremap <buffer> <C-X><Lt> {{
|
||||
inoremap <buffer> <C-X>> }}
|
||||
let b:surround_45 = "{{\r}}"
|
||||
let b:surround_61 = "{{\r}}"
|
||||
elseif &filetype ==# 'html'
|
||||
inoremap <buffer> <SID>ragtagOopen <!--#echo var=
|
||||
inoremap <buffer> <C-X><Lt> <!--#
|
||||
inoremap <buffer> <C-X>> -->
|
||||
let b:surround_45 = "<!--#\r -->"
|
||||
let b:surround_61 = "<!--#echo var=\r -->"
|
||||
else
|
||||
inoremap <buffer> <SID>ragtagOopen <%=<Space>
|
||||
inoremap <buffer> <C-X><Lt> <%
|
||||
inoremap <buffer> <C-X>> %>
|
||||
let b:surround_45 = "<% \r %>"
|
||||
let b:surround_61 = "<%= \r %>"
|
||||
endif
|
||||
imap <script> <buffer> <C-X>= <SID>ragtagOopen<SID>ragtagOclose<Left>
|
||||
imap <script> <buffer> <C-X>+ <C-V><NL><Esc>I<SID>ragtagOopen<Esc>A<SID>ragtagOclose<Esc>F<NL>s
|
||||
" <%\n\n%>
|
||||
if s:isFiletype('cf')
|
||||
inoremap <buffer> <C-X>] <cfscript><CR></cfscript><Esc>O
|
||||
elseif s:isFiletype('mason')
|
||||
inoremap <buffer> <C-X>] <%perl><CR></%perl><Esc>O
|
||||
elseif &filetype ==# 'html' || &filetype ==# 'xml' || &filetype ==# 'xhtml'
|
||||
imap <buffer> <C-X>] <script<C-R>=<SID>javascriptType()<CR>><CR></script><Esc>O
|
||||
else
|
||||
imap <buffer> <C-X>] <C-X><Lt><CR><C-X>><Esc>O
|
||||
endif
|
||||
" <% %>
|
||||
if s:isFiletype('eruby') || s:isFiletype('jst')
|
||||
inoremap <buffer> <C-X>- <%<Space><Space>%><Esc>2hi
|
||||
inoremap <buffer> <C-X>_ <C-V><NL><Esc>I<%<Space><Esc>A<Space>%><Esc>F<NL>s
|
||||
elseif s:isFiletype('cf')
|
||||
inoremap <buffer> <C-X>- <cf><Left>
|
||||
inoremap <buffer> <C-X>_ <cfset ><Left>
|
||||
elseif s:isFiletype('smarty')
|
||||
imap <buffer> <C-X>- <C-X><Lt><C-X>><Esc>i
|
||||
imap <buffer> <C-X>_ <C-V><NL><Esc>I<C-X><Lt><Esc>A<C-X>><Esc>F<NL>s
|
||||
else
|
||||
imap <buffer> <C-X>- <C-X><Lt><Space><Space><C-X>><Esc>2hi
|
||||
imap <buffer> <C-X>_ <C-V><NL><Esc>I<C-X><Lt><Space><Esc>A<Space><C-X>><Esc>F<NL>s
|
||||
endif
|
||||
" Comments
|
||||
if s:isFiletype('aspperl') || s:isFiletype('aspvbs')
|
||||
imap <buffer> <C-X>' <C-X><Lt>'<Space><Space><C-X>><Esc>2hi
|
||||
imap <buffer> <C-X>" <C-V><NL><Esc>I<C-X><Lt>'<Space><Esc>A<Space><C-X>><Esc>F<NL>s
|
||||
let b:surround_35 = maparg("<C-X><Lt>","i")."' \r ".maparg("<C-X>>","i")
|
||||
elseif s:isFiletype('jsp') || s:isFiletype('gsp')
|
||||
inoremap <buffer> <C-X>' <Lt>%--<Space><Space>--%><Esc>4hi
|
||||
inoremap <buffer> <C-X>" <C-V><NL><Esc>I<%--<Space><Esc>A<Space>--%><Esc>F<NL>s
|
||||
let b:surround_35 = "<%-- \r --%>"
|
||||
elseif s:isFiletype('cf')
|
||||
inoremap <buffer> <C-X>' <Lt>!---<Space><Space>---><Esc>4hi
|
||||
inoremap <buffer> <C-X>" <C-V><NL><Esc>I<!---<Space><Esc>A<Space>---><Esc>F<NL>s
|
||||
setlocal commentstring=<!---%s--->
|
||||
let b:surround_35 = "<!--- \r --->"
|
||||
elseif &filetype ==# 'html' || &filetype ==# 'xml' || &filetype ==# 'xhtml'
|
||||
inoremap <buffer> <C-X>' <Lt>!--<Space><Space>--><Esc>3hi
|
||||
inoremap <buffer> <C-X>" <C-V><NL><Esc>I<!--<Space><Esc>A<Space>--><Esc>F<NL>s
|
||||
let b:surround_35 = "<!-- \r -->"
|
||||
elseif s:isFiletype('django') || s:isFiletype('htmldjango') || s:isFiletype('htmljinja')
|
||||
inoremap <buffer> <C-X>' {#<Space><Space>#}<Esc>2hi
|
||||
inoremap <buffer> <C-X>" <C-V><NL><Esc>I<C-X>{#<Space><Esc>A<Space>#}<Esc>F<NL>s
|
||||
let b:surround_35 = "{# \r #}"
|
||||
elseif s:isFiletype('liquid')
|
||||
inoremap <buffer> <C-X>' {%<Space>comment<Space>%}{%<Space>endcomment<Space>%}<Esc>15hi
|
||||
inoremap <buffer> <C-X>" <C-V><NL><Esc>I<C-X>{%<Space>comment<Space>%}<Esc>A{%<Space>endcomment<Space>%}<Esc>F<NL>s
|
||||
let b:surround_35 = "{% comment %}\r{% endcomment %}"
|
||||
elseif s:isFiletype('smarty')
|
||||
inoremap <buffer> <C-X>' {*<Space><Space>*}<Esc>2hi
|
||||
inoremap <buffer> <C-X>" <C-V><NL><Esc>I<C-X>{*<Space><Esc>A<Space>*}<Esc>F<NL>s
|
||||
let b:surround_35 = "{* \r *}"
|
||||
elseif s:isFiletype('handlebars')
|
||||
imap <script> <buffer> <C-X>= <SID>ragtagOopen<SID>ragtagOclose<Left><Left>
|
||||
inoremap <buffer> <C-X>_ <Esc>ciW{{#<C-R>"}}<CR>{{/<C-R>"}}<Esc>khi
|
||||
inoremap <buffer> <C-X>' {{!}}<Esc>hi
|
||||
inoremap <buffer> <C-X>" <C-V><NL><Esc>I{{!<Esc>A}}<Esc>F<NL>s
|
||||
else
|
||||
imap <buffer> <C-X>' <C-X><Lt>#<Space><Space><C-X>><Esc>2hi
|
||||
imap <buffer> <C-X>" <C-V><NL><Esc>I<C-X><Lt>#<Space><Esc>A<Space><C-X>><Esc>F<NL>s
|
||||
let b:surround_35 = maparg("<C-X><Lt>","i")."# \r ".maparg("<C-X>>","i")
|
||||
endif
|
||||
imap <buffer> <C-X>% <Plug>ragtagUrlEncode
|
||||
imap <buffer> <C-X>& <Plug>ragtagXmlEncode
|
||||
imap <buffer> <C-V>% <Plug>ragtagUrlV
|
||||
imap <buffer> <C-V>& <Plug>ragtagXmlV
|
||||
if !exists("b:did_indent")
|
||||
if s:subtype() == "xml"
|
||||
runtime! indent/xml.vim
|
||||
else
|
||||
runtime! indent/html.vim
|
||||
endif
|
||||
endif
|
||||
if exists("g:html_indent_tags") && g:html_indent_tags !~ '\\|p\>'
|
||||
let g:html_indent_tags = g:html_indent_tags.'\|p\|li\|dt\|dd'
|
||||
let g:html_indent_tags = g:html_indent_tags.'\|article\|aside\|audio\|bdi\|canvas\|command\|datalist\|details\|figcaption\|figure\|footer\|header\|hgroup\|mark\|meter\|nav\|output\|progress\|rp\|rt\|ruby\|section\|summary\|time\|video'
|
||||
endif
|
||||
set indentkeys+=!^F
|
||||
let b:surround_indent = 1
|
||||
silent doautocmd User Ragtag
|
||||
silent doautocmd User ragtag
|
||||
endfunction
|
||||
|
||||
function! s:Leave()
|
||||
call s:disableescape()
|
||||
endfunction
|
||||
|
||||
function! s:length(str)
|
||||
return strlen(substitute(a:str,'.','.','g'))
|
||||
endfunction
|
||||
|
||||
function! s:repeat(str,cnt)
|
||||
let cnt = a:cnt
|
||||
let str = ""
|
||||
while cnt > 0
|
||||
let str = str . a:str
|
||||
let cnt = cnt - 1
|
||||
endwhile
|
||||
return str
|
||||
endfunction
|
||||
|
||||
function! s:reindent()
|
||||
if (len(&indentexpr) || &cindent)
|
||||
return "\<C-F>"
|
||||
endif
|
||||
return ""
|
||||
endfun
|
||||
|
||||
function! s:stylesheetType()
|
||||
if s:subtype() == 'html5'
|
||||
return ''
|
||||
else
|
||||
return ' type="text/css"'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:stylesheetTag()
|
||||
if !exists("b:ragtag_stylesheet_link_tag")
|
||||
if exists("b:allml_stylesheet_link_tag")
|
||||
let b:ragtag_stylesheet_link_tag = b:allml_stylesheet_link_tag
|
||||
else
|
||||
let b:ragtag_stylesheet_link_tag = '<link rel="stylesheet"'.s:stylesheetType()." href=\"/stylesheets/\r.css\" />"
|
||||
endif
|
||||
endif
|
||||
return s:insertTag(b:ragtag_stylesheet_link_tag)
|
||||
endfunction
|
||||
|
||||
function! s:javascriptType()
|
||||
if s:subtype() == 'html5'
|
||||
return ''
|
||||
else
|
||||
return ' type="text/javascript"'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:javascriptIncludeTag()
|
||||
if !exists("b:ragtag_javascript_include_tag")
|
||||
if exists("b:allml_javascript_include_tag")
|
||||
let b:ragtag_javascript_include_tag = b:allml_javascript_include_tag
|
||||
else
|
||||
let b:ragtag_javascript_include_tag = '<script'.s:javascriptType()." src=\"/javascripts/\r.js\"></script>"
|
||||
endif
|
||||
endif
|
||||
return s:insertTag(b:ragtag_javascript_include_tag)
|
||||
endfunction
|
||||
|
||||
function! s:insertTag(tag)
|
||||
let tag = a:tag
|
||||
if s:subtype() == "html"
|
||||
let tag = substitute(a:tag,'\s*/>','>','g')
|
||||
endif
|
||||
let before = matchstr(tag,'^.\{-\}\ze\r')
|
||||
let after = matchstr(tag,'\r\zs\%(.*\r\)\@!.\{-\}$')
|
||||
" middle isn't currently used
|
||||
let middle = matchstr(tag,'\r\zs.\{-\}\ze\r')
|
||||
return before.after.s:repeat("\<Left>",s:length(after))
|
||||
endfunction
|
||||
|
||||
function! s:htmlEn()
|
||||
let b:ragtag_omni = &l:omnifunc
|
||||
let b:ragtag_isk = &l:isk
|
||||
let b:ragtag_completeopt = &l:completeopt
|
||||
" : is for namespaced xml attributes
|
||||
setlocal omnifunc=htmlcomplete#CompleteTags isk+=: completeopt=
|
||||
return ""
|
||||
endfunction
|
||||
|
||||
function! s:htmlDis()
|
||||
if exists("b:ragtag_omni")
|
||||
let &l:omnifunc = b:ragtag_omni
|
||||
unlet b:ragtag_omni
|
||||
endif
|
||||
if exists("b:ragtag_isk")
|
||||
let &l:isk = b:ragtag_isk
|
||||
unlet b:ragtag_isk
|
||||
endif
|
||||
if exists("b:ragtag_completeopt")
|
||||
let &l:completeopt = b:ragtag_completeopt
|
||||
unlet b:ragtag_completeopt
|
||||
endif
|
||||
return ""
|
||||
endfunction
|
||||
|
||||
function! s:subtype()
|
||||
let top = getline(1)."\n".getline(2)
|
||||
if (top =~ '<?xml\>' && &ft !~? 'html') || &ft =~? '^\%(xml\|xsd\|xslt\|docbk\)$'
|
||||
return "xml"
|
||||
elseif top =~? '\<xhtml\>'
|
||||
return 'xhtml'
|
||||
elseif top =~? '<!DOCTYPE html>'
|
||||
return 'html5'
|
||||
elseif top =~? '[^<]\<html\>'
|
||||
return "html"
|
||||
elseif s:isFiletype('xhtml')
|
||||
return "xhtml"
|
||||
elseif exists("b:loaded_ragtag")
|
||||
return "html5"
|
||||
else
|
||||
return ""
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:closetagback()
|
||||
if s:subtype() == "html"
|
||||
return ">\<Left>"
|
||||
else
|
||||
return " />\<Left>\<Left>\<Left>"
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:closetag()
|
||||
if s:subtype() == "html"
|
||||
return ">"
|
||||
else
|
||||
return " />"
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:charset()
|
||||
let enc = &fileencoding
|
||||
if enc == ""
|
||||
let enc = &encoding
|
||||
endif
|
||||
if enc == "latin1"
|
||||
return "ISO-8859-1"
|
||||
elseif enc == ""
|
||||
return "US-ASCII"
|
||||
else
|
||||
return enc
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:charsetTag()
|
||||
if s:subtype() == 'html5'
|
||||
return '<meta charset="'.s:charset().'"'.s:closetag()
|
||||
else
|
||||
return '<meta http-equiv="Content-Type" content="text/html; charset='.s:charset().'"'.s:closetag()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:tagextras()
|
||||
if s:subtype() == "xml"
|
||||
return ""
|
||||
elseif @" == 'html' && s:subtype() == 'xhtml'
|
||||
let lang = "en"
|
||||
if exists("$LANG") && $LANG =~ '^..'
|
||||
let lang = strpart($LANG,0,2)
|
||||
endif
|
||||
return ' xmlns="http://www.w3.org/1999/xhtml" lang="'.lang.'" xml:lang="'.lang.'"'
|
||||
elseif @" == 'style'
|
||||
return s:stylesheetType()
|
||||
elseif @" == 'script'
|
||||
return s:javascriptType()
|
||||
elseif @" == 'table'
|
||||
return ' cellspacing="0"'
|
||||
else
|
||||
return ""
|
||||
endif
|
||||
endfunction
|
||||
|
||||
inoremap <silent> <SID>urlspace <C-R>=<SID>getinput()=~?'\%([?&]\<Bar>&\)[%a-z0-9._~+-]*=[%a-z0-9._~+-]*$'?'+':'%20'<CR>
|
||||
|
||||
function! s:urltab(htmlesc)
|
||||
let line = s:getinput()
|
||||
let g:line = line
|
||||
if line =~ '[^ <>"'."'".']\@<!\w\+$'
|
||||
return ":"
|
||||
elseif line =~ '[^ <>"'."'".']\@<!\w\+:/\=/\=[%a-z0-9._~+-]*$'
|
||||
return "/"
|
||||
elseif line =~? '\%([?&]\|&\)[%a-z0-9._~+-]*$'
|
||||
return "="
|
||||
elseif line =~? '\%([?&]\|&\)[%a-z0-9._~+-]*=[%a-z0-9._~+-]*$'
|
||||
if a:htmlesc || synIDattr(synID(line('.'),col('.')-1,1),"name") =~ 'mlString$'
|
||||
return "&"
|
||||
else
|
||||
return "&"
|
||||
endif
|
||||
elseif line =~ '/$\|\.\w\+$'
|
||||
return "?"
|
||||
else
|
||||
return "/"
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:toggleurlescape()
|
||||
let htmllayer = 0
|
||||
if exists("b:ragtag_escape_mode")
|
||||
if b:ragtag_escape_mode == "url"
|
||||
call s:disableescape()
|
||||
return ""
|
||||
elseif b:ragtag_escape_mode == "xml"
|
||||
let htmllayer = 1
|
||||
endif
|
||||
call s:disableescape()
|
||||
endif
|
||||
let b:ragtag_escape_mode = "url"
|
||||
imap <buffer> <BS> <Plug>ragtagBSUrl
|
||||
inoremap <buffer> <CR> %0A
|
||||
imap <script> <buffer> <Space> <SID>urlspace
|
||||
inoremap <buffer> <Tab> &
|
||||
inoremap <buffer> <Bar> %7C
|
||||
if htmllayer
|
||||
inoremap <silent> <buffer> <Tab> <C-R>=<SID>urltab(1)<CR>
|
||||
else
|
||||
inoremap <silent> <buffer> <Tab> <C-R>=<SID>urltab(0)<CR>
|
||||
endif
|
||||
let i = 33
|
||||
while i < 127
|
||||
" RFC3986: reserved = :/?#[]@ !$&'()*+,;=
|
||||
if nr2char(i) =~# '[|=A-Za-z0-9_.~-]'
|
||||
else
|
||||
call s:urlmap(nr2char(i))
|
||||
endif
|
||||
let i = i + 1
|
||||
endwhile
|
||||
return ""
|
||||
endfunction
|
||||
|
||||
function! s:urlencode(char)
|
||||
let i = 0
|
||||
let repl = ""
|
||||
while i < strlen(a:char)
|
||||
let repl = repl . printf("%%%02X",char2nr(strpart(a:char,i,1)))
|
||||
let i = i + 1
|
||||
endwhile
|
||||
return repl
|
||||
endfunction
|
||||
|
||||
function! s:urlmap(char)
|
||||
let repl = s:urlencode(a:char)
|
||||
exe "inoremap <buffer> ".a:char." ".repl
|
||||
endfunction
|
||||
|
||||
function! s:urlv()
|
||||
return s:urlencode(nr2char(getchar()))
|
||||
endfunction
|
||||
|
||||
function! s:togglexmlescape()
|
||||
if exists("b:ragtag_escape_mode")
|
||||
if b:ragtag_escape_mode == "xml"
|
||||
call s:disableescape()
|
||||
return ""
|
||||
endif
|
||||
call s:disableescape()
|
||||
endif
|
||||
let b:ragtag_escape_mode = "xml"
|
||||
imap <buffer> <BS> <Plug>ragtagBSXml
|
||||
inoremap <buffer> <Lt> <
|
||||
inoremap <buffer> > >
|
||||
inoremap <buffer> & &
|
||||
inoremap <buffer> " "
|
||||
return ""
|
||||
endfunction
|
||||
|
||||
function! s:disableescape()
|
||||
if exists("b:ragtag_escape_mode")
|
||||
if b:ragtag_escape_mode == "xml"
|
||||
silent! iunmap <buffer> <BS>
|
||||
silent! iunmap <buffer> <Lt>
|
||||
silent! iunmap <buffer> >
|
||||
silent! iunmap <buffer> &
|
||||
silent! iunmap <buffer> "
|
||||
elseif b:ragtag_escape_mode == "url"
|
||||
silent! iunmap <buffer> <BS>
|
||||
silent! iunmap <buffer> <Tab>
|
||||
silent! iunmap <buffer> <CR>
|
||||
silent! iunmap <buffer> <Space>
|
||||
silent! iunmap <buffer> <Bar>
|
||||
let i = 33
|
||||
while i < 127
|
||||
if nr2char(i) =~# '[|A-Za-z0-9_.~-]'
|
||||
else
|
||||
exe "silent! iunmap <buffer> ".nr2char(i)
|
||||
endif
|
||||
let i = i + 1
|
||||
endwhile
|
||||
endif
|
||||
unlet b:ragtag_escape_mode
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:getinput()
|
||||
return strpart(getline('.'),0,col('.')-1)
|
||||
endfunction
|
||||
|
||||
function! s:bspattern(pattern)
|
||||
let start = s:getinput()
|
||||
let match = matchstr(start,'\%('.a:pattern.'\)$')
|
||||
if match == ""
|
||||
return "\<BS>"
|
||||
else
|
||||
return s:repeat("\<BS>",strlen(match))
|
||||
endif
|
||||
endfunction
|
||||
|
||||
inoremap <silent> <Plug>ragtagBSUrl <C-R>=<SID>bspattern('%\x\x\=\<Bar>&')<CR>
|
||||
inoremap <silent> <Plug>ragtagBSXml <C-R>=<SID>bspattern('&#\=\w*;\<Bar><[^><]*>\=')<CR>
|
||||
inoremap <silent> <SID>ragtagUrlEncode <C-R>=<SID>toggleurlescape()<CR>
|
||||
inoremap <silent> <SID>ragtagXmlEncode <C-R>=<SID>togglexmlescape()<CR>
|
||||
inoremap <silent> <Plug>ragtagUrlEncode <C-R>=<SID>toggleurlescape()<CR>
|
||||
inoremap <silent> <Plug>ragtagXmlEncode <C-R>=<SID>togglexmlescape()<CR>
|
||||
inoremap <silent> <Plug>ragtagUrlV <C-R>=<SID>urlv()<CR>
|
||||
inoremap <silent> <Plug>ragtagXmlV <C-R>="&#".getchar().";"<CR>
|
||||
|
||||
if exists("g:ragtag_global_maps")
|
||||
imap <C-X>H <Plug>ragtagHtmlComplete
|
||||
imap <C-X>/ </<Plug>ragtagHtmlComplete
|
||||
imap <C-X>% <Plug>ragtagUrlEncode
|
||||
imap <C-X>& <Plug>ragtagXmlEncode
|
||||
imap <C-V>% <Plug>ragtagUrlV
|
||||
imap <C-V>& <Plug>ragtagXmlV
|
||||
endif
|
30
vimrc
Normal file
30
vimrc
Normal file
|
@ -0,0 +1,30 @@
|
|||
" source ~/.vim/vimrc.bepo
|
||||
execute pathogen#infect()
|
||||
|
||||
let mapleader=' '
|
||||
|
||||
colorscheme codedark
|
||||
syntax enable
|
||||
|
||||
set tabstop=4
|
||||
set softtabstop=4
|
||||
set expandtab
|
||||
set smarttab
|
||||
set shiftwidth=4
|
||||
set ai
|
||||
set si
|
||||
set wrap
|
||||
|
||||
set number
|
||||
|
||||
set showcmd " show command in bottom bar
|
||||
set cursorline " highlight current line
|
||||
filetype indent on " load filetype-specific indent files
|
||||
set wildmenu " visual autocomplete for command menu
|
||||
set lazyredraw " redraw only when we need to.
|
||||
set showmatch " highlight matching [{()}]
|
||||
|
||||
set incsearch " search as characters are entered
|
||||
set hlsearch " highlight matches
|
||||
|
||||
|
81
vimrc.bepo
Normal file
81
vimrc.bepo
Normal file
|
@ -0,0 +1,81 @@
|
|||
" {W} -> [É]
|
||||
" ——————————
|
||||
" On remappe W sur É :
|
||||
noremap é w
|
||||
noremap É W
|
||||
" Corollaire: on remplace les text objects aw, aW, iw et iW
|
||||
" pour effacer/remplacer un mot quand on n’est pas au début (daé / laé).
|
||||
onoremap aé aw
|
||||
onoremap aÉ aW
|
||||
onoremap ié iw
|
||||
onoremap iÉ iW
|
||||
" Pour faciliter les manipulations de fenêtres, on utilise {W} comme un Ctrl+W :
|
||||
noremap w <C-w>
|
||||
noremap W <C-w><C-w>
|
||||
|
||||
" [HJKL] -> {CTSR}
|
||||
" ————————————————
|
||||
" {cr} = « gauche / droite »
|
||||
noremap c h
|
||||
noremap r l
|
||||
" {ts} = « haut / bas »
|
||||
noremap t j
|
||||
noremap s k
|
||||
" {CR} = « haut / bas de l'écran »
|
||||
noremap C H
|
||||
noremap R L
|
||||
" {TS} = « joindre / aide »
|
||||
noremap T J
|
||||
noremap S K
|
||||
" Corollaire : repli suivant / précédent
|
||||
noremap zs zj
|
||||
noremap zt zk
|
||||
|
||||
" {HJKL} <- [CTSR]
|
||||
" ————————————————
|
||||
" {J} = « Jusqu'à » (j = suivant, J = précédant)
|
||||
noremap j t
|
||||
noremap J T
|
||||
" {L} = « Change » (l = attend un mvt, L = jusqu'à la fin de ligne)
|
||||
noremap l c
|
||||
noremap L C
|
||||
" {H} = « Remplace » (h = un caractère slt, H = reste en « Remplace »)
|
||||
noremap h r
|
||||
noremap H R
|
||||
" {K} = « Substitue » (k = caractère, K = ligne)
|
||||
noremap k s
|
||||
noremap K S
|
||||
" Corollaire : correction orthographique
|
||||
noremap ]k ]s
|
||||
noremap [k [s
|
||||
|
||||
" Désambiguation de {g}
|
||||
" —————————————————————
|
||||
" ligne écran précédente / suivante (à l'intérieur d'une phrase)
|
||||
noremap gs gk
|
||||
noremap gt gj
|
||||
" onglet précédent / suivant
|
||||
noremap gb gT
|
||||
noremap gé gt
|
||||
" optionnel : {gB} / {gÉ} pour aller au premier / dernier onglet
|
||||
noremap gB :exe "silent! tabfirst"<CR>
|
||||
noremap gÉ :exe "silent! tablast"<CR>
|
||||
" optionnel : {g"} pour aller au début de la ligne écran
|
||||
noremap g" g0
|
||||
|
||||
" <> en direct
|
||||
" ————————————
|
||||
noremap « <
|
||||
noremap » >
|
||||
|
||||
" Remaper la gestion des fenêtres
|
||||
" ———————————————————————————————
|
||||
noremap wt <C-w>j
|
||||
noremap ws <C-w>k
|
||||
noremap wc <C-w>h
|
||||
noremap wr <C-w>l
|
||||
noremap wd <C-w>c
|
||||
noremap wo <C-w>s
|
||||
noremap wp <C-w>o
|
||||
noremap w<SPACE> :split<CR>
|
||||
noremap w<CR> :vsplit<CR>
|
Reference in a new issue