diff options
Diffstat (limited to 'lua/talha/functions.lua')
-rw-r--r-- | lua/talha/functions.lua | 71 |
1 files changed, 21 insertions, 50 deletions
diff --git a/lua/talha/functions.lua b/lua/talha/functions.lua index b75185b..ff320e3 100644 --- a/lua/talha/functions.lua +++ b/lua/talha/functions.lua @@ -1,41 +1,8 @@ -local Path = require"plenary.path" - function GetCurrFileName() local filename = vim.api.nvim_buf_get_name(0) return filename end -function CreateDailyNote() - local file_path = vim.api.nvim_buf_get_name(0) - local dir_path = file_path - local path_obj = Path:new(file_path) - - if path_obj:is_file() == true then - path_obj = path_obj:parent() -- get the parent directory - dir_path = path_obj:_fs_filename() - end - - local today_date_fmt = os.date('%Y-%m-%d') - local daily_note_file_name = today_date_fmt .. '.md' - local daily_note_file_obj = path_obj:joinpath(daily_note_file_name) - - local template_file_name = '.daily-notes-template.md' - local template_file_obj = path_obj:joinpath(template_file_name) - - local status = template_file_obj:copy({destination=daily_note_file_obj}) - - -- check if operation was a success - if status[daily_note_file_obj] == false then - print('Error! failed to create daily note') - print([[Possible Causes: - 1. No `.daily-notes-template.md` found - 2. Something went wrong with copy, in which case check nvim config]]) - return - end - - vim.cmd('e ' .. daily_note_file_obj:_fs_filename()) -end - local function _ReloadConfigsInPath(path_selector) local config_paths = vim.fn.glob(path_selector, true, true) @@ -66,12 +33,6 @@ function ToggleSpellCheck() vim.opt.spelllang = 'en_us' end -function SetFocusColors(mode) - vim.o.background = "light" - vim.opt.cursorline = false - vim.cmd("colorscheme vscode") -end - function GetHomeDir() -- for linux/mac local home = os.getenv("HOME") @@ -86,17 +47,6 @@ function GetHomeDir() return nil end -function GetPlatformBuildCommand() - os_ver = vim.loop.os_uname().sysname - local build_command = '' - if os_ver == 'Linux' then - build_command = [[./build.sh]] - elseif os_ver == 'Windows' then - build_command = [[build.bat]] - end - return build_command -end - function SafeCListNav(navdir) -- dir: -- 1 is cnext (forwards) @@ -113,3 +63,24 @@ function SafeCListNav(navdir) return nil end end + +function MakeTags() + local on_exit = function(obj) + print('re-generated tags') + end + + vim.system({'ctags', '-R', '.'}, {text = true}, on_exit) +end + +function LoadSnippet(stype) + local ft = '.lua' + local buft = vim.bo.filetype + if buft == 'cpp' then + ft = '.c' + else + ft = '.' .. vim.bo.filetype + end + vim.cmd.read { + GetHomeDir() .. '/.config/nvim/snippets/' .. stype .. ft + } +end |