mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-04-14 23:49:19 +08:00
Move sid function into file
This commit is contained in:
parent
ddeb8105dc
commit
9f7a33e326
@ -12,8 +12,8 @@
|
|||||||
"" Capture command
|
"" Capture command
|
||||||
|
|
||||||
let s:self = {}
|
let s:self = {}
|
||||||
|
let s:self._file = SpaceVim#api#import('file')
|
||||||
let s:DICT = SpaceVim#api#import('data#dict')
|
let s:self._data_dict = SpaceVim#api#import('data#dict')
|
||||||
|
|
||||||
let s:self._cache = {}
|
let s:self._cache = {}
|
||||||
|
|
||||||
@ -29,9 +29,6 @@ function! s:self._capture(command) abort
|
|||||||
endtry
|
endtry
|
||||||
return out
|
return out
|
||||||
endfunction
|
endfunction
|
||||||
function! s:self._unify_path(path) abort
|
|
||||||
return resolve(fnamemodify(a:path, ':p:gs?[\\/]?/?'))
|
|
||||||
endfunction
|
|
||||||
"" Capture command and return lines
|
"" Capture command and return lines
|
||||||
function! s:self._capture_lines(command) abort
|
function! s:self._capture_lines(command) abort
|
||||||
return split(self._capture(a:command), "\n")
|
return split(self._capture(a:command), "\n")
|
||||||
@ -42,14 +39,14 @@ function! s:self.scriptnames() abort
|
|||||||
let sdict = {} " { sid: path }
|
let sdict = {} " { sid: path }
|
||||||
for line in self._capture_lines(':scriptnames')
|
for line in self._capture_lines(':scriptnames')
|
||||||
let [sid, path] = split(line, '\m^\s*\d\+\zs:\s\ze')
|
let [sid, path] = split(line, '\m^\s*\d\+\zs:\s\ze')
|
||||||
let sdict[str2nr(sid)] = self._unify_path(path) " str2nr(): ' 1' -> 1
|
let sdict[str2nr(sid)] = self._file.unify_path(path) " str2nr(): ' 1' -> 1
|
||||||
endfor
|
endfor
|
||||||
return sdict
|
return sdict
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:self.get_sid_from_path(path) abort
|
function! s:self.get_sid_from_path(path) abort
|
||||||
let path = self._unify_path(a:path)
|
let path = self._file.unify_path(a:path)
|
||||||
let scriptnames = s:DICT.swap(self.scriptnames())
|
let scriptnames = s:self._data_dict.swap(self.scriptnames())
|
||||||
if has_key(scriptnames, path)
|
if has_key(scriptnames, path)
|
||||||
return scriptnames[path]
|
return scriptnames[path]
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user