switch to nvim-goodies
This commit is contained in:
parent
736e14dc5c
commit
01622c75b8
@ -3,9 +3,11 @@ local action_state = require "telescope.actions.state"
|
|||||||
local actions = require "telescope.actions"
|
local actions = require "telescope.actions"
|
||||||
local conf = require("telescope.config").values
|
local conf = require("telescope.config").values
|
||||||
local finders = require("telescope.finders")
|
local finders = require("telescope.finders")
|
||||||
local pickers = require("telescope.pickers")
|
local g = require("nvim-goodies")
|
||||||
local global_state = require("telescope.state")
|
local global_state = require("telescope.state")
|
||||||
local utils = require("nvim-flutter-companion.utils")
|
local gos = require("nvim-goodies.os")
|
||||||
|
local gpath = require("nvim-goodies.path")
|
||||||
|
local pickers = require("telescope.pickers")
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
local companion_title = "Flutter Companion"
|
local companion_title = "Flutter Companion"
|
||||||
@ -21,11 +23,11 @@ local EMULATOR = 1
|
|||||||
local DEVICE = 2
|
local DEVICE = 2
|
||||||
|
|
||||||
local get_config_path = function()
|
local get_config_path = function()
|
||||||
return utils.create_path(vim.fn.getcwd(), ".flutter-companion")
|
return gpath.create_path(vim.fn.getcwd(), ".flutter-companion")
|
||||||
end
|
end
|
||||||
|
|
||||||
local get_flutter_command = function()
|
local get_flutter_command = function()
|
||||||
local cmd = "flutter" .. utils.iff(utils.is_windows, ".bat", "")
|
local cmd = "flutter" .. g.iff(gos.is_windows, ".bat", "")
|
||||||
return cmd
|
return cmd
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -65,7 +67,7 @@ local load_table = function(path)
|
|||||||
return vim.json.decode(lines)
|
return vim.json.decode(lines)
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
return utils.iff(ok, json, {})
|
return g.iff(ok, json, {})
|
||||||
end
|
end
|
||||||
|
|
||||||
local parse = function(line, device_type)
|
local parse = function(line, device_type)
|
||||||
@ -187,9 +189,9 @@ function M.flutter_list(is_emulators)
|
|||||||
local config_path = get_config_path()
|
local config_path = get_config_path()
|
||||||
local config_data = load_table(config_path)
|
local config_data = load_table(config_path)
|
||||||
|
|
||||||
local callback_index = utils.iff(is_emulators, 2, 1)
|
local callback_index = g.iff(is_emulators, 2, 1)
|
||||||
local list_function = utils.iff(is_emulators, list_emulators, list_devices)
|
local list_function = g.iff(is_emulators, list_emulators, list_devices)
|
||||||
local name = utils.iff(is_emulators, "Emulators", "Devices")
|
local name = g.iff(is_emulators, "Emulators", "Devices")
|
||||||
|
|
||||||
local completed_callback
|
local completed_callback
|
||||||
if callbacks[callback_index] ~= nil then
|
if callbacks[callback_index] ~= nil then
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
local Path = require "plenary.path"
|
|
||||||
local M = {}
|
|
||||||
|
|
||||||
M.iff = function(b, l, r)
|
|
||||||
if b then
|
|
||||||
return l
|
|
||||||
end
|
|
||||||
|
|
||||||
return r
|
|
||||||
end
|
|
||||||
|
|
||||||
M.is_windows = vim.fn.has("win32") == 1 or vim.fn.has("win64") == 1
|
|
||||||
M.directory_sep = M.iff(M.is_windows, "\\\\", "/")
|
|
||||||
M.not_directory_sep = M.iff(M.is_windows, "/", "\\\\")
|
|
||||||
|
|
||||||
M.create_path = function(...)
|
|
||||||
return Path:new({...}):absolute():gsub(M.not_directory_sep, M.directory_sep):gsub(
|
|
||||||
M.directory_sep .. M.directory_sep,
|
|
||||||
M.directory_sep
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
return M
|
|
Loading…
x
Reference in New Issue
Block a user