Vim Powerline & Fonts(Fira Code)
# ===?? Airline or Powerline - Tab Bar/Status Bar
- https://github.com/powerline/powerline
- https://github.com/Lokaltog/powerline
- https://github.com/vim-airline/vim-airline
- https://github.com/vim-airline/vim-airline-thremes
- https://linuxconfig.org/introduction-to-powerline-the-statusline-plugin-for-vim
- https://www.alexwhittemore.com/gvim-with-powerline-on-windows-8-64bit/
- https://www.ricalo.com/blog/install-powerline-windows/


Vim 狀態(tài)條插件的內(nèi)容有三個部分:
? ?- 字體文件的介紹,以及安裝與使用;
? ?- Vim-Airline 和 Vim-Powerline 的差別;
? ?- Vim-Airline 和 Vim-Powerline 安裝與配置;
全文參考?https://github.com/jimboyeah/run-snippet/blob/master/material/vim_flavor.md
使用 Windows Terminal 終端應(yīng)用,Set the shell's title
- https://docs.microsoft.com/en-us/windows/terminal/tutorials/tab-title
?PowerShell? >>>>? $Host.UI.RawUI.WindowTitle = "New Title"?
? ?Command? >>>>? Prompt? TITLE "New Title"? ? ? ? ? ? ? ?
? ? ? ? ? ?bash*?>>>>??echo -ne "\033]0;New Title\a"? ? ? ? ? ?
Vim-Airline 和 Vim-Powerline 都是非常棒棒的狀態(tài)條、標(biāo)簽塊插件,可優(yōu)化 Vim 原有的 Tab 有點混亂的狀。
作為更早期的插件,Powerline 使用 Python 腳本開發(fā),不僅支持 Vim,看起來塊頭更大。并且在 Vim 配置上也更顯異類,并且混亂,需要有一定的 Python 配置能力和 Vim 腳本接口擴展知識。
另外,因為 Powerline 使用更好看箭頭,需要安裝額外的 Arimo for Powerline 字體。只在 Windows WSL 系統(tǒng)上安裝,Windows Terminal 上并沒有效果,并且很卡頓體驗不夠好:
? ? sudo apt install --yes powerline
? ? sudo apt-get install fonts-powerline
在 Windows 上的 NeoVim 中也出現(xiàn)了錯誤:
? ? AttributeError: 'LegacyVim' object has no attribute 'bindeval'
安裝字體注意,因為在 Windows WSL 環(huán)境下使用 Vim,控制臺是在宿主系統(tǒng)上執(zhí)行的,字體就要安裝在宿主系統(tǒng)上。因為 Windows Terminal 運行在宿主系統(tǒng)上,WSL 是子系統(tǒng),字體應(yīng)該在宿主機上安裝。
字體特點介紹如,按緊湊度升序:

