neovim: add galaxyline, ditch nord theme

This commit is contained in:
FollieHiyuki 2021-07-04 22:03:20 +03:00
parent 64cc5e1f00
commit 474d27ec30
No known key found for this signature in database
GPG Key ID: 813CF484F4993419
10 changed files with 521 additions and 153 deletions

View File

@ -26,10 +26,15 @@ local leader_map = function()
end
local load_core = function()
-- Global theme
vim.g.global_theme = 'nord'
-- Config
require('options')
disable_distribution_plugins()
leader_map()
require('plugins')
require('colors.' .. vim.g.global_theme).highlight()
require('events').load_autocmds()
end

View File

@ -0,0 +1,45 @@
local api = vim.api
local M = {}
local function hi(group, guifg, guibg, attr, guisp)
if guifg ~= '' then
api.nvim_command('hi ' .. group .. ' guifg=' .. guifg)
end
if guibg ~= '' then
api.nvim_command('hi ' .. group .. ' guibg=' .. guibg)
end
if attr ~= '' then
api.nvim_command('hi ' .. group .. ' gui=' .. attr)
end
if guisp ~= '' then
api.nvim_command('hi ' .. group .. ' guisp=' .. guisp)
end
end
M.colors = {
black = '#2E3440',
grey1 = '#3B4252',
grey2 = '#434C5E',
grey3 = '#4C566A',
grey_bright = '#616E88',
fg = '#D8DEE9',
white1 = '#E5E9F0',
white2 = '#ECEFF4',
teal = '#8FBCBB',
cyan = '#88C0D0',
blue = '#81A1C1',
dark_blue = '#5E81AC',
red = '#BF616A',
orange = '#D08770',
yellow = '#EBCB8B',
green = '#A3BE8C',
purple = '#B48EAD',
highlight = '#7B88A1',
none = 'NONE'
}
function M.highlight()
hi('ModeMsg', M.colors.blue, '', '', '')
end
return M

View File

@ -0,0 +1,46 @@
local api = vim.api
local M = {}
local function hi(group, guifg, guibg, attr, guisp)
if guifg ~= '' then
api.nvim_command('hi ' .. group .. ' guifg=' .. guifg)
end
if guibg ~= '' then
api.nvim_command('hi ' .. group .. ' guibg=' .. guibg)
end
if attr ~= '' then
api.nvim_command('hi ' .. group .. ' gui=' .. attr)
end
if guisp ~= '' then
api.nvim_command('hi ' .. group .. ' guisp=' .. guisp)
end
end
M.colors = {
black = '#282C34',
grey1 = '#3E4452',
grey2 = '#4B5263',
grey3 = '#5C6470',
grey_bright = '#73797E',
fg = '#ABB2BF',
white1 = '#BBC2CF',
white2 = '#DFDFDF',
teal = '#5699AF',
cyan = '#56B6C2',
blue = '#61AFEF',
dark_blue = '#2257A0',
red = '#E06C75',
dark_red = '#BE5046',
orange = '#D19A66',
yellow = '#E5C07B',
green = '#98C379',
purple = '#C678DD',
highlight = '#9CA0A4',
none = 'NONE'
}
function M.highlight()
hi('ModeMsg', M.colors.blue, '', '', '')
end
return M

View File

