-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #224 from pmizio/feature/221-v2
feat: implement `Move to file` code action
- Loading branch information
Showing
6 changed files
with
114 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
local M = {} | ||
|
||
---@param picker function | ||
---@param callback fun(err: boolean|nil, file: string?) | ||
function M.telescope_picker(picker, callback) | ||
local ok, actions = pcall(require, "telescope.actions") | ||
|
||
if not ok then | ||
vim.notify("Telescope need to be installed to call this integration", vim.log.levels.WARN) | ||
callback(true, nil) | ||
return | ||
end | ||
|
||
local action_state = require "telescope.actions.state" | ||
picker = picker or require("telescope.builtin").find_files | ||
|
||
picker { | ||
attach_mappings = function(prompt_bufnr) | ||
local selected = nil | ||
|
||
actions.select_default:replace(function() | ||
local selection = action_state.get_selected_entry() | ||
selected = true | ||
|
||
if selection then | ||
selected = vim.fs.joinpath(vim.loop.cwd(), selection.value) | ||
end | ||
|
||
actions.close(prompt_bufnr) | ||
end) | ||
actions.close:enhance { | ||
post = function() | ||
callback(nil, selected) | ||
end, | ||
} | ||
return true | ||
end, | ||
} | ||
end | ||
|
||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters