Skip to content

Commit 6dc5292

Browse files
committed
added command and improved prompts
1 parent aeb6e33 commit 6dc5292

File tree

4 files changed

+25
-7
lines changed

4 files changed

+25
-7
lines changed

doc/salesforce.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ extension for VS Code. Out of the box commands include:
2323
- `SalesforceRetrieveFromOrg`: Pull the current file from the org
2424
- `SalesforceDiffFile`: Diff the current file against the file in the org
2525
- `SalesforceSetDefaultOrg`: Set the default org for the current project
26+
- `SalesforceCreateLightningComponent`: Create an Aura Component or LWC
27+
- `SalesforceCreateApex`: Create Apex trigger or class
2628

2729
# Setup ~
2830
To use this plugin, you must first setup your project by running `require("salesforce").setup({})`.
@@ -61,4 +63,4 @@ Usage ~
6163
`require("salesforce").setup({})`
6264

6365

64-
vim:tw=78:ts=8:noet:ft=help:norl:
66+
vim:tw=78:ts=8:noet:ft=help:norl:

lua/salesforce/component_generator.lua

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,21 @@ end
6464
M.create_apex = function()
6565
local name, dir = prompt_for_name_and_dir("Apex Name: ", "Please select a directory: ")
6666
vim.ui.select(
67-
{ "class", "trigger" },
67+
{ "Class", "Trigger" },
6868
{
6969
prompt = "Apex file type: ",
7070
},
7171
vim.schedule_wrap(function(choice)
72+
local type
73+
if choice == "Class" then
74+
type = "class"
75+
else
76+
type = "trigger"
77+
end
7278
local command = string.format(
7379
"%s apex generate %s --name %s --output-dir %s",
7480
executable,
75-
choice,
81+
type,
7682
name,
7783
dir
7884
)

lua/salesforce/util.lua

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,11 @@ M.send_cli_command = function(command, on_exit_callback, category, caller_name)
142142
end)
143143
end,
144144
})
145-
if not M.current_job or not M.current_job:is_running() then
146-
M.current_job = new_job
147-
M.current_bufnr = vim.api.nvim_get_current_buf()
148-
M.current_job:start()
145+
if not M[category] or M[category].current_job or not M[category].current_job:is_running() then
146+
M[category] = {}
147+
M[category].current_job = new_job
148+
M[category].current_bufnr = vim.api.nvim_get_current_buf()
149+
M[category].current_job:start()
149150
else
150151
M.notify_command_in_progress(category)
151152
end

plugin/salesforce.lua

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ local Diff = require("salesforce.diff")
1313
local Config = require("salesforce.config")
1414
local OrgManager = require("salesforce.org_manager")
1515
local Debug = require("salesforce.debug")
16+
local ComponentGenerator = require("salesforce.component_generator")
1617

1718
Debug:log("salesforce.lua", "Initializing Salesforce plugin commands...")
1819

@@ -68,3 +69,11 @@ end, {})
6869
vim.api.nvim_create_user_command("SalesforceSetDefaultOrg", function()
6970
OrgManager:set_default_org()
7071
end, {})
72+
73+
vim.api.nvim_create_user_command("SalesforceCreateLightningComponent", function()
74+
ComponentGenerator:create_lightning_component()
75+
end, {})
76+
77+
vim.api.nvim_create_user_command("SalesforceCreateApex", function()
78+
ComponentGenerator:create_apex()
79+
end, {})

0 commit comments

Comments
 (0)