-
-
Notifications
You must be signed in to change notification settings - Fork 3
feat: add 13 new builtin extensions (sources, previewers, renderers) #9
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
75b036b
Add CLAUDE.md to provide guidance for Claude Code
lambdalisue 6bdfbe0
feat(source): add window source for listing Vim windows
lambdalisue ad2d410
feat(source): add tabpage source for listing Vim tab pages
lambdalisue 9004a59
feat(source): add loclist source for listing location list items
lambdalisue d337686
feat(source): add colorscheme source for listing available colorschemes
lambdalisue d8a627c
feat(source): add highlight source for listing highlight groups
lambdalisue 33e58cd
feat(source): add jumplist source for listing jump locations
lambdalisue fd1a7c8
feat(source): add register source for listing Vim registers
lambdalisue 5006534
feat(source): add mark source for listing Vim marks
lambdalisue 1c0e825
feat(source): add command source for listing user-defined commands
lambdalisue 9c39f46
feat(source): add mapping source for listing key mappings
lambdalisue e8f21f1
feat(source): add git status source for listing modified files
lambdalisue 881a059
feat(source): add grep source for vim's :grep command results
lambdalisue c3bf51b
feat(source): add vimgrep source for vim's :vimgrep command results
lambdalisue 89e0265
feat(source): add autocmd source for vim autocmds
lambdalisue c74961d
feat(previewer): add shell command previewer
lambdalisue bfba569
feat(renderer): add file info renderer for displaying file metadata
lambdalisue 8090011
feat(renderer): add buffer info renderer for displaying buffer metadata
lambdalisue 0f0a8f2
feat(renderer): add smart grep renderer for formatting grep-like results
lambdalisue e9a3319
feat(refiner): add file info refiner for filtering by file properties
lambdalisue c166b92
feat(refiner): add buffer info refiner for filtering by buffer proper…
lambdalisue File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,166 @@ | ||
| import * as fn from "@denops/std/function"; | ||
|
|
||
| import { defineSource, type Source } from "../../source.ts"; | ||
|
|
||
| type Detail = { | ||
| /** | ||
| * Mapping key/lhs | ||
| */ | ||
| lhs: string; | ||
|
|
||
| /** | ||
| * Mapping value/rhs | ||
| */ | ||
| rhs: string; | ||
|
|
||
| /** | ||
| * Mapping mode | ||
| */ | ||
| mode: string; | ||
|
|
||
| /** | ||
| * Whether the mapping is buffer-local | ||
| */ | ||
| bufferLocal: boolean; | ||
|
|
||
| /** | ||
| * Whether the mapping is silent | ||
| */ | ||
| silent: boolean; | ||
|
|
||
| /** | ||
| * Whether the mapping is noremap | ||
| */ | ||
| noremap: boolean; | ||
|
|
||
| /** | ||
| * Whether the mapping waits for more input | ||
| */ | ||
| nowait: boolean; | ||
|
|
||
| /** | ||
| * Whether the mapping is an expression | ||
| */ | ||
| expr: boolean; | ||
| }; | ||
|
|
||
| export type MappingOptions = { | ||
| /** | ||
| * Which modes to include mappings from. | ||
| * Default includes all common modes. | ||
| * @default ["n", "i", "v", "x", "s", "o", "c", "t"] | ||
| */ | ||
| modes?: string[]; | ||
|
|
||
| /** | ||
| * Whether to include buffer-local mappings. | ||
| * @default true | ||
| */ | ||
| includeBufferLocal?: boolean; | ||
|
|
||
| /** | ||
| * Whether to include plugin mappings (mappings containing <Plug>). | ||
| * @default false | ||
| */ | ||
| includePluginMappings?: boolean; | ||
| }; | ||
|
|
||
| /** | ||
| * Creates a Source that generates items from Vim key mappings. | ||
| * | ||
| * This Source retrieves all key mappings from specified modes and | ||
| * generates items for each one, showing their definitions and attributes. | ||
| * | ||
| * @param options - Options to customize mapping listing. | ||
| * @returns A Source that generates items representing mappings. | ||
| */ | ||
| export function mapping( | ||
| options: Readonly<MappingOptions> = {}, | ||
| ): Source<Detail> { | ||
| const modes = options.modes ?? ["n", "i", "v", "x", "s", "o", "c", "t"]; | ||
| const includeBufferLocal = options.includeBufferLocal ?? true; | ||
| const includePluginMappings = options.includePluginMappings ?? false; | ||
|
|
||
| return defineSource(async function* (denops, _params, { signal }) { | ||
| const items: Array<{ | ||
| id: number; | ||
| value: string; | ||
| detail: Detail; | ||
| }> = []; | ||
|
|
||
| let id = 0; | ||
| for (const mode of modes) { | ||
| // Get mappings for this mode | ||
| const mappingList = await fn.maplist(denops, mode) as Array<{ | ||
| lhs: string; | ||
| rhs: string; | ||
| silent: number | boolean; | ||
| noremap: number | boolean; | ||
| nowait: number | boolean; | ||
| expr: number | boolean; | ||
| buffer: number | boolean; | ||
| mode?: string; | ||
| sid?: number; | ||
| lnum?: number; | ||
| script?: number | boolean; | ||
| }>; | ||
| signal?.throwIfAborted(); | ||
|
|
||
| for (const mapping of mappingList) { | ||
| // Skip buffer-local mappings if not included | ||
| const isBufferLocal = Boolean(mapping.buffer); | ||
| if (isBufferLocal && !includeBufferLocal) { | ||
| continue; | ||
| } | ||
|
|
||
| // Skip plugin mappings if not included | ||
| if (!includePluginMappings && mapping.rhs.includes("<Plug>")) { | ||
| continue; | ||
| } | ||
|
|
||
| // Build attributes | ||
| const attributes: string[] = []; | ||
| if (mapping.silent) attributes.push("silent"); | ||
| if (mapping.noremap) attributes.push("noremap"); | ||
| if (mapping.nowait) attributes.push("nowait"); | ||
| if (mapping.expr) attributes.push("expr"); | ||
| if (isBufferLocal) attributes.push("buffer"); | ||
|
|
||
| // Format mode indicator | ||
| const modeIndicator = mode === "n" ? " " : `[${mode}]`; | ||
|
|
||
| // Format display value | ||
| const attrStr = attributes.length > 0 | ||
| ? ` (${attributes.join(", ")})` | ||
| : ""; | ||
| const truncatedRhs = mapping.rhs.length > 50 | ||
| ? mapping.rhs.substring(0, 47) + "..." | ||
| : mapping.rhs; | ||
|
|
||
| items.push({ | ||
| id: id++, | ||
| value: `${modeIndicator} ${mapping.lhs}${attrStr} → ${truncatedRhs}`, | ||
| detail: { | ||
| lhs: mapping.lhs, | ||
| rhs: mapping.rhs, | ||
| mode: mode, | ||
| bufferLocal: isBufferLocal, | ||
| silent: Boolean(mapping.silent), | ||
| noremap: Boolean(mapping.noremap), | ||
| nowait: Boolean(mapping.nowait), | ||
| expr: Boolean(mapping.expr), | ||
| }, | ||
| }); | ||
|
Comment on lines
+140
to
+153
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just yield. |
||
| } | ||
| } | ||
|
|
||
| // Sort by mode and then by lhs | ||
| items.sort((a, b) => { | ||
| const modeCmp = a.detail.mode.localeCompare(b.detail.mode); | ||
| if (modeCmp !== 0) return modeCmp; | ||
| return a.detail.lhs.localeCompare(b.detail.lhs); | ||
| }); | ||
|
Comment on lines
+157
to
+162
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should NOT sort in source. |
||
|
|
||
| yield* items; | ||
| }); | ||
| } | ||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid using
as. Try@core/unknownutilto use type guard.