这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions plugin/webdevicons.vim
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
" License: see LICENSE

let s:version = '0.7.1'
let s:operatingsystem = system("uname -s")

" standard fix/safety: line continuation (avoiding side effects) {{{1
"========================================================================
Expand Down Expand Up @@ -137,6 +136,36 @@ endif
" local functions {{{2
"========================================================================

" scope: local
function s:isDarwin()
if exists('s:is_darwin')
return s:is_darwin
endif

if exists('g:WebDevIconsOS')
let s:is_darwin = g:WebDevIconsOS ==? 'Darwin'
return s:is_darwin
endif

if has('macunix')
let s:is_darwin = 1
return s:is_darwin
endif

if ! has('unix')
let s:is_darwin = 0
return s:is_darwin
endif

if system('uname -s') ==# "Darwin\n"
let s:is_darwin = 1
else
let s:is_darwin = 0
endif

return s:is_darwin
endfunction

" scope: local
function! s:strip(input)
return substitute(a:input, '^\s*\(.\{-}\)\s*$', '\1', '')
Expand Down Expand Up @@ -534,7 +563,7 @@ function! WebDevIconsGetFileFormatSymbol(...)
if &fileformat == "dos"
let fileformat = ""
elseif &fileformat == "unix"
if s:operatingsystem == "Darwin\n"
if s:isDarwin()
let fileformat = ""
else
let fileformat = ""
Expand Down
6 changes: 6 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,12 @@ let g:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols = {} " needed
let g:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols['myext'] = 'ƛ'
```

* specify OS to decide an icon for unix fileformat (_not_ defined by default)
- this is useful for avoiding unnecessary `system()` call. you might see [#135](https://github.com/ryanoasis/vim-devicons/pull/135) to know logic further.
```vim
let g:WebDevIconsOS = 'Darwin'
```

## Lightline Setup

To add the appropriate icon to [lightline](https://github.com/itchyny/lightline.vim), call the function `WebDevIconsGetFileTypeSymbol()` and/or `WebDevIconsGetFileFormatSymbol()` in your `.vimrc`. For example, you could set your sections to:
Expand Down