@ -9,54 +9,64 @@ function M.packer_compile()
end
function M.nvim_create_augroups(definitions)
for group_name, definition in pairs(definitions) do
vim.api.nvim_command('augroup '..group_name)
vim.api.nvim_command('autocmd!')
for _, def in ipairs(definition) do
local command = table.concat(vim.tbl_flatten{'autocmd', def}, ' ')
vim.api.nvim_command(command)
for group_name, definition in pairs(definitions) do
vim.api.nvim_command('augroup ' .. group_name)
vim.api.nvim_command('autocmd!')
for _, def in ipairs(definition) do
local command = table.concat(vim.tbl_flatten{'autocmd', def}, ' ')
vim.api.nvim_command(command)
end
vim.api.nvim_command('augroup END')
end
vim.api.nvim_command('augroup END')
end
end
function M.load_autocmds()
local definitions = {
packer = {
{"BufWritePost", "*.lua", "lua require('events').packer_compile()"};
};
{"BufWritePost", "*.lua", "lua require('events').packer_compile()"}
},
-- Edit binary files in hex with xxd (:%!xxd and :%!xxd -r)
-- or using nvim -b to edit files using xxd-format
binary = {
{"BufReadPre" , "*.bin,*.exe", "let &bin=1"};
{"BufReadPost" , "*.bin,*.exe", "if &bin | %!xxd"};
{"BufReadPost" , "*.bin,*.exe", "set ft=xxd | endif"};
{"BufWritePre" , "*.bin,*.exe", "if &bin | %!xxd -r"};
{"BufWritePre" , "*.bin,*.exe", "endif"};
{"BufWritePost", "*.bin,*.exe", "if &bin | %!xxd"};
{"BufWritePost", "*.bin,*.exe", "set nomod | endif"};
};
{"BufReadPre" , "*.bin,*.exe", "let &bin=1"},
{"BufReadPost" , "*.bin,*.exe", "if &bin | %!xxd"},
{"BufReadPost" , "*.bin,*.exe", "set ft=xxd | endif"},
{"BufWritePre" , "*.bin,*.exe", "if &bin | %!xxd -r"},
{"BufWritePre" , "*.bin,*.exe", "endif"},
{"BufWritePost", "*.bin,*.exe", "if &bin | %!xxd"},
{"BufWritePost", "*.bin,*.exe", "set nomod | endif"}
},
document = {
{"BufNewFile,BufEnter,BufRead", "*.md,*.mkd", "setfiletype markdown"};
{"BufNewFile,BufEnter,BufRead", "*.tex", "setfiletype tex"};
{"BufNewFile,BufRead", "*.md,*.mkd", "setlocal spell"};
{"BufNewFile,BufRead", "*.tex", "setlocal spell"};
};
buf = {
-- Auto-spelling in doc files
{"BufNewFile,BufRead", "*.md,*.mkd", "setlocal spell"},
{"BufNewFile,BufRead", "*.tex", "setlocal spell"},
-- Auto-hide numbers, statusline in specific buffers
{"BufEnter", "term://*", "setlocal norelativenumber nonumber"},
{"BufEnter", "term://*", "set laststatus=0"},
{"BufEnter,BufWinEnter,WinEnter,CmdwinEnter", "*", [[if bufname('%') == "NvimTree" | set laststatus=0 | else | set laststatus=2 | endif]]}
},
wins = {
-- Equalize window dimensions when resizing vim window
{"VimResized", "*", [[tabdo wincmd =]]};
-- Force write shada on leaving nvim
{"VimLeave", "*", [[if has('nvim') | wshada! | else | wviminfo! | endif]]};
{"VimResized", "*", [[tabdo wincmd =]]},
-- Force writing shada on leaving nvim
{"VimLeave", "*", [[if has('nvim') | wshada! | else | wviminfo! | endif]]},
-- Check if file changed when its window is focus, more eager than 'autoread'
{"FocusGained", "* checktime"};
};
{"FocusGained", "* checktime"}
},
ft = {
{"FileType", "dashboard", "set showtabline=0 | autocmd WinLeave <buffer> set showtabline=2"},
{"BufNewFile,BufRead", "*.md,*.mkd", "setfiletype markdown"},
{"BufNewFile,BufRead", "*.toml", "setfiletype toml"},
{"BufNewFile,BufRead", "*.tex", "setfiletype tex"}
},
yank = {
{"TextYankPost", [[* silent! lua vim.highlight.on_yank({higroup="IncSearch", timeout=300})]]};
};
{"TextYankPost", [[* silent! lua vim.highlight.on_yank({higroup="IncSearch", timeout=300})]]}
}
}
M.nvim_create_augroups(definitions)

View File

@ -0,0 +1,13 @@
return require('colorizer').setup(
{'*';},
{
RGB = true; -- #RGB hex codes
RRGGBB = true; -- #RRGGBB hex codes
names = true; -- "Name" codes like Blue
RRGGBBAA = true; -- #RRGGBBAA hex codes
rgb_fn = true; -- CSS rgb() and rgba() functions
hsl_fn = true; -- CSS hsl() and hsla() functions
css = true; -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB
css_fn = true; -- Enable all CSS *functions*: rgb_fn, hsl_fn
mode = 'background'; -- Set the display mode.
})

