Skip to content

Commit

Permalink
fix(config): create default config on :Rocks edit if it does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcjkb committed Feb 16, 2024
1 parent 5446cd4 commit 7b35d9a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lua/rocks/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ local commands = {}

local fzy = require("rocks.fzy")
local cache = require("rocks.cache")
local fs = require("rocks.fs")
local constants = require("rocks.constants")

---@param name string
---@param query string | nil
Expand Down Expand Up @@ -140,7 +142,11 @@ local rocks_command_tbl = {
},
edit = {
impl = function(_)
vim.cmd.e(require("rocks.config.internal").config_path)
local config_path = require("rocks.config.internal").config_path
if not fs.file_exists(config_path) then
fs.write_file(config_path, "w+", vim.trim(constants.DEFAULT_CONFIG))
end
vim.cmd.e(config_path)
end,
},
packadd = {
Expand Down

0 comments on commit 7b35d9a

Please sign in to comment.