From fdd5c39d40da44b79efcace32ca89a6d27a1afe8 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 14 Jan 2025 22:49:16 +0800 Subject: [PATCH] feat(winbar): add winbar plugin --- .ci/detach_plugin.sh | 10 ++++++ .github/workflows/async.yml | 2 +- autoload/SpaceVim/layers/core.vim | 8 +++++ bundle/winbar.nvim/README.md | 36 +++++++++++++++++++++ bundle/winbar.nvim/lua/winbar/init.lua | 44 ++++++++++++++++++++++++++ bundle/winbar.nvim/plugin/winbar.lua | 11 +++++++ doc/SpaceVim.txt | 1 + 7 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 bundle/winbar.nvim/README.md create mode 100644 bundle/winbar.nvim/lua/winbar/init.lua create mode 100644 bundle/winbar.nvim/plugin/winbar.lua diff --git a/.ci/detach_plugin.sh b/.ci/detach_plugin.sh index 842209528..df6272ffe 100755 --- a/.ci/detach_plugin.sh +++ b/.ci/detach_plugin.sh @@ -577,6 +577,16 @@ EOT _detact LICENSE _detact_bundle quickfix.nvim README.md ;; + winbar.nvim) + git clone https://github.com/wsdjeg/winbar.nvim.git detach/$1 + cd detach/$1 + _checkdir plugin + _checkdir lua/winbar + _detact_bundle winbar.nvim lua/winbar/init.lua + _detact_bundle winbar.nvim plugin/winbar.lua + _detact LICENSE + _detact_bundle winbar.nvim README.md + ;; GitHub.vim) git clone https://github.com/wsdjeg/GitHub.vim.git detach/$1 cd detach/$1 diff --git a/.github/workflows/async.yml b/.github/workflows/async.yml index 6ab7e484b..5a2fa081b 100644 --- a/.github/workflows/async.yml +++ b/.github/workflows/async.yml @@ -7,7 +7,7 @@ jobs: strategy: fail-fast: false matrix: - detachPlugin: ["FlyGrep.vim", "dein-ui.vim", "vim-todo", "iedit.vim", "scrollbar.vim", "vim-chat", "vim-cheat", "xmake.vim", "GitHub.vim", "JavaUnit.vim", "git.vim", "cpicker.nvim", "SourceCounter.vim", "vim-zettelkasten", "format.nvim", "record-key.nvim", "quickfix.nvim"] + detachPlugin: ["FlyGrep.vim", "dein-ui.vim", "vim-todo", "iedit.vim", "scrollbar.vim", "vim-chat", "vim-cheat", "xmake.vim", "GitHub.vim", "JavaUnit.vim", "git.vim", "cpicker.nvim", "SourceCounter.vim", "vim-zettelkasten", "format.nvim", "record-key.nvim", "quickfix.nvim", "winbar.nvim"] runs-on: ubuntu-latest steps: - name: Checkout diff --git a/autoload/SpaceVim/layers/core.vim b/autoload/SpaceVim/layers/core.vim index be6e23cf4..4476be858 100644 --- a/autoload/SpaceVim/layers/core.vim +++ b/autoload/SpaceVim/layers/core.vim @@ -23,6 +23,7 @@ scriptencoding utf-8 " 5. `enable_netrw`: enable/disable netrw, disabled by default. " 6. `enable_quickfix_key_bindings`: enable/disable quickfix.nvim, mappings " for neovim quickfix window. This option is only for neovim. +" 7. `enable_winbar`: enable/disable `wsdjeg/winbar.nvim` " " NOTE: the `enable_vimfiler_gitstatus` and `enable_filetree_gitstatus` option " has been deprecated. Use layer option instead. @@ -155,6 +156,7 @@ endif let s:enable_smooth_scrolling = 1 let s:enable_netrw = 0 let s:enable_quickfix_key_bindings = 0 +let s:enable_winbar = 0 let g:_spacevim_enable_filetree_gitstatus = 0 let g:_spacevim_enable_filetree_filetypeicon = 0 @@ -245,6 +247,9 @@ function! SpaceVim#layers#core#plugins() abort if s:enable_quickfix_key_bindings call add(plugins, [g:_spacevim_root_dir . 'bundle/quickfix.nvim' , { 'merged' : 0} ]) endif + if s:enable_winbar + call add(plugins, [g:_spacevim_root_dir . 'bundle/winbar.nvim' , { 'merged' : 0} ]) + endif return plugins endfunction @@ -1223,6 +1228,9 @@ function! SpaceVim#layers#core#set_variable(var) abort let s:enable_quickfix_key_bindings = get(a:var, \ 'enable_quickfix_key_bindings', \ s:enable_quickfix_key_bindings) + let s:enable_winbar = get(a:var, + \ 'enable_winbar', + \ s:enable_winbar) endfunction function! s:defx_find_current_file() abort diff --git a/bundle/winbar.nvim/README.md b/bundle/winbar.nvim/README.md new file mode 100644 index 000000000..e0ba6a6ea --- /dev/null +++ b/bundle/winbar.nvim/README.md @@ -0,0 +1,36 @@ +# winbar.nvim + +> _winbar.nvim_ is a plugin which provides default winbar for neovim. + +[![](https://spacevim.org/img/build-with-SpaceVim.svg)](https://spacevim.org) +[![GPLv3 License](https://img.spacevim.org/license-GPLv3-blue.svg)](LICENSE) + + + +- [Install](#install) +- [Feedback](#feedback) + + + +## Install + +1. Using `winbar.nvim` in SpaceVim: + +```toml +[[layers]] + name = 'core' + enable_winbar = true +``` + +2. Using `winbar.nvim` without SpaceVim: + +``` +Plug 'wsdjeg/winbar.nvim' +``` + +## Feedback + +The development of this plugin is in [`SpaceVim/bundle/winbar.nvim`](https://github.com/SpaceVim/SpaceVim/tree/master/bundle/winbar.nvim) directory. + +If you encounter any bugs or have suggestions, please file an issue in the [issue tracker](https://github.com/SpaceVim/SpaceVim/issues) + diff --git a/bundle/winbar.nvim/lua/winbar/init.lua b/bundle/winbar.nvim/lua/winbar/init.lua new file mode 100644 index 000000000..620b00375 --- /dev/null +++ b/bundle/winbar.nvim/lua/winbar/init.lua @@ -0,0 +1,44 @@ +--============================================================================= +-- init.lua --- winbar plugin +-- Copyright 2025 Eric Wong +-- Author: Eric Wong < wsdjeg@outlook.com > +-- URL: https://spacevim.org +-- License: GPLv3 +--============================================================================= + +local M = {} + +local default_conf = { + winbar_seperator = '>', + excluded_filetypes = {}, +} + +local function redraw_winbar() + local file_name = vim.fn.expand('%:t') + + if file_name == '' then + return + end + + local value = '%#SpaceVim_winbar#' .. file_name .. ' ' .. default_conf.winbar_seperator + + vim.api.nvim_set_option_value('winbar', value, { scope = 'local' }) +end + +function M.setup(opt) + if type(opt) == 'table' then + default_conf = vim.tbl_deep_extend('force', {}, default_conf, opt) + end + local augroup = vim.api.nvim_create_augroup('winbar.nvim', { + clear = true, + }) + vim.api.nvim_create_autocmd({ 'WinEnter' }, { + group = augroup, + pattern = '*', + callback = function(e) + redraw_winbar() + end, + }) +end + +return M diff --git a/bundle/winbar.nvim/plugin/winbar.lua b/bundle/winbar.nvim/plugin/winbar.lua new file mode 100644 index 000000000..6e2c8a1a9 --- /dev/null +++ b/bundle/winbar.nvim/plugin/winbar.lua @@ -0,0 +1,11 @@ +--============================================================================= +-- winbar.lua --- winbar plugin +-- Copyright 2025 Eric Wong +-- Author: Eric Wong < wsdjeg@outlook.com > +-- URL: https://spacevim.org +-- License: GPLv3 +--============================================================================= + +if vim.fn.exists('+winbar') == 1 then + require('winbar').setup() +end diff --git a/doc/SpaceVim.txt b/doc/SpaceVim.txt index 050f70c63..259a8af13 100644 --- a/doc/SpaceVim.txt +++ b/doc/SpaceVim.txt @@ -2287,6 +2287,7 @@ OPTIONS 5. `enable_netrw`: enable/disable netrw, disabled by default. 6. `enable_quickfix_key_bindings`: enable/disable quickfix.nvim, mappings for neovim quickfix window. This option is only for neovim. + 7. `enable_winbar`: enable/disable `wsdjeg/winbar.nvim` NOTE: the `enable_vimfiler_gitstatus` and `enable_filetree_gitstatus` option has been deprecated. Use layer option instead.