mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-03 03:10:06 +08:00
Add language aliases (#4044)
This commit is contained in:
parent
95ff6e3c3a
commit
52bbc0c408
32
autoload/SpaceVim/api/language.vim
Normal file
32
autoload/SpaceVim/api/language.vim
Normal file
@ -0,0 +1,32 @@
|
||||
"=============================================================================
|
||||
" language.vim --- programming language information layer
|
||||
" Copyright (c) 2016-2019 Wang Shidong & Contributors
|
||||
" Author: Wang Shidong < wsdjeg@outlook.com >
|
||||
" URL: https://spacevim.org
|
||||
" License: GPLv3
|
||||
"=============================================================================
|
||||
|
||||
|
||||
let s:self = {}
|
||||
|
||||
let s:self.__aliases = {
|
||||
\ 'typescript' : 'TypeScript',
|
||||
\ 'typescriptreact' : 'TypeScript React',
|
||||
\ 'python' : 'Python',
|
||||
\ 'java' : 'Java',
|
||||
\ }
|
||||
|
||||
|
||||
function! s:self.get_alias(filetype) abort
|
||||
if !empty(a:filetype) && has_key(self.__aliases, a:filetype)
|
||||
return self.__aliases[a:filetype]
|
||||
else
|
||||
return a:filetype
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#api#language#get() abort
|
||||
return deepcopy(s:self)
|
||||
endfunction
|
||||
|
||||
|
@ -27,6 +27,7 @@ let s:STATUSLINE = SpaceVim#api#import('vim#statusline')
|
||||
let s:VIMCOMP = SpaceVim#api#import('vim#compatible')
|
||||
let s:SYSTEM = SpaceVim#api#import('system')
|
||||
let s:ICON = SpaceVim#api#import('unicode#icon')
|
||||
let s:LANG = SpaceVim#api#import('language')
|
||||
|
||||
let s:JSON = SpaceVim#api#import('data#json')
|
||||
|
||||
@ -153,7 +154,8 @@ function! s:fileformat() abort
|
||||
endfunction
|
||||
|
||||
function! s:major_mode() abort
|
||||
return '%{empty(&ft)? "" : " " . &ft . " "}'
|
||||
let alias = s:LANG.get_alias(&filetype)
|
||||
return empty(alias) ? '' : ' ' . alias . ' '
|
||||
endfunction
|
||||
|
||||
function! s:modes() abort
|
||||
|
Loading…
Reference in New Issue
Block a user