nvimdev / galaxyline.nvim

neovim statusline plugin written in lua
MIT License
868 stars 113 forks source link

Doesn't work with Packer.nvim? #13

Closed madskjeldgaard closed 3 years ago

madskjeldgaard commented 3 years ago

Hi! Thanks for making this awesome plugin. I am trying to install it using Packer. It seems to kind of work. From the command line I can run :lua require'galaxyline' with no errors and I am able to manually populate the galaxyline from the command line, but as soon as I source galaxyline in a lua settings file instead I get massive amounts of errors.

2020-10-29-175534_1920x1080_scrot

The plugin is installed using the packer.nvim package manager https://github.com/wbthomason/packer.nvim

like this:

use 'glepnir/galaxyline.nvim'
use 'kyazdani42/nvim-web-devicons' -- lua
salkin-mada commented 3 years ago

Having the same issue here so started using Plug again only for galaxyline Would be very nice to figure out why this is. Great to get galaxyline via packer.nvim and the inbuild pack system of nvim also tried with this using the additional packer param - requires for the icons.

    -- Galaxyline
    use {
        'glepnir/galaxyline.nvim',
        -- some optional icons baby
        requires = {'kyazdani42/nvim-web-devicons', opt = true}
    }

no luck

carlitux commented 3 years ago

This works for me, do not forget run the command :PackerSync