View File

@ -0,0 +1,34 @@
local function dashboard_options()
-- vim.g.dashboard_disable_at_vimenter = 1
-- vim.g.dashboard_disable_statusline = 1
vim.g.dashboard_preview_file_height = 12
vim.g.dashboard_preview_file_width = 80
vim.g.dashboard_default_executive = 'telescope'
vim.g.dashboard_session_directory = vim.fn.stdpath('data') .. '/sessions'
vim.g.dashboard_custom_section = {
a = {description = {' Find File SPC f f'}, command = 'Telescope find_files'},
b = {description = {' Recents SPC f o'}, command = 'Telescope oldfiles'},
c = {description = {' Find Word SPC f w'}, command = 'Telescope live_grep'},
d = {description = {'洛 New File SPC f n'}, command = 'DashboardNewFile'},
e = {description = {' Bookmarks SPC b m'}, command = 'Telescope marks'},
f = {description = {' Load Last Session SPC s l'}, command = 'SessionLoad'}
}
vim.g.dashboard_custom_header = {
" ",
" ",
" ",
"<-. (`-')_ (`-') _ (`-') _ <-. (`-') ",
" \\( OO) ) ( OO).-/ .-> _(OO ) (_) \\(OO )_ ",
",--./ ,--/ (,------.(`-')----. ,--.(_/,-.\\ ,-(`-'),--./ ,-.)",
"| \\ | | | .---'( OO).-. '\\ \\ / (_/ | ( OO)| `.' |",
"| . '| |)(| '--. ( _) | | | \\ / / | | )| |'.'| |",
"| |\\ | | .--' \\| |)| |_ \\ /_)(| |_/ | | | |",
"| | \\ | | `---. ' '-' '\\-'\\ / | |'->| | | |",
"`--' `--' `------' `-----' `-' `--' `--' `--'",
}
vim.g.dashboard_custom_footer = {
'おかえりなさい'
}
end
dashboard_options()

View File

@ -1,10 +0,0 @@
local function nord_options()
vim.g.nord_contrast = true
vim.g.nord_borders = true
vim.g.nord_disable_background = false
vim.g.nord_cursorline_transparent = false
require('nord').set()
end
nord_options()

View File

