From 7e3ce5094b626b3d01acbf5887bd19cfd307395c Mon Sep 17 00:00:00 2001 From: Matt Leong Date: Fri, 29 Oct 2021 15:57:31 -0700 Subject: [PATCH] feat(utils): learning some plenary --- lua/cosmic/pluginsInit.lua | 32 +++++++++++++++++--------------- lua/cosmic/utils.lua | 23 ++++++----------------- 2 files changed, 23 insertions(+), 32 deletions(-) diff --git a/lua/cosmic/pluginsInit.lua b/lua/cosmic/pluginsInit.lua index bc2eca8..4578675 100644 --- a/lua/cosmic/pluginsInit.lua +++ b/lua/cosmic/pluginsInit.lua @@ -37,6 +37,23 @@ return packer.startup(function() end, }) + use({ 'nvim-lua/plenary.nvim' }) + + use({ -- color scheme + 'folke/tokyonight.nvim', + config = function() + vim.g.tokyonight_style = 'night' + vim.g.tokyonight_sidebars = { 'qf', 'packer' } + vim.cmd('color tokyonight') + end, + disable = vim.tbl_contains(user_plugins.disable, 'theme'), + }) + + use({ -- icons + 'kyazdani42/nvim-web-devicons', + after = 'tokyonight.nvim', + }) + use({ 'rcarriga/nvim-notify', config = function() @@ -56,21 +73,6 @@ return packer.startup(function() disable = vim.tbl_contains(user_plugins.disable, 'notify'), }) - use({ -- color scheme - 'folke/tokyonight.nvim', - config = function() - vim.g.tokyonight_style = 'night' - vim.g.tokyonight_sidebars = { 'qf', 'packer' } - vim.cmd('color tokyonight') - end, - disable = vim.tbl_contains(user_plugins.disable, 'theme'), - }) - - use({ -- icons - 'kyazdani42/nvim-web-devicons', - after = 'tokyonight.nvim', - }) - -- theme stuff use({ -- statusline 'NTBBloodbath/galaxyline.nvim', diff --git a/lua/cosmic/utils.lua b/lua/cosmic/utils.lua index 6e42096..5279b49 100644 --- a/lua/cosmic/utils.lua +++ b/lua/cosmic/utils.lua @@ -28,23 +28,12 @@ function M.highlight(group, bg, fg, gui) end end -function M.get_relative_path(path) - local split_path = M.split(path, '/') - local split_cwd = M.split(vim.fn.getcwd(), '/') - local curr_dir = split_cwd[#split_cwd] - local nice_path = '' - - local ok = false - for _, dir in ipairs(split_path) do - if dir == curr_dir then - ok = true - end - if ok then - nice_path = nice_path .. '/' .. dir - end - end - - return '.' .. nice_path +function M.get_relative_path(file_path) + local plenary_path = require('plenary.path') + local parsed_path, _ = file_path:gsub('file://', '') + local path = plenary_path:new(parsed_path) + local relative_path = path:make_relative(vim.fn.getcwd()) + return './' .. relative_path end return M