8000 fix typings by phanen · Pull Request #68 · chrishrb/gx.nvim · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix typings #68

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions lua/gx/handler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ local search_handler = require("gx.handlers.search")

local M = {}

---@param handlers table<string, boolean|GxHandler>
---@param handler boolean|GxHandler
---@param active boolean
local function add_handler(handlers, handler, active)
if
active == false
Expand All @@ -23,7 +26,7 @@ local function add_handler(handlers, handler, active)
handlers[#handlers + 1] = handler
end

---@param handlers { [string]: (boolean | GxHandler)[] }
---@param handlers table<string, boolean|GxHandler>
---@return GxHandler[]
local function resolve_handlers(handlers)
local resolved = {}
Expand Down Expand Up @@ -55,8 +58,9 @@ end
-- handler function
---@param mode string
---@param line string
---@param configured_handlers { [string]: (boolean | GxHandler)[] }
---@return { [number]: GxSelection }
---@param configured_handlers table<string, boolean|GxHandler>
---@param handler_options GxHandlerOptions
---@return GxSelection[]
function M.get_url(mode, line, configured_handlers, handler_options)
local detected_urls_set = {}
local detected_urls = {}
Expand Down
1 change: 1 addition & 0 deletions lua/gx/handlers/brewfile.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local helper = require("gx.helper")

---@type GxHandler
local M = {
-- only Brewfile
name = "brewfile",
Expand Down
3 changes: 2 additions & 1 deletion lua/gx/handlers/commit.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local helper = require("gx.helper")

---@type GxHandler
local M = {
-- every filetype and filename
name = "commit",
Expand All @@ -20,7 +21,7 @@ function M.handle(mode, line, handler_options)
remotes = remotes(vim.fn.expand("%:p"))
end

local push = handler_options.push
local push = handler_options.git_remote_push
if type(push) == "function" then
push = push(vim.fn.expand("%:p"))
end
Expand Down
1 change: 1 addition & 0 deletions lua/gx/handlers/cve.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local helper = require("gx.helper")

---@type GxHandler
local M = {
-- every filetype and filename
name = "cve",
Expand Down
3 changes: 2 additions & 1 deletion lua/gx/handlers/github.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local helper = require("gx.helper")

---@type GxHandler
local M = {
-- every filetype and filename
name = "github",
Expand All @@ -26,7 +27,7 @@ function M.handle(mode, line, handler_options)
remotes = remotes(vim.fn.expand("%:p"))
end

local push = handler_options.push
local push = handler_options.git_remote_push
if type(push) == "function" then
push = push(vim.fn.expand("%:p"))
end
Expand Down
1 change: 1 addition & 0 deletions lua/gx/handlers/go.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---@type GxHandler
local M = {
-- every filetype and filename
name = "go",
Expand Down
1 change: 1 addition & 0 deletions lua/gx/handlers/markdown.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local helper = require("gx.helper")

---@type GxHandler
local M = {
-- every filetype and filename
name = "markdown",
Expand Down
1 change: 1 addition & 0 deletions lua/gx/handlers/package_json.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local helper = require("gx.helper")

---@type GxHandler
local M = {
-- only package.json
name = "package_json",
Expand Down
1 change: 1 addition & 0 deletions lua/gx/handlers/plugin.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local helper = require("gx.helper")

---@type GxHandler
local M = {
-- every filename but only lua
name = "nvim-plugin",
Expand Down
1 change: 1 addition & 0 deletions lua/gx/handlers/search.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local helper = require("gx.helper")

---@type GxHandler
local M = {
-- every filetype and filename
name = "search",
Expand Down
1 change: 1 addition & 0 deletions lua/gx/handlers/url.lua
10A75
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local helper = require("gx.helper")

---@type GxHandler
local M = {
-- every filetype
name = "url",
Expand Down
17 changes: 10 additions & 7 deletions lua/gx/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,24 @@ local M = {}

---@class GxHandlerOptions
---@field search_engine string
---@field select_for_search string
---@field select_for_search boolean
---@field git_remotes string[]
---@field git_remote_push boolean

---@class GxHandler
---@field name string
---@field filetypes string[] | nil
---@field filename string | nil
---@field handle fun(mode: string, line: string, handler_options: GxHandlerOptions | nil)
---@field filetype string[]?
---@field filename string?
---@field handle fun(mode: string, line: string, handler_options: GxHandlerOptions): string?

---@class GxOptions
---@field open_browser_app string
---@field open_browser_args string[]
---@field handlers (boolean | GxHandler)[]
---@field handler_options GxHandlerOptions | nil
---@field handlers table<string, boolean|GxHandler>
---@field handler_options GxHandlerOptions

---@class GxSelection
---@field name string | nil
---@field name string?
---@field url string

-- search for url with handler
Expand Down Expand Up @@ -87,6 +89,7 @@ local function get_open_browser_args()
return args
end

---@param options GxOptions
local function with_defaults(options)
options = options or {}
options.handler_options = options.handler_options or {}
Expand Down
0