Skip to content

Commit 4dcd3c2

Browse files
committed
Moving itchyny/lightline.vim plugins configurations to the plugin files.
After moving to Lua based configs and the Lazy plugin-manager, plugins can now be configured separately instead of globally. Signed-off-by: Yoni Bettan <yonibettan@gmail.com>
1 parent 24e93f6 commit 4dcd3c2

2 files changed

Lines changed: 40 additions & 24 deletions

File tree

dotfiles/nvim/lua/config/plugin_settings.lua

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,5 @@ local g = vim.g
33
-- supertab
44
g.SuperTabDefaultCompletionType = "<c-n>"
55

6-
-- lightline
7-
g.lightline = {
8-
active = {
9-
left = {
10-
{ "mode", "paste" },
11-
{ "gitbranch", "readonly", "filename", "modified" },
12-
},
13-
},
14-
component_function = {
15-
gitbranch = "FugitiveHead",
16-
filename = "LightlineFilename",
17-
},
18-
}
19-
20-
-- Lightline filename function
21-
vim.cmd([[
22-
function! LightlineFilename()
23-
return &filetype ==# 'vimfiler' ? vimfiler#get_status_string() :
24-
\ &filetype ==# 'unite' ? unite#get_status_string() :
25-
\ &filetype ==# 'vimshell' ? vimshell#get_status_string() :
26-
\ expand('%') !=# '' ? expand('%') : '[No Name]'
27-
endfunction
28-
]])
29-
306
-- gh-line
317
g.gh_open_command = 'fn() { echo "$@" | xclip; }; fn '

dotfiles/nvim/lua/plugins/lightline.lua

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,45 @@
22
return {
33
{
44
'itchyny/lightline.vim',
5+
config = function()
6+
-- Define the LightlineFilename function in Lua
7+
vim.fn["lightline#component_expand"] = vim.fn["lightline#component_expand"] or {}
8+
9+
-- Register the global Lua function for lightline to call
10+
vim.cmd([[
11+
function! LightlineFilename()
12+
return v:lua.LightlineFilename()
13+
endfunction
14+
]])
15+
16+
_G.LightlineFilename = function()
17+
local ft = vim.bo.filetype
18+
if ft == "vimfiler" then
19+
return vim.fn["vimfiler#get_status_string"]()
20+
elseif ft == "unite" then
21+
return vim.fn["unite#get_status_string"]()
22+
elseif ft == "vimshell" then
23+
return vim.fn["vimshell#get_status_string"]()
24+
elseif vim.fn.expand("%") ~= "" then
25+
return vim.fn.expand("%")
26+
else
27+
return "[No Name]"
28+
end
29+
end
30+
31+
-- Set lightline configuration to use that function
32+
vim.g.lightline = {
33+
active = {
34+
left = {
35+
{ "mode", "paste" },
36+
{ "gitbranch", "readonly", "filename", "modified" },
37+
},
38+
},
39+
component_function = {
40+
gitbranch = "FugitiveHead",
41+
filename = "LightlineFilename",
42+
},
43+
}
44+
end,
545
},
646
}

0 commit comments

Comments
 (0)