This is a major mode for Emacs for the Slang Shading Language
- Syntax Highlighting:
- Core language keywords (
interface,struct,enum,module,import, etc.) - Built-in types (scalar, vector, matrix types like
float3,int4x4) - Texture and buffer types (
Texture2D,RWBuffer,StructuredBuffer, etc.) - HLSL semantics (
SV_Position,SV_Target,TEXCOORD0, etc.) - Built-in functions and intrinsics (
sin,cos,Sample,WaveActiveSum, etc.) - Preprocessor directives and attributes
- Core language keywords (
- C-style Indentation: Proper indentation based on C-mode
- Comment Support: Both single-line (
//) and multi-line (/* */) comments - Electric Braces: Automatic indentation when inserting
{and} - Imenu Support: Navigation of functions, structs, interfaces, enums, and classes
Optional Language Server Protocol integration via slang-lsp.el:
- Real-time Diagnostics: Error checking as you type
- Code Completion: Context-aware autocompletion
- Go to Definition: Jump to symbol definitions (
C-c l d) - Hover Documentation: View documentation on hover (
C-c l h) - Code Formatting: Format code with slangd (
C-c l f) - Symbol Renaming: Rename across project (
C-c l n) - Signature Help: Function parameter hints
Requirements:
slangdlanguage server from Slang releases or Vulkan SDKeglot(built into Emacs 29+)
Note: Current slangd version doesn't support find references, implementation, or type definition.
- Download or clone the
slang-mode.elfile - Place it in a directory in Emacs load path
- Add to your
.emacsorinit.el:
(require 'slang-mode)
;; Optional: Enable LSP support
(require 'slang-lsp)
(slang-lsp-initialize)(use-package slang-mode
:straight (:host github :repo "k1ngst0m/slang-mode")
:mode (("\\.slang\\'" . slang-mode)
("\\.sl\\'" . slang-mode)
("\\.slangh\\'" . slang-mode))
:config
;; Optional: Enable LSP support
(require 'slang-lsp)
(slang-lsp-initialize))Add to your packages.el:
(package! slang-mode
:recipe (:host github :repo "k1ngst0m/slang-mode"))Add to your config.el:
(use-package! slang-mode
:mode (("\\.slang\\'" . slang-mode)
("\\.sl\\'" . slang-mode)
("\\.slangh\\'" . slang-mode))
:config
;; Optional: Enable LSP support
(require 'slang-lsp)
(slang-lsp-initialize))Then run doom sync
Add to your dotspacemacs-additional-packages:
(setq-default dotspacemacs-additional-packages
'((slang-mode :location (recipe :fetcher github
:repo "k1ngst0m/slang-mode"))))
;; In dotspacemacs/user-config, optionally enable LSP:
(with-eval-after-load 'slang-mode
(require 'slang-lsp)
(slang-lsp-initialize))The mode automatically activates for files with these extensions:
.slang- Slang source files.sl- Slang source files.slangh- Slang header files
The mode provides a customization group accessible via:
M-x customize-group RET slang RETAvailable customizations:
slang-indent-offset: Indentation offset for Slang code (default: 4)
- Syntax Highlighting: Comprehensive highlighting of all Slang language constructs
- Indentation: C-style indentation that properly handles Slang syntax
- Comments: Proper handling of both
//single-line and/* */multi-line comments
- Auto-completion: Press
TaborC-ifor context-aware suggestions - Go to Definition:
C-c l dto jump to symbol definitions - Hover Documentation:
C-c l hto view symbol documentation - Code Formatting:
C-c l fto format current buffer - Symbol Renaming:
C-c l nto rename symbols across project - Menu Access: Use
Slang > LSPmenu for all LSP commands
slang-moderequires Emacs 24.3 or laterslang-lsp(LSP integration) requires Emacs 26.1 or later andeglot(version 1.4+ or Emacs 29+)
MIT License