Added stylua and reformated lua files

This commit is contained in:
Salar Rahmanian 2021-07-15 08:19:22 -07:00
parent c1cd430cae
commit c11d9351a6
4 changed files with 224 additions and 197 deletions

7
.stylua.toml Normal file
View file

@ -0,0 +1,7 @@
column_width = 160
line_endings = "Unix"
indent_type = "Spaces"
indent_width = 2
quote_style = "AutoPreferSingle"
no_call_parentheses = true

View file

@ -221,6 +221,7 @@
pkgs.ripgrep pkgs.ripgrep
pkgs.rnix-lsp pkgs.rnix-lsp
pkgs.shellcheck pkgs.shellcheck
pkgs.stylua
pkgs.sumneko-lua-language-server pkgs.sumneko-lua-language-server
pkgs.tealdeer pkgs.tealdeer
pkgs.tig pkgs.tig

View file

@ -1,25 +1,29 @@
local execute = vim.api.nvim_command local execute = vim.api.nvim_command
local fn = vim.fn local fn = vim.fn
local install_path = fn.stdpath 'data' .. '/site/pack/packer/start/packer.nvim'
local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim'
local function load_plugins() local function load_plugins()
local use = require('packer').use local use = require('packer').use
require('packer').startup(function() require('packer').startup(function()
use 'wbthomason/packer.nvim' -- Package manager use 'wbthomason/packer.nvim' -- Package manager
use 'nvim-treesitter/nvim-treesitter' use 'nvim-treesitter/nvim-treesitter'
use 'nvim-treesitter/nvim-treesitter-textobjects' use 'nvim-treesitter/nvim-treesitter-textobjects'
use 'folke/which-key.nvim' use 'folke/which-key.nvim'
use {'nvim-telescope/telescope.nvim', requires = {{'nvim-lua/popup.nvim'}, {'nvim-lua/plenary.nvim'}} } use { 'nvim-telescope/telescope.nvim', requires = { { 'nvim-lua/popup.nvim' }, { 'nvim-lua/plenary.nvim' } } }
use 'folke/tokyonight.nvim' -- Theme use 'folke/tokyonight.nvim' -- Theme
use 'windwp/nvim-autopairs' -- Autopairs use 'windwp/nvim-autopairs' -- Autopairs
use 'kyazdani42/nvim-tree.lua' -- File explorer use 'kyazdani42/nvim-tree.lua' -- File explorer
use { 'glepnir/galaxyline.nvim', config = function() require'salargalaxyline' end, requires = 'kyazdani42/nvim-web-devicons' } use {
'glepnir/galaxyline.nvim',
config = function()
require 'salargalaxyline'
end,
requires = 'kyazdani42/nvim-web-devicons',
}
use 'lukas-reineke/indent-blankline.nvim' use 'lukas-reineke/indent-blankline.nvim'
use { 'lewis6991/gitsigns.nvim', requires = 'nvim-lua/plenary.nvim' } use { 'lewis6991/gitsigns.nvim', requires = 'nvim-lua/plenary.nvim' }
use { 'TimUntersberger/neogit', requires = {{'nvim-lua/plenary.nvim'}, {'sindrets/diffview.nvim'}} } use { 'TimUntersberger/neogit', requires = { { 'nvim-lua/plenary.nvim' }, { 'sindrets/diffview.nvim' } } }
use 'neovim/nvim-lspconfig' -- Collection of configurations for built-in LSP client use 'neovim/nvim-lspconfig' -- Collection of configurations for built-in LSP client
use { 'hrsh7th/nvim-compe', requires = 'L3MON4D3/LuaSnip' } -- Autocompletion plugin use { 'hrsh7th/nvim-compe', requires = 'L3MON4D3/LuaSnip' } -- Autocompletion plugin
use 'kevinhwang91/nvim-bqf' use 'kevinhwang91/nvim-bqf'
@ -30,27 +34,26 @@ local function load_plugins()
use { 'folke/trouble.nvim', requires = 'kyazdani42/nvim-web-devicons' } use { 'folke/trouble.nvim', requires = 'kyazdani42/nvim-web-devicons' }
use 'nvim-treesitter/playground' use 'nvim-treesitter/playground'
use 'b3nj5m1n/kommentary' use 'b3nj5m1n/kommentary'
use 'ckipp01/stylua-nvim'
end) end)
end end
_G.load_config = function() _G.load_config = function()
require('nvim-autopairs').setup() require('nvim-autopairs').setup()
require('which-key').setup() require('which-key').setup()
require('trouble').setup() require('trouble').setup()
require('gitsigns').setup() require('gitsigns').setup()
require("salargalaxyline") require 'salargalaxyline'
require('kommentary.config').use_extended_mappings() require('kommentary.config').use_extended_mappings()
-- Treesitter -- Treesitter
require('nvim-treesitter.configs').setup { require('nvim-treesitter.configs').setup {
query_linter = { query_linter = {
enable = true, enable = true,
use_virtual_text = true, use_virtual_text = true,
lint_events = { "BufWrite", "CursorHold" }, lint_events = { 'BufWrite', 'CursorHold' },
}, },
ensure_installed = "maintained", ensure_installed = 'maintained',
highlight = { enable = true }, highlight = { enable = true },
incremental_selection = { incremental_selection = {
enable = true, enable = true,
@ -114,18 +117,18 @@ _G.load_config = function()
goto_node = '<cr>', goto_node = '<cr>',
show_help = '?', show_help = '?',
}, },
} },
} }
-- neogit -- neogit
require('neogit').setup({ require('neogit').setup {
integrations = { integrations = {
diffview = true diffview = true,
},
} }
})
--Incremental live completion --Incremental live completion
vim.o.inccommand = "nosplit" vim.o.inccommand = 'nosplit'
--Set highlight on search --Set highlight on search
vim.o.hlsearch = false vim.o.hlsearch = false
@ -138,7 +141,7 @@ _G.load_config = function()
vim.o.hidden = true vim.o.hidden = true
--Enable mouse mode --Enable mouse mode
vim.o.mouse = "a" vim.o.mouse = 'a'
-- clipboard -- clipboard
vim.o.clipboard = 'unnamedplus' vim.o.clipboard = 'unnamedplus'
@ -147,7 +150,7 @@ _G.load_config = function()
vim.o.breakindent = true vim.o.breakindent = true
--Save undo history --Save undo history
vim.cmd[[set undofile]] vim.cmd [[set undofile]]
--Case insensitive searching UNLESS /C or capital in search --Case insensitive searching UNLESS /C or capital in search
vim.o.ignorecase = true vim.o.ignorecase = true
@ -155,50 +158,49 @@ _G.load_config = function()
--Decrease update time --Decrease update time
vim.o.updatetime = 250 vim.o.updatetime = 250
vim.wo.signcolumn="yes" vim.wo.signcolumn = 'yes'
--Set colorscheme (order is important here) --Set colorscheme (order is important here)
vim.g.tokyonight_style = "night" vim.g.tokyonight_style = 'night'
vim.g.tokyonight_italic_functions = true vim.g.tokyonight_italic_functions = true
vim.o.termguicolors = true vim.o.termguicolors = true
vim.cmd[[colorscheme tokyonight]] vim.cmd [[colorscheme tokyonight]]
--Remap space as leader key --Remap space as leader key
vim.api.nvim_set_keymap('', '<Space>', '<Nop>', { noremap = true, silent=true}) vim.api.nvim_set_keymap('', '<Space>', '<Nop>', { noremap = true, silent = true })
vim.g.mapleader = " " vim.g.mapleader = ' '
vim.g.maplocalleader = " " vim.g.maplocalleader = ' '
--Remap for dealing with word wrap --Remap for dealing with word wrap
vim.api.nvim_set_keymap('n', 'k', "v:count == 0 ? 'gk' : 'k'", { noremap=true, expr = true, silent = true}) vim.api.nvim_set_keymap('n', 'k', "v:count == 0 ? 'gk' : 'k'", { noremap = true, expr = true, silent = true })
vim.api.nvim_set_keymap('n', 'j', "v:count == 0 ? 'gj' : 'j'", {noremap= true, expr = true, silent = true}) vim.api.nvim_set_keymap('n', 'j', "v:count == 0 ? 'gj' : 'j'", { noremap = true, expr = true, silent = true })
--Remap escape to leave terminal mode --Remap escape to leave terminal mode
vim.api.nvim_set_keymap('t', '<Esc>', [[<c-\><c-n>]], {noremap = true}) vim.api.nvim_set_keymap('t', '<Esc>', [[<c-\><c-n>]], { noremap = true })
--Add map to enter paste mode --Add map to enter paste mode
vim.o.pastetoggle="<F3>" vim.o.pastetoggle = '<F3>'
--Map blankline --Map blankline
vim.g.indent_blankline_char = "" vim.g.indent_blankline_char = ''
vim.g.indent_blankline_filetype_exclude = { 'help', 'packer' } vim.g.indent_blankline_filetype_exclude = { 'help', 'packer' }
vim.g.indent_blankline_buftype_exclude = { 'terminal', 'nofile'} vim.g.indent_blankline_buftype_exclude = { 'terminal', 'nofile' }
vim.g.indent_blankline_char_highlight = 'LineNr' vim.g.indent_blankline_char_highlight = 'LineNr'
-- Toggle to disable mouse mode and indentlines for easier paste -- Toggle to disable mouse mode and indentlines for easier paste
ToggleMouse = function() ToggleMouse = function()
if vim.o.mouse == 'a' then if vim.o.mouse == 'a' then
vim.cmd[[IndentBlanklineDisable]] vim.cmd [[IndentBlanklineDisable]]
vim.wo.signcolumn='no' vim.wo.signcolumn = 'no'
vim.o.mouse = 'v' vim.o.mouse = 'v'
vim.wo.number = false vim.wo.number = false
print("Mouse disabled") print 'Mouse disabled'
else else
vim.cmd[[IndentBlanklineEnable]] vim.cmd [[IndentBlanklineEnable]]
vim.wo.signcolumn='yes' vim.wo.signcolumn = 'yes'
vim.o.mouse = 'a' vim.o.mouse = 'a'
vim.wo.number = true vim.wo.number = true
print("Mouse enabled") print 'Mouse enabled'
end end
end end
@ -209,53 +211,56 @@ _G.load_config = function()
defaults = { defaults = {
mappings = { mappings = {
i = { i = {
["<C-u>"] = false, ['<C-u>'] = false,
["<C-d>"] = false, ['<C-d>'] = false,
}, },
}, },
generic_sorter = require'telescope.sorters'.get_fzy_sorter, generic_sorter = require('telescope.sorters').get_fzy_sorter,
file_sorter = require'telescope.sorters'.get_fzy_sorter, file_sorter = require('telescope.sorters').get_fzy_sorter,
} },
} }
--Add leader shortcuts --Add leader shortcuts
vim.api.nvim_set_keymap('n', '<leader>f', [[<cmd>lua require('telescope.builtin').find_files()<cr>]], { noremap = true, silent = true}) vim.api.nvim_set_keymap('n', '<leader>f', [[<cmd>lua require('telescope.builtin').find_files()<cr>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader><space>', [[<cmd>lua require('telescope.builtin').buffers()<cr>]], { noremap = true, silent = true}) vim.api.nvim_set_keymap('n', '<leader><space>', [[<cmd>lua require('telescope.builtin').buffers()<cr>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>l', [[<cmd>lua require('telescope.builtin').current_buffer_fuzzy_find()<cr>]], { noremap = true, silent = true}) vim.api.nvim_set_keymap('n', '<leader>l', [[<cmd>lua require('telescope.builtin').current_buffer_fuzzy_find()<cr>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>t', [[<cmd>lua require('telescope.builtin').tags()<cr>]], { noremap = true, silent = true}) vim.api.nvim_set_keymap('n', '<leader>t', [[<cmd>lua require('telescope.builtin').tags()<cr>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>?', [[<cmd>lua require('telescope.builtin').oldfiles()<cr>]], { noremap = true, silent = true}) vim.api.nvim_set_keymap('n', '<leader>?', [[<cmd>lua require('telescope.builtin').oldfiles()<cr>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>sd', [[<cmd>lua require('telescope.builtin').grep_string()<cr>]], { noremap = true, silent = true}) vim.api.nvim_set_keymap('n', '<leader>sd', [[<cmd>lua require('telescope.builtin').grep_string()<cr>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>sp', [[<cmd>lua require('telescope.builtin').live_grep()<cr>]], { noremap = true, silent = true}) vim.api.nvim_set_keymap('n', '<leader>sp', [[<cmd>lua require('telescope.builtin').live_grep()<cr>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>o', [[<cmd>lua require('telescope.builtin').tags{ only_current_buffer = true }<cr>]], { noremap = true, silent = true}) vim.api.nvim_set_keymap('n', '<leader>o', [[<cmd>lua require('telescope.builtin').tags{ only_current_buffer = true }<cr>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>gc', [[<cmd>lua require('telescope.builtin').git_commits()<cr>]], { noremap = true, silent = true}) vim.api.nvim_set_keymap('n', '<leader>gc', [[<cmd>lua require('telescope.builtin').git_commits()<cr>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>gb', [[<cmd>lua require('telescope.builtin').git_branches()<cr>]], { noremap = true, silent = true}) vim.api.nvim_set_keymap('n', '<leader>gb', [[<cmd>lua require('telescope.builtin').git_branches()<cr>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>gs', [[<cmd>lua require('telescope.builtin').git_status()<cr>]], { noremap = true, silent = true}) vim.api.nvim_set_keymap('n', '<leader>gs', [[<cmd>lua require('telescope.builtin').git_status()<cr>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>gp', [[<cmd>lua require('telescope.builtin').git_bcommits()<cr>]], { noremap = true, silent = true}) vim.api.nvim_set_keymap('n', '<leader>gp', [[<cmd>lua require('telescope.builtin').git_bcommits()<cr>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>m', [[<cmd>lua require('nvim-tree').toggle()<cr>]], { noremap = true, silent = true}) vim.api.nvim_set_keymap('n', '<leader>m', [[<cmd>lua require('nvim-tree').toggle()<cr>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>ng', [[<cmd>lua require('neogit').open({ kind = "split" })<cr>]], { noremap = true, silent = true}) vim.api.nvim_set_keymap('n', '<leader>ng', [[<cmd>lua require('neogit').open({ kind = "split" })<cr>]], { noremap = true, silent = true })
vim.api.nvim_set_keymap('n', '<leader>nu', ':PackerUpdate<CR>', { noremap = true, silent = true }) vim.api.nvim_set_keymap('n', '<leader>nu', ':PackerUpdate<CR>', { noremap = true, silent = true })
-- Change preview window location -- Change preview window location
vim.g.splitbelow = true vim.g.splitbelow = true
-- Highlight on yank -- Highlight on yank
vim.api.nvim_exec([[ vim.api.nvim_exec(
[[
augroup YankHighlight augroup YankHighlight
autocmd! autocmd!
autocmd TextYankPost * silent! lua vim.highlight.on_yank() autocmd TextYankPost * silent! lua vim.highlight.on_yank()
augroup end augroup end
]], false) ]],
false
)
-- Y yank until the end of line -- Y yank until the end of line
vim.api.nvim_set_keymap('n', 'Y', 'y$', { noremap = true}) vim.api.nvim_set_keymap('n', 'Y', 'y$', { noremap = true })
-- --
-- LSP settings -- LSP settings
local nvim_lsp = require('lspconfig') local nvim_lsp = require 'lspconfig'
local on_attach = function(_client, bufnr) local on_attach = function(_client, bufnr)
require('lsp_signature').on_attach() require('lsp_signature').on_attach()
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
local opts = { noremap=true, silent=true } local opts = { noremap = true, silent = true }
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', '<Cmd>lua vim.lsp.buf.declaration()<CR>', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', '<Cmd>lua vim.lsp.buf.declaration()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', '<Cmd>lua vim.lsp.buf.definition()<CR>', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', '<Cmd>lua vim.lsp.buf.definition()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts) vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts)
@ -275,19 +280,26 @@ _G.load_config = function()
end end
-- Enable the following language servers -- Enable the following language servers
local servers = { 'jdtls', 'pyright', 'rnix','sourcekit' } local servers = { 'jdtls', 'pyright', 'rnix', 'sourcekit' }
for _, lsp in ipairs(servers) do for _, lsp in ipairs(servers) do
nvim_lsp[lsp].setup { on_attach = on_attach } nvim_lsp[lsp].setup { on_attach = on_attach }
end end
-- lua language server -- lua language server
local sumneko_binary = vim.fn.getenv("HOME").."/.nix-profile/bin/lua-language-server" local sumneko_binary = vim.fn.getenv 'HOME' .. '/.nix-profile/bin/lua-language-server'
local runtime_path = vim.split(package.path, ';') local runtime_path = vim.split(package.path, ';')
table.insert(runtime_path, 'lua/?.lua') table.insert(runtime_path, 'lua/?.lua')
table.insert(runtime_path, 'lua/?/init.lua') table.insert(runtime_path, 'lua/?/init.lua')
require('lspconfig').sumneko_lua.setup { require('lspconfig').sumneko_lua.setup {
cmd = { sumneko_binary }, cmd = { sumneko_binary },
commands = {
Format = {
function()
require('stylua-nvim').format_file()
end,
},
},
on_attach = on_attach, on_attach = on_attach,
settings = { settings = {
Lua = { Lua = {
@ -311,49 +323,48 @@ require('lspconfig').sumneko_lua.setup {
}, },
}, },
}, },
} }
-- metals -- metals
vim.opt_global.shortmess:remove("F"):append("c") vim.opt_global.shortmess:remove('F'):append 'c'
metals_config = require("metals").bare_config metals_config = require('metals').bare_config
metals_config.init_options.statusBarProvider = "on" metals_config.init_options.statusBarProvider = 'on'
vim.cmd [[augroup lsp]] vim.cmd [[augroup lsp]]
vim.cmd [[au!]] vim.cmd [[au!]]
vim.cmd [[au FileType scala,sbt lua require("metals").initialize_or_attach(metals_config)]] vim.cmd [[au FileType scala,sbt lua require("metals").initialize_or_attach(metals_config)]]
vim.cmd [[augroup end]] vim.cmd [[augroup end]]
-- Map :Format to vim.lsp.buf.formatting() -- Map :Format to vim.lsp.buf.formatting()
vim.cmd([[ command! Format execute 'lua vim.lsp.buf.formatting()' ]]) vim.cmd [[ command! Format execute 'lua vim.lsp.buf.formatting()' ]]
-- Set completeopt to have a better completion experience -- Set completeopt to have a better completion experience
vim.o.completeopt="menuone,noinsert" vim.o.completeopt = 'menuone,noinsert'
-- Compe setup -- Compe setup
require'compe'.setup { require('compe').setup {
enabled = true; enabled = true,
autocomplete = true; autocomplete = true,
debug = false; debug = false,
min_length = 1; min_length = 1,
preselect = 'enable'; preselect = 'enable',
throttle_time = 80; throttle_time = 80,
source_timeout = 200; source_timeout = 200,
incomplete_delay = 400; incomplete_delay = 400,
max_abbr_width = 100; max_abbr_width = 100,
max_kind_width = 100; max_kind_width = 100,
max_menu_width = 100; max_menu_width = 100,
documentation = true; documentation = true,
source = { source = {
path = true; path = true,
nvim_lsp = { nvim_lsp = {
priority = 1000, priority = 1000,
filetypes = { "scala", "sbt", "java" }, filetypes = { 'scala', 'sbt', 'java' },
}, },
nvim_lua = true, nvim_lua = true,
buffer = true, buffer = true,
luasnip = true, luasnip = true,
}; },
} }
local t = function(str) local t = function(str)
@ -361,8 +372,8 @@ require('lspconfig').sumneko_lua.setup {
end end
local check_back_space = function() local check_back_space = function()
local col = vim.fn.col('.') - 1 local col = vim.fn.col '.' - 1
if col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then if col == 0 or vim.fn.getline('.'):sub(col, col):match '%s' then
return true return true
else else
return false return false
@ -374,30 +385,29 @@ require('lspconfig').sumneko_lua.setup {
--- jump to prev/next snippet's placeholder --- jump to prev/next snippet's placeholder
_G.tab_complete = function() _G.tab_complete = function()
if vim.fn.pumvisible() == 1 then if vim.fn.pumvisible() == 1 then
return t "<C-n>" return t '<C-n>'
elseif check_back_space() then elseif check_back_space() then
return t "<Tab>" return t '<Tab>'
else else
return vim.fn['compe#complete']() return vim.fn['compe#complete']()
end end
end end
_G.s_tab_complete = function() _G.s_tab_complete = function()
if vim.fn.pumvisible() == 1 then if vim.fn.pumvisible() == 1 then
return t "<C-p>" return t '<C-p>'
else else
return t "<S-Tab>" return t '<S-Tab>'
end end
end end
vim.api.nvim_set_keymap("i", "<Tab>", "v:lua.tab_complete()", {expr = true}) vim.api.nvim_set_keymap('i', '<Tab>', 'v:lua.tab_complete()', { expr = true })
vim.api.nvim_set_keymap("s", "<Tab>", "v:lua.tab_complete()", {expr = true}) vim.api.nvim_set_keymap('s', '<Tab>', 'v:lua.tab_complete()', { expr = true })
vim.api.nvim_set_keymap("i", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true}) vim.api.nvim_set_keymap('i', '<S-Tab>', 'v:lua.s_tab_complete()', { expr = true })
vim.api.nvim_set_keymap("s", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true}) vim.api.nvim_set_keymap('s', '<S-Tab>', 'v:lua.s_tab_complete()', { expr = true })
end end
if fn.isdirectory(install_path) == 0 then if fn.isdirectory(install_path) == 0 then
fn.system({'git', 'clone', 'https://github.com/wbthomason/packer.nvim', install_path}) fn.system { 'git', 'clone', 'https://github.com/wbthomason/packer.nvim', install_path }
load_plugins() load_plugins()
require('packer').sync() require('packer').sync()
vim.cmd 'autocmd User PackerComplete ++once lua load_config()' vim.cmd 'autocmd User PackerComplete ++once lua load_config()'

View file

@ -1,6 +1,6 @@
local gl = require('galaxyline') local gl = require 'galaxyline'
local gls = gl.section local gls = gl.section
gl.short_line_list = {'LuaTree','vista','dbui'} gl.short_line_list = { 'LuaTree', 'vista', 'dbui' }
local colors = { local colors = {
bg = '#282c34', bg = '#282c34',
@ -13,11 +13,11 @@ local colors = {
magenta = '#d16d9e', magenta = '#d16d9e',
grey = '#c0c0c0', grey = '#c0c0c0',
blue = '#0087d7', blue = '#0087d7',
red = '#ec5f67' red = '#ec5f67',
} }
local buffer_not_empty = function() local buffer_not_empty = function()
if vim.fn.empty(vim.fn.expand('%:t')) ~= 1 then if vim.fn.empty(vim.fn.expand '%:t') ~= 1 then
return true return true
end end
return false return false
@ -25,56 +25,63 @@ end
gls.left[1] = { gls.left[1] = {
FirstElement = { FirstElement = {
provider = function() return '' end, provider = function()
highlight = {colors.blue,colors.yellow} return ''
end,
highlight = { colors.blue, colors.yellow },
}, },
} }
gls.left[2] = { gls.left[2] = {
ViMode = { ViMode = {
provider = function() provider = function()
local alias = {n = 'NORMAL',i = 'INSERT',c= 'COMMAND',v= 'VISUAL',V= 'VISUAL LINE', [''] = 'VISUAL BLOCK'} local alias = { n = 'NORMAL', i = 'INSERT', c = 'COMMAND', v = 'VISUAL', V = 'VISUAL LINE', [''] = 'VISUAL BLOCK' }
return alias[vim.fn.mode()] return alias[vim.fn.mode()]
end, end,
separator = '', separator = '',
separator_highlight = {colors.purple,function() separator_highlight = {
colors.purple,
function()
if not buffer_not_empty() then if not buffer_not_empty() then
return colors.purple return colors.purple
end end
return colors.darkblue return colors.darkblue
end}, end,
highlight = {colors.darkblue,colors.purple,'bold'}, },
highlight = { colors.darkblue, colors.purple, 'bold' },
}, },
} }
gls.left[3] ={ gls.left[3] = {
FileIcon = { FileIcon = {
provider = 'FileIcon', provider = 'FileIcon',
condition = buffer_not_empty, condition = buffer_not_empty,
highlight = {require('galaxyline.provider_fileinfo').get_file_icon_color,colors.darkblue}, highlight = { require('galaxyline.provider_fileinfo').get_file_icon_color, colors.darkblue },
}, },
} }
gls.left[4] = { gls.left[4] = {
FileName = { FileName = {
provider = {'FileName','FileSize'}, provider = { 'FileName', 'FileSize' },
condition = buffer_not_empty, condition = buffer_not_empty,
separator = '', separator = '',
separator_highlight = {colors.purple,colors.darkblue}, separator_highlight = { colors.purple, colors.darkblue },
highlight = {colors.magenta,colors.darkblue} highlight = { colors.magenta, colors.darkblue },
} },
} }
gls.left[5] = { gls.left[5] = {
GitIcon = { GitIcon = {
provider = function() return '' end, provider = function()
return ''
end,
condition = buffer_not_empty, condition = buffer_not_empty,
highlight = {colors.orange,colors.purple}, highlight = { colors.orange, colors.purple },
} },
} }
gls.left[6] = { gls.left[6] = {
GitBranch = { GitBranch = {
provider = 'GitBranch', provider = 'GitBranch',
condition = buffer_not_empty, condition = buffer_not_empty,
highlight = {colors.grey,colors.purple}, highlight = { colors.grey, colors.purple },
} },
} }
local checkwidth = function() local checkwidth = function()
@ -90,99 +97,101 @@ gls.left[7] = {
provider = 'DiffAdd', provider = 'DiffAdd',
condition = checkwidth, condition = checkwidth,
icon = '', icon = '',
highlight = {colors.green,colors.purple}, highlight = { colors.green, colors.purple },
} },
} }
gls.left[8] = { gls.left[8] = {
DiffModified = { DiffModified = {
provider = 'DiffModified', provider = 'DiffModified',
condition = checkwidth, condition = checkwidth,
icon = '', icon = '',
highlight = {colors.orange,colors.purple}, highlight = { colors.orange, colors.purple },
} },
} }
gls.left[9] = { gls.left[9] = {
DiffRemove = { DiffRemove = {
provider = 'DiffRemove', provider = 'DiffRemove',
condition = checkwidth, condition = checkwidth,
icon = '', icon = '',
highlight = {colors.red,colors.purple}, highlight = { colors.red, colors.purple },
} },
} }
gls.left[10] = { gls.left[10] = {
LeftEnd = { LeftEnd = {
provider = function() return '' end, provider = function()
return ''
end,
separator = '', separator = '',
separator_highlight = {colors.purple,colors.bg}, separator_highlight = { colors.purple, colors.bg },
highlight = {colors.purple,colors.purple} highlight = { colors.purple, colors.purple },
} },
} }
gls.left[11] = { gls.left[11] = {
DiagnosticError = { DiagnosticError = {
provider = 'DiagnosticError', provider = 'DiagnosticError',
icon = '', icon = '',
highlight = {colors.red,colors.bg} highlight = { colors.red, colors.bg },
} },
} }
gls.left[12] = { gls.left[12] = {
Space = { Space = {
provider = function () return ' ' end provider = function()
} return ' '
end,
},
} }
gls.left[13] = { gls.left[13] = {
DiagnosticWarn = { DiagnosticWarn = {
provider = 'DiagnosticWarn', provider = 'DiagnosticWarn',
icon = '', icon = '',
highlight = {colors.blue,colors.bg}, highlight = { colors.blue, colors.bg },
} },
} }
gls.right[1]= { gls.right[1] = {
FileFormat = { FileFormat = {
provider = 'FileFormat', provider = 'FileFormat',
separator = '', separator = '',
separator_highlight = {colors.bg,colors.purple}, separator_highlight = { colors.bg, colors.purple },
highlight = {colors.grey,colors.purple}, highlight = { colors.grey, colors.purple },
} },
} }
gls.right[2] = { gls.right[2] = {
LineInfo = { LineInfo = {
provider = 'LineColumn', provider = 'LineColumn',
separator = ' | ', separator = ' | ',
separator_highlight = {colors.darkblue,colors.purple}, separator_highlight = { colors.darkblue, colors.purple },
highlight = {colors.grey,colors.purple}, highlight = { colors.grey, colors.purple },
}, },
} }
gls.right[3] = { gls.right[3] = {
PerCent = { PerCent = {
provider = 'LinePercent', provider = 'LinePercent',
separator = '', separator = '',
separator_highlight = {colors.darkblue,colors.purple}, separator_highlight = { colors.darkblue, colors.purple },
highlight = {colors.grey,colors.darkblue}, highlight = { colors.grey, colors.darkblue },
} },
} }
gls.right[4] = { gls.right[4] = {
ScrollBar = { ScrollBar = {
provider = 'ScrollBar', provider = 'ScrollBar',
highlight = {colors.yellow,colors.purple}, highlight = { colors.yellow, colors.purple },
} },
} }
gls.short_line_left[1] = { gls.short_line_left[1] = {
BufferType = { BufferType = {
provider = 'FileTypeName', provider = 'FileTypeName',
separator = '', separator = '',
separator_highlight = {colors.purple,colors.bg}, separator_highlight = { colors.purple, colors.bg },
highlight = {colors.grey,colors.purple} highlight = { colors.grey, colors.purple },
} },
} }
gls.short_line_right[1] = { gls.short_line_right[1] = {
BufferIcon = { BufferIcon = {
provider= 'BufferIcon', provider = 'BufferIcon',
separator = '', separator = '',
separator_highlight = {colors.purple,colors.bg}, separator_highlight = { colors.purple, colors.bg },
highlight = {colors.grey,colors.purple} highlight = { colors.grey, colors.purple },
} },
} }