@ -0,0 +1,225 @@
local gl = require('galaxyline')
local gls = gl.section
local condition = require('galaxyline.condition')
gl.short_line_list = {'NvimTree', 'packer'}
local colors = require('colors.' .. vim.g.global_theme).colors
gls.left[1] = {
LeftCorner = {
provider = function()
return ''
end,
highlight = {colors.blue, colors.grey1}
}
}
gls.left[2] = {
ViMode = {
provider = function()
local mode_color = {
n = colors.green, -- Normal
no = colors.green, -- N-Pending
i = colors.blue, -- Insert
ic = colors.blue, -- Insert
v = colors.yellow, -- Visual
[''] = colors.yellow, -- V-Block
V = colors.yellow, -- V-Line
c = colors.white2, -- Command
s = colors.purple, -- Select
S = colors.purple, -- S-Line
[''] = colors.purple, -- S-Block
R = colors.red, -- Replace
Rv = colors.red, -- V-Replace
cv = colors.white2, -- Vim-Ex
ce = colors.white2, -- Ex
r = colors.cyan, -- Prompt
rm = colors.cyan, -- More
['r?'] = colors.cyan, -- Confirm
['!'] = colors.orange, -- Shell
t = colors.orange -- Terminal
}
vim.api.nvim_command('hi GalaxyViMode guifg=' .. mode_color[vim.fn.mode()])
return ''
end,
highlight = {colors.green, colors.grey1}
}
}
gls.left[3] = {
FileSize = {
provider = 'FileSize',
condition = condition.buffer_not_empty,
highlight = {colors.fg, colors.grey1}
}
}
gls.left[4] ={
FileIcon = {
provider = 'FileIcon',
condition = condition.buffer_not_empty,
highlight = {
require('galaxyline.provider_fileinfo').get_file_icon_color,
colors.grey1
}
}
}
gls.left[5] = {
FileName = {
provider = 'FileName',
condition = condition.buffer_not_empty,
highlight = {colors.fg, colors.grey1, 'bold'}
}
}
gls.left[6] = {
LineInfo = {
provider = 'LineColumn',
highlight = {colors.fg, colors.grey1}
}
}
gls.left[7] = {
PerCent = {
provider = 'LinePercent',
highlight = {colors.fg, colors.grey1, 'bold'}
}
}
gls.left[8] = {
DiagnosticError = {
provider = 'DiagnosticError',
icon = '',
highlight = {colors.red, colors.grey1}
}
}
gls.left[9] = {
DiagnosticWarn = {
provider = 'DiagnosticWarn',
icon = '',
highlight = {colors.yellow, colors.grey1}
}
}
gls.left[10] = {
DiagnosticHint = {
provider = 'DiagnosticHint',
icon = '',
highlight = {colors.cyan, colors.grey1}
}
}
gls.left[11] = {
DiagnosticInfo = {
provider = 'DiagnosticInfo',
icon = '',
highlight = {colors.blue, colors.grey1}
}
}
gls.right[1] = {
ShowLspClient = {
provider = 'GetLspClient',
condition = function ()
local tbl = {['dashboard'] = true, [''] = true}
if tbl[vim.bo.filetype] then
return false
end
return true
end,
icon = ' LSP:',
highlight = {colors.purple, colors.grey1, 'bold'}
}
}
gls.right[2] = {
FileEncode = {
provider = 'FileEncode',
condition = condition.hide_in_width,
separator = ' ',
separator_highlight = {'NONE', colors.grey1},
highlight = {colors.fg, colors.grey1}
}
}
gls.right[3] = {
FileFormat = {
provider = 'FileFormat',
condition = condition.hide_in_width,
separator = ' ',
separator_highlight = {'NONE', colors.grey1},
highlight = {colors.fg, colors.grey1}
}
}
gls.right[4] = {
GitIcon = {
provider = function() return '' end,
condition = condition.check_git_workspace,
separator = ' ',
separator_highlight = {'NONE', colors.grey1},
highlight = {colors.green, colors.grey1, 'bold'}
}
}
gls.right[5] = {
GitBranch = {
provider = 'GitBranch',
condition = condition.check_git_workspace,
highlight = {colors.green, colors.grey1, 'bold'}
}
}
gls.right[6] = {
DiffAdd = {
provider = 'DiffAdd',
condition = condition.hide_in_width,
icon = '',
highlight = {colors.green, colors.grey1}
}
}
gls.right[7] = {
DiffModified = {
provider = 'DiffModified',
condition = condition.hide_in_width,
icon = '',
highlight = {colors.yellow, colors.grey1}
}
}
gls.right[8] = {
DiffRemove = {
provider = 'DiffRemove',
condition = condition.hide_in_width,
icon = '',
highlight = {colors.red, colors.grey1}
}
}
gls.short_line_left[1] = {
BufferType = {
provider = 'FileTypeName',
separator = ' ',
separator_highlight = {'NONE', colors.grey1},
highlight = {colors.blue, colors.grey1, 'bold'}
}
}
gls.short_line_left[2] = {
SFileName = {
provider = 'SFileName',
condition = condition.buffer_not_empty,
highlight = {colors.fg, colors.grey1, 'bold'}
}
}
gls.short_line_right[1] = {
BufferIcon = {
provider= 'BufferIcon',
highlight = {colors.fg, colors.grey1}
}
}

View File

