glsl_analyzer icon indicating copy to clipboard operation
glsl_analyzer copied to clipboard

Support `textDocument/rangeFormatting`

Open b0o opened this issue 1 year ago • 2 comments

First, thank you for your work on this project, it's been a very helpful tool!

I'm using glsl_analyzer in Neovim, primarily for embedded glsl code blocks inside of other languages. For example, inside a TypeScript file:

// This is a test

const foo = "bar";

const vert = glsl`
  void main() {
    vec4 position = vec4(0.0, 0.0, 0.0, 1.0);
    gl_Position = position;
  }
`;

const hello = "world";

I'm using treesitter parsers for both TypeScript and GLSL. The TypeScript treesitter parser supports injected code blocks using tagged template literals as I've demonstrated above. Then, I'm using otter.nvim which lets you run LSPs on these embedded code blocks.

In this way, LSP autocompletion and hovering works perfectly. One drawback is that otter.nvim seems to need the attached LSP to support textDocument/rangeFormatting in order to format the code blocks, so I'm unable to use glsl_analyzer for formatting with my setup. Adding range formatting support should fix this.

b0o avatar Dec 02 '23 23:12 b0o