diff --git a/readme.md b/readme.md index 18a10be..ea6c057 100644 --- a/readme.md +++ b/readme.md @@ -295,6 +295,7 @@ Columns: - bufnr - readonly - fullpath +- relativePath default: `[selection | 1] [bufnr] [name][modified][readonly] [fullpath]` diff --git a/src/source/sources/buffer/child-columns/relativePath.ts b/src/source/sources/buffer/child-columns/relativePath.ts new file mode 100644 index 0000000..c37a8da --- /dev/null +++ b/src/source/sources/buffer/child-columns/relativePath.ts @@ -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, + }); + }, + }; + }, +})); diff --git a/src/source/sources/buffer/load.ts b/src/source/sources/buffer/load.ts index 4db798e..8a1d8bd 100644 --- a/src/source/sources/buffer/load.ts +++ b/src/source/sources/buffer/load.ts @@ -12,3 +12,4 @@ import './child-columns/diagnosticError'; import './child-columns/diagnosticWarning'; import './child-columns/readonly'; import './child-columns/fullpath'; +import './child-columns/relativePath';