From f835cee49e85c0174c78b4674b65dc9c59b82946 Mon Sep 17 00:00:00 2001 From: Oleksii Demennikov Date: Mon, 9 Aug 2021 13:13:43 +0300 Subject: [PATCH 1/2] Added icons for neovim from lua --- autoload/ctrlsf/view.vim | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/autoload/ctrlsf/view.vim b/autoload/ctrlsf/view.vim index 91f5577..a4ec556 100644 --- a/autoload/ctrlsf/view.vim +++ b/autoload/ctrlsf/view.vim @@ -26,8 +26,17 @@ func! s:Summary(procbar) abort endf func! s:Filename(paragraph) abort - " empty line + filename - return ["", a:paragraph.filename . ":"] + " empty line + icon + filename +lua << EOF + local fname = vim.api.nvim_eval('a:paragraph.filename') + local fname_parts = vim.split(fname, "/") + local fname_without_path = fname_parts[#fname_parts] + local extension = fname:match "[^.]+$" + + local icon = require'nvim-web-devicons'.get_icon(fname_without_path, extension) + vim.g.ctrlsf_icon = icon +EOF + return ["", g:ctrlsf_icon . " " . a:paragraph.filename . ":"] endf func! s:Ellipsis() abort From 89a92c1bd76f37f2068e64be861fd1a76203cf89 Mon Sep 17 00:00:00 2001 From: Oleksii Demennikov Date: Mon, 9 Aug 2021 13:21:40 +0300 Subject: [PATCH 2/2] Added the non-breaking fetching of variable --- autoload/ctrlsf/view.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/autoload/ctrlsf/view.vim b/autoload/ctrlsf/view.vim index a4ec556..197637d 100644 --- a/autoload/ctrlsf/view.vim +++ b/autoload/ctrlsf/view.vim @@ -36,7 +36,8 @@ lua << EOF local icon = require'nvim-web-devicons'.get_icon(fname_without_path, extension) vim.g.ctrlsf_icon = icon EOF - return ["", g:ctrlsf_icon . " " . a:paragraph.filename . ":"] + let icon = get(g:, "ctrlsf_icon", "") + return ["", icon . " " . a:paragraph.filename . ":"] endf func! s:Ellipsis() abort