summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
authorfdschmidt93 <39233597+fdschmidt93@users.noreply.github.com>2022-01-11 22:00:31 +0100
committerGitHub <noreply@github.com>2022-01-11 22:00:31 +0100
commit015a35626d5a293dc9c19dc2bb301f25850961f6 (patch)
tree9449dd24c76fb2bb708d59709f1ceb3e11c19d0f /lua
parentc54fc1733e440ebe730f68a838c54c7c7e70e6fd (diff)
break!: remove file_browser from builtins (#1453)
The file_browser now has been fully removed. Please move to github.com/nvim-telescope/telescope-file-browser.nvim for a more featureful extension that replaces the builtin file browser.
Diffstat (limited to 'lua')
-rw-r--r--lua/telescope/builtin/files.lua139
-rw-r--r--lua/telescope/builtin/init.lua16
2 files changed, 0 insertions, 155 deletions
diff --git a/lua/telescope/builtin/files.lua b/lua/telescope/builtin/files.lua
index d71cf65..886745a 100644
--- a/lua/telescope/builtin/files.lua
+++ b/lua/telescope/builtin/files.lua
@@ -1,4 +1,3 @@
-local actions = require "telescope.actions"
local action_state = require "telescope.actions.state"
local action_set = require "telescope.actions.set"
local finders = require "telescope.finders"
@@ -10,9 +9,7 @@ local utils = require "telescope.utils"
local conf = require("telescope.config").values
local log = require "telescope.log"
-local scan = require "plenary.scandir"
local Path = require "plenary.path"
-local os_sep = Path.path.sep
local flatten = vim.tbl_flatten
local filter = vim.tbl_filter
@@ -263,142 +260,6 @@ local function prepare_match(entry, kind)
return entries
end
-files.file_browser = function(opts)
- vim.api.nvim_err_writeln [[Deprecation notice: file browser will be carved out into a more featureful extension, see:
-https://github.com/nvim-telescope/telescope-file-browser.nvim]]
-
- opts = opts or {}
-
- local is_dir = function(value)
- return value:sub(-1, -1) == os_sep
- end
-
- opts.depth = opts.depth or 1
- opts.cwd = opts.cwd and vim.fn.expand(opts.cwd) or vim.loop.cwd()
- opts.new_finder = opts.new_finder
- or function(path)
- opts.cwd = path
- local data = {}
-
- scan.scan_dir(path, {
- hidden = opts.hidden or false,
- add_dirs = true,
- depth = opts.depth,
- on_insert = function(entry, typ)
- table.insert(data, typ == "directory" and (entry .. os_sep) or entry)
- end,
- })
- table.insert(data, 1, ".." .. os_sep)
-
- local maker = function()
- local mt = {}
- mt.cwd = opts.cwd
- mt.display = function(entry)
- local hl_group
- local display = utils.transform_path(opts, entry.value)
- if is_dir(entry.value) then
- display = display .. os_sep
- if not opts.disable_devicons then
- display = (opts.dir_icon or "") .. " " .. display
- hl_group = "Default"
- end
- else
- display, hl_group = utils.transform_devicons(entry.value, display, opts.disable_devicons)
- end
-
- if hl_group then
- return display, { { { 1, 3 }, hl_group } }
- else
- return display
- end
- end
-
- mt.__index = function(t, k)
- local raw = rawget(mt, k)
- if raw then
- return raw
- end
-
- if k == "path" then
- local retpath = Path:new({ t.cwd, t.value }):absolute()
- if not vim.loop.fs_access(retpath, "R", nil) then
- retpath = t.value
- end
- if is_dir(t.value) then
- retpath = retpath .. os_sep
- end
- return retpath
- end
-
- return rawget(t, rawget({ value = 1 }, k))
- end
-
- return function(line)
- local tbl = { line }
- tbl.ordinal = Path:new(line):make_relative(opts.cwd)
- return setmetatable(tbl, mt)
- end
- end
-
- return finders.new_table { results = data, entry_maker = maker() }
- end
-
- pickers.new(opts, {
- prompt_title = "File Browser",
- finder = opts.new_finder(opts.cwd),
- previewer = conf.file_previewer(opts),
- sorter = conf.file_sorter(opts),
- attach_mappings = function(prompt_bufnr, map)
- action_set.select:replace_if(function()
- return is_dir(action_state.get_selected_entry().path)
- end, function()
- local new_cwd = vim.fn.expand(action_state.get_selected_entry().path:sub(1, -2))
- local current_picker = action_state.get_current_picker(prompt_bufnr)
- current_picker.cwd = new_cwd
- current_picker:refresh(opts.new_finder(new_cwd), { reset_prompt = true })
- end)
-
- local create_new_file = function()
- local current_picker = action_state.get_current_picker(prompt_bufnr)
- local file = action_state.get_current_line()
- if file == "" then
- print(
- "To create a new file or directory(add "
- .. os_sep
- .. " at the end of file) "
- .. "write the desired new into the prompt and press <C-e>. "
- .. "It works for not existing nested input as well."
- .. "Example: this"
- .. os_sep
- .. "is"
- .. os_sep
- .. "a"
- .. os_sep
- .. "new_file.lua"
- )
- return
- end
-
- local fpath = current_picker.cwd .. os_sep .. file
- if not is_dir(fpath) then
- actions.close(prompt_bufnr)
- Path:new(fpath):touch { parents = true }
- vim.cmd(string.format(":e %s", fpath))
- else
- Path:new(fpath:sub(1, -2)):mkdir { parents = true }
- local new_cwd = vim.fn.expand(fpath)
- current_picker.cwd = new_cwd
- current_picker:refresh(opts.new_finder(new_cwd), { reset_prompt = true })
- end
- end
-
- map("i", "<C-e>", create_new_file)
- map("n", "<C-e>", create_new_file)
- return true
- end,
- }):find()
-end
-
-- TODO: finish docs for opts.show_line
files.treesitter = function(opts)
opts.show_line = utils.get_default(opts.show_line, true)
diff --git a/lua/telescope/builtin/init.lua b/lua/telescope/builtin/init.lua
index 7834da1..9425602 100644
--- a/lua/telescope/builtin/init.lua
+++ b/lua/telescope/builtin/init.lua
@@ -86,22 +86,6 @@ builtin.find_files = require_on_exported_call("telescope.builtin.files").find_fi
--- This is an alias for the `find_files` picker
builtin.fd = builtin.find_files
---- Lists files and folders in your current working directory, open files, navigate your filesystem, and create new
---- files and folders
---- - Default keymaps:
---- - `<cr>`: opens the currently selected file, or navigates to the currently selected directory
---- - `<C-e>`: creates new file in current directory, creates new directory if the name contains a trailing '/'
---- - Note: you can create files nested into several directories with `<C-e>`, i.e. `lua/telescope/init.lua` would
---- create the file `init.lua` inside of `lua/telescope` and will create the necessary folders (similar to how
---- `mkdir -p` would work) if they do not already exist
----@deprecated Please move to https://github.com/nvim-telescope/telescope-file-browser.nvim
----@param opts table: options to pass to the picker
----@field cwd string: root dir to browse from (default: cwd, use utils.buffer_dir() to search relative to open buffer)
----@field depth number: file tree depth to display (default: 1)
----@field dir_icon string: change the icon for a directory. (default: )
----@field hidden boolean: determines whether to show hidden files or not (default: false)
-builtin.file_browser = require_on_exported_call("telescope.builtin.files").file_browser
-
--- Lists function names, variables, and other symbols from treesitter queries
--- - Default keymaps:
--- - `<C-l>`: show autocompletion menu to prefilter your query by kind of ts node you want to see (i.e. `:var:`)