-
Notifications
You must be signed in to change notification settings - Fork 16
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 #270 from vim-denops/option-local-scope
👍 generate sub local scope option types
- Loading branch information
Showing
8 changed files
with
466 additions
and
205 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
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 |
---|---|---|
@@ -1,24 +1,56 @@ | ||
import type { Predicate } from "@core/unknownutil/type"; | ||
import { isLiteralOneOf } from "@core/unknownutil/is"; | ||
|
||
export type Option = { | ||
name: string; | ||
type: OptionType; | ||
scope: OptionScope[]; | ||
localScope?: OptionLocalScope; | ||
docs: string; | ||
}; | ||
|
||
export const OPTION_TYPES = ["string", "number", "boolean"] as const; | ||
|
||
export type OptionType = typeof OPTION_TYPES[number]; | ||
|
||
export function isOptionType(x: unknown): x is OptionType { | ||
return OPTION_TYPES.includes(x as OptionType); | ||
} | ||
export const isOptionType = isLiteralOneOf( | ||
OPTION_TYPES, | ||
) satisfies Predicate<OptionType>; | ||
|
||
export const OPTION_SCOPES = ["global", "local"] as const; | ||
|
||
export type OptionScope = typeof OPTION_SCOPES[number]; | ||
|
||
export function isOptionScope(x: unknown): x is OptionScope { | ||
return OPTION_SCOPES.includes(x as OptionScope); | ||
} | ||
export const isOptionScope = isLiteralOneOf( | ||
OPTION_SCOPES, | ||
) satisfies Predicate<OptionScope>; | ||
|
||
export const OPTION_LOCAL_SCOPES = ["buffer", "tab", "window"] as const; | ||
|
||
export type OptionLocalScope = typeof OPTION_LOCAL_SCOPES[number]; | ||
|
||
export const isOptionLocalScope = isLiteralOneOf( | ||
OPTION_LOCAL_SCOPES, | ||
) satisfies Predicate<OptionLocalScope>; | ||
|
||
export type DocsType = "vim" | "nvim"; | ||
|
||
export const OPTION_EXPORT_TYPES = [ | ||
"BufferLocalOption", | ||
"TabPageLocalOption", | ||
"WindowLocalOption", | ||
"GlobalOption", | ||
"GlobalOrBufferLocalOption", | ||
"GlobalOrTabPageLocalOption", | ||
"GlobalOrWindowLocalOption", | ||
] as const; | ||
|
||
export type OptionExportType = typeof OPTION_EXPORT_TYPES[number]; | ||
|
||
export const OPTION_CONSTRUCTORS = [ | ||
"BooleanOption", | ||
"NumberOption", | ||
"StringOption", | ||
] as const; | ||
|
||
export type OptionConstructor = typeof OPTION_CONSTRUCTORS[number]; |
Oops, something went wrong.