aboutsummaryrefslogtreecommitdiffstats
path: root/after/ftplugin/gdscript.vim
diff options
context:
space:
mode:
authorAriel D'Alessandro <ariel.dalessandro@auto1.com>2022-11-18 09:07:46 +0100
committerAriel D'Alessandro <ariel.dalessandro@auto1.com>2022-11-18 09:07:58 +0100
commit877c889e43678110a0c5056f30587b60b3282eba (patch)
treefbfe080d5ba2adc3ec8e6857254b7879b8d010b7 /after/ftplugin/gdscript.vim
parent522e50582299aa8e9194e6b9cd0749748c42b243 (diff)
downloadnvim-conf-877c889e43678110a0c5056f30587b60b3282eba.tar.gz
nvim-conf-877c889e43678110a0c5056f30587b60b3282eba.zip
small changes
Diffstat (limited to 'after/ftplugin/gdscript.vim')
0 files changed, 0 insertions, 0 deletions
#n106'>106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
SHOULD_RELOAD_TELESCOPE = true

local reloader = function()
	if SHOULD_RELOAD_TELESCOPE then
		RELOAD("plenary")
		RELOAD("telescope")
		RELOAD("alpha.telescope.setup")
	end
end

local action_state = require("telescope.actions.state")
local fb_actions = require("telescope").extensions.file_browser.actions
local actions = require("telescope.actions")

local M = {}

function M.project_files()
	local opts = {show_untracked = true} -- define here if you want to define something
	local ok = pcall(require("telescope.builtin").git_files, opts)
	if not ok then
		require("telescope.builtin").find_files(opts)
	end
end

function M.branches()
	require("telescope.builtin").git_branches({
		attach_mappings = function(_, map)
			map("i", "<c-j>", actions.git_create_branch)
			map("n", "<c-j>", actions.git_create_branch)
			return true
		end,
	})
end

function M.search_config()
	require("telescope.builtin").git_files({
		prompt_title = "< dotfiles >",
		cwd = "$HOME/.dotfiles",
	})
end

function M.grep_string()
	vim.ui.input({ prompt = "Grep for > " }, function(input)
		if input == nil then
			return
		end
		require("telescope.builtin").grep_string({ search = input })
	end)
end

function M.grep_word()
	require("telescope.builtin").grep_string({ search = vim.fn.expand("<cword>") })
end

function M.find_symbol()
	vim.ui.input("Symbol for > ", function(input)
		if input == nil then
			return
		end
		require("telescope.builtin").lsp_workspace_symbols({ query = input })
	end)
end

function M.my_plugins()
	require("telescope.builtin").find_files({
		cwd = "~/plugins/",
	})
end

function M.projectionist()
	return require("telescope").extensions.projectionist.projectionist()
end

function M.laravel()
	vim.env.NO_TTY = 1
	return require("telescope").extensions.laravel.laravel()
end

function M.worktree()
	return require("telescope").extensions.git_worktree.git_worktrees()
end

function M.worktree_create()
	return require("telescope").extensions.git_worktree.create_git_worktree()
end

function M.refactor()
	return require("telescope").extensions.refactoring.refactors()
end

function M.file_browser_relative()
	return M.file_browser({ path = "%:p:h" })
end

function M.file_browser(opts)
	opts = opts or {}

	opts = {
		path = opts.path,
		sorting_strategy = "ascending",
		scroll_strategy = "cycle",
		layout_config = {
			prompt_position = "top",
		},

		attach_mappings = function(prompt_bufnr, map)
			local current_picker = action_state.get_current_picker(prompt_bufnr)

			local modify_cwd = function(new_cwd)
				local finder = current_picker.finder

				finder.path = new_cwd
				finder.files = true
				current_picker:refresh(false, { reset_prompt = true })
			end

			map("n", "-", function()
				modify_cwd(current_picker.cwd .. "/..")
			end)

			map("i", "~", function()
				modify_cwd(vim.fn.expand("~"))
			end)

			map("n", "yy", function()
				local entry = action_state.get_selected_entry()
				vim.fn.setreg("+", entry.value)
			end)

			map("i", "<c-y>", fb_actions.create)

			return true
		end,
	}

	return require("telescope").extensions.file_browser.file_browser(opts)
end

return setmetatable({}, {
	__index = function(_, k)
		reloader()
		if M[k] then
			return M[k]
		else
			return require("telescope.builtin")[k]
		end
	end,
})