Code Monkey home page Code Monkey logo

windline.nvim's Introduction

Windline

Animation statusline. Use lua + luv make some ๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅ

Features:

  • custom statusline for every file type
  • built-in animation library
  • change colors with your colorscheme
  • fast and powerful customization
  • custommize display of global statusline

demo

demo Displaying two different animated status line (markdown and lua file types).

Intro

Windline supports having a different status line per file type. terminal,nvimtree,qf,help,spectre,lsptrouble,diffview,lspoutline. It also supports displaying a different status line on inactive windows

We offer a built-in animations and color library for status line. I know it is not useful but why not :).

It is not loaded if you don't use animations.

demo

Setup

You can create your own custom status line, using as a base/example the included status line setups is recommended for new users.

local windline = require('windline')
windline.setup({
  statuslines = {
    --- you need to define your status lines here
  }
})

Included Status lines

You can also use any of this status lines and avoid setting up your own (skipping the example above) by just requiring it.

Bubble

require('wlsample.bubble')

Bubble2

require('wlsample.bubble2')

evilline

require('wlsample.evil_line')

airline

require('wlsample.airline')
--  the animated alternative. you can toggle animation by press `<leader>u9`
require('wlsample.airline_anim')

vscode

require('wlsample.vscode')

basic animation

require('wlsample.basic')

wind animation

require('wlsample.wind')

luffy animation

require('wlsample.airline_luffy')

[cava]

cava animation

-- only support linux it need install cava
lua require("windline.components.cava").toggle()

Remember windline can display a different status line per file type, so you can have bubble line for markdown or latex file, and airline for your working file.

You need install gitsigns.nvim to get git information.

Swap

Status line

You need to define a default status line that will be used on all filetypes that do not define a custom one.

local default = {
    filetypes={'default'},
    active={
      --- components...
    },
    inactive={
      --- components...
    }
}

local explorer = {
    filetypes = {'fern', 'NvimTree','netrw'},
    active = {
        {' ๏” ', {'white', 'black'} },
    },
    --- show active components when the window is inactive
    always_active = true,
    --- It will display a last window statusline even that window should inactive
    show_last_status = true
}

components

A component is defined as {text ,{ fgcolor, bgcolor } }

local default = {
    filetypes={'default'},
    active={
      --- components...
      {'[',{'red', 'black'}},
      {'%f',{'green','black'}},
      {']',{'red','black'}},

      -- empty color definition uses the previous component colors
      {"%=", ''} ,

      -- hightlight groups can also be used
      {' ','StatusLine'},

      {' %3l:%-2c ',{'white','black'}}
    },
}

demo

A text function has a bufnr and winid parameter that can be used to get data from the buffer or window

A text function can return a group of child components

local lsp_comps = require('windline.components.lsp')

basic.lsp_diagnos = {
    name = 'diagnostic',
    hl_colors = {
        red_text = {'red', 'black'}
    },
    text = function(bufnr, winid, width)
        if lsp_comps.check_lsp() then
            return {

                { '[ lsp: ', 'red_text' },
                -- red_text define in hl_colors. It make easy cache value first
                -- because text function run multiple time on redraw

                { lsp_comps.lsp_name() , 'IncSearch'},
                -- it use a hightlight group IncSearch

                -- but you can create a hightlight on child component too
                { lsp_comps.lsp_error({ format = ' ๏— %s' }), {'red','black'} },

                { lsp_comps.lsp_warning({ format = ' ๏ฑ %s' }), {'yellow',''} },
                -- it have same background black with the previous component

                { lsp_comps.lsp_hint({ format = ' ๏š %s' }), {'', 'blue'} },
                -- it have same foreground yellow with the previous component

                { ' ] ' },
            }
        end
        return ''
    end,
}

Don't do something complex on component. It run multiple times when statusline rendering. If you want to do that you need to use cache component

Never use a Job or run system command inside component. You need to use it inside cache component

Windline doesn't have a component condition just return an empty string ''or nil to remove it.

It doesn't have seperator or padding so you can add it by create a child component.

More info

Width setting

you can hide components by setting a minimum window width

local git_comps = require('windline.components.git')

-- short syntax
local git_branch = { git_comps.git_branch(), {'white', 'black'}, 100}

-- syntax using table
local git_branch = {
    text = git_comps.git_branch(),
    hl_colors = {'white','black'},
    --- component not visible if window width is less than 100
    width = 100,
}

Colors

Windline use a terminal color. It generate from your colorscheme terminal. Every time you change colorschemes it will be generate a new colors to map with your colorscheme

demo

Color name is use to define component and animation

-- sample
local colors = {
  black         = "",  -- terminal_color_0,
  red           = "",  -- terminal_color_1,
  green         = "",  -- terminal_color_2,
  yellow        = "",  -- terminal_color_3,
  blue          = "",  -- terminal_color_4,
  magenta       = "",  -- terminal_color_5,
  cyan          = "",  -- terminal_color_6,
  white         = "",  -- terminal_color_7,
  black_light   = "",  -- terminal_color_8,
  red_light     = "",  -- terminal_color_9,
  green_light   = "",  -- terminal_color_10,
  yellow_light  = "",  -- terminal_color_11,
  blue_light    = "",  -- terminal_color_12,
  magenta_light = "",  -- terminal_color_13,
  cyan_light    = "",  -- terminal_color_14,
  white_light   = "",  -- terminal_color_15,

  NormalFg      = "",  -- hightlight Normal fg
  NormalBg      = "",  -- hightlight Normal bg
  ActiveFg      = "",  -- hightlight StatusLine fg
  ActiveBg      = "",  -- hightlight StatusLine bg
  InactiveFg    = "",  -- hightlight StatusLineNc fg
  InactiveBg    = "",  -- hightlight StatusLineNc bg
}
return colors

If you need to define a new color to use on animation you need to define it on the colors_name function.

local windline = require('windline')

windline.setup({
  -- this function will run on ColorScheme autocmd
  colors_name = function(colors)
      --- add new colors
      colors.FilenameFg = colors.white_light
      colors.FilenameBg = colors.black

      -- this color will not update if you change a colorscheme
      colors.gray = "#fefefe"

      -- dynamically get color from colorscheme hightlight group
      local searchFg, searchBg = require('windline.themes').get_hl_color('Search')
      colors.SearchFg = searchFg or colors.white
      colors.SearchBg = searchBg or colors.yellow

      return colors
  end,

})

you can create a theme for a colorscheme gruvbox

animations

animations with colors_name from colors defined above

animation.animation({
   data = {
        {'red_light',efffects.rainbow()},
        {'green_light',efffects.rainbow()},
        {'cyan_light',efffects.blackwhite()},
        {'FilenameBg',efffects.rainbow()},
        {'FilenameFg',efffects.blackwhite()}
    },
    timeout = 10,
    delay = 200,
    interval = 100,
})

you can create multi animation but only list of data on animation is sync

effects

Usage KEY
rainbow() a rainbow animation color
blackwhite() toggle between black and white
list_color({..list_color}) swap color from list
flashyH([number 0-360]) increase H on every step of animation
flashyS([number 0.01 - 1) increase S on every step of animation
flashyL([number 0.01 - 1) increase L on every step of animation
-- you can write your own effect
local Hsl = require('wlanimation.hsl')
animation.animation({
   data = {
        {'red',efffects.wrap(function(color)
            return HSL.new(color.H + 1, color.S, color.L)
        end)},
    },
    timeout = 100,
    delay = 200,
    interval = 100,
})

Global statusline setting

windline.setup({
  -- hide that filetype on global statusline
    global_skip_filetypes = {
        'NvimTree',
        'lir',
    }
})

If that filetype display on floating window (popup).It will always hiding.You can change that behavior create a custome statusline

local telescope = {
    filetypes = {'TelescopePrompt'},
    active = {
        {' ๏‘ซ ', {'white', 'black'} },
    },
    --- for global statusline (laststatus = 3). 
    --- by default it skip all floating window on global statusline but you can
    --- change it here
    global_show_float = false
}

winbar

view

Click

view

Benchmark

A command to benchmark current status line by rendering it 10.000 time. :WindLineBenchMark

Tabline

view

Document

wiki

windline.nvim's People

Contributors

alex-popov-tech avatar etiamnullam avatar muniter avatar otherjl0 avatar ttytm avatar undercooled avatar windwp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

windline.nvim's Issues

Configuration is too cumbersome

Sorry, I haven't tried lua language before.

Although the built-in wlsample.airline is nicely styled, I would like to modify it a bit, like adding gps and github status.

But I don't know where to start, I'm sure I've read the readme file countless times. .

Enable temporary hiding the float status line

Hi,

I have set up the status line as a float using:

require("wlfloatline").setup {
  interval = 300,
  ui = {
    active_char = "โ–",
    active_color = "line_bg",
    active_hl = "Error",
  },
  skip_filetypes = {
    "NvimTree",
  },
}

The problem is that some windows pickers such as the one implemented by NvimTree will use the status line to display a code to use to pick that window. Therefore, I want to hide the float windline when the picker is called and restore it again after the window has been selected. I tried using WindLineFloatToggle but its not doing anything. My guess is that it gets rendered again by some autocmd. Would it be possible to disable those autocmds when the windline is supposed to be hidden?

Thanks!

[Feature] `showcmdloc` not working

showcmdloc is a new feature for neovim 0.8+

I set showcmdloc=statusline
also added this
{ '%S', { 'green', 'NormalBg' } },
But the message flashes for a very short period and goes away.

Could you provide some default/preconfigured settings?

I don't know how to setup :( I have tried this one but I didn't see the wind animation:

config = function ()
  require('wlsample.wind')
end

Could it be something like this?

config = function ()
  require('windline').setup {
    predefined: 'some_cool_default'
  }
end

Error when executing vim.schedule: table idnex is nil

When i launch neovim and run telescope right away it throws:

Error executing vim.schedule lua callback: .../dein/.cache/init.vim/.dein/lua/windline/cache_utils.lua:55: table index is nil

Is there something i can do to avoid this?

i can provide a minimal init.vim if you need.

Windline is_git() broken on nightly

local git_comps = require("windline.components.git").is_git()

got_comps is false when inside a git repo
works on 0.6.1 just fine but on 0.7.0 nightly it breaks and does not work

Error in component.lua

ERROR:

E5108: Error executing lua ...pack/packer/opt/windline.nvim/lua/windline/component.lua
:91: bad argument #2 to 'text' (number expected, got nil)

CONFIG:

    use({
        "windwp/windline.nvim",
        config = function()
            require("wlsample.bubble2")
        end,
		after = "neovim",	-- load after colorscheme (rose-pine/neovim)
        module = "windline",
    })

Checklist:

  • Tried with paq-nvim
  • Tried manually installing
  • Tried without impatient
  • Tried without lazy loading

NEOVIM VERSION:

NVIM v0.6.0-dev
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by nixbld

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "
/nix/store/75951jz05giqb8h3yi5xl4irzf8vj2s8-neovim-unwrapped-master/share/nvim
"

Run :checkhealth for more info

Windline floating window stops updating when setting interval to zero

Windline stops updating when using the following config:

require('wlfloatline').setup({
    interval = 0
})

However, it still updates when entering command mode (with a small delay).

Everything works after changing the interval to 1, but the command mode delay still exists. It does not delay when floating window is not enabled.

Also, sometimes when I enter Neovim, this error shows:

E5108: Error executing lua [string "v:lua"]:1: attempt to call field 'floatline_show' (a nil value) 

[Defect] windline.nvim/lua/wlanimation/components/job.lua:122: attempt to index field 'buffer_auto_funcs' (a nil value)

Code:

local job_utils = require('wlanimation.components.job')

basic.job_event = {
  hl_colors = { 'green', 'black_light' },
  text = job_utils.job_event('sleep 4', 'BufEnter', 'job_sleep', function(data)
    -- ....
  end),
}

error:

Error executing vim.schedule lua callback: ...im/lazy/windline.nvim/lua/wlanimation/components/job.lua:122: attempt to index field 'buffer_auto_funcs' (a nil value)
stack traceback:
        ...im/lazy/windline.nvim/lua/wlanimation/components/job.lua:122: in function 'job_event'

The autocmd `CursorHold` will fail if animation is triggered

As title. I'm using require('wlsample.airline_anim'), and my config are these:

use {
  'windwp/windline.nvim',
  config = function ()
    require('wlsample.airline_anim')
  end
}
vim.keymap.set('n', '<Leader>w', function()
  WindLine.airline_anim_toggle()
end, NOREF_NOERR_TRUNC)

If I enter the animation mode with <Leader>w, then the following autocmd will fail:

vim.cmd [[autocmd CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focus=false, scope="cursor"})]]

i.e. there will be no auto-hover anymore.


nvim -v:

NVIM v0.7.0-dev+886-ga88046fe2
Build type: Release
LuaJIT 2.1.0-beta3

I experience this after the lastest update on branch master.

Colors not working with konsole

Hi there,
im new to nvim and want to use the beautiful windline.

I made everything working but the color of the windline theme (i try to use airline_luffy) are only working if i use
:set termguicolors
My terminal is "konsole 21.08" which i think is a 256-color terminal?

If i reset this option to the default
:set notermguicolors
windline looks like this: (no colors applied)
Screenshot_20211024_143913
:

Can someone tell me how i can use windline with my current terminal, the option :set notermguicolors and having nice colors?

The reason is:
I love the way nvim looks with my current setup and i dont want to switch to :set termguicolors

My current guess:
I have somehow to manipulate either windline or the airline_luffy to use 256-color codes

Sorry if im asking this question only because of my lack of experience

highlight group style

Good day to you!

is it possible to set style (bold, underscore, etc.) to highlight groups in setup function?
image

e.g. `... colors.InactiveStyle = "bold: ..."

Thank you!

Floating statusline disabled in command line

I really like this statusline and the main reason for me is the floating statusline.

Sadly, the statusline loses "floatingness" as soon as I'm in the "normal" commandline (:) => the statusline gets split. This doesn't occure for the searching commandlines (/, ?).

Is this a known issue or is there anything to avoid this behaviour?

I use this with packer:

use {
    "windwp/windline.nvim",
    event = "VimEnter",
    config = function()
        require("wlsample.airline")
        require("wlfloatline").setup(
            {
                interval = 100,
                skip_filetypes = {
                    "NvimTree",
                    "Outline",
                    "undotree"
                }
            }
        )
    end
}

[EDIT] I'm always on the latest nightly build, currently:

NVIM v0.7.0-dev
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/cc -g -O2 -ffile-prefix-map=/build/neovim-TaFwuh/neovim-0.7.0~ubuntu1+git202203110047-6170574d2-dd05b3569=. -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -DNVIM_TS_HAS_SET_ALLOCATOR -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/build/neovim-TaFwuh/neovim-0.7.0~ubuntu1+git202203110047-6170574d2-dd05b3569/build/config -I/build/neovim-TaFwuh/neovim-0.7.0~ubuntu1+git202203110047-6170574d2-dd05b3569/src -I/build/neovim-TaFwuh/neovim-0.7.0~ubuntu1+git202203110047-6170574d2-dd05b3569/.deps/usr/include -I/usr/include -I/build/neovim-TaFwuh/neovim-0.7.0~ubuntu1+git202203110047-6170574d2-dd05b3569/build/src/nvim/auto -I/build/neovim-TaFwuh/neovim-0.7.0~ubuntu1+git202203110047-6170574d2-dd05b3569/build/include
Compiled by buildd@lcy02-amd64-015

Features: +acl +iconv +tui

I also tend to update my plugins very frequently - at least once per day.

None is not a valid color on nvim nightly

Issue on nvim nightly (NVIM v0.7.0-dev+1109-gfaeff49cb):
packer.nvim: Error running config for windline.nvim: ...e/pack/packer/start/windline.nvim/lua/windline/utils.lua:79: 'NONE' is not a valid color

windline.setup({
  colors_name = function(colors)
    -- print(vim.inspect(colors))
    -- ADD MORE COLOR HERE ----
    colors.FilenameFg = colors.white_light
    colors.FilenameBg = colors.black_light
    colors.transparent = "none"                 -- this is the issue
    colors.grey = "#3d3d3d"
    colors.orange = "#d8a657"
    colors.debug_yellow = "#eae611"
    colors.debug_red = "#ff6902"

    colors.wavedefault = colors.black

    colors.waveright1 = colors.wavedefault
    colors.waveright2 = colors.wavedefault
    colors.waveright3 = colors.wavedefault
    colors.waveright4 = colors.wavedefault
    colors.waveright5 = colors.wavedefault
    colors.waveright6 = colors.wavedefault
    colors.waveright7 = colors.wavedefault
    colors.waveright8 = colors.wavedefault
    colors.waveright9 = colors.wavedefault

    return colors
  end,
  statuslines = {
    default,
    quickfix,
    repl,
    explorer,
    dashboard,
  },
})

None is a valid background color in vim highlights
this works just fine on 0.6.1 but breaks on nightly
this might indicate that we have to adapt to neovim changes

background of statusline becomes #303030 with a low enough value for color hex

configs

my "theme" (it's just a modification of evil-line):
https://gist.github.com/4f0bafffa81e23b445fe31d02b02381e

and here's my windline setup:
https://gist.github.com/dad544ecceea50ecce53326174fb24a1

problem

I can set theme colors as relatively "large" hex values and they work fine but using smaller ones (darker colors) seemingly just substitutes the color I want for plain gray, so far seemingly #262626 and #303030

I know both are really messy but at the moment I'd just like to get this working. the colors_name func is reading in colors from a directory full of text files with colors in them, I know it's a really sloppy system but my theming stuff still kinda uses this (it's related to an old script I wrote but don't use anymore).

creating a color "test" and then setting the normal mode background to it these are the results:

#ff0000:
image

#3a0000:
image

#390000:
image

Somehow a red value under 3a results in it just becoming black, how can I prevent this???

Bug: lsp diagnostics won't work when positioned after lsp name

Reproduction with one of the sample configs e.g., evil line is as simple as moving basic.lsp_diagnos below basic.lsp_name for the default statusline. After reload, if you force a scenario that produces diagnostics you should see that they won't get counted.

local default = {
	filetypes = { 'default' },
	active = {
		basic.square_mode,
		basic.vi_mode,
		basic.file,
		-- basic.lsp_diagnos,
		basic.divider,
		basic.file_right,
		basic.lsp_name,
		-- + 
		basic.lsp_diagnos,
		basic.git,
		{ git_comps.git_branch(), { 'magenta', 'black' }, breakpoint_width },
		{ ' ', hl_list.Black },
		basic.square_mode,
	},
	inactive = {
		{ b_components.full_file_name, hl_list.Inactive },
		basic.file_name_inactive,
		basic.divider,
		basic.divider,
		{ b_components.line_col, hl_list.Inactive },
		{ b_components.progress, hl_list.Inactive },
	},
}

Animations are breaking after approx 2min

Problem

After Approx 2-3min the Animations go blank and stop working

Video:

at 2:26 you can see it stop working

screen1_recording_2021-09-22_00-20-32.mp4

ps: ignore the music lol

Config

animation.stop_all()

animation.animation(
    {
        data = {
            {"waveright1", efffects.list_color(anim_colors, 2)},
            {"waveright2", efffects.list_color(anim_colors, 3)},
            {"waveright3", efffects.list_color(anim_colors, 4)},
            {"waveright4", efffects.list_color(anim_colors, 5)},
            {"waveright5", efffects.list_color(anim_colors, 6)},
            {"waveright6", efffects.list_color(anim_colors, 7)},
            {"waveright7", efffects.list_color(anim_colors, 8)},
            {"waveright8", efffects.list_color(anim_colors, 9)},
            {"waveright9", efffects.list_color(anim_colors, 10)}
        },
        timeout = 100,
        delay = 200,
        interval = 150
    }
)

Error check_lsp() failed

updated the packer plugins. Seem check_lsp() not working

        /usr/local/share/nvim/runtime/lua/vim/lsp.lua:80: in function 
'resolve_bufnr'                                                       
        /usr/local/share/nvim/runtime/lua/vim/lsp.lua:1586: in functio
n 'get_active_clients'                                                
        ...packer/opt/windline.nvim/lua/windline/components/lsp.lua:22
: in function 'lsp_check'                                             
        ...packer/opt/windline.nvim/lua/windline/components/lsp.lua:45
: in function 'check_lsp'   

some custom status line does not work

I have 3 custom statusline,

  1. Default
  2. quickfix
  3. Nvimtree

the default and quickfix statusline works great but the statusline for nvimtree does not work, instead it shows as if the current file is changed. There is my config.

-- Req Variable
local windline = require('windline')
local helper = require('windline.helpers')
local sep = helper.separators
local vim_components = require('windline.components.vim')
local b_components = require('windline.components.basic')
local state = _G.WindLine.state
local lsp_comps = require('windline.components.lsp')

-- Main Colors
local hl_list = {
    Black = { 'white', 'black' },
    White = { 'black', 'white' },
    Inactive = { 'InactiveFg', 'InactiveBg' },
    Active = { 'ActiveFg', 'ActiveBg' },
}

-- Basic Array that gets filled with stuff
local basic = {}

-- Components
basic.divider = { b_components.divider, '' }
basic.space = { ' ', '' }
basic.bg = { ' ', 'StatusLine' }
basic.file_name_inactive = { b_components.full_file_name, hl_list.Inactive }
basic.line_col_inactive = { b_components.line_col, hl_list.Inactive }
basic.progress_inactive = { b_components.progress, hl_list.Inactive }

-- Show Error,Hint,Warning Only
basic.lsp_diagnos = {
    width = 90,
    hl_colors = {
        yellow = { 'yellow', 'black' },
        red = { 'red', 'black' },
        blue = { 'blue', 'black' },
    },
    text = function(bufnr)
        if lsp_comps.check_lsp(bufnr) then
            return {
                { lsp_comps.lsp_error({ format = ' %s ๏ช ' }), 'red' },
                { lsp_comps.lsp_warning({ format = ' %s ๏ฑ ' }), 'yellow' },
                { lsp_comps.lsp_hint({ format = ' %s ๏š ' }), 'blue' },
            }
        end
        return ''
    end,
}

-- Info of Current File
basic.file = {
    hl_colors = {
        default = { 'black', 'black_light' },
    },
    text = function(bufnr)
        return {
            { ' ', 'default' },
            {b_components.cache_file_icon({ default = '๏…›' }), 'default'},
            { ' ', 'default' },
            { b_components.cache_file_name('No Name', ''), '' },
            { b_components.file_modified('๏ฃช '), '' },
        }
    end,
}

-- Right side of statusline [ lsp & line number ]
basic.right = {
    hl_colors = {
        sep_before = { 'black_light', 'black_light' },
        sep_after = { 'black_light', 'black' },
        text = { 'black', 'black_light' },
    },
    text = function()
        return {
            { ' %l of %L ๏ฉฐ', 'text' },
        }
    end,
}

-- Show Code Context
basic.gps = {
    hl_colors = {
        text = { 'black_light', 'black' },
    },
    text = function()
        return {
            { ' %{NvimGps()} ', 'text' },
        }
      end,
    }

-- Default Statusbar for every file
local default = {
    filetypes = { 'default' },
    -- Active bar
    active = {
        { sep.left_rounded, {'black_light' , 'black'} },
        basic.file,
        { sep.right_rounded, { 'black_light', 'black' } },
        basic.gps,
        basic.divider,
        { ' ', hl_list.Black },
        basic.lsp_diagnos,
        { ' ', hl_list.Black },
        { sep.left_rounded, { 'black_light', 'black' } },
        basic.right,
        { sep.right_rounded, {'black_light' , 'black'} },
    },
    -- Inactive bar
    inactive = {
        { sep.left_rounded, {'black_light' , 'black'} },
        basic.file,
        { sep.right_rounded, { 'black_light', 'black' } },

    },
}

-- Statusbar for quick fix window
local quickfix = {
    filetypes = { 'qf', 'Trouble' },
    active = {
        { '๐Ÿšฆ Quickfix ', { 'black_light', 'black' } },
      },
    always_active = true,
    show_last_status = true
}

-- Statusbar for Nvim Tree
local explorer = {
    filetypes = { 'fern', 'NvimTree', 'lir' },
    active = {
        { '    ๏†ป  NvimTree  ๏†ป      ', { 'black_light', 'black' } },
        { b_components.divider, '' },
    },
    always_active = true,
    show_last_status = true
}

-- Terminal
local terminal = {
    filetypes = {'floaterm'},
    active = {
        { '', { 'black_light', 'black' } },
        { b_components.divider, '' },
    },
    always_active = true,
    show_last_status = true
}


-- Custom Colors
windline.setup({
    colors_name = function(colors)
        colors.black = "#000000"
        colors.black_light = "#004eff"
        colors.red = "#ff1767"
        colors.yellow = "#ffac00"
        colors.blue = "#004eff"
        return colors
    end,

    global_skip_filetypes = {
        'NvimTree',
        'lir',
    },

    skip_filetypes = {
                    "NvimTree",
                    "Outline",
                    "undotree"
                },

-- Final setup of all bars
    statuslines = {
        default,
        quickfix,
        explorer,
        terminal,
    },
})

Is italic / boldItalic text supported?

Hi,

I wanted to ask if it is possible to italicize the text displayed. I am trying to do something like this:

foo_component = {
  name = "foo",
  text = function()
    return { "foo", { "yellow", "ActiveBg", "bold,italic" } }
  end,
}

So I want the text foo to be displayed in bold-italic font.

Unfortunately this doesn't work with my config (text is displayed in regular font). Changing it to plain "bold" however (like in the evil-line example) works just fine.

Am I missing something, or is "italic" / "bold,italic" text not yet supported?

getchar() not allowed here

in init.lua

function _G.getchar()
   if vim.fn.getchar(1)
     vim.fn.getchar()
  end
end

vim.api.nvim_set_keymap(mode key "v:lua.getchar()" {noremap=true, expr=true })
5108: Error executing lua Vim(echo):Error executing vim.schedule lua callback: ...pack/packer/start/windline.nvim/lua/wlfloatline/init.lua:221: E523: Not allowed here                    
stack traceback:
        [C]: in function 'nvim_buf_set_lines'
        ...pack/packer/start/windline.nvim/lua/wlfloatline/init.lua:221: in function 'update_status'
        ...pack/packer/start/windline.nvim/lua/wlfloatline/init.lua:568: in function 'tick'
        ...packer/start/windline.nvim/lua/wlanimation/animation.lua:82: in function ''
        vim.lua: in function <vim.lua:0>
        [C]: at 0x010687c69d
stack traceback:
        [C]: at 0x010687c69d

So I wrote like below (code 3)

-- code 3 (This code worked.)
function _G.getchar()
   require('wfloatline').stop_runner() -- here
   if vim.fn.getchar(1)
     vim.fn.getchar()
   end
   require('wfloatline').start_runner() -- here
end

vim.api.nvim_set_keymap(mode key "v:lua.getchar()" {noremap=true, expr=true })

Is it possible to control this with setup-config (or close_on_cmdlne) but write inline like code 3 ?

should basic components always return a function?

I've noticed some basic components are not so compatible with laststatus=3.

For example, basic.file_modified() always fetches vim.bo.modified in current buffer. When I open Telescope, vim.bo.modified is always true, which causes a modified flag to be rendered in global status line.
windline-issue

So I think maybe, instead of vim.bo.*, some components should return a function(bufnr) like basic.file_name(), to better work with global status.

Floatline error on neovim master

A number of plugins have had some issue(s) with the changes to a few API methods that now throw errors on nil buffer/window IDs. Here is the error I am getting with windline:

Error executing vim.schedule lua callback: ...pack/packer/start/windline.nvim/lua/wlfloatline/init.lua:209: Expected Lua number
stack traceback:
        [C]: in function 'nvim_win_is_valid'
        ...pack/packer/start/windline.nvim/lua/wlfloatline/init.lua:209: in function 'update_status'
        ...pack/packer/start/windline.nvim/lua/wlfloatline/init.lua:568: in function 'tick'
        ...packer/start/windline.nvim/lua/wlanimation/animation.lua:82: in function ''
        vim.lua: in function <vim.lua:0>

It looks like this function is bailing early if the buffer or window ID aren't valid, so it seems like maybe we should check those against nil values first? Not totally sure, so don't want to open a bad PR!

Thank you :)

[Feature Request] Dynamic add section

This is for integrate with other plugins

e.g. To add a status line section for plugin runs unit test:

require'windline'.add_section({get_test_progress={get_test_progress(), 'white'}})

And once test completed

require'windline'.remove_section('get_test_progress')

Or add animation

animation.add_animation({get_test_progress = {
    timeout = 3000,
    delay = 200,
    interval = 150,
    effect = efffects.list_text(get_test_progress),
    on_tick = function(value)
       get_test_progress()
    end
}})

And remove animation on test finish callback

animation.remove_animation('get_test_progress')

Toggle Floatwin conflict with CMD output

without floatwin
image

with floatwin

image

I enable floatwin by default and I noticed above

I think it can be solved by hook a check in CmdwinEnter/Leave event. But I need some API to make it works. Something like this:

--- CmdWinEnter/CmdlineEnter:
if WinlineFloatwin.enabled then
   WindlineFloatwin.disable()
end
--- CmdWinLeave/CmdlineEnter:
if WinlineFloatwin.enabled then
   WindlineFloatwin.enable()
end

Error on lastest neovim update

packer.nvim: Error running config for windline.nvim: ...e/pack/packer/start/windline.nvim/lua/windline/utils.lua:79: invalid key: name

Double "##" in colors s

I'm migrating to lazy at the moment
and I kept getting this error which complains about the hex not being a valid hex color when trying to run
on this line

api.nvim_set_hl(0, group, color)

the color parameter contains two '##" I searched through my whole codebase that could create a double '##" but could find nothing
using packer it works just fine.

windline.setup({
  colors_name = function(colors)
    -- colors contains strings with hex colors that look like this: ##ffffff
  end
})

my current workaround

windline.setup({
  colors_name = function(colors)
    for k, v in pairs(colors) do
      colors[k] = string.gsub(v, "##", "#")
    end
    return colors
  end
 })

the pr that bricks it for me (i know you probably don't want to look at this but yeah provided it anyways)
https://github.com/danielnehrig/nvim/pull/20/files
my master with packer works just fine

Some of the element failed to show in floating window

Please refer to the photo

It is supposed to show a nerdfont scroll bar and percentage(picture on top). But with floating win, it shows %3l:%-2c %3p%

image

scrollbar char setup:

function scrollbar_instance(scrollbar_chars)
  local current_line = vim.fn.line('.')
  local total_lines = vim.fn.line('$')
  local default_chars = {
    '__', 'โ–โ–', 'โ–‚โ–‚', 'โ–ƒโ–ƒ', 'โ–„โ–„', 'โ–…โ–…', 'โ–†โ–†', 'โ–‡โ–‡', 'โ–ˆโ–ˆ'
  }
  local chars = scrollbar_chars or default_chars
  local index = 1

  if current_line == 1 then
    index = 1
  elseif current_line == total_lines then
    index = #chars
  else
    local line_no_fraction = vim.fn.floor(current_line) / vim.fn.floor(total_lines)
    index = vim.fn.float2nr(line_no_fraction * #chars)
    if index == 0 then
      index = 1
    end
  end
  return chars[index]
end


basic.scrollbar_right = {
  hl_colors = {default = hl_list.Black, white = {'white', 'black'}, blue = {'blue', 'black'}},
  text = function(_, winnr)
    if vim.api.nvim_win_get_width(winnr) > breakpoint_width then
      return {{b_components.progress, ''}, {' ', ''}, {scrollbar_instance(), 'blue'}}
    end
  end
}

Exception thrown when attempting to run benchmark

Exception is thrown when attempting to run benchmark using :WindLineBenchmark:

E5108: Error executing lua C:\Users\user\.vim-plug\plenary.nvim/lua/plenary/profile/p.lua:46: module 'jit.vmdef' not found:
	no field package.preload['jit.vmdef']
	no file 'C:\Users\user\scoop\apps\lua\current'
	no file 'C:\Users\user\scoop\apps\lua\current'
	no file 'C:\Users\user\scoop\apps\lua\current'
stack traceback:
	[C]: in function 'require'
	C:\Users\user\.vim-plug\plenary.nvim/lua/plenary/profile/p.lua:46: in main chunk
	[C]: in function 'require'
	C:\Users\user\.vim-plug\plenary.nvim/lua/plenary/profile.lua:5: in main chunk
	[C]: in function 'require'
	...ers\user\.vim-plug\windline.nvim/lua/windline/benchmark.lua:9: in function 'benchmark'
	[string ":lua"]:1: in main chunk

Different exception is thrown when attempting to run a second time, not sure if helpful:

E5108: Error executing lua ...ers\user\.vim-plug\windline.nvim/lua/windline/benchmark.lua:9: loop or previous error loading module 'plenary.profile'
stack traceback:
	[C]: in function 'require'
	...ers\user\.vim-plug\windline.nvim/lua/windline/benchmark.lua:9: in function 'benchmark'
	[string ":lua"]:1: in main chunk

NVIM v0.7.0
Windows 10

Any ideas of this table overflow error?

Not sure anyone see this before:

Error executing vim.schedule lua callback: table overflow                                                                                                                          
stack traceback:                                                                                                                                                                   
        [C]: in function 'insert'                                                                                                                                                  
        ...e/pack/packer/opt/windline.nvim/lua/wlfloatline/init.lua:95: in function 'render_comp'                                                                                  
        ...e/pack/packer/opt/windline.nvim/lua/wlfloatline/init.lua:121: in function 'render_float_status'                                                                         
        ...e/pack/packer/opt/windline.nvim/lua/wlfloatline/init.lua:196: in function 'tick'                                                                                        
        ...k/packer/opt/windline.nvim/lua/wlanimation/animation.lua:82: in function ''                   

It is the first time I saw this.

If comp.text() function through an error, will this happen? Some time I saw this error:

Error executing vim.schedule lua callback: ...ker/opt/nvim-treesitter/lua/nvim-treesitter/ts_utils.lua:23: bad argument #1 to 'sub' (string expected, got nil)
stack traceback:
	[C]: in function 'sub'
	...ker/opt/nvim-treesitter/lua/nvim-treesitter/ts_utils.lua:23: in function 'get_node_text'
	.../pack/packer/opt/nvim-treesitter/lua/nvim-treesitter.lua:40: in function 'get_line_for_node'
	.../pack/packer/opt/nvim-treesitter/lua/nvim-treesitter.lua:72: in function 'statusline'
	~/.config/nvim/lua/modules/ui/eviline.lua:83: in function 'current_treesitter_context'
	~/.config/nvim/lua/modules/ui/eviline.lua:105: in function 'current_function'
	~/.config/nvim/lua/modules/ui/eviline.lua:344: in function 'text'
	...e/pack/packer/opt/windline.nvim/lua/wlfloatline/init.lua:76: in function 'render_comp'
	...e/pack/packer/opt/windline.nvim/lua/wlfloatline/init.lua:114: in function 'render_float_status'
	...e/pack/packer/opt/windline.nvim/lua/wlfloatline/init.lua:179: in function 'tick'
	...k/packer/opt/windline.nvim/lua/wlanimation/animation.lua:82: in function ''
	vim.lua: in function <vim.lua:0>โŽ                                                 

Not sure if those two related.

How does re-rendering the statusline work?

I was reading through the project and I was wondering how you implemented statusline redrawing? Does it call redraw! on every tick? Does it draw the entire statusline or are there optimizations that allow only the changed parts to be redrawn? Thanks!

file_modified icon is not buffer local

Hey Mr. wind ๐Ÿ‘‹, thank you for building this next level status line plugin ๐Ÿ”ฅ. Also, for the maintenance and solving the last opened issue.

I'm being bold enough to open another one - hoping that's not too bothering ๐Ÿ™ˆ.
The problem the issue title describes reveals itself using the file_modified component in an inactive status line. The component will use the state of the currently active buffer instead of the local buffer. Modifying a buffer will show the modified icon in the inactive buffer even when no modifications happen.

I tried to solve it by mimicking the cache variant of other components like you for example for the file_name and file icon. Unfortunately I wasn't able to solve it that way. Maybe it's something really simple I didn't spot.

Feat: File Icon Colors

Ability to use cache_file_icon with the correct color of the language in context
example:
in a lua file lua icon should be displayed blue
in a TS file TS icon should be displayed blue
in a Rust file Rust icon should be displayed orangeyish

Any chance of modifying this to work with lazy.nvim?

Appears to work somewhat, but have to just load the defaults and then set it to disabled in the loader for the module with lazy.nvim. It still loads and runs, but doesn't run any of the config so just left with the defaults.

I can provide more details if you'd like.

github-nvim-theme colorscheme

It seems that there is an issue when using github-nvim-theme.

Once loaded, if I try to switch to any other colorscheme (even github-nvim-theme own variants) windline colors broke, and I have to restart to fix.

Starting colors when using github_light โœ…
screenshot

When trying to switch to darkblue โŒ
screenshot2

When trying to switch to github_dark โŒ
screenshot3

Otherwise, it's working when I'm not loading github-nvim-theme. Any idea what can cause this?

[Feature] register and push message to status bar

I want to push messages to a statusline component. To do that, I need

  1. The plugin provides a API so I can push message through
  2. It will reset back to empty after timeout (e.g. 5sec)
  3. I can limit the size (width) of message

Here is an example:
I run a unit test for a package. The output is
test 1 done
test 2 done
...
test finished

I has a callback hook to stdout for each message, I do

require('windline').push('component_show_test_result', 'test 1 done')

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.