GithubHelp home page GithubHelp logo

ojroques / nvim-hardline Goto Github PK

View Code? Open in Web Editor NEW
180.0 5.0 25.0 147 KB

A simple Neovim statusline

License: BSD 2-Clause "Simplified" License

Lua 99.78% Vim Script 0.22%
neovim-plugin statusline neovim-lua

nvim-hardline's Introduction

nvim-hardline

A statusline / bufferline for Neovim written in Lua. It is inspired by vim-airline but aims to be as light and simple as possible.

Note: I won't add new features/parts/themes if I don't need them. Feel free to submit PRs or fork the plugin though.

screenshot

Installation

With packer.nvim:

use {'ojroques/nvim-hardline'}

With paq-nvim:

paq {'ojroques/nvim-hardline'}

With lazy.nvim:

-- init.lua:
{'ojroques/nvim-hardline'},

-- plugins/hardline.lua:
return {
'ojroques/nvim-hardline',
}

Usage

In your init.lua:

require('hardline').setup {}

If you're using a .vimrc or init.vim:

lua require('hardline').setup {}

Configuration

You can pass options to the setup() function. Here are all available options with their default settings:

require('hardline').setup {
  bufferline = false,  -- disable bufferline
  bufferline_settings = {
    exclude_terminal = false,  -- don't show terminal buffers in bufferline
    show_index = false,        -- show buffer indexes (not the actual buffer numbers) in bufferline
  },
  theme = 'default',   -- change theme
  sections = {         -- define sections
    {class = 'mode', item = require('hardline.parts.mode').get_item},
    {class = 'high', item = require('hardline.parts.git').get_item, hide = 100},
    {class = 'med', item = require('hardline.parts.filename').get_item},
    '%<',
    {class = 'med', item = '%='},
    {class = 'low', item = require('hardline.parts.wordcount').get_item, hide = 100},
    {class = 'error', item = require('hardline.parts.lsp').get_error},
    {class = 'warning', item = require('hardline.parts.lsp').get_warning},
    {class = 'warning', item = require('hardline.parts.whitespace').get_item},
    {class = 'high', item = require('hardline.parts.filetype').get_item, hide = 60},
    {class = 'mode', item = require('hardline.parts.line').get_item},
  },
}

You can define your own sections using the sections list. Each element of that list is a table with the following attributes:

  • class: the section colorscheme. The following classes are currently available:
    • mode: change color based on the current mode.
    • low, med, high: colors for different levels of importance.
    • bufferline: colors for the bufferline.
    • error, warning: colors for the diagnostics of Neovim built-in LSP client.
  • item: the actual text being displayed. Must be a string or a function returning a string.
  • hide: threshold (in number of characters) below which the section will be hidden.

Available section parts

Part Description
cwd Current working directory
filename Filename and file status (readonly, modified, ...)
filetype Filetype
git Git hunks (requires vim-gitgutter / vim-signify / gitsigns.nvim) and Git branch (requires vim-fugitive / gina.vim / vim-branchname / gitsigns.nvim)
line Line and column positions
lsp Diagnostics from Neovim LSP client
mode Current mode
treesitter-context Current treesitter node (requires nvim-gps)
whitespace Trailing whitespaces, mixed indent and Git conflict markers warnings
wordcount Current word count (enabled only for some filetypes)

License

LICENSE

nvim-hardline's People

Contributors

adisen99 avatar alessandromorelli96 avatar cljoly avatar crispgm avatar halshar avatar jameskeim avatar jan-xyz avatar jogubo avatar johann2357 avatar kasfil avatar ojroques avatar ouuan avatar ryujinscales 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

nvim-hardline's Issues

`vim.lsp.diagnostic.get_count()` is deprecated in nvim v0.6.0+

Starting from nvim version 0.6.0, vim.lsp.diagnostic.get_count() is deprecated. This can be fixed by the following changes to ./lua/hardline/parts/lsp.lua:

diff --git a/lua/hardline/parts/lsp.lua b/lua/hardline/parts/lsp.lua
index 923f163..04d553b 100644
--- a/lua/hardline/parts/lsp.lua
+++ b/lua/hardline/parts/lsp.lua
@@ -2,7 +2,8 @@ local lsp = vim.lsp
 local fmt = string.format
 
 local function get_diagnostic(prefix, severity)
-  local count = lsp.diagnostic.get_count(0, severity)
+  local count = #vim.diagnostic.get(0, {severity=severity})
   if count < 1 then
     return ''
   end
@@ -10,11 +11,11 @@ local function get_diagnostic(prefix, severity)
 end
 
 local function get_error()
-  return get_diagnostic('E', 'Error')
+  return get_diagnostic('E', vim.diagnostic.severity.ERROR)
 end
 
 local function get_warning()
-  return get_diagnostic('W', 'Warning')
+  return get_diagnostic('W', vim.diagnostic.severity.WARN)
 end
 
 return {

I didn't create a PR because I don't know if 1) you want to prepare it for v0.6.0 because you stated it's for you own use in the README, and 2) if the fix is welcome, how you want implement it to work on both v0.5 and v0.6.

Let me know if you want to create a PR for this!

Empty statusline aftering using nvim-hardline

Hi, nvim-hardline authors

I'm new to neovim, need a statueline plugin, nvim-hardline's screenshot is what I expected. I followed the steps in the readme, however, my neovim just give empty statusline. Can you please help figure out why and how to resolve this?

My init.lua is:

local fn = vim.fn
local install_path = fn.stdpath('data') .. '/site/pack/paqs/start/paq-nvim'
if fn.empty(fn.glob(install_path)) > 0 then
    fn.system({'git', 'clone', '--depth=1', 'https://github.com/savq/paq-nvim.git', install_path})
end

require 'paq' {
  {'savq/paq-nvim'},                  
  {'Mofiqul/vscode.nvim'},
  {'ojroques/nvim-hardline'},     
}

require('hardline').setup {}

I've executed :PaqInstall, and there is nvim-hardline repo cloned in my local cache directories. The statusline is always empty.

git information is only available on single buffer

Hello,
I've enabled the git option and it works fine when I'm working with single buffer, but when I work with splits I don't see the git information on the status bar.

Is this the expected behaviour or am I missing something?

this is my hardline config

require('hardline').setup {
  bufferline = false,
  bufferline_settings = {
    exclude_terminal = false,
    show_index = false,
  },
  theme = 'dracula',
  sections = {
    {class = 'mode', item = require('hardline.parts.mode').get_item},
    {class = 'high', item = require('hardline.parts.git').get_item, hide = 100},
    {class = 'med', item = require('hardline.parts.filename').get_item},
    '%<',
    {class = 'med', item = '%='},
    {class = 'error', item = require('hardline.parts.lsp').get_error},
    {class = 'warning', item = require('hardline.parts.lsp').get_warning},
    {class = 'warning', item = require('hardline.parts.whitespace').get_item},
    {class = 'high', item = require('hardline.parts.filetype').get_item, hide = 60},
    {class = 'mode', item = require('hardline.parts.line').get_item},
  },
}

Colors are not working

I see no colors in the status bar. Everything strays grey. Any idea of what could be the cause?

Running :highlight shows no hardline specific highlight group.

I am using the defautl configuration shown in the README.md

[Question] Custom themes

I'm hoping to implement my own theme, by customising the default one.

Is it at all possible to have custom configuration, and to source it via the options? For example:

require('hardline').setup {
  theme = './custom-default.lua'
}

Loving this plugin by the way!

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.