Skip to content

Commit

Permalink
feature: added MakeShada command
Browse files Browse the repository at this point in the history
  • Loading branch information
BartSte committed Apr 27, 2024
1 parent ba25916 commit 212cc9d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lua/projectmarks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,24 @@ M.last_column_position = function()
M.jump_with('`')
end

--- Create a file at `vim.go.shadafile`. If it exists, or the variable is not
--- set, do nothing.
M.make_shada = function()
if vim.go.shadafile ~= '' then
if vim.fn.filereadable(vim.go.shadafile) == 0 then
vim.fn.writefile({}, vim.go.shadafile)
vim.api.nvim_notify('Shada file created.', vim.log.levels.INFO, {})
else
vim.api.nvim_notify('Shada file already exists.', vim.log.levels.INFO, {})
end
else
vim.api.nvim_notify('No shada file is set.', vim.log.levels.WARN, {})
end
end

-- Make M.make_shada() available as a command MakeShada
vim.cmd('command! MakeShada lua require("projectmarks").make_shada()')

-- Default configuration
---@type table
---@field shadafile string|boolean
Expand Down

0 comments on commit 212cc9d

Please sign in to comment.