nvim: statusline (lualine) has been made

This commit is contained in:
PowerUser64 2021-12-26 16:18:33 -08:00
parent ee7de5f557
commit 75c3986785
4 changed files with 312 additions and 19 deletions

View file

@ -7,10 +7,8 @@ require('blake.settings')
-- TODO: -- TODO:
-- Plugins to install: -- Plugins to install:
-- status line
-- lightspeed.nvim -- lightspeed.nvim
-- lightbulb? -- lightbulb?
-- shade.nvim
-- telescope -- telescope
-- - trouble.nvim -- - trouble.nvim

View file

@ -189,6 +189,233 @@ M.autosession = function()
vim.cmd 'command! SessionRestore RestoreSession' vim.cmd 'command! SessionRestore RestoreSession'
end -- <<< end -- <<<
-- Lualine >>>
M.lualine = function()
-- From https://github.com/nvim-lualine/lualine.nvim/blob/master/examples/evil_lualine.lua
-- Eviline config for lualine
-- Author: shadmansaleh
-- Credit: glepnir
-- Example:
-- ▊  20.2k .zshrc 320:1 56%  LSP: bashls UTF-8 UNIX ▊
local lualine = require 'lualine'
-- Color table for highlights
-- stylua: ignore
local colors = {
bg = '#21242B',
fg = '#bbc2cf',
yellow = '#ECBE7B',
cyan = '#008080',
darkblue = '#081633',
green = '#98be65',
orange = '#FF8800',
violet = '#a9a1e1',
magenta = '#c678dd',
blue = '#51afef',
red = '#ec5f67',
}
local conditions = {
buffer_not_empty = function()
return vim.fn.empty(vim.fn.expand '%:t') ~= 1
end,
hide_in_width = function()
return vim.fn.winwidth(0) > 80
end,
check_git_workspace = function()
local filepath = vim.fn.expand '%:p:h'
local gitdir = vim.fn.finddir('.git', filepath .. ';')
return gitdir and #gitdir > 0 and #gitdir < #filepath
end,
}
-- Config
local config = {
options = {
-- Disable sections and component separators
component_separators = '',
section_separators = '',
theme = {
-- We are going to use lualine_c an lualine_x as left and
-- right section. Both are highlighted by c theme . So we
-- are just setting default looks o statusline
normal = { c = { fg = colors.fg, bg = colors.bg } },
inactive = { c = { fg = colors.fg, bg = colors.bg } },
},
},
sections = {
-- these are to remove the defaults
lualine_a = {},
lualine_b = {},
lualine_y = {},
lualine_z = {},
-- These will be filled later
lualine_c = {},
lualine_x = {},
},
inactive_sections = {
-- these are to remove the defaults
lualine_a = {},
lualine_b = {},
lualine_y = {},
lualine_z = {},
lualine_c = {},
lualine_x = {},
},
}
-- Inserts a component in lualine_c at left section
local function ins_left(component)
table.insert(config.sections.lualine_c, component)
end
-- Inserts a component in lualine_x ot right section
local function ins_right(component)
table.insert(config.sections.lualine_x, component)
end
ins_left {
function()
return ''
end,
color = { fg = colors.blue }, -- Sets highlighting of component
padding = { left = 0, right = 1 }, -- We don't need space before this
}
ins_left {
-- mode component
function()
-- auto change color according to neovims mode
local mode_color = {
n = colors.green,
i = colors.blue,
v = colors.magenta,
[''] = colors.magenta,
V = colors.magenta,
c = colors.violet,
no = colors.green,
s = colors.orange,
S = colors.orange,
[''] = colors.orange,
ic = colors.yellow,
R = colors.red,
Rv = colors.red,
cv = colors.green,
ce = colors.green,
r = colors.cyan,
rm = colors.cyan,
['r?'] = colors.cyan,
['!'] = colors.green,
t = colors.green,
}
vim.api.nvim_command('hi! LualineMode guifg=' .. mode_color[vim.fn.mode()] .. ' guibg=' .. colors.bg)
return ''
end,
color = 'LualineMode',
padding = { right = 1 },
}
ins_left {
-- filesize component
'filesize',
cond = conditions.buffer_not_empty,
}
ins_left {
'filename',
cond = conditions.buffer_not_empty,
color = { fg = colors.magenta, gui = 'bold' },
}
ins_left { 'location' }
ins_left { 'progress', color = { fg = colors.fg, gui = 'bold' } }
ins_left {
'diagnostics',
sources = { 'nvim_diagnostic' },
symbols = { error = '', warn = '', info = '' },
diagnostics_color = {
color_error = { fg = colors.red },
color_warn = { fg = colors.yellow },
color_info = { fg = colors.cyan },
},
}
-- Insert mid section. You can make any number of sections in neovim :)
-- for lualine it's any number greater then 2
ins_left {
function()
return '%='
end,
}
ins_left {
-- Lsp server name .
function()
local msg = 'No Active Lsp'
local buf_ft = vim.api.nvim_buf_get_option(0, 'filetype')
local clients = vim.lsp.get_active_clients()
if next(clients) == nil then
return msg
end
for _, client in ipairs(clients) do
local filetypes = client.config.filetypes
if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then
return client.name
end
end
return msg
end,
icon = ' LSP:',
color = { fg = '#ffffff', gui = 'bold' },
}
-- Add components to right sections
ins_right {
'o:encoding', -- option component same as &encoding in viml
fmt = string.upper, -- I'm not sure why it's upper case either ;)
cond = conditions.hide_in_width,
color = { fg = colors.green, gui = 'bold' },
}
ins_right {
'fileformat',
fmt = string.upper,
icons_enabled = false, -- I think icons are cool but Eviline doesn't have them. sigh
color = { fg = colors.green, gui = 'bold' },
}
ins_right {
'branch',
icon = '',
color = { fg = colors.violet, gui = 'bold' },
}
ins_right {
'diff',
-- Is it me or the symbol for modified us really weird
symbols = { added = '', modified = '', removed = '' },
diff_color = {
added = { fg = colors.green },
modified = { fg = colors.orange },
removed = { fg = colors.red },
},
cond = conditions.hide_in_width,
}
ins_right {
function()
return ''
end,
color = { fg = colors.blue },
padding = { left = 1 },
}
-- Now don't forget to initialize lualine
lualine.setup(config)
end -- <<<
return M return M
-- vim:fdm=marker:fmr=>>>,<<<:expandtab:tabstop=3:sw=3 -- vim:fdm=marker:fmr=>>>,<<<:expandtab:tabstop=3:sw=3

