huynle / ogpt.nvim

Chat with Ollama/Huggingface/TextGen/OpenAI/Gemini/Anthropic GPT Neovim Plugin: Effortless Natural Language Generation with LLM API
Apache License 2.0
155 stars 13 forks source link

Use Treesitter Syntax Highlighting #38

Open a-priestley opened 1 month ago

a-priestley commented 1 month ago

The OGPT output window appears to support rudimentary syntax highlighting for markdown. At runtime, I can substantially improve this by issuing :setfiletype markdown while inside the OGPT output window, enabling features like fenced code block highlighting(```tsx[linebreak][code][linebreak]```) resulting in nested language parsing within markdown like the following:

import ErrorComponent, { ErrorProps } from "@/components/error";
import LayoutComponent from "@/components/layout";

export default function Custom404({
  errorProps,
  version,
}: {
  errorProps: ErrorProps;
  version: string;
}) {
  return (
    <LayoutComponent {...{ version }}>
      <ErrorComponent props={errorProps} />
    </LayoutComponent>
  );
}

export const getStaticProps = async () => {
  const errorProps = {
    title: "404",
    description: "Page Not Found",
    return: true,
  };
  return {
    props: { errorProps },
  };
};

This greatly improves readability for prompt outputs involving code especially.

Is it possible to integrate this capability automatically when loading OGPT?

a-priestley commented 1 month ago

39