{"action":"closed","issue":{"url":"https://api.github.com/repos/vim-airline/vim-airline/issues/446","repository_url":"https://api.github.com/repos/vim-airline/vim-airline","labels_url":"https://api.github.com/repos/vim-airline/vim-airline/issues/446/labels{/name}","comments_url":"https://api.github.com/repos/vim-airline/vim-airline/issues/446/comments","events_url":"https://api.github.com/repos/vim-airline/vim-airline/issues/446/events","html_url":"https://github.com/vim-airline/vim-airline/issues/446","id":28023919,"number":446,"title":"[Feature request] Patch for integrate with my vimcaps plugin.","user":{"login":"suxpert","id":1191414,"avatar_url":"https://avatars.githubusercontent.com/u/1191414?v=3","gravatar_id":"","url":"https://api.github.com/users/suxpert","html_url":"https://github.com/suxpert","followers_url":"https://api.github.com/users/suxpert/followers","following_url":"https://api.github.com/users/suxpert/following{/other_user}","gists_url":"https://api.github.com/users/suxpert/gists{/gist_id}","starred_url":"https://api.github.com/users/suxpert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/suxpert/subscriptions","organizations_url":"https://api.github.com/users/suxpert/orgs","repos_url":"https://api.github.com/users/suxpert/repos","events_url":"https://api.github.com/users/suxpert/events{/privacy}","received_events_url":"https://api.github.com/users/suxpert/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/vim-airline/vim-airline/labels/needs%20reply","name":"needs reply","color":"dddddd"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2014-02-21T07:42:37Z","updated_at":"2016-03-01T20:16:23Z","closed_at":"2016-03-01T20:16:23Z","body":"Hi, we know that as an editor, vim can not show the keyboard lock state on its statusline like most other editors do. Thus I've wrote a plugin named `vimcaps`, which can turn off the capslock automatically when back to normal mode (Now works under windows and x-window), It also provide a function for displaying the lock state. So how about integrate this feature in airline? :)\r\n\r\nI've read some source files of airline, then added some lines to make vimcaps's statusline function works with airline. Here is the patch (Ah, with some other changes, too). It might be not so good, if you think it is useful, you may consider to add this feature to airline, thanks. :)\r\n```patch\r\ndiff --git a/autoload/airline/extensions.vim b/autoload/airline/extensions.vim\r\nindex f32abd3..927bae3 100644\r\n--- a/autoload/airline/extensions.vim\r\n+++ b/autoload/airline/extensions.vim\r\n@@ -194,6 +194,10 @@ function! airline#extensions#load()\r\n     call airline#extensions#whitespace#init(s:ext)\r\n   endif\r\n \r\n+  if (get(g:, 'airline#extensions#vimcaps#enabled', 1) && exists('g:vimcaps_loaded'))\r\n+    call airline#extensions#vimcaps#init(s:ext)\r\n+  endif\r\n+\r\n   if get(g:, 'airline#extensions#tabline#enabled', 0)\r\n     call airline#extensions#tabline#init(s:ext)\r\n   endif\r\ndiff --git a/autoload/airline/init.vim b/autoload/airline/init.vim\r\nindex a60774d..8186a15 100644\r\n--- a/autoload/airline/init.vim\r\n+++ b/autoload/airline/init.vim\r\n@@ -78,7 +78,7 @@ function! airline#init#bootstrap()\r\n   call airline#parts#define_raw('file', '%f%m')\r\n   call airline#parts#define_raw('linenr', '%{g:airline_symbols.linenr}%#__accent_bold#%4l%#__restore__#')\r\n   call airline#parts#define_function('ffenc', 'airline#parts#ffenc')\r\n-  call airline#parts#define_empty(['hunks', 'branch', 'tagbar', 'syntastic', 'eclim', 'whitespace'])\r\n+  call airline#parts#define_empty(['hunks', 'branch', 'tagbar', 'syntastic', 'eclim', 'whitespace', 'vimcaps'])\r\n \r\n   unlet g:airline#init#bootstrapping\r\n endfunction\r\n@@ -107,7 +107,7 @@ function! airline#init#sections()\r\n     let g:airline_section_z = airline#section#create(['%3p%%'.spc, 'linenr', ':%3c '])\r\n   endif\r\n   if !exists('g:airline_section_warning')\r\n-    let g:airline_section_warning = airline#section#create(['syntastic', 'eclim', 'whitespace'])\r\n+    let g:airline_section_warning = airline#section#create(['syntastic', 'eclim', 'whitespace', 'vimcaps'])\r\n   endif\r\n endfunction\r\n \r\ndiff --git a/autoload/airline/parts.vim b/autoload/airline/parts.vim\r\nindex b0356b1..9a32f79 100644\r\n--- a/autoload/airline/parts.vim\r\n+++ b/autoload/airline/parts.vim\r\n@@ -74,6 +74,6 @@ function! airline#parts#filetype()\r\n endfunction\r\n \r\n function! airline#parts#ffenc()\r\n-  return printf('%s%s', &fenc, strlen(&ff) > 0 ? '['.&ff.']' : '')\r\n+  return printf('%s%s%s', &fenc, &bomb? '[B]': '', strlen(&ff) > 0 ? '['.&ff.']' : '')\r\n endfunction\r\n```\r\nAnd `autoload/airline/extensions/vimcaps.vim`:\r\n```vim\r\n\" MIT License. Copyright (c) 2013-2014 Bailey Ling.\r\n\" vim: et ts=2 sts=2 sw=2\r\n\r\nif !exists('g:vimcaps_loaded')\r\n  finish\r\nendif\r\n\r\nif !exists('g:airline#extensions#vimcaps#style')\r\n  let g:airline#extensions#vimcaps#style = 1\r\nendif\r\n\r\nfunction! airline#extensions#vimcaps#statusline()\r\n  return vimcaps#statusline(g:airline#extensions#vimcaps#style)\r\nendfunction\r\n\r\nfunction! airline#extensions#vimcaps#init(ext)\r\n  call airline#parts#define_function('vimcaps', 'airline#extensions#vimcaps#statusline')\r\nendfunction\r\n```\r\n\r\nBTW, vim shows the file name in the tab label in a short way, which can not be obtained via `fnamemodify` AFAIK. I've write a function for `echofunc` to truncate the path, it might be not good enogh, but works for normal path. The main part of the function is like this:\r\n```vim\r\nlet fnamelist = '.,~!@#$%_=+'\r\nlet fnamenorm = '0-9a-zA-Z'\r\nlet shorten = substitute(fname, '\\%(\\/\\|\\\\\\%(['.fnamelist.fnamenorm.']\\)\\@=\\)['.fnamelist.']*['.fnamenorm.']\\zs.\\{-}\\ze\\%(\\/\\|\\\\['.fnamelist.fnamenorm.']\\)', '', 'g')\r\n```\r\nIf you think it is worthwhile to use a truncated file name instead of `%f`, it might be helpful."}}