From 0c9fe47f29b8bbe6de4228a17f7d609ac9a8f1ad Mon Sep 17 00:00:00 2001 From: Wu Zhenyu Date: Sun, 28 May 2023 15:17:47 +0800 Subject: [PATCH] :sparkles: Support fileformat --- .pre-commit-config.yaml | 13 ++++++------- autoload/airline_renderer_nerdfont.vim | 22 ++++++++++++++++++++-- doc/airline-renderer-nerdfont.txt | 6 +++++- pyproject.toml | 2 ++ 4 files changed, 33 insertions(+), 10 deletions(-) create mode 100644 pyproject.toml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2aa0ac6..bdef86a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -21,17 +21,17 @@ repos: - id: check-toml - id: check-json - repo: https://github.com/Lucas-C/pre-commit-hooks - rev: v1.4.2 + rev: v1.5.1 hooks: - id: remove-crlf - repo: https://github.com/codespell-project/codespell - rev: v2.2.2 + rev: v2.2.4 hooks: - id: codespell additional_dependencies: - tomli - repo: https://github.com/jorisroovers/gitlint - rev: v0.19.0dev + rev: v0.19.1 hooks: - id: gitlint args: @@ -45,16 +45,15 @@ repos: hooks: - id: check-mailmap - repo: https://github.com/adrienverge/yamllint - rev: v1.29.0 + rev: v1.32.0 hooks: - id: yamllint - repo: https://github.com/executablebooks/mdformat rev: 0.7.16 hooks: - id: mdformat - args: - - --number additional_dependencies: + - mdformat-pyproject - mdformat-gfm - mdformat-myst - mdformat-toc @@ -63,7 +62,7 @@ repos: - mdformat-black - mdformat-config - repo: https://github.com/DavidAnson/markdownlint-cli2 - rev: v0.6.0 + rev: v0.7.1 hooks: - id: markdownlint-cli2 additional_dependencies: diff --git a/autoload/airline_renderer_nerdfont.vim b/autoload/airline_renderer_nerdfont.vim index c1528ee..f66b238 100644 --- a/autoload/airline_renderer_nerdfont.vim +++ b/autoload/airline_renderer_nerdfont.vim @@ -13,9 +13,9 @@ call g:airline_renderer_nerdfont#utils#plugin.Flag('g:airline_renderer_nerdfont# "" " Override |airline|'s section y. " -" Default: ' %{&fenc} %{nerdfont#platform#find()} '` +" Default: ' %{&fenc} %{airline_renderer_nerdfont#fileformat()} '` call g:airline_renderer_nerdfont#utils#plugin.Flag('g:airline_renderer_nerdfont#y', - \ ' %{&fenc} %{nerdfont#platform#find()} ') + \ ' %{&fenc} %{airline_renderer_nerdfont#fileformat()} ') "" " Expand '%s' to icon then append to |airline|'s tabline. call g:airline_renderer_nerdfont#utils#plugin.Flag('g:airline_renderer_nerdfont#tabline', @@ -31,3 +31,21 @@ function! airline_renderer_nerdfont#main(...) abort let w:airline_section_y = g:airline_renderer_nerdfont#y endif endfunction + +"" +" Use icon to display fileformat. +function! airline_renderer_nerdfont#fileformat() abort + if &fileformat ==# 'dos' + return nerdfont#platform#find('windows') + endif + if &fileformat ==# 'mac' + return nerdfont#platform#find('macos') + endif + if &fileformat ==# 'unix' + if has('unix') + return nerdfont#platform#find() + else + return nerdfont#platform#find('linux') + endif + endif +endfunction diff --git a/doc/airline-renderer-nerdfont.txt b/doc/airline-renderer-nerdfont.txt index 373a2be..9c642e5 100644 --- a/doc/airline-renderer-nerdfont.txt +++ b/doc/airline-renderer-nerdfont.txt @@ -25,7 +25,7 @@ Default: ' %{nerdfont#find()} '` *airline-renderer-nerdfont:g:airline_renderer_nerdfont#y* Override |airline|'s section y. -Default: ' %{&fenc} %{nerdfont#platform#find()} '` +Default: ' %{&fenc} %{airline_renderer_nerdfont#fileformat()} '` *airline-renderer-nerdfont:g:airline_renderer_nerdfont#tabline* Expand '%s' to icon then append to |airline|'s tabline. @@ -49,5 +49,9 @@ FUNCTIONS *airline-renderer-nerdfont-functions* airline_renderer_nerdfont#main() *airline_renderer_nerdfont#main()* Main function to render |airline|'s section x and y. +airline_renderer_nerdfont#fileformat() + *airline_renderer_nerdfont#fileformat()* + Use icon to display fileformat. + vim:tw=78:ts=8:ft=help:norl: diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..3f11426 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,2 @@ +[tool.mdformat] +number = true