;;; development.el -*- lexical-binding: t; -*- (after! lsp-ui (setq lsp-ui-doc-include-signature t ;; Show method signatures in docs lsp-ui-sideline-show-symbol t ;; Show symbols in the sideline lsp-ui-doc-show-with-cursor t ;; Show docs when cursor is on symbol lsp-ui-doc-max-height 30 ;; Increase doc height to show more info lsp-ui-sideline-show-hover t ;; Show hover information in sideline lsp-ui-doc-enable t ;; Enable documentation lsp-signature-auto-activate t ;; Show signature help automatically lsp-signature-render-documentation t)) ;; Include docs in signature help (after! eldoc (setq eldoc-echo-area-use-multiline-p t eldoc-echo-area-prefer-doc-buffer t)) (use-package! corfu-popupinfo :after corfu :hook (corfu-mode . corfu-popupinfo-mode) :custom (corfu-popupinfo-delay '(0.25 . 0.1)) ; Faster popup display (corfu-popupinfo-hide nil) ; Don't hide automatically ) ;; Configure Corfu for richer display (after! corfu (setq corfu-auto t ; Enable auto completion corfu-auto-prefix 2 ; Complete after 2 characters corfu-preview-current t ; Preview current candidate corfu-show-documentation t ; Show documentation in popup corfu-doc-max-height 20 ; Max height for doc popup corfu-doc-delay 0.2 ; Faster doc popup corfu-quit-no-match t) ; Quit if no match ;; Show more detailed annotations (setq corfu-show-annotations t corfu-annotate-max-width 50) ) ;; If using LSP, configure to show more details (after! lsp-mode (setq lsp-completion-show-detail t ; Show method signatures lsp-completion-show-kind t ; Show completion item kind lsp-completion-show-label-description t ; Show more details in label )) ;; Haskell LSP uses HLS by default in Doom; removed outdated fourmolu config (use-package! bnf-mode :mode "\\.bnf\\'" :config ;; Optional: Add any custom configuration here (setq bnf-mode-hook (lambda () ;; Enable line numbers (display-line-numbers-mode) ;; Enable auto-pairing of angle brackets (modify-syntax-entry ?< "(>" bnf-mode-syntax-table) (modify-syntax-entry ?> ")<" bnf-mode-syntax-table)))) (use-package! ebnf-mode :mode "\\.ebnf\\'" :config ;; Optional customizations: (setq ebnf-mode-indent-offset 4) ; Default is 8 spaces (setq ebnf-mode-indent-by-production t) ; Align with the '=' in productions (setq ebnf-mode-comment-char ?\;) ; Use ; for comments (setq ebnf-mode-eop-char ?\.)) ; Use . for end of production (use-package! nix-mode :mode "\\.nix\\'" :hook (nix-mode . lsp-deferred) :config ;; Configure nil LSP server (after! lsp-mode (add-to-list 'lsp-language-id-configuration '(nix-mode . "nix")) (lsp-register-client (make-lsp-client :new-connection (lsp-stdio-connection "nil") :major-modes '(nix-mode) :server-id 'nil-ls :priority 0))) ;; Function to check if we're in a nixpkgs repository (defun in-nixpkgs-repo-p () (when-let ((root (or (locate-dominating-file default-directory ".git") (vc-root-dir)))) (or (string-match-p "/nixpkgs/?$" root) (file-exists-p (expand-file-name "pkgs/top-level/all-packages.nix" root)) (file-exists-p (expand-file-name ".nixpkgs-version.json" root))))) ;; Set up format-all-mode to use our custom formatter selection (set-formatter! 'nixfmt '("nixfmt") :modes '(nix-mode)) (set-formatter! 'alejandra '("alejandra" "--quiet") :modes '(nix-mode)) ;; Add hooks to handle all formatting scenarios (add-hook! 'nix-mode-hook ;; Disable LSP formatting (setq-local +format-with-lsp nil) ;; Set formatter for format-all-mode (+format/buffer) (setq-local +format-with (if (in-nixpkgs-repo-p) 'nixfmt 'alejandra)) ;; Handle format-on-save (when (bound-and-true-p format-all-mode) (format-all-mode -1)) (add-hook! 'before-save-hook :local (when (eq major-mode 'nix-mode) (if (in-nixpkgs-repo-p) (format-all-buffer 'nixfmt) (format-all-buffer 'alejandra)))) ;; Override lsp-format-buffer (advice-add 'lsp-format-buffer :around (lambda (orig-fun &rest args) (if (eq major-mode 'nix-mode) (let ((fmt (if (in-nixpkgs-repo-p) (executable-find "nixfmt") (executable-find "alejandra")))) (when fmt (format-all-buffer (intern (file-name-nondirectory fmt))))) (apply orig-fun args)))))) ;; Enable format-on-save globally if desired (setq +format-on-save-enabled-modes '(nix-mode)) (use-package! llvm-ts-mode :mode "\\.ll\\'" ; LLVM IR files :mode "\\.td\\'" ; TableGen files :hook (llvm-ts-mode . tree-sitter-mode)) (after! tree-sitter (add-to-list 'tree-sitter-major-mode-language-alist '(llvm-ts-mode . llvm))) (after! lsp-clangd (setq lsp-clients-clangd-executable "clangd") (setq lsp-clients--clangd-default-executable "clangd") (setq lsp-clangd-binary-path "clangd")) ;; Justfile mode (psibi/justl.el) (use-package! justl :config (map! :n "e" 'justl-exec-recipe))