feat(nvim): word wrap and snap tree width to characters
This commit is contained in:
@@ -85,7 +85,7 @@ export const Kitty = (props: {
|
|||||||
ref={container}
|
ref={container}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
className="whitespace-pre"
|
className="whitespace-pre-wrap"
|
||||||
style={{ backdropFilter: "blur(2px)", width, height }}
|
style={{ backdropFilter: "blur(2px)", width, height }}
|
||||||
>
|
>
|
||||||
<KittyProvider value={context}>{props.children}</KittyProvider>
|
<KittyProvider value={context}>{props.children}</KittyProvider>
|
||||||
|
|||||||
@@ -14,5 +14,5 @@ export const NvimEditor = (props: { source: string | undefined }) => {
|
|||||||
});
|
});
|
||||||
}, [props.source]);
|
}, [props.source]);
|
||||||
|
|
||||||
return <div className="h-full">{loading ? "Loading..." : data}</div>;
|
return <p>{loading ? "Loading..." : data}</p>;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ export const NvimStatusBar = (props: {
|
|||||||
fileIcon?: string;
|
fileIcon?: string;
|
||||||
fileName: string;
|
fileName: string;
|
||||||
}) => (
|
}) => (
|
||||||
<div className="bg-[#29293c]">
|
<div className="select-none bg-[#29293c]">
|
||||||
<span className="text-[#272332]" style={{ background: props.labelColor }}>
|
<span className="text-[#272332]" style={{ background: props.labelColor }}>
|
||||||
{` ${props.label} `}
|
{` ${props.label} `}
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import {
|
|||||||
import { type Nvim } from "..";
|
import { type Nvim } from "..";
|
||||||
import { NvimTreeDirectory } from "./NvimTreeDirectory";
|
import { NvimTreeDirectory } from "./NvimTreeDirectory";
|
||||||
import { NvimTreeFile } from "./NvimTreeFile";
|
import { NvimTreeFile } from "./NvimTreeFile";
|
||||||
import { promiseHooks } from "v8";
|
|
||||||
|
|
||||||
const sortFiles = (files: Array<File | Directory>) =>
|
const sortFiles = (files: Array<File | Directory>) =>
|
||||||
files
|
files
|
||||||
|
|||||||
@@ -1,15 +1,19 @@
|
|||||||
import { useKitty } from "~/hooks/useKitty";
|
import { useKitty } from "~/hooks/useKitty";
|
||||||
import { CHAR_HEIGHT } from "../Kitty";
|
import { CHAR_HEIGHT, CHAR_WIDTH } from "../Kitty";
|
||||||
import { NvimEditor } from "./NvimEditor";
|
import { NvimEditor } from "./NvimEditor";
|
||||||
import { NvimInput } from "./NvimInput";
|
import { NvimInput } from "./NvimInput";
|
||||||
import { NvimStatusBar } from "./NvimStatusBar";
|
import { NvimStatusBar } from "./NvimStatusBar";
|
||||||
import { NvimTree } from "./NvimTree";
|
import { NvimTree } from "./NvimTree";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { File } from "~/utils/types";
|
import { File, InnerKittyProps } from "~/utils/types";
|
||||||
|
|
||||||
export const Nvim = (_props: {}) => {
|
export const Nvim = (_props: {}) => {
|
||||||
const kitty = useKitty();
|
const kitty = useKitty();
|
||||||
|
|
||||||
|
return kitty && <InnerNvimTree {...kitty} />;
|
||||||
|
};
|
||||||
|
|
||||||
|
const InnerNvimTree = (props: InnerKittyProps<typeof Nvim>) => {
|
||||||
const [activeFile, setActiveFile] = useState<{
|
const [activeFile, setActiveFile] = useState<{
|
||||||
name: string;
|
name: string;
|
||||||
url: string;
|
url: string;
|
||||||
@@ -32,16 +36,23 @@ export const Nvim = (_props: {}) => {
|
|||||||
<div
|
<div
|
||||||
className="grid h-full"
|
className="grid h-full"
|
||||||
style={{
|
style={{
|
||||||
gridTemplateColumns: `0.4fr 2fr`,
|
gridTemplateColumns: `minmax(${CHAR_WIDTH * 20}px, ${
|
||||||
|
Math.round(props.cols * 0.2) * CHAR_WIDTH
|
||||||
|
}px) 1fr`,
|
||||||
gridTemplateRows: `1fr ${CHAR_HEIGHT}px ${CHAR_HEIGHT}px`,
|
gridTemplateRows: `1fr ${CHAR_HEIGHT}px ${CHAR_HEIGHT}px`,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{kitty && (
|
|
||||||
<>
|
|
||||||
<div style={{ gridArea: "1 / 1 / 1 / 2" }}>
|
<div style={{ gridArea: "1 / 1 / 1 / 2" }}>
|
||||||
<NvimTree {...kitty} onOpen={handleOpenFile} />
|
<NvimTree {...props} onOpen={handleOpenFile} />
|
||||||
</div>
|
</div>
|
||||||
<div style={{ gridArea: "1 / 2 / 1 / 3", overflow: "scroll" }}>
|
<div
|
||||||
|
className="overflow-y-auto break-all"
|
||||||
|
style={{
|
||||||
|
gridArea: "1 / 2 / 1 / 3",
|
||||||
|
overflowY: "auto",
|
||||||
|
wordWrap: "break-word",
|
||||||
|
}}
|
||||||
|
>
|
||||||
<NvimEditor source={activeFile?.url} />
|
<NvimEditor source={activeFile?.url} />
|
||||||
</div>
|
</div>
|
||||||
<div style={{ gridArea: "2 / 1 / 2 / 3" }}>
|
<div style={{ gridArea: "2 / 1 / 2 / 3" }}>
|
||||||
@@ -55,8 +66,6 @@ export const Nvim = (_props: {}) => {
|
|||||||
<div style={{ gridArea: "3 / 1 / 3 / 3" }}>
|
<div style={{ gridArea: "3 / 1 / 3 / 3" }}>
|
||||||
<NvimInput />
|
<NvimInput />
|
||||||
</div>
|
</div>
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user