Skip to content

Commit

Permalink
refactor: use indexing of vim.cmd
Browse files Browse the repository at this point in the history
Switch to using Lua indexing of `vim.cmd` instead of string concatenation
  • Loading branch information
mawkler committed Feb 7, 2023
1 parent 5b3bc3a commit 4fd4ae2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ require('telescope').setup{
["<C-s>"] = {
before_action = function(selection) print("before C-s") end,
action = function(selection)
vim.cmd("edit " .. selection.path)
vim.cmd.edit(selection.path)
end
},
-- Opens the selected entry in a new split
Expand Down Expand Up @@ -109,7 +109,7 @@ t.setup({
["<C-s>"] = {
before_action = function(selection) print("before C-s") end,
action = function(selection)
vim.cmd("edit " .. selection.path)
vim.cmd.edit(selection.path)
end
},
["<C-q>"] = { action = z_utils.create_basic_command("split") },
Expand All @@ -136,7 +136,7 @@ vim.keymap.set("n", "<leader>cd", t.extensions.zoxide.list)
mappings = {
default = {
action = function(selection)
vim.cmd("cd " .. selection.path)
vim.cmd.edit(selection.path)
end,
after_action = function(selection)
print("Directory changed to " .. selection.path)
Expand Down
2 changes: 1 addition & 1 deletion lua/telescope/_extensions/zoxide/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ local default_config = {
mappings = {
default = {
action = function(selection)
vim.cmd("cd " .. selection.path)
vim.cmd.cd(selection.path)
end,
after_action = function(selection)
print("Directory changed to " .. selection.path)
Expand Down
2 changes: 1 addition & 1 deletion lua/telescope/_extensions/zoxide/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local utils = {}

utils.create_basic_command = function(command)
return function(selection)
vim.cmd(command .. " " .. selection.path)
vim.cmd[command](selection.path)
end
end

Expand Down

0 comments on commit 4fd4ae2

Please sign in to comment.