refactor(utils): clean out inappropriate methods

This commit is contained in:
Matt Leong 2021-10-28 17:44:00 -07:00
parent a6b5dd1584
commit d9c294e814
6 changed files with 21 additions and 20 deletions

View file

@ -10,7 +10,7 @@ local plugins = {
requires = { 'kyazdani42/nvim-web-devicons' }, requires = { 'kyazdani42/nvim-web-devicons' },
}, },
}, },
disable = { -- disabling some plugins may mean you'll have to remap some keybindings disable = { -- disabling some core plugins may mean you'll have to remap some keybindings
'auto-session', 'auto-session',
'colorizer', 'colorizer',
'fugitive', 'fugitive',

View file

@ -31,6 +31,20 @@ local get_mode = function()
end end
end end
local function get_basename(file)
return file:match('^.+/(.+)$')
end
local function get_git_root()
local git_dir = require('galaxyline.providers.vcs').get_git_dir()
if not git_dir then
return 'not a git dir '
end
local git_root = git_dir:gsub('/.git/?$', '')
return get_basename(git_root) .. ' '
end
local check_width_and_git_and_buffer = function() local check_width_and_git_and_buffer = function()
return condition.check_git_workspace() and condition.buffer_not_empty() return condition.check_git_workspace() and condition.buffer_not_empty()
end end
@ -337,7 +351,7 @@ gls.right = {
}, },
{ {
GitRoot = { GitRoot = {
provider = utils.get_git_root, provider = get_git_root,
condition = check_buffer_and_width, condition = check_buffer_and_width,
icon = ' ' .. icons.file .. ' ', icon = ' ' .. icons.file .. ' ',
highlight = 'GalaxyViModeInv', highlight = 'GalaxyViModeInv',
@ -434,7 +448,7 @@ gls.short_line_right = {
}, },
{ {
GitRootShort = { GitRootShort = {
provider = utils.get_git_root, provider = get_git_root,
condition = condition.buffer_not_empty, condition = condition.buffer_not_empty,
icon = ' ' .. icons.file .. ' ', icon = ' ' .. icons.file .. ' ',
highlight = { colors.bg, colors.white }, highlight = { colors.bg, colors.white },

View file

@ -1,5 +1,3 @@
local colors = require('cosmic.core.theme.colors')
local highlight = require('cosmic.utils').highlight
local g = vim.g local g = vim.g
local title = vim.env.SHELL local title = vim.env.SHELL
@ -7,4 +5,3 @@ g.floaterm_width = 0.7
g.floaterm_height = 0.8 g.floaterm_height = 0.8
g.floaterm_title = '[' .. title .. ']:($1/$2)' g.floaterm_title = '[' .. title .. ']:($1/$2)'
g.floaterm_opener = 'vsplit' g.floaterm_opener = 'vsplit'
highlight('FloatermBorder', 'None', colors.floatBorder)

View file

@ -51,6 +51,9 @@ highlight('NotifyTRACEBorder', nil, colors.trace)
highlight('NotifyTRACETitle', nil, colors.trace) highlight('NotifyTRACETitle', nil, colors.trace)
highlight('NotifyTRACEIcon', nil, colors.trace) highlight('NotifyTRACEIcon', nil, colors.trace)
-- terminal highlight
highlight('FloatermBorder', 'None', colors.floatBorder)
vim.cmd([[ vim.cmd([[
highlight clear NormalFloat highlight clear NormalFloat
highlight link NormalFloat Normal highlight link NormalFloat Normal

View file

@ -62,6 +62,7 @@ return packer.startup(function()
vim.g.tokyonight_sidebars = { 'qf', 'packer' } vim.g.tokyonight_sidebars = { 'qf', 'packer' }
vim.cmd('color tokyonight') vim.cmd('color tokyonight')
end, end,
-- disable = vim.tbl_contains(user_plugins.disable, 'theme'),
}) })
use({ -- icons use({ -- icons

View file

@ -1,9 +1,5 @@
local M = {} local M = {}
local function get_basename(file)
return file:match('^.+/(.+)$')
end
function M.map(mode, lhs, rhs, opts) function M.map(mode, lhs, rhs, opts)
local options = { noremap = true } local options = { noremap = true }
if opts then if opts then
@ -12,16 +8,6 @@ function M.map(mode, lhs, rhs, opts)
vim.api.nvim_set_keymap(mode, lhs, rhs, options) vim.api.nvim_set_keymap(mode, lhs, rhs, options)
end end
function M.get_git_root()
local git_dir = require('galaxyline.providers.vcs').get_git_dir()
if not git_dir then
return 'not a git dir '
end
local git_root = git_dir:gsub('/.git/?$', '')
return get_basename(git_root) .. ' '
end
function M.split(str, sep) function M.split(str, sep)
local res = {} local res = {}
for w in str:gmatch('([^' .. sep .. ']*)') do for w in str:gmatch('([^' .. sep .. ']*)') do