diff options
| author | nsfisis <nsfisis@gmail.com> | 2022-12-21 21:20:49 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2022-12-21 21:20:49 +0900 |
| commit | 665cf512e3084356ba4362e80342828a2c6b2409 (patch) | |
| tree | 13a0956473170fa8a2333253b85488deade3bee0 | |
| parent | 215f6e0a1cd55b18c20a51fc4f19144326ce3302 (diff) | |
| download | dotfiles-665cf512e3084356ba4362e80342828a2c6b2409.tar.gz dotfiles-665cf512e3084356ba4362e80342828a2c6b2409.tar.zst dotfiles-665cf512e3084356ba4362e80342828a2c6b2409.zip | |
neovim:statusline: improve integration with fern.vim
| -rw-r--r-- | .config/nvim/lua/init/05-appearance.lua | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/.config/nvim/lua/init/05-appearance.lua b/.config/nvim/lua/init/05-appearance.lua index 29ba657..0edd3b3 100644 --- a/.config/nvim/lua/init/05-appearance.lua +++ b/.config/nvim/lua/init/05-appearance.lua @@ -122,15 +122,33 @@ function vimrc.statusline.filename(bufnr) return '*scratch*' end - local this_path = F.expand(('#%s:p'):format(bufnr)) + local simplify_bufname + if vim.b[bufnr].fern then + simplify_bufname = function(bufname) + bufname = F['fern#fri#parse'](bufname).path + if vim.startswith(bufname, 'file://') then + bufname = bufname:sub(#'file://' + 1) + end + return bufname + end + else + simplify_bufname = function(bufname) return bufname end + end + + local this_path = simplify_bufname(F.expand(('#%s:p'):format(bufnr))) local other_paths = {} for b = 1, F.bufnr('$') do if F.bufexists(b) and b ~= bufnr then - other_paths[#other_paths+1] = F.bufname(b) + other_paths[#other_paths+1] = simplify_bufname(F.bufname(b)) end end - return uniquify.uniquify(this_path, other_paths) + local result = uniquify.uniquify(this_path, other_paths) + if vim.b[bufnr].fern then + return '[fern] ' .. result .. '/' + else + return result + end end function vimrc.statusline.modified(bufnr) |
