Skip to content

Commit

Permalink
feat: realtivePath column for buffer, fix #586
Browse files Browse the repository at this point in the history
  • Loading branch information
weirongxu committed Jun 8, 2024
1 parent a033895 commit 82ce582
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ Columns:
- bufnr
- readonly
- fullpath
- relativePath

default: `[selection | 1] [bufnr] [name][modified][readonly] [fullpath]`

Expand Down
16 changes: 16 additions & 0 deletions src/source/sources/buffer/child-columns/relativePath.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import pathLib from 'path';
import { bufferColumnRegistrar } from '../bufferColumnRegistrar';
import { bufferHighlights } from '../bufferSource';

bufferColumnRegistrar.registerColumn('child', 'relativePath', ({ source }) => ({
draw() {
return {
drawNode(row, { node }) {
const relativePath = pathLib.relative(source.root, node.fullpath);
row.add(relativePath, {
hl: bufferHighlights.fullpath,
});
},
};
},
}));
1 change: 1 addition & 0 deletions src/source/sources/buffer/load.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ import './child-columns/diagnosticError';
import './child-columns/diagnosticWarning';
import './child-columns/readonly';
import './child-columns/fullpath';
import './child-columns/relativePath';

0 comments on commit 82ce582

Please sign in to comment.