mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-09 09:10:04 +08:00
Compare commits
4 Commits
f725666783
...
057c0d5ed0
Author | SHA1 | Date | |
---|---|---|---|
|
057c0d5ed0 | ||
|
c555aa156c | ||
|
40edbe8d6c | ||
|
a974fb5646 |
@ -179,6 +179,39 @@ main () {
|
|||||||
rm -rf detach/$1
|
rm -rf detach/$1
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
|
SourceCounter.vim)
|
||||||
|
git clone https://github.com/wsdjeg/SourceCounter.vim.git detach/$1
|
||||||
|
cd detach/$1
|
||||||
|
_checkdir plugin
|
||||||
|
_detact_bundle SourceCounter.vim plugin/SourceCounter.vim
|
||||||
|
_checkdir autoload
|
||||||
|
_detact_bundle SourceCounter.vim autoload/SourceCounter.vim
|
||||||
|
_checkdir doc
|
||||||
|
_detact_bundle SourceCounter.vim doc/SourceCounter.vim.txt
|
||||||
|
_detact_bundle SourceCounter.vim README.md
|
||||||
|
_detact_bundle SourceCounter.vim addon-info.json
|
||||||
|
_detact LICENSE
|
||||||
|
_checkdir pic
|
||||||
|
_detact_bundle SourceCounter.vim pic/screen.png
|
||||||
|
_checkdir autoload/SpaceVim/api/vim
|
||||||
|
_checkdir autoload/SpaceVim/api/data
|
||||||
|
_detact autoload/SpaceVim/api/notify.vim
|
||||||
|
_detact autoload/SpaceVim/api/data/string.vim
|
||||||
|
_detact autoload/SpaceVim/api/data/number.vim
|
||||||
|
_detact autoload/SpaceVim/api/vim/buffer.vim
|
||||||
|
_detact autoload/SpaceVim/api/vim/floatting.vim
|
||||||
|
_checkdir autoload/SpaceVim/api/neovim
|
||||||
|
_detact autoload/SpaceVim/api/neovim/floatting.vim
|
||||||
|
git add .
|
||||||
|
git config user.email "eric@wsdjeg.net"
|
||||||
|
git config user.name "Eric Wong"
|
||||||
|
git commit -m "Auto Update based on https://github.com/SpaceVim/SpaceVim/commit/${GITHUB_SHA}"
|
||||||
|
git remote add wsdjeg_sourcecounter https://SpaceVimBot:${BOTSECRET}@github.com/wsdjeg/SourceCounter.vim.git
|
||||||
|
git push wsdjeg_sourcecounter master
|
||||||
|
cd -
|
||||||
|
rm -rf detach/$1
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
iedit)
|
iedit)
|
||||||
git clone https://github.com/wsdjeg/iedit.vim.git detach/$1
|
git clone https://github.com/wsdjeg/iedit.vim.git detach/$1
|
||||||
cd detach/$1
|
cd detach/$1
|
||||||
|
2
.github/workflows/async.yml
vendored
2
.github/workflows/async.yml
vendored
@ -7,7 +7,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
detachPlugin: ["flygrep", "dein-ui", "vim-todo", "iedit", "scrollbar.vim", "vim-chat", "vim-cheat", "xmake.vim", "github.vim", "JavaUnit.vim", "git.vim", "cpicker.nvim"]
|
detachPlugin: ["flygrep", "dein-ui", "vim-todo", "iedit", "scrollbar.vim", "vim-chat", "vim-cheat", "xmake.vim", "github.vim", "JavaUnit.vim", "git.vim", "cpicker.nvim", "SourceCounter.vim"]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
|
@ -26,26 +26,22 @@ if has('nvim-0.10.0')
|
|||||||
call SpaceVim#logger#info('run root changed callback on VimEnter!')
|
call SpaceVim#logger#info('run root changed callback on VimEnter!')
|
||||||
call SpaceVim#plugins#projectmanager#RootchandgeCallback()
|
call SpaceVim#plugins#projectmanager#RootchandgeCallback()
|
||||||
if !empty(get(g:, '_spacevim_bootstrap_after', ''))
|
if !empty(get(g:, '_spacevim_bootstrap_after', ''))
|
||||||
try
|
function! s:bootstrap_after(...) abort
|
||||||
call call(g:_spacevim_bootstrap_after, [])
|
try
|
||||||
let g:_spacevim_bootstrap_after_success = 1
|
call call(g:_spacevim_bootstrap_after, [])
|
||||||
catch
|
let g:_spacevim_bootstrap_after_success = 1
|
||||||
call SpaceVim#logger#error('failed to call bootstrap_after function: ' . g:_spacevim_bootstrap_after)
|
catch
|
||||||
call SpaceVim#logger#error(' exception: ' . v:exception)
|
call SpaceVim#logger#error('failed to call bootstrap_after function: ' . g:_spacevim_bootstrap_after)
|
||||||
call SpaceVim#logger#error(' throwpoint: ' . v:throwpoint)
|
call SpaceVim#logger#error(' exception: ' . v:exception)
|
||||||
let g:_spacevim_bootstrap_after_success = 0
|
call SpaceVim#logger#error(' throwpoint: ' . v:throwpoint)
|
||||||
endtry
|
let g:_spacevim_bootstrap_after_success = 0
|
||||||
endif
|
endtry
|
||||||
|
endfunction
|
||||||
if !get(g:, '_spacevim_bootstrap_before_success', 1)
|
if has('timers')
|
||||||
echohl Error
|
call timer_start(g:spacevim_lazy_conf_timeout, function('s:bootstrap_after'))
|
||||||
echom 'bootstrap_before function failed to execute. Check `SPC h L` for errors.'
|
else
|
||||||
echohl None
|
call s:bootstrap_after()
|
||||||
endif
|
endif
|
||||||
if !get(g:, '_spacevim_bootstrap_after_success', 1)
|
|
||||||
echohl Error
|
|
||||||
echom 'bootstrap_after function failed to execute. Check `SPC h L` for errors.'
|
|
||||||
echohl None
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if !filereadable('.SpaceVim.d/init.toml') && filereadable('.SpaceVim.d/init.vim')
|
if !filereadable('.SpaceVim.d/init.toml') && filereadable('.SpaceVim.d/init.vim')
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2016 Wang Shidong
|
|
||||||
|
|
||||||
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.
|
|
@ -1,150 +1,188 @@
|
|||||||
let s:JOB = SpaceVim#api#import('job')
|
|
||||||
let s:NOTI = SpaceVim#api#import('notify')
|
let s:NOTI = SpaceVim#api#import('notify')
|
||||||
|
|
||||||
scriptencoding utf-8
|
scriptencoding utf-8
|
||||||
let s:support_ft = ['vim', 'java', 'c', 'py', 'md', 'txt']
|
let s:support_ft = ['vim', 'java', 'c', 'py', 'md', 'txt']
|
||||||
function! SourceCounter#View(bang, ...) abort
|
function! SourceCounter#View(bang, ...) abort
|
||||||
let result = []
|
call s:NOTI.notify(string(a:000))
|
||||||
if a:0
|
let fts = []
|
||||||
let fts = a:000
|
let dirs = []
|
||||||
else
|
let result = {}
|
||||||
let fts = s:support_ft
|
let argv_type = ''
|
||||||
|
for argv in a:000
|
||||||
|
if argv == '-d'
|
||||||
|
let argv_type = 'dir'
|
||||||
|
continue
|
||||||
|
elseif argv == '-ft'
|
||||||
|
let argv_type = 'filetype'
|
||||||
|
continue
|
||||||
endif
|
endif
|
||||||
call s:NOTI.notify('counting for: ' . join(fts, ', '))
|
if argv_type == 'dir'
|
||||||
" return
|
call add(dirs, argv)
|
||||||
|
elseif argv_type == 'filetype'
|
||||||
|
call add(fts, argv)
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
call s:NOTI.notify('counting for: ' . join(fts, ', '))
|
||||||
|
" return
|
||||||
|
for dir in dirs
|
||||||
for ft in fts
|
for ft in fts
|
||||||
let _rs = s:counter(ft)
|
let _rs = s:counter(ft, dir)
|
||||||
if !empty(_rs)
|
if !empty(_rs)
|
||||||
call add(result, _rs)
|
if has_key(result, ft)
|
||||||
|
let result[ft].files = result[ft].files + _rs.files
|
||||||
|
let result[ft].lines = result[ft].lines + _rs.lines
|
||||||
|
else
|
||||||
|
let result[ft] = {
|
||||||
|
\ 'files' : _rs.files,
|
||||||
|
\ 'lines' : _rs.lines,
|
||||||
|
\ }
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
endfor
|
endfor
|
||||||
let result = sort(deepcopy(result), function('s:compare'))
|
endfor
|
||||||
let table = s:draw_table(result)
|
let result = sort(s:build(result), function('s:compare'))
|
||||||
if a:bang
|
let table = s:draw_table(result)
|
||||||
tabnew
|
if a:bang
|
||||||
for line in table
|
tabnew
|
||||||
call append(line('$'), line)
|
setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline nospell nonumber norelativenumber
|
||||||
endfor
|
setlocal modifiable
|
||||||
else
|
noautocmd normal! gg"_dG
|
||||||
call s:NOTI.notify(join(table, "\n"))
|
for line in table
|
||||||
endif
|
call append(line('$'), line)
|
||||||
|
endfor
|
||||||
|
normal! G
|
||||||
|
setlocal nomodifiable
|
||||||
|
nnoremap <buffer><silent> q :bd<CR>
|
||||||
|
else
|
||||||
|
call s:NOTI.notify(join(table, "\n"))
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! s:build(rst) abort
|
||||||
|
let rst = []
|
||||||
|
for k in keys(a:rst)
|
||||||
|
call add(rst, [k, a:rst[k].files, a:rst[k].lines])
|
||||||
|
endfor
|
||||||
|
return rst
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:compare(a, b) abort
|
function! s:compare(a, b) abort
|
||||||
let m = get(g:, 'source_counter_sort', 'files')
|
let m = get(g:, 'source_counter_sort', 'files')
|
||||||
if m ==# 'lines'
|
if m ==# 'lines'
|
||||||
return a:a[2] == a:b[2] ? 0 : a:a[2] > a:b[2] ? -1 : 1
|
return a:a[2] == a:b[2] ? 0 : a:a[2] > a:b[2] ? -1 : 1
|
||||||
else
|
else
|
||||||
return a:a[1] == a:b[1] ? 0 : a:a[1] > a:b[1] ? -1 : 1
|
return a:a[1] == a:b[1] ? 0 : a:a[1] > a:b[1] ? -1 : 1
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
" https://en.wikipedia.org/wiki/Box-drawing_character
|
" https://en.wikipedia.org/wiki/Box-drawing_character
|
||||||
function! s:draw_table(rst) abort
|
function! s:draw_table(rst) abort
|
||||||
if &encoding ==# 'utf-8'
|
if &encoding ==# 'utf-8'
|
||||||
let top_left_corner = '╭'
|
let top_left_corner = '╭'
|
||||||
let top_right_corner = '╮'
|
let top_right_corner = '╮'
|
||||||
let bottom_left_corner = '╰'
|
let bottom_left_corner = '╰'
|
||||||
let bottom_right_corner = '╯'
|
let bottom_right_corner = '╯'
|
||||||
let side = '│'
|
let side = '│'
|
||||||
let top_bottom_side = '─'
|
let top_bottom_side = '─'
|
||||||
let middle = '┼'
|
let middle = '┼'
|
||||||
let top_middle = '┬'
|
let top_middle = '┬'
|
||||||
let left_middle = '├'
|
let left_middle = '├'
|
||||||
let right_middle = '┤'
|
let right_middle = '┤'
|
||||||
let bottom_middle = '┴'
|
let bottom_middle = '┴'
|
||||||
else
|
else
|
||||||
let top_left_corner = '*'
|
let top_left_corner = '*'
|
||||||
let top_right_corner = '*'
|
let top_right_corner = '*'
|
||||||
let bottom_left_corner = '*'
|
let bottom_left_corner = '*'
|
||||||
let bottom_right_corner = '*'
|
let bottom_right_corner = '*'
|
||||||
let side = '|'
|
let side = '|'
|
||||||
let top_bottom_side = '-'
|
let top_bottom_side = '-'
|
||||||
let middle = '*'
|
let middle = '*'
|
||||||
let top_middle = '*'
|
let top_middle = '*'
|
||||||
let left_middle = '*'
|
let left_middle = '*'
|
||||||
let right_middle = '*'
|
let right_middle = '*'
|
||||||
let bottom_middle = '*'
|
let bottom_middle = '*'
|
||||||
endif
|
endif
|
||||||
let table = []
|
let table = []
|
||||||
let top_line = top_left_corner
|
let top_line = top_left_corner
|
||||||
\ . repeat(top_bottom_side, 15)
|
\ . repeat(top_bottom_side, 15)
|
||||||
\ . top_middle
|
\ . top_middle
|
||||||
\ . repeat(top_bottom_side, 15)
|
\ . repeat(top_bottom_side, 15)
|
||||||
\ . top_middle
|
\ . top_middle
|
||||||
\ . repeat(top_bottom_side, 15)
|
\ . repeat(top_bottom_side, 15)
|
||||||
\ . top_right_corner
|
\ . top_right_corner
|
||||||
|
|
||||||
let middle_line = left_middle
|
let middle_line = left_middle
|
||||||
\ . repeat(top_bottom_side, 15)
|
\ . repeat(top_bottom_side, 15)
|
||||||
\ . middle
|
\ . middle
|
||||||
\ . repeat(top_bottom_side, 15)
|
\ . repeat(top_bottom_side, 15)
|
||||||
\ . middle
|
\ . middle
|
||||||
\ . repeat(top_bottom_side, 15)
|
\ . repeat(top_bottom_side, 15)
|
||||||
\ . right_middle
|
\ . right_middle
|
||||||
|
|
||||||
let bottom_line = bottom_left_corner
|
let bottom_line = bottom_left_corner
|
||||||
\ . repeat(top_bottom_side, 15)
|
\ . repeat(top_bottom_side, 15)
|
||||||
\ . bottom_middle
|
\ . bottom_middle
|
||||||
\ . repeat(top_bottom_side, 15)
|
\ . repeat(top_bottom_side, 15)
|
||||||
\ . bottom_middle
|
\ . bottom_middle
|
||||||
\ . repeat(top_bottom_side, 15)
|
\ . repeat(top_bottom_side, 15)
|
||||||
\ . bottom_right_corner
|
\ . bottom_right_corner
|
||||||
|
|
||||||
call add(table, top_line)
|
call add(table, top_line)
|
||||||
let result = [['filetype', 'files', 'lines']] + a:rst
|
let result = [['filetype', 'files', 'lines']] + a:rst
|
||||||
for rsl in result
|
for rsl in result
|
||||||
let ft_line = side
|
let ft_line = side
|
||||||
\ . rsl[0] . repeat(' ', 15 - strwidth(rsl[0]))
|
\ . rsl[0] . repeat(' ', 15 - strwidth(rsl[0]))
|
||||||
\ . side
|
\ . side
|
||||||
\ . rsl[1] . repeat(' ', 15 - strwidth(rsl[1]))
|
\ . rsl[1] . repeat(' ', 15 - strwidth(rsl[1]))
|
||||||
\ . side
|
\ . side
|
||||||
\ . rsl[2] . repeat(' ', 15 - strwidth(rsl[2]))
|
\ . rsl[2] . repeat(' ', 15 - strwidth(rsl[2]))
|
||||||
\ . side
|
\ . side
|
||||||
call add(table, ft_line)
|
call add(table, ft_line)
|
||||||
call add(table, middle_line)
|
call add(table, middle_line)
|
||||||
endfor
|
endfor
|
||||||
let table[-1] = bottom_line
|
let table[-1] = bottom_line
|
||||||
return table
|
return table
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:list_files_stdout(id, data, event) abort
|
function! s:list_files_stdout(id, data, event) abort
|
||||||
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:list_files_exit(id, data, event) abort
|
function! s:list_files_exit(id, data, event) abort
|
||||||
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:counter(ft) abort
|
function! s:counter(ft, dir) abort
|
||||||
let path = getcwd()
|
if executable('ag')
|
||||||
let partten = '**/*.' . a:ft
|
|
||||||
if executable('ag')
|
|
||||||
if has('nvim')
|
|
||||||
let files = systemlist(['ag','-g', '.' . a:ft . '$'])
|
|
||||||
else
|
|
||||||
let files = split(system('ag -g .'.a:ft.'$'),nr2char(10))
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
let files = globpath(l:path, l:partten, 0, 1)
|
|
||||||
endif
|
|
||||||
if len(files) == 0
|
|
||||||
return []
|
|
||||||
endif
|
|
||||||
let lines = 0
|
|
||||||
if has('nvim')
|
if has('nvim')
|
||||||
if len(files) > 380
|
let files = systemlist(['ag','-g', '.' . a:ft . '$'])
|
||||||
while !empty(files)
|
|
||||||
let lines += matchstr(systemlist(['wc', '-l'] + remove(files, 0, min([380, len(files) - 1])))[-1], '\d\+')
|
|
||||||
endwhile
|
|
||||||
else
|
|
||||||
let lines = matchstr(systemlist(['wc', '-l'] + files)[-1], '\d\+')
|
|
||||||
endif
|
|
||||||
else
|
else
|
||||||
for fl in files
|
let files = split(system('ag -g .'.a:ft.'$'),nr2char(10))
|
||||||
let lines += str2nr(matchstr(system('wc -l '. fl), '\d\+'))
|
|
||||||
endfor
|
|
||||||
endif
|
endif
|
||||||
return [a:ft, len(files), lines]
|
else
|
||||||
|
let partten = '**/*.' . a:ft
|
||||||
|
let files = globpath(a:dir, l:partten, 0, 1)
|
||||||
|
endif
|
||||||
|
if len(files) == 0
|
||||||
|
return []
|
||||||
|
endif
|
||||||
|
let lines = 0
|
||||||
|
let _file_count = len(files)
|
||||||
|
if has('nvim')
|
||||||
|
if len(files) > 380
|
||||||
|
while !empty(files)
|
||||||
|
let _fs = remove(files, 0, min([380, len(files) - 1]))
|
||||||
|
let _rst = systemlist(['wc', '-l'] + _fs)[-1]
|
||||||
|
let lines += matchstr(_rst, '\d\+')
|
||||||
|
endwhile
|
||||||
|
else
|
||||||
|
let lines = matchstr(systemlist(['wc', '-l'] + files)[-1], '\d\+')
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
for fl in files
|
||||||
|
let lines += str2nr(matchstr(system('wc -l '. fl), '\d\+'))
|
||||||
|
endfor
|
||||||
|
endif
|
||||||
|
return {'files' : _file_count, 'lines' : lines}
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,9 +3,9 @@ wsdjeg *SourceCounter.vim*
|
|||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
CONTENTS *SourceCounter.vim-contents*
|
CONTENTS *SourceCounter.vim-contents*
|
||||||
1. Introduction....................................|SourceCounter.vim-intro|
|
1. Introduction..................................... |SourceCounter.vim-intro|
|
||||||
2. Configuration..................................|SourceCounter.vim-config|
|
2. Configuration................................... |SourceCounter.vim-config|
|
||||||
3. Commands.....................................|SourceCounter.vim-commands|
|
3. Commands...................................... |SourceCounter.vim-commands|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
INTRODUCTION *SourceCounter.vim-intro*
|
INTRODUCTION *SourceCounter.vim-intro*
|
||||||
|
Loading…
Reference in New Issue
Block a user