From d9c294e8141726c336cbb417f1e4baf4ecbbb157 Mon Sep 17 00:00:00 2001
From: Matt Leong <mattleong91@gmail.com>
Date: Thu, 28 Oct 2021 17:44:00 -0700
Subject: [PATCH] refactor(utils): clean out inappropriate methods

---
 lua/cosmic/config/plugins.lua        |  2 +-
 lua/cosmic/core/statusline/init.lua  | 18 ++++++++++++++++--
 lua/cosmic/core/terminal/init.lua    |  3 ---
 lua/cosmic/core/theme/highlights.lua |  3 +++
 lua/cosmic/pluginsInit.lua           |  1 +
 lua/cosmic/utils.lua                 | 14 --------------
 6 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/lua/cosmic/config/plugins.lua b/lua/cosmic/config/plugins.lua
index b30c20d..3195a06 100644
--- a/lua/cosmic/config/plugins.lua
+++ b/lua/cosmic/config/plugins.lua
@@ -10,7 +10,7 @@ local plugins = {
       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',
     'colorizer',
     'fugitive',
diff --git a/lua/cosmic/core/statusline/init.lua b/lua/cosmic/core/statusline/init.lua
index e963faa..4bddb34 100644
--- a/lua/cosmic/core/statusline/init.lua
+++ b/lua/cosmic/core/statusline/init.lua
@@ -31,6 +31,20 @@ local get_mode = function()
   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()
   return condition.check_git_workspace() and condition.buffer_not_empty()
 end
@@ -337,7 +351,7 @@ gls.right = {
   },
   {
     GitRoot = {
-      provider = utils.get_git_root,
+      provider = get_git_root,
       condition = check_buffer_and_width,
       icon = '  ' .. icons.file .. ' ',
       highlight = 'GalaxyViModeInv',
@@ -434,7 +448,7 @@ gls.short_line_right = {
   },
   {
     GitRootShort = {
-      provider = utils.get_git_root,
+      provider = get_git_root,
       condition = condition.buffer_not_empty,
       icon = '  ' .. icons.file .. ' ',
       highlight = { colors.bg, colors.white },
diff --git a/lua/cosmic/core/terminal/init.lua b/lua/cosmic/core/terminal/init.lua
index b5a88dd..a46fab4 100644
--- a/lua/cosmic/core/terminal/init.lua
+++ b/lua/cosmic/core/terminal/init.lua
@@ -1,5 +1,3 @@
-local colors = require('cosmic.core.theme.colors')
-local highlight = require('cosmic.utils').highlight
 local g = vim.g
 local title = vim.env.SHELL
 
@@ -7,4 +5,3 @@ g.floaterm_width = 0.7
 g.floaterm_height = 0.8
 g.floaterm_title = '[' .. title .. ']:($1/$2)'
 g.floaterm_opener = 'vsplit'
-highlight('FloatermBorder', 'None', colors.floatBorder)
diff --git a/lua/cosmic/core/theme/highlights.lua b/lua/cosmic/core/theme/highlights.lua
index e52c7a4..430be1e 100644
--- a/lua/cosmic/core/theme/highlights.lua
+++ b/lua/cosmic/core/theme/highlights.lua
@@ -51,6 +51,9 @@ highlight('NotifyTRACEBorder', nil, colors.trace)
 highlight('NotifyTRACETitle', nil, colors.trace)
 highlight('NotifyTRACEIcon', nil, colors.trace)
 
+-- terminal highlight
+highlight('FloatermBorder', 'None', colors.floatBorder)
+
 vim.cmd([[
 highlight clear NormalFloat
 highlight link NormalFloat Normal
diff --git a/lua/cosmic/pluginsInit.lua b/lua/cosmic/pluginsInit.lua
index f3753de..b536724 100644
--- a/lua/cosmic/pluginsInit.lua
+++ b/lua/cosmic/pluginsInit.lua
@@ -62,6 +62,7 @@ return packer.startup(function()
       vim.g.tokyonight_sidebars = { 'qf', 'packer' }
       vim.cmd('color tokyonight')
     end,
+    -- disable = vim.tbl_contains(user_plugins.disable, 'theme'),
   })
 
   use({ -- icons
diff --git a/lua/cosmic/utils.lua b/lua/cosmic/utils.lua
index 36f459f..6e42096 100644
--- a/lua/cosmic/utils.lua
+++ b/lua/cosmic/utils.lua
@@ -1,9 +1,5 @@
 local M = {}
 
-local function get_basename(file)
-  return file:match('^.+/(.+)$')
-end
-
 function M.map(mode, lhs, rhs, opts)
   local options = { noremap = true }
   if opts then
@@ -12,16 +8,6 @@ function M.map(mode, lhs, rhs, opts)
   vim.api.nvim_set_keymap(mode, lhs, rhs, options)
 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)
   local res = {}
   for w in str:gmatch('([^' .. sep .. ']*)') do