{
  'glepnir/galaxyline.nvim', 
  branch = 'main',
  config = function()
    local gl = require('galaxyline')
    local gls = gl.section
    gl.short_line_list = {'LuaTree','vista','dbui'}

    local colors = {
      bg = '#282c34',
      yellow = '#fabd2f',
      cyan = '#008080',
      darkblue = '#081633',
      green = '#afd700',
      orange = '#FF8800',
      purple = '#5d4d7a',
      magenta = '#d16d9e',
      grey = '#c0c0c0',
      blue = '#0087d7',
      red = '#ec5f67'
    }

    local empty_buffer = function()
      if vim.fn.empty(vim.fn.expand('%:t')) ~= 1 then
        return true
      end
      return false
    end

    gls.left[1] = {
      FirstElement = {
        provider = function() return '▋' end,
        highlight = {colors.blue,colors.yellow}
      },
    }
    gls.left[2] = {
      ViMode = {
        provider = function()
          local alias = {n = 'NORMAL',i = 'INSERT',c= 'COMMAND',V= 'VISUAL', [''] = 'VISUAL'}
          return alias[vim.fn.mode()]
        end,
        separator = '◤ ',
        separator_highlight = {colors.yellow,function()
          if not empty_buffer() then
            return colors.purple
          end
          return colors.darkblue
        end},
        highlight = {colors.magenta,colors.yellow,'bold'},
      },
    }
    gls.left[3] ={
      FileIcon = {
        provider = 'FileIcon',
        condition = empty_buffer,
        highlight = {require('galaxyline.provider_fileinfo').get_file_icon_color,colors.darkblue},
      },
    }
    gls.left[4] = {
      FileName = {
        provider = {'FileName','FileSize'},
        condition = empty_buffer,
        separator = '◥',
        separator_highlight = {colors.purple,colors.darkblue},
        highlight = {colors.magenta,colors.darkblue}
      }
    }

    gls.left[5] = {
      GitIcon = {
        provider = function() return '  ' end,
        condition = empty_buffer,
        highlight = {colors.orange,colors.purple},
      }
    }
    gls.left[6] = {
      GitBranch = {
        provider = 'GitBranch',
        condition = empty_buffer,
        highlight = {colors.grey,colors.purple},
      }
    }

    local checkwidth = function()
      local squeeze_width  = vim.fn.winwidth(0) / 2
      if squeeze_width > 40 then
        return true
      end
      return false
    end

    gls.left[7] = {
      DiffAdd = {
        provider = 'DiffAdd',
        condition = checkwidth,
        icon = ' ',
        highlight = {colors.green,colors.purple},
      }
    }
    gls.left[8] = {
      DiffModified = {
        provider = 'DiffModified',
        condition = checkwidth,
        icon = ' ',
        highlight = {colors.orange,colors.purple},
      }
    }
    gls.left[9] = {
      DiffRemove = {
        provider = 'DiffRemove',
        condition = checkwidth,
        icon = ' ',
        highlight = {colors.red,colors.purple},
      }
    }
    gls.left[10] = {
      LeftEnd = {
        provider = function() return '◤' end,
        separator = '◤',
        separator_highlight = {colors.purple,colors.bg},
        highlight = {colors.purple,colors.purple}
      }
    }
    gls.left[11] = {
      DiagnosticError = {
        provider = 'DiagnosticError',
        icon = '  ',
        highlight = {colors.red,colors.bg}
      }
    }
    gls.left[12] = {
      Space = {
        provider = function () return ' ' end
      }
    }
    gls.left[13] = {
      DiagnosticWarn = {
        provider = 'DiagnosticWarn',
        icon = '  ',
        highlight = {colors.blue,colors.bg},
      }
    }
    gls.right[1]= {
      FileFormat = {
        provider = 'FileFormat',
        separator = '◤ ',
        separator_highlight = {colors.bg,colors.purple},
        highlight = {colors.grey,colors.purple},
      }
    }
    gls.right[2] = {
      LineInfo = {
        provider = 'LineColumn',
        separator = ' | ',
        separator_highlight = {colors.darkblue,colors.purple},
        highlight = {colors.grey,colors.purple},
      },
    }
    gls.right[3] = {
      PerCent = {
        provider = 'LinePercent',
        separator = ' ◥',
        separator_highlight = {colors.darkblue,colors.purple},
        highlight = {colors.grey,colors.darkblue},
      }
    }
    gls.right[4] = {
      ScrollBar = {
        provider = 'ScrollBar',
        highlight = {colors.yellow,colors.purple},
      }
    }

    gls.short_line_left[1] = {
      BufferType = {
        provider = 'FileTypeName',
        separator = '◤',
        separator_highlight = {colors.purple,colors.bg},
        highlight = {colors.grey,colors.purple}
      }
    }

    gls.short_line_right[1] = {
      BufferIcon = {
        provider= 'BufferIcon',
        separator = '◥',
        separator_highlight = {colors.purple,colors.bg},
        highlight = {colors.grey,colors.purple}
      }
    }
  end
}
madskjeldgaard commented 3 years ago
 gls.left[2] = {
      ViMode = {
        provider = function()
          local alias = {n = 'NORMAL',i = 'INSERT',c= 'COMMAND',V= 'VISUAL', [''] = 'VISUAL'}
          return alias[vim.fn.mode()]
        end,
        separator = '◤ ',
        separator_highlight = {colors.yellow,function()
          if not empty_buffer() then
            return colors.purple
          end
          return colors.darkblue
        end},
        highlight = {colors.magenta,colors.yellow,'bold'},
      },
    }
    gls.left[3] ={
      FileIcon = {
        provider = 'FileIcon',
        condition = empty_buffer,
        highlight = {require('galaxyline.provider_fileinfo').get_file_icon_color,colors.darkblue},
      },
    }
    gls.left[4] = {
      FileName = {
        provider = {'FileName','FileSize'},
        condition = empty_buffer,
        separator = '◥',
        separator_highlight = {colors.purple,colors.darkblue},
        highlight = {colors.magenta,colors.darkblue}
      }
    }

    gls.left[5] = {
      GitIcon = {
        provider = function() return '  ' end,
        condition = empty_buffer,
        highlight = {colors.orange,colors.purple},
      }
    }
    gls.left[6] = {
      GitBranch = {
        provider = 'GitBranch',
        condition = empty_buffer,
        highlight = {colors.grey,colors.purple},
      }
    }

    local checkwidth = function()
      local squeeze_width  = vim.fn.winwidth(0) / 2
      if squeeze_width > 40 then
        return true
      end
      return false
    end

    gls.left[7] = {
      DiffAdd = {
        provider = 'DiffAdd',
        condition = checkwidth,
        icon = ' ',
        highlight = {colors.green,colors.purple},
      }
    }
    gls.left[8] = {
      DiffModified = {
        provider = 'DiffModified',
        condition = checkwidth,
        icon = ' ',
        highlight = {colors.orange,colors.purple},
      }
    }
    gls.left[9] = {
      DiffRemove = {
        provider = 'DiffRemove',
        condition = checkwidth,
        icon = ' ',
        highlight = {colors.red,colors.purple},
      }
    }
    gls.left[10] = {
      LeftEnd = {
        provider = function() return '◤' end,
        separator = '◤',
        separator_highlight = {colors.purple,colors.bg},
        highlight = {colors.purple,colors.purple}
      }
    }
    gls.left[11] = {
      DiagnosticError = {
        provider = 'DiagnosticError',
        icon = '  ',
        highlight = {colors.red,colors.bg}
      }
    }
    gls.left[12] = {
      Space = {
        provider = function () return ' ' end
      }
    }
    gls.left[13] = {
      DiagnosticWarn = {
        provider = 'DiagnosticWarn',
        icon = '  ',
        highlight = {colors.blue,colors.bg},
      }
    }
    gls.right[1]= {
      FileFormat = {
        provider = 'FileFormat',
        separator = '◤ ',
        separator_highlight = {colors.bg,colors.purple},
        highlight = {colors.grey,colors.purple},
      }
    }
    gls.right[2] = {
      LineInfo = {
        provider = 'LineColumn',
        separator = ' | ',
        separator_highlight = {colors.darkblue,colors.purple},
        highlight = {colors.grey,colors.purple},
      },
    }
    gls.right[3] = {
      PerCent = {
        provider = 'LinePercent',
        separator = ' ◥',
        separator_highlight = {colors.darkblue,colors.purple},
        highlight = {colors.grey,colors.darkblue},
      }
    }
    gls.right[4] = {
      ScrollBar = {
        provider = 'ScrollBar',
        highlight = {colors.yellow,colors.purple},
      }
    }

    gls.short_line_left[1] = {
      BufferType = {
        provider = 'FileTypeName',
        separator = '◤',
        separator_highlight = {colors.purple,colors.bg},
        highlight = {colors.grey,colors.purple}
      }
    }

    gls.short_line_right[1] = {
      BufferIcon = {
        provider= 'BufferIcon',
        separator = '◥',
        separator_highlight = {colors.purple,colors.bg},
        highlight = {colors.grey,colors.purple}
      }
    }

Thanks! I can seem to get your example to work, with some errors though:

2020-10-29-221458_1920x1080_scrot

Thanks a lot!!

madskjeldgaard commented 3 years ago

(but removing the problematic providers seem to solve all for me. Thanks!

madskjeldgaard commented 3 years ago

2020-10-29-221938_1920x1080_scrot

all good :)

glepnir commented 3 years ago

@madskjeldgaard I had fixed diff bug with vim-gitgutter. sorry for this bug. btw saw your pic I found that the separator symbol too small with your font.

madskjeldgaard commented 3 years ago

@madskjeldgaard I had fixed diff bug with vim-gitgutter. sorry for this bug. btw saw your pic I found that the separator symbol too small with your font.

thanks so much!