@@ -7,6 +7,8 @@ import * as nvimFn from "../function/nvim/mod.ts";
7
7
8
8
const cacheKey = "denops_std/buffer/decoration/vimDecorate/rs@1" ;
9
9
10
+ const prefix = "denops_std:buffer:decoration:decorate" ;
11
+
10
12
export interface Decoration {
11
13
/**
12
14
* Line number
@@ -140,8 +142,7 @@ async function vimDecorate(
140
142
bufnr : number ,
141
143
decorations : Decoration [ ] ,
142
144
) : Promise < void > {
143
- const toPropType = ( n : string ) =>
144
- `denops_std:buffer:decoration:decorate:${ n } ` ;
145
+ const toPropType = ( n : string ) => `${ prefix } :${ n } ` ;
145
146
const rs = ( denops . context [ cacheKey ] ?? new Set ( ) ) as Set < string > ;
146
147
denops . context [ cacheKey ] = rs ;
147
148
const hs = uniq ( decorations . map ( ( v ) => v . highlight ) ) . filter ( ( v ) =>
@@ -180,9 +181,9 @@ async function vimUndecorate(
180
181
end_lnum : end ,
181
182
} ) as { id : string ; type : string } [ ] ;
182
183
const propIds = new Set (
183
- propList . filter ( ( p ) =>
184
- p . type . startsWith ( "denops_std:buffer:decoration:decorate:" )
185
- ) . map ( ( p ) => p . id ) ,
184
+ propList
185
+ . filter ( ( p ) => p . type . startsWith ( ` ${ prefix } :` ) )
186
+ . map ( ( p ) => p . id ) ,
186
187
) ;
187
188
await batch ( denops , async ( denops ) => {
188
189
for ( const propId of propIds ) {
@@ -196,10 +197,7 @@ async function nvimDecorate(
196
197
bufnr : number ,
197
198
decorations : Decoration [ ] ,
198
199
) : Promise < void > {
199
- const ns = await nvimFn . nvim_create_namespace (
200
- denops ,
201
- "denops_std:buffer:decoration:decorate" ,
202
- ) ;
200
+ const ns = await nvimFn . nvim_create_namespace ( denops , prefix ) ;
203
201
for ( const chunk of itertools . chunked ( decorations , 1000 ) ) {
204
202
await batch ( denops , async ( denops ) => {
205
203
for ( const deco of chunk ) {
@@ -223,9 +221,6 @@ async function nvimUndecorate(
223
221
start : number ,
224
222
end : number ,
225
223
) : Promise < void > {
226
- const ns = await nvimFn . nvim_create_namespace (
227
- denops ,
228
- "denops_std:buffer:decoration:decorate" ,
229
- ) ;
224
+ const ns = await nvimFn . nvim_create_namespace ( denops , prefix ) ;
230
225
await nvimFn . nvim_buf_clear_namespace ( denops , bufnr , ns , start , end ) ;
231
226
}
0 commit comments