0
我有像這樣定義的對象:如何防止VimL字符串串聯中的逗號?
let g:lightline = {
\ 'component': {
\ 'fugitive': '%{exists("*fugitive#statusline") ? "⎇ " . fugitive#statusline() : ""}'
\ },
\ }
的fugitive#statusline()
輸出爲GIT(master)
,所以最終的字符串,最終出現在我的狀態行作爲⎇ ,GIT(master)
用逗號。
爲什麼會有逗號?我們如何避免逗號?
我使用lightline.vim定製我的狀態行,整個配置是這樣的:
let g:lightline = {
\ 'active': {
\ 'left': [
\ [ 'mode', 'paste' ],
\ [ 'filename', 'readonly', 'modified' ],
\ [ 'fugitive', ],
\ ]
\ },
\ 'inactive': {
\ 'left': [
\ [ 'filename', 'readonly', 'modified' ],
\ [ 'fugitive', ],
\ ]
\ },
\ 'component': {
\ 'readonly': '%{&readonly?"x":""}',
\ 'fugitive': '%{exists("*fugitive#statusline") ? "⎇ " . fugitive#statusline() . "" : ""}'
\ },
\ 'component_visible_condition': {
\ 'fugitive': '(exists("*fugitive#head") && ""!=fugitive#head())'
\ },
\ 'separator': { 'left': '', 'right': '' },
\ 'subseparator': { 'left': '|', 'right': '|' }
\ }
你爲什麼不問,關於插件的問題跟蹤? – romainl
@romainl因爲我有一種感覺,它與字符串連接有關。當我做'富'時。逃犯#statusline()',那麼結果是'foo,GIT(master)',但是如果我做'逃亡#statusline()。 「foo」,那麼結果就是沒有逗號的GIT(master)foo'。如果我做'「foo」。逃亡#頭()'那麼結果是'foomaster'沒有逗號!這讓我相信,也許我不像我想過的字符串連接那樣知道。這似乎不可能與插件有關。 – trusktr
@romainl說這個問題來自'vim-fugitive';請參閱[這些源代碼行](https://github.com/tpope/vim-fugitive/blob/444ba9fda5d05aa14c7e8664fa4a66a59c62a550/plugin/fugitive.vim#L3033-L3037) – dNitro