nvim: Switch galaxyline for lualine
Recently, galaxyline created some troubles in the setup. Lualine is much much easier to configure and, since I don't need some of the more advanced features of galaxyline anyway, I can just use the simple setup it offers. If ever those features become necessary again I can presumably just reintroduce them based on the old galaxyline setup that got removed in this commit.
This commit is contained in:
parent
8b3b49275c
commit
ff0ddb2b2d
3 changed files with 43 additions and 256 deletions
|
@ -1,244 +0,0 @@
|
|||
-- set up statusline
|
||||
local gl = require 'galaxyline'
|
||||
local gls = gl.section
|
||||
local fileinfo = require 'galaxyline.provider_fileinfo'
|
||||
local devicons = require 'nvim-web-devicons'
|
||||
|
||||
local mode_colors = {
|
||||
normal = '#' .. '98c379',
|
||||
insert = '#' .. '61afef',
|
||||
replace = '#' .. 'e06c75',
|
||||
visual = '#' .. 'e5c07b',
|
||||
command = '#' .. 'd19a66',
|
||||
terminal = '#' .. '56b6c2'
|
||||
}
|
||||
|
||||
-- create icons from unicode
|
||||
local function u(code)
|
||||
if type(code) == 'string' then code = tonumber('0x' .. code) end
|
||||
local c = string.char
|
||||
if code <= 0x7f then return c(code) end
|
||||
local t = {}
|
||||
if code <= 0x07ff then
|
||||
t[1] = c(bit.bor(0xc0, bit.rshift(code, 6)))
|
||||
t[2] = c(bit.bor(0x80, bit.band(code, 0x3f)))
|
||||
elseif code <= 0xffff then
|
||||
t[1] = c(bit.bor(0xe0, bit.rshift(code, 12)))
|
||||
t[2] = c(bit.bor(0x80, bit.band(bit.rshift(code, 6), 0x3f)))
|
||||
t[3] = c(bit.bor(0x80, bit.band(code, 0x3f)))
|
||||
else
|
||||
t[1] = c(bit.bor(0xf0, bit.rshift(code, 18)))
|
||||
t[2] = c(bit.bor(0x80, bit.band(bit.rshift(code, 12), 0x3f)))
|
||||
t[3] = c(bit.bor(0x80, bit.band(bit.rshift(code, 6), 0x3f)))
|
||||
t[4] = c(bit.bor(0x80, bit.band(code, 0x3f)))
|
||||
end
|
||||
return table.concat(t)
|
||||
end
|
||||
|
||||
local mode_map = {
|
||||
['n'] = {'NORMAL', mode_colors.normal},
|
||||
['i'] = {'INSERT', mode_colors.insert},
|
||||
['R'] = {'REPLACE', mode_colors.replace},
|
||||
['v'] = {'VISUAL', mode_colors.visual},
|
||||
['V'] = {'V-LINE', mode_colors.visual},
|
||||
['c'] = {'COMMAND', mode_colors.command},
|
||||
['s'] = {'SELECT', mode_colors.visual},
|
||||
['S'] = {'S-LINE', mode_colors.visual},
|
||||
['t'] = {'TERMINAL', mode_colors.terminal},
|
||||
[''] = {'V-BLOCK', mode_colors.visual},
|
||||
[''] = {'S-BLOCK', mode_colors.visual},
|
||||
['Rv'] = {'VIRTUAL'},
|
||||
['rm'] = {'--MORE'}
|
||||
}
|
||||
|
||||
local sep = {
|
||||
right_filled = u 'e0b2',
|
||||
left_filled = u 'e0b0',
|
||||
right = u 'e0b3',
|
||||
left = u 'e0b1'
|
||||
}
|
||||
|
||||
local icons = {
|
||||
locker = u 'f023',
|
||||
unsaved = u 'f693',
|
||||
lsp_warn = u 'f071',
|
||||
lsp_error = u 'f46e'
|
||||
}
|
||||
|
||||
local function mode_label() return mode_map[vim.fn.mode()][1] or 'N/A' end
|
||||
local function mode_hl() return mode_map[vim.fn.mode()][2] or '#ff0000' end
|
||||
|
||||
local function highlight(group, fg, bg, gui)
|
||||
local cmd = string.format('highlight %s guifg=%s guibg=%s', group, fg, bg)
|
||||
if gui ~= nil then cmd = cmd .. ' gui=' .. gui end
|
||||
vim.cmd(cmd)
|
||||
end
|
||||
|
||||
local function buffer_not_empty()
|
||||
if vim.fn.empty(vim.fn.expand '%:t') ~= 1 then return true end
|
||||
return false
|
||||
end
|
||||
|
||||
local function wide_enough()
|
||||
local squeeze_width = vim.fn.winwidth(0)
|
||||
if squeeze_width > 80 then return true end
|
||||
return false
|
||||
end
|
||||
|
||||
gl.short_line_list = {'NvimTree', 'vista', 'dbui'}
|
||||
|
||||
gls.left = {
|
||||
{
|
||||
ViMode = {
|
||||
provider = function()
|
||||
local modehl = mode_hl()
|
||||
highlight('GalaxyViMode', '000000', modehl, 'bold')
|
||||
highlight('GalaxyViModeInv', modehl, '000000', 'bold')
|
||||
return string.format(' %s ', mode_label())
|
||||
end,
|
||||
separator = sep.left_filled,
|
||||
separator_highlight = 'GalaxyViModeInv'
|
||||
}
|
||||
}, {
|
||||
FileName = {
|
||||
provider = function()
|
||||
if not buffer_not_empty() then return '' end
|
||||
local fname
|
||||
if wide_enough() then
|
||||
fname = vim.fn.fnamemodify(vim.fn.expand '%', ':~:.')
|
||||
else
|
||||
fname = vim.fn.expand '%:t'
|
||||
end
|
||||
if #fname == 0 then return '' end
|
||||
if vim.bo.readonly then
|
||||
fname = fname .. ' ' .. icons.locker
|
||||
end
|
||||
if vim.bo.modified then
|
||||
fname = fname .. ' ' .. icons.unsaved
|
||||
end
|
||||
return ' ' .. fname .. ' '
|
||||
end,
|
||||
highlight = 'Normal',
|
||||
separator = sep.left,
|
||||
separator_highlight = 'GalaxyViModeInv'
|
||||
}
|
||||
}, {
|
||||
-- I am unsure how lua specifies order in these, or are tables unordered?
|
||||
-- anyway, without the weird section in between add ALWAYS appears to the left
|
||||
-- of the Branch display
|
||||
DiffAdd = {
|
||||
provider = 'DiffAdd',
|
||||
condition = wide_enough,
|
||||
icon = '+',
|
||||
highlight = 'DiffAdded'
|
||||
},
|
||||
WithoutThisAddedComesBeforeBranch = {
|
||||
provider = function() return '' end
|
||||
},
|
||||
DiffModified = {
|
||||
provider = 'DiffModified',
|
||||
condition = wide_enough,
|
||||
icon = '~',
|
||||
highlight = 'DiffLine'
|
||||
},
|
||||
DiffRemove = {
|
||||
provider = 'DiffRemove',
|
||||
condition = wide_enough,
|
||||
icon = '-',
|
||||
highlight = 'DiffRemoved',
|
||||
separator = sep.left,
|
||||
separator_highlight = 'GalaxyViModeInv'
|
||||
},
|
||||
GitBranch = {
|
||||
provider = {
|
||||
function() return ' ' end, 'GitBranch',
|
||||
function() return ' ' end
|
||||
},
|
||||
condition = require('galaxyline.condition').check_git_workspace and
|
||||
wide_enough,
|
||||
highlight = 'NonText'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gls.right = {
|
||||
{
|
||||
LspStatus = {
|
||||
provider = function()
|
||||
local connected =
|
||||
not vim.tbl_isempty(vim.lsp.buf_get_clients(0))
|
||||
if connected then
|
||||
return ' ' .. u 'f817' .. ' '
|
||||
else
|
||||
return ''
|
||||
end
|
||||
end,
|
||||
highlight = 'DiffAdded',
|
||||
separator = sep.right,
|
||||
separator_highlight = 'GalaxyViModeInv'
|
||||
}
|
||||
}, {
|
||||
DiagnosticWarn = {
|
||||
provider = function()
|
||||
local n = vim.lsp.diagnostic.get_count(0, 'Warning')
|
||||
if n == 0 then return '' end
|
||||
return string.format(' %s %d ', icons.lsp_warn, n)
|
||||
end,
|
||||
highlight = 'LspDiagnosticsDefaultWarning'
|
||||
},
|
||||
DiagnosticError = {
|
||||
provider = function()
|
||||
local n = vim.lsp.diagnostic.get_count(0, 'Error')
|
||||
if n == 0 then return '' end
|
||||
return string.format(' %s %d ', icons.lsp_error, n)
|
||||
end,
|
||||
highlight = 'LspDiagnosticsDefaultError'
|
||||
}
|
||||
}, {
|
||||
FileIcon = {
|
||||
provider = function()
|
||||
local fname, ext = vim.fn.expand '%:t', vim.fn.expand '%:e'
|
||||
local icon, _ = devicons.get_icon(fname, ext)
|
||||
if icon == nil then return '' end
|
||||
return ' ' .. icon .. ' '
|
||||
end,
|
||||
separator = sep.right,
|
||||
highlight = 'Normal',
|
||||
separator_highlight = 'GalaxyViModeInv'
|
||||
},
|
||||
FileType = {
|
||||
provider = function()
|
||||
-- if not buffer_not_empty() then
|
||||
-- return ''
|
||||
-- end
|
||||
return string.format(' %s ', vim.bo.filetype)
|
||||
end,
|
||||
-- condition = buffer_not_empty,
|
||||
highlight = 'Normal'
|
||||
}
|
||||
}, {
|
||||
PositionInfo = {
|
||||
provider = {
|
||||
function()
|
||||
return string.format('%s:%s', vim.fn.line('.'),
|
||||
vim.fn.col('.'))
|
||||
end
|
||||
},
|
||||
highlight = 'GalaxyViMode',
|
||||
separator = sep.right_filled,
|
||||
separator_highlight = 'GalaxyViModeInv'
|
||||
},
|
||||
PercentInfo = {
|
||||
provider = fileinfo.current_line_percent,
|
||||
highlight = 'GalaxyViMode',
|
||||
separator = sep.right,
|
||||
separator_highlight = 'GalaxyViMode'
|
||||
}
|
||||
}
|
||||
}
|
||||
for k, v in pairs(gls.left) do gls.short_line_left[k] = v end
|
||||
table.remove(gls.short_line_left, 1)
|
||||
|
||||
for k, v in pairs(gls.right) do gls.short_line_right[k] = v end
|
||||
table.remove(gls.short_line_right)
|
||||
table.remove(gls.short_line_right)
|
28
nvim/.config/nvim/lua/plug/_lualine.lua
Normal file
28
nvim/.config/nvim/lua/plug/_lualine.lua
Normal file
|
@ -0,0 +1,28 @@
|
|||
require('lualine').setup {
|
||||
options = {
|
||||
icons_enabled = true,
|
||||
theme = 'auto',
|
||||
component_separators = {left = '', right = ''},
|
||||
section_separators = {left = '', right = ''},
|
||||
disabled_filetypes = {},
|
||||
always_divide_middle = true
|
||||
},
|
||||
sections = {
|
||||
lualine_a = {'mode'},
|
||||
lualine_b = {'branch', 'diff', 'diagnostics'},
|
||||
lualine_c = {'filename'},
|
||||
lualine_x = {'encoding', 'fileformat', 'filetype'},
|
||||
lualine_y = {'progress', 'location'},
|
||||
lualine_z = {'hostname'}
|
||||
},
|
||||
inactive_sections = {
|
||||
lualine_a = {},
|
||||
lualine_b = {'branch', 'diff'},
|
||||
lualine_c = {'filename'},
|
||||
lualine_x = {},
|
||||
lualine_y = {'location'},
|
||||
lualine_z = {}
|
||||
},
|
||||
tabline = {},
|
||||
extensions = {'quickfix', 'toggleterm'}
|
||||
}
|
|
@ -36,12 +36,11 @@ require("packer").startup(function()
|
|||
'lewis6991/gitsigns.nvim', -- show vcs changes on left-hand gutter
|
||||
requires = {'nvim-lua/plenary.nvim'},
|
||||
tag = 'release',
|
||||
config = function() require('gitsigns').setup{
|
||||
keymaps = {
|
||||
['n ]c'] = nil,
|
||||
['n [c'] = nil,
|
||||
config = function()
|
||||
require('gitsigns').setup {
|
||||
keymaps = {['n ]c'] = nil, ['n [c'] = nil}
|
||||
}
|
||||
} end,
|
||||
end,
|
||||
event = "BufRead"
|
||||
}
|
||||
use {
|
||||
|
@ -101,9 +100,9 @@ require("packer").startup(function()
|
|||
|
||||
-- statusline
|
||||
use {
|
||||
'glepnir/galaxyline.nvim',
|
||||
'nvim-lualine/lualine.nvim',
|
||||
requires = {'kyazdani42/nvim-web-devicons', opt = true},
|
||||
config = function() require('plug._galaxyline') end
|
||||
config = function() require('plug._lualine') end
|
||||
}
|
||||
|
||||
-- writing
|
||||
|
@ -116,7 +115,7 @@ require("packer").startup(function()
|
|||
require("true-zen").setup({
|
||||
integrations = {
|
||||
gitsigns = true,
|
||||
galaxyline = true,
|
||||
lualine = true,
|
||||
tmux = {global = false},
|
||||
limelight = true
|
||||
}
|
||||
|
@ -135,17 +134,21 @@ require("packer").startup(function()
|
|||
ft = "python",
|
||||
config = function()
|
||||
vim.g.slime_target = 'tmux'
|
||||
vim.g.slime_default_config = {socket_name = "default", target_pane = "{last}"}
|
||||
vim.g.slime_default_config = {
|
||||
socket_name = "default",
|
||||
target_pane = "{last}"
|
||||
}
|
||||
vim.g.slime_python_ipython = 1
|
||||
vim.g.slime_no_mappings = 1
|
||||
end,
|
||||
end
|
||||
}
|
||||
use { 'hanschen/vim-ipython-cell', -- send code 'cells' to REPL
|
||||
use {
|
||||
'hanschen/vim-ipython-cell', -- send code 'cells' to REPL
|
||||
ft = "python",
|
||||
config = function()
|
||||
vim.g.ipython_cell_highlight_cells_ft = {'python'}
|
||||
vim.g.ipython_cell_insert_tag = "## Cell"
|
||||
end,
|
||||
end
|
||||
}
|
||||
|
||||
--
|
||||
|
|
Loading…
Reference in a new issue