mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-03 02:30:03 +08:00
Fix invalid fileformat of some files. (#3190)
This commit is contained in:
parent
37f1cf4af4
commit
7c87580d26
@ -1,83 +1,83 @@
|
||||
let s:ns = expand('<sfile>:p:r:gs?[\\/]?#?:s?^.*#autoload#??:s?$?#?')
|
||||
|
||||
function {s:ns}import()
|
||||
return s:bytes
|
||||
endfunction
|
||||
|
||||
let s:bytes = {}
|
||||
|
||||
function s:bytes.tobytes(v)
|
||||
if type(a:v) == type([])
|
||||
return a:v
|
||||
elseif type(a:v) == type("")
|
||||
return self.str2bytes(a:v)
|
||||
else
|
||||
throw "Can't convert to bytes"
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function s:bytes.str2bytes(str)
|
||||
return map(range(len(a:str)), 'char2nr(a:str[v:val])')
|
||||
endfunction
|
||||
|
||||
function s:bytes.bytes2str(bytes)
|
||||
return eval('"' . join(map(copy(a:bytes), 'printf(''\x%02x'', v:val)'), '') . '"')
|
||||
endfunction
|
||||
|
||||
function s:bytes.bytes2hex(bytes)
|
||||
return join(map(copy(a:bytes), 'printf("%02x", v:val)'), '')
|
||||
endfunction
|
||||
|
||||
function s:bytes.hex2bytes(hex)
|
||||
return map(split(a:hex, '..\zs'), 'str2nr(v:val, 16)')
|
||||
endfunction
|
||||
|
||||
function s:bytes.lines2bytes(lines)
|
||||
let bytes = []
|
||||
let first = 1
|
||||
for line in a:lines
|
||||
if !first
|
||||
call add(bytes, 10)
|
||||
endif
|
||||
let first = 0
|
||||
call extend(bytes, map(range(len(line)), 'line[v:val] == "\n" ? 0 : char2nr(line[v:val])'))
|
||||
endfor
|
||||
return bytes
|
||||
endfunction
|
||||
|
||||
function s:bytes.bytes2lines(bytes)
|
||||
let table = map(range(256), 'printf(''\x%02x'', v:val == 0 ? 10 : v:val)')
|
||||
let lines = []
|
||||
let start = 0
|
||||
while start < len(a:bytes)
|
||||
let end = index(a:bytes, 10, start)
|
||||
if end == -1
|
||||
let end = len(a:bytes)
|
||||
endif
|
||||
let line = eval('"' . join(map(range(start, end - 1), 'table[a:bytes[v:val]]'), '') . '"')
|
||||
call add(lines, line)
|
||||
if end == len(a:bytes) - 1
|
||||
call add(lines, '')
|
||||
endif
|
||||
let start = end + 1
|
||||
endwhile
|
||||
return lines
|
||||
endfunction
|
||||
|
||||
function s:bytes.readfile(filename)
|
||||
try
|
||||
let lines = readfile(a:filename, 'b')
|
||||
catch /^Vim\%((\a\+)\)\=:E484:/
|
||||
throw "Can't read file"
|
||||
endtry
|
||||
let bytes = self.lines2bytes(lines)
|
||||
return bytes
|
||||
endfunction
|
||||
|
||||
function s:bytes.writefile(bytes, filename)
|
||||
let lines = self.bytes2lines(a:bytes)
|
||||
if writefile(lines, a:filename, 'b') != 0
|
||||
throw "Can't write file"
|
||||
endif
|
||||
endfunction
|
||||
|
||||
let s:ns = expand('<sfile>:p:r:gs?[\\/]?#?:s?^.*#autoload#??:s?$?#?')
|
||||
|
||||
function {s:ns}import()
|
||||
return s:bytes
|
||||
endfunction
|
||||
|
||||
let s:bytes = {}
|
||||
|
||||
function s:bytes.tobytes(v)
|
||||
if type(a:v) == type([])
|
||||
return a:v
|
||||
elseif type(a:v) == type("")
|
||||
return self.str2bytes(a:v)
|
||||
else
|
||||
throw "Can't convert to bytes"
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function s:bytes.str2bytes(str)
|
||||
return map(range(len(a:str)), 'char2nr(a:str[v:val])')
|
||||
endfunction
|
||||
|
||||
function s:bytes.bytes2str(bytes)
|
||||
return eval('"' . join(map(copy(a:bytes), 'printf(''\x%02x'', v:val)'), '') . '"')
|
||||
endfunction
|
||||
|
||||
function s:bytes.bytes2hex(bytes)
|
||||
return join(map(copy(a:bytes), 'printf("%02x", v:val)'), '')
|
||||
endfunction
|
||||
|
||||
function s:bytes.hex2bytes(hex)
|
||||
return map(split(a:hex, '..\zs'), 'str2nr(v:val, 16)')
|
||||
endfunction
|
||||
|
||||
function s:bytes.lines2bytes(lines)
|
||||
let bytes = []
|
||||
let first = 1
|
||||
for line in a:lines
|
||||
if !first
|
||||
call add(bytes, 10)
|
||||
endif
|
||||
let first = 0
|
||||
call extend(bytes, map(range(len(line)), 'line[v:val] == "\n" ? 0 : char2nr(line[v:val])'))
|
||||
endfor
|
||||
return bytes
|
||||
endfunction
|
||||
|
||||
function s:bytes.bytes2lines(bytes)
|
||||
let table = map(range(256), 'printf(''\x%02x'', v:val == 0 ? 10 : v:val)')
|
||||
let lines = []
|
||||
let start = 0
|
||||
while start < len(a:bytes)
|
||||
let end = index(a:bytes, 10, start)
|
||||
if end == -1
|
||||
let end = len(a:bytes)
|
||||
endif
|
||||
let line = eval('"' . join(map(range(start, end - 1), 'table[a:bytes[v:val]]'), '') . '"')
|
||||
call add(lines, line)
|
||||
if end == len(a:bytes) - 1
|
||||
call add(lines, '')
|
||||
endif
|
||||
let start = end + 1
|
||||
endwhile
|
||||
return lines
|
||||
endfunction
|
||||
|
||||
function s:bytes.readfile(filename)
|
||||
try
|
||||
let lines = readfile(a:filename, 'b')
|
||||
catch /^Vim\%((\a\+)\)\=:E484:/
|
||||
throw "Can't read file"
|
||||
endtry
|
||||
let bytes = self.lines2bytes(lines)
|
||||
return bytes
|
||||
endfunction
|
||||
|
||||
function s:bytes.writefile(bytes, filename)
|
||||
let lines = self.bytes2lines(a:bytes)
|
||||
if writefile(lines, a:filename, 'b') != 0
|
||||
throw "Can't write file"
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,17 +1,17 @@
|
||||
"=============================================================================
|
||||
" foxpro.vim --- Visual FoxPro language support
|
||||
" Copyright (c) 2016-2019 Wang Shidong & Contributors
|
||||
" Author: Wang Shidong < wsdjeg@outlook.com >
|
||||
" URL: https://spacevim.org
|
||||
" License: GPLv3
|
||||
"=============================================================================
|
||||
|
||||
function! SpaceVim#layers#lang#foxpro#plugins() abort
|
||||
let plugins = []
|
||||
call add(plugins, ['wsdjeg/vim-foxpro', { 'merged' : 0}])
|
||||
return plugins
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#lang#foxpro#config() abort
|
||||
|
||||
endfunction
|
||||
"=============================================================================
|
||||
" foxpro.vim --- Visual FoxPro language support
|
||||
" Copyright (c) 2016-2019 Wang Shidong & Contributors
|
||||
" Author: Wang Shidong < wsdjeg@outlook.com >
|
||||
" URL: https://spacevim.org
|
||||
" License: GPLv3
|
||||
"=============================================================================
|
||||
|
||||
function! SpaceVim#layers#lang#foxpro#plugins() abort
|
||||
let plugins = []
|
||||
call add(plugins, ['wsdjeg/vim-foxpro', { 'merged' : 0}])
|
||||
return plugins
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#lang#foxpro#config() abort
|
||||
|
||||
endfunction
|
||||
|
@ -1,36 +1,36 @@
|
||||
"=============================================================================
|
||||
" io.vim --- io language support
|
||||
" Copyright (c) 2016-2019 Wang Shidong & Contributors
|
||||
" Author: Wang Shidong < wsdjeg@outlook.com >
|
||||
" URL: https://spacevim.org
|
||||
" License: GPLv3
|
||||
"=============================================================================
|
||||
|
||||
function! SpaceVim#layers#lang#io#plugins() abort
|
||||
let plugins = []
|
||||
call add(plugins, ['wsdjeg/vim-iolang', { 'merged' : 0}])
|
||||
return plugins
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#lang#io#config() abort
|
||||
call SpaceVim#plugins#repl#reg('io', 'io_static')
|
||||
call SpaceVim#plugins#runner#reg_runner('io', 'io %s')
|
||||
call SpaceVim#mapping#space#regesit_lang_mappings('io', function('s:language_specified_mappings'))
|
||||
endfunction
|
||||
|
||||
function! s:language_specified_mappings() abort
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','r'], 'call SpaceVim#plugins#runner#open()', 'execute current file', 1)
|
||||
let g:_spacevim_mappings_space.l.s = {'name' : '+Send'}
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'i'],
|
||||
\ 'call SpaceVim#plugins#repl#start("io")',
|
||||
\ 'start REPL process', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'l'],
|
||||
\ 'call SpaceVim#plugins#repl#send("line")',
|
||||
\ 'send line and keep code buffer focused', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'b'],
|
||||
\ 'call SpaceVim#plugins#repl#send("buffer")',
|
||||
\ 'send buffer and keep code buffer focused', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 's'],
|
||||
\ 'call SpaceVim#plugins#repl#send("selection")',
|
||||
\ 'send selection and keep code buffer focused', 1)
|
||||
endfunction
|
||||
"=============================================================================
|
||||
" io.vim --- io language support
|
||||
" Copyright (c) 2016-2019 Wang Shidong & Contributors
|
||||
" Author: Wang Shidong < wsdjeg@outlook.com >
|
||||
" URL: https://spacevim.org
|
||||
" License: GPLv3
|
||||
"=============================================================================
|
||||
|
||||
function! SpaceVim#layers#lang#io#plugins() abort
|
||||
let plugins = []
|
||||
call add(plugins, ['wsdjeg/vim-iolang', { 'merged' : 0}])
|
||||
return plugins
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#lang#io#config() abort
|
||||
call SpaceVim#plugins#repl#reg('io', 'io_static')
|
||||
call SpaceVim#plugins#runner#reg_runner('io', 'io %s')
|
||||
call SpaceVim#mapping#space#regesit_lang_mappings('io', function('s:language_specified_mappings'))
|
||||
endfunction
|
||||
|
||||
function! s:language_specified_mappings() abort
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','r'], 'call SpaceVim#plugins#runner#open()', 'execute current file', 1)
|
||||
let g:_spacevim_mappings_space.l.s = {'name' : '+Send'}
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'i'],
|
||||
\ 'call SpaceVim#plugins#repl#start("io")',
|
||||
\ 'start REPL process', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'l'],
|
||||
\ 'call SpaceVim#plugins#repl#send("line")',
|
||||
\ 'send line and keep code buffer focused', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'b'],
|
||||
\ 'call SpaceVim#plugins#repl#send("buffer")',
|
||||
\ 'send buffer and keep code buffer focused', 1)
|
||||
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 's'],
|
||||
\ 'call SpaceVim#plugins#repl#send("selection")',
|
||||
\ 'send selection and keep code buffer focused', 1)
|
||||
endfunction
|
||||
|
Loading…
Reference in New Issue
Block a user