glsl-mode icon indicating copy to clipboard operation
glsl-mode copied to clipboard

Fix glsl-ts-mode.

Open drshapeless opened this issue 1 year ago • 9 comments

Derive glsl-ts-mode from prog-mode instead of c-ts-mode.

Remove the use of deprecated `c-ts-mode--get-indent-style'

drshapeless avatar Mar 06 '25 14:03 drshapeless

Any particular reason you think we should stop deriving from c-ts-mode? I very much expect useful things to be available from the upstream C version (such as easily swappable indentation styles), even if it right now is, evidently, a bit unstable

Xaldew avatar Mar 07 '25 08:03 Xaldew

How to prevent eglot from managing glsl buffers then? Any glsl-ts-buffer gets assigned to clangd even if i have glsl_analyzer explicitly set for glsl-ts-mode because its derived from c-ts-mode.

TideSofDarK avatar Apr 18 '25 22:04 TideSofDarK

I'm afraid I don't actually use either glsl_analyzer or eglot unfortunately. How have you you configured it? Looking at the docs, it seems like you should be able to enable it using:

(with-eval-after-load 'eglot
  (add-to-list 'eglot-server-programs
               '(glsl-ts-mode . ("glsl_analyzer"))))

Similar code could be written using use-package. Are you saying that such a configuration is picking up clangd as a server program instead? To me, that sounds like a bug in the handling of derived modes in eglot rather than anything else, but I don't know enough here

Xaldew avatar Apr 20 '25 11:04 Xaldew

Nah. If I open a C/C++ first then eglot starts to manage whole c-ts-mode family with clangd. No luck trying to fix it so far.

TideSofDarK avatar Apr 20 '25 13:04 TideSofDarK

Also, c-ts-mode--get-indent-style really needs to be handled. Emacs 31.x simply won't enter glsl-ts-mode anymore since that function is absent. I'm going to tackle glsl-ts-mode a bit to see what can be improved. Will make a PR if something nice comes out of it.

TideSofDarK avatar Apr 20 '25 13:04 TideSofDarK

No need, I've fixed that already (https://github.com/Xaldew/glsl-mode), I just haven't had time to verify it properly due to work

Xaldew avatar Apr 20 '25 13:04 Xaldew

Which, should now be fixed with commit 8d4ff33. I looked a bit more at eglot, and it seems the default (for some version of Emacs), includes:

    ((c-mode c-ts-mode c++-mode c++-ts-mode objc-mode)
     . ,(eglot-alternatives
         '("clangd" "ccls")))

Which probably explains why clangd starts. I think simply adding:

(use-package glsl-mode
    :ensure t
    :config
    (with-eval-after-load 'eglot
      (add-to-list 'eglot-server-programs
               '(glsl-ts-mode . ("glsl_analyzer")))))

Might fix it for you, but as I said, I'm not using either of these components at the moment

Xaldew avatar Apr 20 '25 13:04 Xaldew

This works only if there is no active clangd managing c-ts-* family. Example: run Emacs, open a GLSL file. Enter glsl-ts-mode, glsl_analyzer starts to manage glsl-ts-mode buffers. Then you open a C/C++ file which makes eglot manage any c-ts-* buffer. From that point entering glsl-ts-mode in other buffers would use clangd.

TideSofDarK avatar Apr 20 '25 15:04 TideSofDarK

@Xaldew Could you take a look at #18 ? As promised, some improvements. Been running those for a couple of days, seems great so far.

TideSofDarK avatar Apr 24 '25 16:04 TideSofDarK