Created
July 3, 2023 11:27
-
-
Save tluyben/aede19e23368c5a64ecdefd2d574e512 to your computer and use it in GitHub Desktop.
emacs setup for typescript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require 'package) | |
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) | |
(package-initialize) | |
(add-to-list 'image-types 'svg) | |
(defvar bootstrap-version) | |
(let ((bootstrap-file | |
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory)) | |
(bootstrap-version 6)) | |
(unless (file-exists-p bootstrap-file) | |
(with-current-buffer | |
(url-retrieve-synchronously | |
"https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el" | |
'silent 'inhibit-cookies) | |
(goto-char (point-max)) | |
(eval-print-last-sexp))) | |
(load bootstrap-file nil 'nomessage)) | |
(setq mac-option-key-is-meta nil | |
mac-command-key-is-meta t | |
mac-command-modifier 'meta | |
mac-option-modifier 'none) | |
(straight-use-package 'use-package) | |
(use-package copilot | |
:straight (:host github :repo "zerolfx/copilot.el" :files ("dist" "*.el")) | |
:ensure t) | |
;; you can utilize :map :hook and :config to customize copilot | |
;; https://github.com/milanglacier/dotemacs/blob/5bce7519d2ffb33371705bbe0bcfbbef1033c8ea/lisp/my-init-langtools.el#L180 | |
(add-hook 'prog-mode-hook 'copilot-mode) | |
(define-key copilot-completion-map (kbd "<tab>") 'copilot-accept-completion) | |
(define-key copilot-completion-map (kbd "TAB") 'copilot-accept-completion) | |
;;(add-to-list 'copilot-major-mode-alist '(("enh-ruby" . "ruby"))) | |
(add-to-list 'copilot-major-mode-alist '(("typescript" . "typescript"))) | |
(add-to-list 'copilot-major-mode-alist '("gfm" . "markdown")) | |
(unless package-archive-contents (package-refreseh-contents)) | |
(package-initialize) | |
(setq package-list '(dap-mode)) | |
(dolist (package package-list) | |
(unless (package-installed-p package) (package-install package))) | |
(package-install 'typescript-mode) | |
;;(package-install 'javascript-mode) | |
(package-install 'tree-sitter-langs) | |
(setq package-list '(dap-mode typescript-mode)) | |
(setq package-list '(dap-mode typescript-mode tree-sitter tree-sitter-langs)) | |
(require 'tree-sitter-langs) | |
(require 'tree-sitter) | |
;; Activate tree-sitter globally (minor mode registered on every buffer) | |
(global-tree-sitter-mode) | |
(add-hook 'tree-sitter-after-on-hook #'tree-sitter-hl-mode) | |
;;(load-theme 'tango-dark) | |
(setq package-list '(dap-mode typescript-mode tree-sitter tree-sitter-langs lsp-mode lsp-ui)) | |
(require 'lsp-mode) | |
(add-hook 'typescript-mode-hook 'lsp-deferred) | |
(add-hook 'javascript-mode-hook 'lsp-deferred) | |
(defun my-setup-dap-node () | |
"Require dap-node feature and run dap-node-setup if VSCode module isn't already installed" | |
(require 'dap-node) | |
(unless (file-exists-p dap-node-debug-path) (dap-node-setup))) | |
(add-hook 'typescript-mode-hook 'my-setup-dap-node) | |
(add-hook 'javascript-mode-hook 'my-setup-dap-node) | |
;;(dap-node-setup) | |
;;(load-theme 'tango-dark) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment