Code Monkey home page Code Monkey logo

nougat.nvim's Introduction

GitHub Workflow Status: CI Coverage License

๐Ÿซ nougat.nvim

Hyperextensible plugin for Neovim's 'statusline', 'tabline' and 'winbar'.

โœจ Features

  • ๐Ÿ› ๏ธ Hyperextensible.
  • ๐Ÿš€ Fast, Performance focused, Submillisecond evaluation time.
  • ๐Ÿ–ฅ๏ธ Responsive Breakpoints, Smart Truncation.
  • ๐ŸŽจ Color Palette, Automatic and Adaptive.
  • ๐Ÿ“ฆ Modular Design, only use what you need.
  • ๐Ÿ”ฎ Dynamic statusline / tabline / winbar.
  • ๐Ÿ“ƒ Filetype Specific statusline / winbar.
  • ๐Ÿ’… Fancy Separator.
  • ๐Ÿ–ฑ๏ธ Mouse-Click.
  • ๐Ÿ’ผ Caching out-of-the-box.
  • ๐Ÿ“Š Built-in Profiler.
  • ๐Ÿฅœ Common Items included.

๐Ÿ•ธ๏ธ Requirements

  • Neovim >= 0.7.0

๐Ÿ“ฅ Installation

Install with your preferred plugin manager. For example:

With lazy.nvim

{
  "MunifTanjim/nougat.nvim",
},
With packer.nvim
use({
  "MunifTanjim/nougat.nvim",
})
With vim-plug
Plug 'MunifTanjim/nougat.nvim'

Usage

nougat.nvim is at your disposal to build exactly what you want.

local nougat = require("nougat")

set_statusline

Signature: (bar: NougatBar | nougat_bar_selector, opts?: { filetype?: string }) -> nil

bar can be a NougatBar instance:

local stl = Bar("statusline")

nougat.set_statusline(stl)

Or a nougat_bar_selector function (ctx: nougat_core_expression_context) -> NougatBar.

local stl = Bar("statusline")
local stl_inactive = Bar("statusline")

-- use separate statusline focused/unfocused window
nougat.set_statusline(function(ctx)
  return ctx.is_focused and stl or stl_inactive
end)

opts is a table with the shape { filetype?: string }.

If filetype is given, the bar will only be used for that filetype.

local stl_fugitive = Bar("statusline")
local stl_help = Bar("statusline")

-- set filetype specific statusline
for ft, stl_ft in pairs({
  fugitive = stl_fugitive,
  help = stl_help,
}) do
  nougat.set_statusline(stl_ft, { filetype = ft })
end

refresh_statusline

Signature: (force_all? boolean) -> nil

set_tabline

Signature: (bar: NougatBar | nougat_bar_selector) -> nil

bar can be a NougatBar instance or a nougat_bar_selector function.

refresh_tabline

Signature: () -> nil

set_winbar

Signature: (bar: NougatBar | nougat_bar_selector, opts?: { filetype: string }|{ global?: boolean }|{ winid: integer }) -> nil

bar can be a NougatBar instance or a nougat_bar_selector function.

opts is a table with one of the shapes { filetype: string } / { global?: boolean } / { winid: integer }.

If filetype is given, the bar will only be used for that filetype.

If global is true, the bar will be used for global 'winbar', otherwise the local 'winbar' is set whenever a new window is created.

If winid is present, the bar will be used for only that specific window.

refresh_winbar

Signature: (force_all?: boolean) -> nil

Examples

A handful of examples are available to get you started.

Bubbly

Source: bubbly.lua

Bubbly Statusline

Pointy

Source: pointy.lua

Pointy Statusline

Slanty

Source: slanty.lua

Slanty Statusline


๐ŸŽจ Color Palette

Check Detailed Documentation for nougat.color

โš™๏ธ NougatBar

The sweet NougatBar represents the statusline / tabline / winbar.

Check Detailed Documentation for nougat.bar

โš™๏ธ NougatItem

Each NougatBar is made of a bunch of NougatItem.

Check Detailed Documentation for nougat.item

โš™๏ธ Separator

Separator that goes between two NougatItems.

Check Detailed Documentation for nougat.separator

โš™๏ธ Cache

Check Detailed Documentation for nougat.cache

โš™๏ธ Store

Check Detailed Documentation for nougat.store

๐Ÿฅœ Nuts

Commonly used NougatItems for your NougatBar are available inside nougat.nut.* module.

๐Ÿ“Š Profiler

The built-in profiler can be used with the :Nougat profile command.


๐Ÿ““ Links

๐Ÿ“œ License

Licensed under the MIT License. Check the LICENSE file for details.

nougat.nvim's People

Contributors

axdank avatar github-actions[bot] avatar linrongbin16 avatar muniftanjim 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

nougat.nvim's Issues

Add filetype icon for filetype component

Did you check the docs and existing issues?

  • I am using latest nougat.nvim
  • I have read all the nougat.nvim docs
  • I have searched the existing issues of nougat.nvim

Problem

https://github.com/MunifTanjim/nougat.nvim/blob/main/lua/nougat/nut/buf/filetype.lua, the filetype component don't have 'format' function, which cannot use devicons to show the colored file type icons.

lualine have filetype icon:

SAVE_20240102_180639

Solution

add 'format' function to allow user do customization.

Alternatives

No response

Additional Context

No response

:hammer_and_wrench: Show clock

Did you check the docs and existing issues?

  • I am using latest nougat.nvim
  • I have read all the nougat.nvim docs
  • I have searched the existing issues of nougat.nvim

Problem

I want to display a clock, but it is not updating.

nougat.nvim config

-- datetime {{{
local datetime = (function()
  local item = Item {
    sep_left = sep.left_half_circle_solid(true),
    content = {
      Item {
        hl = { bg = color.green, fg = color.bg },
        content = vim.fn.strftime('%H:%M'), -- FIXME: Not refreshing
      },
    },
    sep_right = sep.right_half_circle_solid(true),
  }

  return item
end)()
-- }}}

-- statusline {{{
local stl = Bar('statusline')
stl:add_item(datetime)
bar_util.set_statusline(stl)
-- }}}

Solution

Clock is refreshed.

Alternatives

No response

Additional Context

No response

Color API Design: the `red` `yellow` API name seems confusing

Did you check the docs and existing issues?

  • I am using latest nougat.nvim
  • I have read all the nougat.nvim docs
  • I have searched the existing issues of nougat.nvim

Problem

This is not a bug, much more relate to system design.

But I think it's worth to discuss, when people use (for example) color.yellow config/API, I believe this API is going to try to retrieve color from a syntax highlighting group (for example 'Visual'), if failed it's going to use yellow color as fallback.

But people will not know what highlighting it's going to use.

We could either document it explicitly, or change the API to color.yellow('Visual') to be more explicit, and even people can customize the highlighting group name by themselves.

Solution

Already in Problem section.

Alternatives

No response

Additional Context

No response

Support vim-gitbranch/vim-gitgutter as git branch/status source

Did you check the docs and existing issues?

  • I am using latest nougat.nvim
  • I have read all the nougat.nvim docs
  • I have searched the existing issues of nougat.nvim

Problem

I'm using vim-gitbranch as git branch data source, and vim-gitgutter as git diff/status data source.

I know most people are using gitsigns, but it has some small bugs on Windows, gitgutter has much better cross-platform compatibilities.

For now I'm configure it with:

local function git_branch()
    if vim.g.loaded_gitbranch == nil or vim.g.loaded_gitbranch <= 0 then
        return ""
    end
    local name = vim.fn["gitbranch#name"]()
    return name or ""
end

local function git_diff()
    if vim.g.loaded_gitgutter == nil or vim.g.loaded_gitgutter <= 0 then
        return ""
    end
    local changes = vim.fn["GitGutterGetHunkSummary"]()
    if changes == nil or #changes ~= 3 then
        return ""
    end
    local symbols = { "+", "~", "-" }
    local builder = {}
    for i, c in ipairs(changes) do
        if type(c) == "number" and c > 0 then
            table.insert(builder, string.format("%s%d", symbols[i], c))
        end
    end
    return table.concat(builder, " ")
end

-- git branch and status
stl:add_item(Item({
    hl = { bg = color.magenta, fg = color.bg },
    sep_right = sep.right_upper_triangle_solid(true),
    prefix = " ๎œฅ ",
    suffix = " ",
    type = "lua_expr",
    content = function(ctx)
        local branch = git_branch()
        if string.len(branch) == 0 then
            return ""
        end
        local changes = git_diff()
        if string.len(changes) == 0 then
            return branch
        else
            return branch .. " " .. changes
        end
    end,
}))

It is working, looks like:

image

But I want to enable the green, yellow, red colors for the added, changed and removed lines count number.

How should I do it?

I am using the slanty.lua template, the git status sample is:

-- -- git changes
stl:add_item(nut.git.status.create({
    hl = { fg = color.bg },
    content = {
        nut.git.status.count("added", {
            hl = { bg = color.green },
            prefix = "+",
            sep_right = sep.right_upper_triangle_solid(true),
        }),
        nut.git.status.count("changed", {
            hl = { bg = color.yellow },
            prefix = "~",
            sep_right = sep.right_upper_triangle_solid(true),
        }),
        nut.git.status.count("removed", {
            hl = { bg = color.red },
            prefix = "-",
            sep_right = sep.right_upper_triangle_solid(true),
        }),
    },
}))

It seems the content in nut.git.status.count is not overwrite-able, correct?

Solution

Use self-defined data source for git status.

Alternatives

No response

Additional Context

No response

:hammer_and_wrench: How to configure `lsp.servers` content?

Did you check the docs and existing issues?

  • I am using latest nougat.nvim
  • I have read all the nougat.nvim docs
  • I have searched the existing issues of nougat.nvim

Problem

get_content of LSP config is currently hardcoded to a set function

Solution

Allow for a configurable opts to be passed to allow overriding the default implementation

Alternatives

An alternative would be created the Item then merging it with another table that has my custom function

local item = nut.lsp({
  config = {},
  prefix = " ๏‚… ",
  hl = { fg = color.green },
  sep_right = sep.right_chevron_solid(true),
  on_click = function()
    vim.cmd("LspInfo")
  end,
})

stl:add_item(Utils.merge(item, { content = custom_content_fn }))

Additional Context

No response

quest: get the number of lines of a file?

i saw this snippet in the examples:

stl:add_item(Item({
  hl = {fg = color.bg, bg = color.fg0},
  prefix = ' ',
  suffix = ' ',
  content = core.group({core.code('l'), ':', core.code('c')})
}))

is it somehow possible to get the number of lines a file has too with core.code?

i could not find the documentation for it.

Use colorscheme patterns

Instead of hardcode color palettes, could we consider extract the existing palettes from the current using colorscheme? that way the statusline style would be very naturally blended in with the rest of themes.

quest: possibility to change colors for the modes and diagnostics?

hey hey,

awesome plugin, thx for writing it!

is it possible to change the colors for the different modes like normal, visual, insert?
i looked at the 3 examples and wasn't able to find it?

the same goes for the diagnostic_count?
can i somewhere change these too, like i'll do it for the git counts?

thx again for the plugin!

Stack trace for type mismatch

E5108: Error executing lua Error executing lua: ...cal/share/nvim/lazy/nougat.nvim/lua/nougat/item/init.lua:117: attempt to index local 'cache' (a function value)
stack traceback:
	...cal/share/nvim/lazy/nougat.nvim/lua/nougat/item/init.lua:117: in function 'item'
	/Users/dsully/.config/nvim/lua/plugins/nougat.lua:156: in function 'content'
	...y/.local/share/nvim/lazy/nougat.nvim/lua/nougat/util.lua:388: in function 'prepare_parts'
	...ocal/share/nvim/lazy/nougat.nvim/lua/nougat/bar/init.lua:118: in function 'generate'
	...ocal/share/nvim/lazy/nougat.nvim/lua/nougat/bar/util.lua:19: in function <...ocal/share/nvim/lazy/nougat.nvim/lua/nougat/bar/util.lua:17>
	[C]: at 0x0100ec0e38
stack traceback:
	[C]: at 0x0100ec0e38

This started happening with change dba049f or more likely 45cc6e6 which started using the cache.

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.