@ -1,126 +1,130 @@
local opt = vim.opt
local function load_options()
vim.cmd('filetype indent plugin on')
vim.cmd('syntax on')
vim.cmd('set iskeyword+=-')
-- General settings
opt.termguicolors = true;
-- opt.background = 'dark';
opt.mouse = 'nv';
opt.errorbells = false;
opt.visualbell = false;
opt.hidden = true;
opt.fileformats = 'unix';
opt.magic = true;
opt.virtualedit = 'block';
opt.encoding = 'utf-8';
opt.fileencoding = 'utf-8';
opt.clipboard = 'unnamedplus';
opt.wildignorecase = true;
opt.wildignore = '.git,.hg,.svn,*.pyc,*.o,*.out,*.jpg,*.jpeg,*.png,*.gif,*.zip,**/tmp/**,*.DS_Store,**/node_modules/**';
opt.history = 1000;
opt.showmode = false;
opt.jumpoptions = 'stack';
opt.formatoptions = '1jcroql';
opt.shortmess = 'aoOTIcF';
opt.startofline = false;
opt.wrap = false;
opt.sidescrolloff = 4;
opt.scrolloff = 4;
opt.whichwrap = '<,>,[,],~';
opt.ruler = true;
opt.display = 'lastline';
-- opt.colorcolumn = '80';
-- opt.cursorline = true;
-- opt.backspace = 'indent,eol,start';
opt.showcmd = false;
opt.cmdheight = 2;
opt.cmdwinheight = 6;
opt.showtabline = 2;
opt.laststatus = 2;
opt.textwidth = 80;
opt.synmaxcol = 2500;
-- opt.shell = 'bash';
opt.grepformat = '%f:%l:%c:%m';
opt.grepprg = 'rg --hidden --vimgrep --smart-case --';
opt.diffopt = 'filler,iwhite,internal,algorithm:patience';
opt.termguicolors = true
-- opt.background = 'dark'
opt.mouse = 'nv'
opt.errorbells = false
opt.visualbell = false
opt.hidden = true
opt.fileformats = 'unix'
opt.magic = true
opt.virtualedit = 'block'
opt.encoding = 'utf-8'
opt.fileencoding = 'utf-8'
opt.clipboard = 'unnamedplus'
opt.wildignorecase = true
opt.wildignore = '.git,.hg,.svn,*.pyc,*.o,*.out,*.jpg,*.jpeg,*.png,*.gif,*.zip,**/tmp/**,*.DS_Store,**/node_modules/**'
opt.history = 1000
-- opt.showmode = false
opt.jumpoptions = 'stack'
opt.formatoptions = '1jcroql'
opt.shortmess = 'aoOTIcF'
opt.startofline = false
opt.wrap = false
opt.sidescrolloff = 4
opt.scrolloff = 4
opt.whichwrap = '<,>,[,],~'
opt.ruler = true
opt.display = 'lastline'
-- opt.colorcolumn = '80'
-- opt.cursorline = true
-- opt.backspace = 'indent,eol,start'
opt.showcmd = false
-- opt.cmdheight = 2
-- opt.cmdwinheight = 6
opt.showtabline = 2
opt.laststatus = 2
opt.textwidth = 80
opt.synmaxcol = 2500
-- opt.shell = 'bash'
opt.grepformat = '%f:%l:%c:%m'
opt.grepprg = 'rg --hidden --vimgrep --smart-case --'
opt.diffopt = 'filler,iwhite,internal,algorithm:patience'
-- Transparency
opt.pumblend = 10;
opt.winblend = 10;
opt.pumblend = 5
opt.winblend = 5
-- Conceal
opt.conceallevel = 2;
opt.concealcursor = 'niv';
-- opt.foldenable = true;
opt.foldlevelstart = 99;
opt.conceallevel = 2
opt.concealcursor = 'niv'
-- opt.foldenable = true
opt.foldlevelstart = 99
-- Case insensitive
opt.ignorecase = true;
opt.smartcase = true;
opt.infercase = true;
opt.ignorecase = true
opt.smartcase = true
opt.infercase = true
-- Searching
opt.incsearch = true;
opt.hlsearch = false;
-- opt.wrapscan = true;
opt.incsearch = true
opt.hlsearch = false
-- opt.wrapscan = true
-- Update time
opt.timeout = true;
opt.ttimeout = true;
opt.timeoutlen = 300;
opt.ttimeoutlen = 10;
opt.updatetime = 150;
opt.redrawtime = 1500;
opt.timeout = true
opt.ttimeout = true
opt.timeoutlen = 300
opt.ttimeoutlen = 10
opt.updatetime = 150
opt.redrawtime = 1500
-- No swapfile
opt.backup = false;
opt.writebackup = false;
opt.swapfile = false;
opt.backup = false
opt.writebackup = false
opt.swapfile = false
-- Completion menu
opt.wildmenu = true;
opt.wildmode = 'full';
opt.complete = '.,w,b,k';
opt.completeopt = 'menuone,noselect';
opt.pumheight = 16;
opt.helpheight = 12;
opt.previewheight = 12;
opt.wildmenu = true
opt.wildmode = 'full'
opt.complete = '.,w,b,k'
opt.completeopt = 'menuone,noselect'
opt.pumheight = 16
opt.helpheight = 12
opt.previewheight = 12
-- Window rules
opt.splitbelow = true;
opt.splitright = true;
opt.inccommand = 'nosplit';
opt.switchbuf = 'useopen';
opt.winwidth = 30;
opt.winminwidth = 10;
opt.equalalways = false;
opt.splitbelow = true
opt.splitright = true
opt.inccommand = 'nosplit'
opt.switchbuf = 'useopen'
opt.winwidth = 30
opt.winminwidth = 10
opt.equalalways = false
-- Left column
opt.signcolumn = 'yes';
opt.number = true;
opt.relativenumber = true;
opt.numberwidth = 4;
opt.signcolumn = 'yes'
opt.number = true
opt.relativenumber = true
opt.numberwidth = 4
-- 4 spaces = 1 tab
opt.tabstop = 4;
opt.softtabstop = 4;
opt.shiftwidth = 4;
opt.smarttab = true;
opt.expandtab = true;
opt.smartindent = true;
opt.autoindent = true;
opt.shiftround = true;
opt.tabstop = 4
opt.softtabstop = 4
opt.shiftwidth = 4
opt.smarttab = true
opt.expandtab = true
opt.smartindent = true
opt.autoindent = true
opt.shiftround = true
-- Trailings, line break
opt.list = true;
opt.listchars = 'tab:»·,nbsp:+,trail:·,extends:→,precedes:←';
opt.showbreak = '';
opt.linebreak = true;
opt.breakat = [[\ \ ;:,!?]];
-- opt.breakindentopt = 'shift:4,min:20';
opt.list = true
opt.listchars = 'tab:»·,nbsp:+,trail:·,extends:→,precedes:←'
opt.showbreak = ''
opt.linebreak = true
opt.breakat = [[\ \ ;:,!?]]
-- opt.breakindentopt = 'shift:4,min:20'
-- Undo file path
opt.undofile = true;
opt.undodir = vim.fn.stdpath('data') .. '/undodir'
opt.undofile = true
opt.undodir = vim.fn.stdpath('cache') .. '/undodir'
-- Python path
vim.g.python_host_prog = '/usr/bin/python'