Cascadia Code、Fira Code、JetBrains Mono 三款字體均支持連字,>= <= => -> != <> 這類兩字并作一格,也均有非連字版本,字體均強調(diào)了 'l' 的辨識度。
- [Arimo for Powerline](https://github.com/powerline/fonts)
- [Cascadia Code](https://github.com/microsoft/cascadia-code/releases)
- [Fira Code](https://github.com/tonsky/FiraCode/releases)
- [JetBrains Mono](https://github.com/JetBrains/JetBrainsMono/releases)
- [Sarasa Gothic 更紗黑體](https://github.com/be5invis/Sarasa-Gothic)
各字體的變體:

Fira Code 是 Mozilla 公司主推的字體系列,專為寫程序設(shè)計的字體。出來具有等寬等基本屬性外,還加入了編程連字特性(ligatures),這點做得非常好,并且對視網(wǎng)膜高清屏有支持,有 Retina 變體。
Fira Code 就是利用這個特性對編程中的常用符號進(jìn)行優(yōu)化,比如把輸入的「!=」直接顯示成 「≠」 或者把 「>=」 變成 「≥ 」 等等,以此來提高代碼的可讀性。并且 1liIoOpP0 這此字符辨識度極高。
Fira Code 對 Unicode 字符集支持度還非常高,其中 Medium 變體中文有粗線不一問題;

更紗黑體是一種中文編程字體,包含以下樣式:
? ?- Sarasa Gothic / 更紗黑體:基于Inter,全寬引號
? ?- Sarasa UI / 更紗黑體 UI:基于Inter,窄引號
以下 PowerSHell 腳本供參考,可以直接下載 Powerline 字包,解壓后執(zhí)行安裝腳本,它會執(zhí)行 Windows 字體安裝程序,將字體安裝到 Windows Fonts 目錄下:
$url = "https://github.com/powerline/fonts/archive/master.zip"
powershell -command "& { iwr $url -OutFile ~\fonts.zip }"
Expand-Archive -Path ~\fonts.zip -DestinationPath ~
~\fonts-master\install.ps1
另一個替代選擇是微軟的 Cascadia Code 字體,它支持 Powerline Glyph。Windows Terminal 要使用此字體,需要修改屬性,或者直接修改配置文件 settings.json,通過 Ctrl-Shift-P 打開 Open Settings file,或設(shè)置 Open settings ? PowerShell ? apperance ? Text ? Font Face 指定:
"fontFace" : "Cascadia Mono PL",
Cascadia Code 字體包內(nèi)含有 OTF\TTF\WOFF2 三種格式,通常選擇其中 TTF 格式安裝。WOFF2 這種格式在網(wǎng)頁上應(yīng)用很常見,因為它體積更小。選擇其中一個字體文件,雙擊打開字體瀏覽程序安裝,或者多選通過右鍵菜單批量安裝。
另外,字體包中還提供了 static 目錄下的字體文件,這部分是靜態(tài)字體,在 Variable 字體不支持的情況可以使用,一般都是使用可變形字體。變體字的好處就是包含了 Thin/Light/Medium/Bold 等變體字形,使用起來比較方便。Cascadia Code 目前有四個組合變體,主要是 Code 和 Mono 兩種,后者是等寬不連字,PL 表示 PowerLine。
Cascadia Code 是 Microsoft 提供的一種新的等寬字體,可為命令行應(yīng)用程序和文本編輯器提供全新的體驗。 Cascadia Code 是與 Windows 終端一起開發(fā)的。 建議將此字體與終端應(yīng)用程序和文本編輯器(如 Visual Studio 和 Visual Studio Code)一起使用。
Cascadia Code is a purpose-built monospaced TrueType font for Windows Terminal, the new command-line interface for Microsoft Windows. It includes programming ligatures and was designed to enhance the look and feel of Windows Terminal, terminal applications and text editors such as Visual Studio and Visual Studio Code. The font is open source under the SIL Open Font License and available on GitHub.?
Windows 終端在其包中提供 Cascadia Code 和 Cascadia Mono,字體信息如下:
Font Variants
? ?1. Cascadia Code: standard version of Cascadia
? ?2. Cascadia Mono: a version of Cascadia that doesn't have ligatures
? ?3. Cascadia (Code|Mono) PL: a version of Cascadia that has embedded Powerline symbols

目前,Vim-Powerline 已經(jīng)停止更新,并轉(zhuǎn)向 Powerline 項目。
在 Vim 配置腳本中測試當(dāng)前環(huán)境是否對 Python 3.x 的支持。
配置上需要 Python 基礎(chǔ),需要使用 `pip` 和 `setuptools` 包安裝工具,并且對 Windows 系統(tǒng)支持還不好,PowerShell 腳本也沒提供。

Airline 更輕量化,安裝后免配置即可用,還可以搭配主題,Vundle 或 Vim-Plug 方式安裝如下??梢栽?Airline 中使用 Powerline 的好看字體,通過 g:airline_powerline_font 全局變量啟用。

圖形界面字體還可以通過 guifont 選項設(shè)置,格式參考 :help guifont。
以 Vim-Plug 為例,修改 .vimrc 配置文件后,通過 :PlugStatus 查詢插件狀態(tài),通過 :PlugInstall 安裝插件。
插件樣式主題命令參考:
? ?? In .vimrc, use let g:airline_theme='<theme>', e.g. ='simple'
? ?? :AirlineTheme <theme> to set the theme, e.g. :AirlineTheme simple
? ?? :AirlineTheme random to set a randomly selected
? ?? `:help airline` `:help airline-themes` to get help