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