1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 17:30:04 +08:00

Merge pull request #291 from SpaceVim/airline

Add messletters api
This commit is contained in:
Wang Shidong 2017-02-26 21:15:10 +08:00 committed by GitHub
commit 1322b791e3
10 changed files with 340 additions and 12 deletions

View File

@ -41,7 +41,7 @@ to select the layers they need. It got inspired by [spacemacs](https://github.co
please star it on github. It's a great way of getting feedback and gives me the kick to
put more time into development.
![2017-02-05_1359x721](https://cloud.githubusercontent.com/assets/13142418/22622826/f88881a8-eb80-11e6-880b-b12e0430689a.png)
![2017-02-26_1365x739](https://cloud.githubusercontent.com/assets/13142418/23339920/590f2e9a-fc67-11e6-99ec-794f79ba0902.png)
If you are new to vim, you should learning about Vim in general, read [vim-galore](https://github.com/mhinz/vim-galore).

View File

@ -170,8 +170,21 @@ let g:spacevim_enable_debug = 0
let g:spacevim_debug_level = 1
let g:spacevim_hiddenfileinfo = 1
let g:spacevim_plugin_groups_exclude = []
""
" Set SpaceVim buffer index type, default is 0.
" >
" " types:
" " 0: 1 ➛ ➊
" " 1: 1 ➛ ➀
" " 2: 1 ➛ ⓵
" " 3: 1 ➛ ¹
" " 4: 1 ➛ 1
" let g:spacevim_buffer_index_type = 1
" <
let g:spacevim_buffer_index_type = 0
""
" Enable/Disable tabline filetype icon. default is 0.
let g:spacevim_enable_tabline_filetype_icon = 0
""
" Plugin groups to be loaded.
" >

View File

@ -1,3 +1,4 @@
scriptencoding utf-8
let s:file = {}
let s:system = SpaceVim#api#import('system')
@ -9,6 +10,147 @@ else
let s:file['pathSeparator'] = ':'
endif
let s:file_node_extensions = {
\ 'styl' : '',
\ 'scss' : '',
\ 'htm' : '',
\ 'html' : '',
\ 'erb' : '',
\ 'slim' : '',
\ 'ejs' : '',
\ 'wxml' : '',
\ 'css' : '',
\ 'less' : '',
\ 'wxss' : '',
\ 'md' : '',
\ 'markdown' : '',
\ 'json' : '',
\ 'js' : '',
\ 'jsx' : '',
\ 'rb' : '',
\ 'php' : '',
\ 'py' : '',
\ 'pyc' : '',
\ 'pyo' : '',
\ 'pyd' : '',
\ 'coffee' : '',
\ 'mustache' : '',
\ 'hbs' : '',
\ 'conf' : '',
\ 'ini' : '',
\ 'yml' : '',
\ 'bat' : '',
\ 'jpg' : '',
\ 'jpeg' : '',
\ 'bmp' : '',
\ 'png' : '',
\ 'gif' : '',
\ 'ico' : '',
\ 'twig' : '',
\ 'cpp' : '',
\ 'c++' : '',
\ 'cxx' : '',
\ 'cc' : '',
\ 'cp' : '',
\ 'c' : '',
\ 'hs' : '',
\ 'lhs' : '',
\ 'lua' : '',
\ 'java' : '',
\ 'sh' : '',
\ 'fish' : '',
\ 'ml' : 'λ',
\ 'mli' : 'λ',
\ 'diff' : '',
\ 'db' : '',
\ 'sql' : '',
\ 'dump' : '',
\ 'clj' : '',
\ 'cljc' : '',
\ 'cljs' : '',
\ 'edn' : '',
\ 'scala' : '',
\ 'go' : '',
\ 'dart' : '',
\ 'xul' : '',
\ 'sln' : '',
\ 'suo' : '',
\ 'pl' : '',
\ 'pm' : '',
\ 't' : '',
\ 'rss' : '',
\ 'f#' : '',
\ 'fsscript' : '',
\ 'fsx' : '',
\ 'fs' : '',
\ 'fsi' : '',
\ 'rs' : '',
\ 'rlib' : '',
\ 'd' : '',
\ 'erl' : '',
\ 'hrl' : '',
\ 'vim' : '',
\ 'ai' : '',
\ 'psd' : '',
\ 'psb' : '',
\ 'ts' : '',
\ 'jl' : ''
\}
let s:file_node_exact_matches = {
\ 'exact-match-case-sensitive-1.txt' : 'X1',
\ 'exact-match-case-sensitive-2' : 'X2',
\ 'gruntfile.coffee' : '',
\ 'gruntfile.js' : '',
\ 'gruntfile.ls' : '',
\ 'gulpfile.coffee' : '',
\ 'gulpfile.js' : '',
\ 'gulpfile.ls' : '',
\ 'dropbox' : '',
\ '.ds_store' : '',
\ '.gitconfig' : '',
\ '.gitignore' : '',
\ '.bashrc' : '',
\ '.bashprofile' : '',
\ 'favicon.ico' : '',
\ 'license' : '',
\ 'node_modules' : '',
\ 'react.jsx' : '',
\ 'Procfile' : '',
\ '.vimrc' : '',
\}
let s:file_node_pattern_matches = {
\ '.*jquery.*\.js$' : '',
\ '.*angular.*\.js$' : '',
\ '.*backbone.*\.js$' : '',
\ '.*require.*\.js$' : '',
\ '.*materialize.*\.js$' : '',
\ '.*materialize.*\.css$' : '',
\ '.*mootools.*\.js$' : ''
\}
function! s:filetypeIcon(path) abort
let file = fnamemodify(a:path, ':t')
if has_key(s:file_node_exact_matches, file)
return s:file_node_exact_matches[file]
endif
for [k, v] in items(s:file_node_pattern_matches)
if match(file, k) != -1
return v
endif
endfor
let ext = fnamemodify(file, ':e')
if has_key(s:file_node_extensions, ext)
return s:file_node_extensions[ext]
endif
return ''
endfunction
let s:file['fticon'] = function('s:filetypeIcon')
function! SpaceVim#api#file#get() abort
return deepcopy(s:file)
endfunction

View File

@ -0,0 +1,108 @@
scriptencoding utf-8
let s:chars = {}
" type :
" 0: 1 ➛ ➊
" 1: 1 ➛ ➀
" 2: 1 ➛ ⓵
function! s:bubble_num(num, type) abort
let list = []
call add(list,['➊', '➋', '➌', '➍', '➎', '➏', '➐', '➑', '➒', '➓'])
call add(list,['➀', '➁', '➂', '➃', '➄', '➅', '➆', '➇', '➈', '➉'])
call add(list,['⓵', '⓶', '⓷', '⓸', '⓹', '⓺', '⓻', '⓼', '⓽', '⓾'])
let n = ''
try
let n = list[a:type][a:num-1]
catch
endtry
return n
endfunction
let s:chars['bubble_num'] = function('s:bubble_num')
" type :
" 0: 1 ➛ ➊
" 1: 1 ➛ ➀
" 2: 1 ➛ ⓵
function! s:circled_num(num, type) abort
" http://www.unicode.org/charts/beta/nameslist/n_2460.html
if a:type == 0
if a:num == 0
return nr2char(9471)
elseif index(range(1,10), a:num) != -1
return nr2char(10102 + a:num - 1)
elseif index(range(11, 20), a:num)
return nr2char(9451 + a:num - 11)
else
return ''
endif
elseif a:type == 1
if index(range(20), a:num) != -1
if a:num == 0
return nr2char(9450)
else
return nr2char(9311 + a:num)
endif
else
return ''
endif
elseif a:type == 2
if index(range(1, 10), a:num) != -1
return nr2char(9461 + a:num - 1)
else
return ''
endif
endif
endfunction
let s:chars['circled_num'] = function('s:circled_num')
function! s:parenthesized_num(num) abort
" http://www.unicode.org/charts/beta/nameslist/n_2460.html
if index(range(1, 20), a:num) != -1
return nr2char(9331 + a:num)
else
return ''
endif
endfunction
let s:chars['parenthesized_num'] = function('s:parenthesized_num')
function! s:num_period(num) abort
" http://www.unicode.org/charts/beta/nameslist/n_2460.html
if index(range(1, 20), a:num) != -1
return nr2char(9351 + a:num)
else
return ''
endif
endfunction
let s:chars['num_period'] = function('s:num_period')
function! s:parenthesized_letter(letter) abort
" http://www.unicode.org/charts/beta/nameslist/n_2460.html
if index(range(1, 26), char2nr(a:letter) - 96) != -1
return nr2char(9371 + char2nr(a:letter) - 96)
else
return ''
endif
endfunction
let s:chars['parenthesized_letter'] = function('s:parenthesized_letter')
function! s:circled_letter(letter) abort
" http://www.unicode.org/charts/beta/nameslist/n_2460.html
if index(range(1, 26), char2nr(a:letter) - 64) != -1
return nr2char(9397 + char2nr(a:letter) - 64)
elseif index(range(1, 26), char2nr(a:letter) - 96) != -1
return nr2char(9423 + char2nr(a:letter) - 96)
else
return ''
endif
endfunction
let s:chars['circled_letter'] = function('s:circled_letter')
function! SpaceVim#api#messletters#get() abort
return deepcopy(s:chars)
endfunction

View File

@ -0,0 +1,19 @@
" @vimlint(EVL103, 1, a:buffers)
function! airline#extensions#tabline#formatters#spacevim#format(bufnr, buffers) abort
let id = SpaceVim#api#messletters#get().bubble_num(a:bufnr, g:spacevim_buffer_index_type) . ' '
let fn = fnamemodify(bufname(a:bufnr), ':t')
if g:spacevim_enable_tabline_filetype_icon
let icon = SpaceVim#api#import('file').fticon(fn)
if !empty(icon)
let fn = icon . ' ' . fn
endif
endif
if empty(fn)
return 'No Name'
elseif !g:airline#extensions#tabline#buffer_idx_mode
return id . fn
else
return fn
endif
endfunction
" @vimlint(EVL103, 0, a:buffers)

View File

@ -52,8 +52,8 @@ let g:terminal_color_14 = "#8ec07c"
" light4 + light1
let g:terminal_color_7 = "#a89984"
let g:terminal_color_15 = "#ebdbb2"
nnoremap <FocusGained> <Nop>
nnoremap <FocusLost> <Nop>
nnoremap <nowait> <FocusGained> <Nop>
nnoremap <nowait> <FocusLost> <Nop>
augroup Terminal
au!
au TermOpen * let g:last_terminal_job_id = b:terminal_job_id | IndentLinesDisable

View File

@ -1 +1 @@
let g:gruvbox_italic = 1
let g:gruvbox_italic = 0

View File

@ -4,13 +4,40 @@ let g:airline_skip_empty_sections = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tmuxline#enabled = 1
let g:Powerline_sybols = 'unicode'
let g:airline#extensions#tabline#buffer_idx_mode = 1
let g:airline#extensions#tabline#buffer_nr_show = 1
let g:airline#extensions#tabline#buffer_nr_format = '%s:'
if g:spacevim_buffer_index_type < 3
let g:airline#extensions#tabline#buffer_idx_mode = 1
let g:airline#extensions#tabline#buffer_idx_format = {}
for s:i in range(9)
call extend(g:airline#extensions#tabline#buffer_idx_format,
\ {s:i : SpaceVim#api#import('messletters').bubble_num(s:i,
\ g:spacevim_buffer_index_type). ' '})
endfor
unlet s:i
elseif g:spacevim_buffer_index_type == 3
let g:airline#extensions#tabline#buffer_idx_mode = 1
elseif g:spacevim_buffer_index_type == 4
let g:airline#extensions#tabline#buffer_idx_mode = 1
let g:airline#extensions#tabline#buffer_idx_format = {
\ '0': '0 ',
\ '1': '1 ',
\ '2': '2 ',
\ '3': '3 ',
\ '4': '4 ',
\ '5': '5 ',
\ '6': '6 ',
\ '7': '7 ',
\ '8': '8 ',
\ '9': '9 '
\}
endif
let g:airline#extensions#tabline#formatter = 'spacevim'
"let g:airline#extensions#tabline#buffer_nr_show = 1
"let g:airline#extensions#tabline#buffer_nr_format = '%s:'
let g:airline#extensions#tabline#fnamemod = ':t'
let g:airline#extensions#tabline#fnamecollapse = 1
let g:airline#extensions#tabline#fnametruncate = 0
let g:airline#extensions#tabline#formatter = 'unique_tail_improved'
"let g:airline#extensions#tabline#formatter = 'unique_tail_improved'
nmap <leader>1 <Plug>AirlineSelectTab1
nmap <leader>2 <Plug>AirlineSelectTab2
nmap <leader>3 <Plug>AirlineSelectTab3
@ -47,4 +74,8 @@ if get(g:, 'airline_powerline_fonts', 0)
let g:airline_symbols.linenr = ''
let g:airline_symbols.maxlinenr= ''
endif
let g:airline#extensions#tabline#show_tab_nr = 1
let g:airline#extensions#tabline#tab_nr_type= 2
let g:airline#extensions#tabline#show_tab_type = 1
let g:airline#extensions#tabline#buffers_label = 'BUFFERS'
let g:airline#extensions#tabline#tabs_label = 'TABS'

View File

@ -198,6 +198,21 @@ Enable/Disable debug mode for SpaceVim. Default is 0.
*g:spacevim_debug_level*
Set the debug level of SpaceVim. Default is 1.
*g:spacevim_buffer_index_type*
Set SpaceVim buffer index type, default is 0.
>
" types:
" 0: 1 ➛ ➊
" 1: 1 ➛ ➀
" 2: 1 ➛ ⓵
" 3: 1 ➛ ¹
" 4: 1 ➛ 1
let g:spacevim_buffer_index_type = 1
<
*g:spacevim_enable_tabline_filetype_icon*
Enable/Disable tabline filetype icon. default is 0.
*g:spacevim_plugin_groups*
Plugin groups to be loaded.
>

View File

@ -15,7 +15,7 @@ to select the layers they need. It got inspired by [spacemacs](https://github.co
please star it on github. It's a great way of getting feedback and gives me the kick to
put more time into development.
![2017-02-05_1359x721](https://cloud.githubusercontent.com/assets/13142418/22622826/f88881a8-eb80-11e6-880b-b12e0430689a.png)
![2017-02-26_1365x739](https://cloud.githubusercontent.com/assets/13142418/23339920/590f2e9a-fc67-11e6-99ec-794f79ba0902.png)
If you are new to vim, you should learning about Vim in general, read [vim-galore](https://github.com/mhinz/vim-galore).