nvim-lualine / lualine.nvim

A blazing fast and easy to configure neovim statusline plugin written in pure lua.
MIT License
6.19k stars 466 forks source link

Bug: Unable to get `diff` and `diagnostics` not working #291

Closed mushi-nova closed 3 years ago

mushi-nova commented 3 years ago

I've been trying to make the diff and diagnostics modules to work but unable to achieve it. Though there are no errors or anything to prevent that.

Actual behaviour 2021-07-13-103418_672x21_scrot

Expected behaviour

To show the diff and diagnostic signs but all are absent or not getting triggered.

My Config

sections =
  {
    lualine_a = { 'mode' },
    lualine_b = { 'branch', 'filename' },
    lualine_c = {
      {
        'diff',
        colored = true,
        symbols = {added = '+', modified = '~', removed = '-'}
      },

      {
        "diagnostics",
        source = {'g:coc_status'},
        symbols = {error = 'E:', warn = 'W:', info = 'I:'}
      }
  },
    lualine_x = { 'encoding', 'fileformat', 'filetype' },
    lualine_y = { 'progress' },
    lualine_z = { 'location' },
  },

  inactive_sections =
  {
    lualine_a = {},
    lualine_b = {},
    lualine_c = {'filename'},
    lualine_x = {'location'},
    lualine_y = {},
    lualine_z = {}
  },

Versions:

  1. Nvim - v0.5.0
shadmansaleh commented 3 years ago

g:coc_status isn't a diagnostic source . See here for valid sources ; In your caae it should be 'coc'.

diff should work. Are you in a file that is under git version control and is differs from staged worktree ?

What does

git --no-pager diff --no-color --no-ext-diff -U0 -- ${your file path}

show ?

mushi-nova commented 3 years ago

I actually tried the diagnostic with source = 'coc' but it didn't work out so later on tried it with source = g:coc_status. Yet the result was the same.

Moving on to the next question. I'm not getting any output for the same. I'm using src/main.rs for the file path within my Rust project file.

shadmansaleh commented 3 years ago

I actually tried the diagnostic with source = 'coc' but it didn't work out so later on tried it with source = g:coc_status. Yet the result was the same.

Rust analyzer can take a while to index project and it's dependencies . coc won't give diagnostics until that's done . When you say you can't get diagnostics working does coc give diagnostics in that time ? I mean do you see errors or wanrings on your file?

I actually tried the diagnostic with source = 'coc' but it didn't work out so later on tried it with source = g:coc_status. Yet the result was the same.

Does the file differ from your commited and staged version of the file ?

benfrain commented 3 years ago

I get a similar issue but I get the error no sources for diagnostics configured. My config:

require "lualine".setup {
  options = {
    icons_enabled = true,
    theme = "everforest",
    component_separators = {"", ""},
    section_separators = {"", ""},
    disabled_filetypes = {}
  },
  sections = {
    lualine_a = {"mode", "paste"},
    lualine_b = {"branch", "diff"},
    lualine_c = { "diagnostics", source = {"nvim_lsp" }},
    lualine_x = {"filetype"},
    lualine_y = {"progress"},
    lualine_z = {"location"}
  },
  inactive_sections = {
    lualine_a = {},
    lualine_b = {},
    lualine_c = {"filename"},
    lualine_x = {"location"},
    lualine_y = {},
    lualine_z = {}
  },
  tabline = {},
  extensions = {}
}

compe is using nvim_lsp with no issues in the same config. Am I writing this incorrectly?

shadmansaleh commented 3 years ago

@beauwilliams It's sources not source see here

mushi-nova commented 3 years ago

Sorry, it's my bad then. Changing it to sources did the trick and thanks a lot. Mind telling me what's causing diff not to show any sort of output.

shadmansaleh commented 3 years ago

Mind telling me what's causing diff not to show any sort of output.

Moving on to the next question. I'm not getting any output for the same

lualine gets the diff counts from that git command I gave you earlier . If it's not outputing anything then something is wrong with your git setup . There's really no way how I can know what's wrong there ;)

mushi-nova commented 3 years ago

Thanks a lot. Indeed there were few things wrong with my git setup.