View file

@ -41,7 +41,32 @@ return require('packer').startup({function()
'navarasu/onedark.nvim', 'navarasu/onedark.nvim',
config = function() config = function()
-- vim.g.onedark_transparent_background = true -- vim.g.onedark_transparent_background = true
require('onedark').setup() vim.cmd [[
au ColorScheme onedark hi TabLine gui=none guibg='#282C34' guifg='#5C6370' " all tabs color
au ColorScheme onedark hi TabLineSel guibg='#282C34' guifg='#B5BBC7' " Highlighted tab color
au ColorScheme onedark hi TabLineFill guibg='#282C34' " tabline portion without tabs (right-hand side)
colorscheme onedark
]]
end
}
use { -- statusline: lualine
'nvim-lualine/lualine.nvim',
requires = {'kyazdani42/nvim-web-devicons', opt = true},
config = function()
require('blake.other').lualine()
end,
}
use { -- tabline
'alvarosevilla95/luatab.nvim',
requires = 'kyazdani42/nvim-web-devicons',
config = function()
-- vim.cmd [[
-- exec('au ColorScheme gruvbox hi TabLine gui=none guibg=' . $color01 . ' guifg=' . $color03)
-- exec('au ColorScheme gruvbox hi TabLineSel guibg=' . $color01 . ' guifg=' . $color06)
-- exec('au ColorScheme gruvbox hi TabLineFill guibg=' . $color01)
-- ]]
require('luatab').setup {}
end end
} }
use { -- css color tag highlighter (ex: #FFB13B) use { -- css color tag highlighter (ex: #FFB13B)
@ -50,9 +75,6 @@ return require('packer').startup({function()
vim.cmd 'command! COL ColorizerToggle' vim.cmd 'command! COL ColorizerToggle'
end, end,
} }
use { -- tabline
'alvarosevilla95/luatab.nvim'
}
-- IDE features -- IDE features
---- LSP (document analysis) ---- LSP (document analysis)
@ -66,6 +88,18 @@ return require('packer').startup({function()
require('blake.lsp').lspconfig() require('blake.lsp').lspconfig()
end end
} }
use { -- commentstring based on context from treesitter
'JoosepAlviste/nvim-ts-context-commentstring',
requires = 'nvim-treesitter/nvim-treesitter',
config = function()
require'nvim-treesitter.configs'.setup {
context_commentstring = {
enable = true,
enable_autocmd = false,
}
}
end,
}
use { -- compe use { -- compe
'hrsh7th/nvim-cmp', 'hrsh7th/nvim-cmp',
config = function() config = function()
@ -141,13 +175,13 @@ return require('packer').startup({function()
require('blake.other').gitsigns() require('blake.other').gitsigns()
end, end,
} }
use { -- file manager -- use { -- file manager
'kyazdani42/nvim-tree.lua', -- 'kyazdani42/nvim-tree.lua',
requires = 'kyazdani42/nvim-web-devicons', -- requires = 'kyazdani42/nvim-web-devicons',
config = function() -- config = function()
require('blake.other').nvimtree() -- require('blake.other').nvimtree()
end -- end
} -- }
use { -- terminal use { -- terminal
'akinsho/toggleterm.nvim', 'akinsho/toggleterm.nvim',
config = function() config = function()
@ -218,6 +252,20 @@ return require('packer').startup({function()
vim.api.nvim_set_keymap('n', '<F5>', '<cmd>UndotreeToggle<CR>', { noremap = true, silent = true, }) vim.api.nvim_set_keymap('n', '<F5>', '<cmd>UndotreeToggle<CR>', { noremap = true, silent = true, })
end end
} }
-- use { -- Dim inactive window
-- 'sunjon/shade.nvim',
-- config = function()
-- require'shade'.setup({
-- overlay_opacity = 50,
-- opacity_step = 1,
-- keys = {
-- brightness_up = '<C-Up>',
-- brightness_down = '<C-Down>',
-- toggle = '<Leader>s',
-- }
-- })
-- end
-- }
use { -- Quote pairing use { -- Quote pairing
'windwp/nvim-autopairs', 'windwp/nvim-autopairs',
config = function() config = function()
@ -230,12 +278,28 @@ return require('packer').startup({function()
use { -- cheat.sh integration use { -- cheat.sh integration
'dbeniamine/cheat.sh-vim', 'dbeniamine/cheat.sh-vim',
} }
use { -- Comments (gb and gc) -- use { -- Comments (gb and gc)
'numToStr/Comment.nvim', -- 'numToStr/Comment.nvim',
config = function() -- config = function()
require('Comment').setup() -- require('Comment').setup {
end -- pre_hook = function(ctx)
} -- local U = require 'Comment.utils'
--
-- local location = nil
-- if ctx.ctype == U.ctype.block then
-- location = require('ts_context_commentstring.utils').get_cursor_location()
-- elseif ctx.cmotion == U.cmotion.v or ctx.cmotion == U.cmotion.V then
-- location = require('ts_context_commentstring.utils').get_visual_start_location()
-- end
--
-- return require('ts_context_commentstring.internal').calculate_commentstring {
-- key = ctx.ctype == U.ctype.line and '__default' or '__multiline',
-- location = location,
-- }
-- end,
-- }
-- end
-- }
-- use { -- lewis6991: spellsitter: Spell checking in treesitter files -- use { -- lewis6991: spellsitter: Spell checking in treesitter files
-- 'lewis6991/spellsitter.nvim', -- 'lewis6991/spellsitter.nvim',
-- config = function() -- config = function()
@ -254,6 +318,9 @@ return require('packer').startup({function()
require('foldsigns').setup() require('foldsigns').setup()
end, end,
} }
use { -- tpope: commentary
'tpope/vim-commentary',
}
use { -- tpope: surround use { -- tpope: surround
'tpope/vim-surround' 'tpope/vim-surround'
} }

View file

@ -16,6 +16,7 @@ set.hidden = true
set.backspace = 'indent,eol,start' set.backspace = 'indent,eol,start'
set.ignorecase = true set.ignorecase = true
set.smartcase = true set.smartcase = true
set.showmode = false
set.wrap = false set.wrap = false
set.linebreak = true set.linebreak = true
set.redrawtime = 200 set.redrawtime = 200