View File

@ -10,33 +10,29 @@ local packer = require('packer')
local use = packer.use
return packer.startup(
function()
function(use)
use 'wbthomason/packer.nvim'
-- Appearance / UI
-- Appearance/UI
use {
'shaunsingh/nord.nvim',
'glepnir/dashboard-nvim',
setup = function()
require('modules.dashboard')
end
}
use {
'glepnir/galaxyline.nvim',
branch = 'main',
requires = 'kyazdani42/nvim-web-devicons',
config = function()
require('modules.nord')
require('modules.statusline')
end
}
use {
'norcalli/nvim-colorizer.lua',
event = 'BufRead',
config = function()
require('colorizer').setup(
{'*';},
{
RGB = true; -- #RGB hex codes
RRGGBB = true; -- #RRGGBB hex codes
names = true; -- "Name" codes like Blue
RRGGBBAA = true; -- #RRGGBBAA hex codes
rgb_fn = true; -- CSS rgb() and rgba() functions
hsl_fn = true; -- CSS hsl() and hsla() functions
css = true; -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB
css_fn = true; -- Enable all CSS *functions*: rgb_fn, hsl_fn
mode = 'background'; -- Set the display mode.
})
require('modules.colorizer')
vim.cmd('ColorizerReloadAllBuffers')
end
}