My May 2023 Emacs configuration
(show-paren-mode t)
(set-default 'truncate-lines t)
(setq inhibit-startup-message t)
(setq initial-scratch-message nil)
(setq-default indent-tabs-mode nil)
(setq-default tab-width 2)
(setq-default typescript-indent-level 2)
(setq tab-stop-list
'(
2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80
))
(set-frame-font "Ubuntu Mono 12" nil t)
(add-to-list 'exec-path "/home/mihamina/Apps/node/bin")
(add-to-list 'exec-path "/home/mihamina/node_modules/.bin")
(add-to-list 'load-path "~/.local/bin")
(add-to-list 'load-path "/home/mihamina/.emacs.d/copilot")
(add-to-list 'load-path "/home/mihamina/.emacs.d/pulumi-lsp/bin")
(require 'package)
(setq package-archives
'(
("gnu" . "http://elpa.gnu.org/packages/")
("nongnu" . "http://elpa.nongnu.org/nongnu/")
("melpa" . "http://melpa.org/packages/")
("melpa-stable" . "https://stable.melpa.org/packages/")))
(package-initialize)
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(eval-when-compile
(require 'use-package))
(require 'copilot)
(require 'pulumi-yaml)
(speedbar 1)
(speedbar-toggle-show-all-files)
(speedbar-add-supported-extension ".ts")
(speedbar-add-supported-extension ".tsx")
(speedbar-add-supported-extension ".js")
(speedbar-add-supported-extension ".jsx")
(speedbar-add-supported-extension ".json")
(speedbar-add-supported-extension ".yaml")
(speedbar-add-supported-extension ".yml")
(speedbar-add-supported-extension ".md")
(speedbar-add-supported-extension ".php")
(speedbar-add-supported-extension ".html")
(speedbar-add-supported-extension ".css")
;; Origami mode keys
(require 'origami)
(define-key global-map (kbd "C-x C-z") 'origami-mode-map)
(define-prefix-command 'origami-mode-map)
(define-key origami-mode-map (kbd "o") 'origami-open-node)
(define-key origami-mode-map (kbd "O") 'origami-open-node-recursively)
(define-key origami-mode-map (kbd "c") 'origami-close-node)
(define-key origami-mode-map (kbd "C") 'origami-close-node-recursively)
(define-key origami-mode-map (kbd "a") 'origami-toggle-node)
(define-key origami-mode-map (kbd "A") 'origami-recursively-toggle-node)
(define-key origami-mode-map (kbd "R") 'origami-open-all-nodes)
(define-key origami-mode-map (kbd "M") 'origami-close-all-nodes)
(define-key origami-mode-map (kbd "v") 'origami-show-only-node)
(define-key origami-mode-map (kbd "k") 'origami-previous-fold)
(define-key origami-mode-map (kbd "j") 'origami-forward-fold)
(define-key origami-mode-map (kbd "x") 'origami-reset)
(show-paren-mode t)
(set-default 'truncate-lines t)
(setq inhibit-startup-message t)
(setq initial-scratch-message nil)
(setq-default indent-tabs-mode nil)
(setq-default tab-width 2)
(setq-default typescript-indent-level 2)
(setq tab-stop-list
'(
2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80
))
(defun rktmb/copilot-complete-or-accept ()
"Command that either triggers a completion or accepts one if one
is available. Useful if you tend to hammer your keys like I do."
(interactive)
(if (copilot--overlay-visible)
(progn
(copilot-accept-completion)
(open-line 1)
(next-line))
(copilot-complete)))
(defvar rktmb/copilot-manual-mode nil
"When `t' will only show completions when manually triggered, e.g. via s-.")
(defun rktmb/copilot-change-activation ()
"Switch between two activation modes:
- manual: you need to press a key (s) to trigger completions
- off: copilot is completely disabled."
(interactive)
(if copilot-mode
(progn
(message "deactivating copilot")
(global-copilot-mode -1))
(progn
(message "activating copilot mode")
(global-copilot-mode)
(setq copilot-enable-predicate t)
)
)
)
(define-key copilot-mode-map (kbd "s-") #'copilot-next-completion)
(define-key copilot-mode-map (kbd "s-") #'copilot-previous-completion)
(define-key copilot-mode-map (kbd "s-") #'copilot-accept-completion-by-word)
(define-key copilot-mode-map (kbd "s-") #'copilot-accept-completion-by-line)
(define-key global-map (kbd "s-") #'rktmb/copilot-complete-or-accept)
(define-key global-map (kbd "s-") #'rktmb/copilot-change-activation)
(use-package tree-sitter
:ensure t
:config
;; activate tree-sitter on any buffer containing code for which it has a parser available
(global-tree-sitter-mode)
;; you can easily see the difference tree-sitter-hl-mode makes for python, ts or tsx
;; by switching on and off
(add-hook 'tree-sitter-after-on-hook #'tree-sitter-hl-mode))
(use-package tree-sitter-langs
:ensure t
:after tree-sitter)
(use-package eglot
:ensure t)
(add-hook 'after-init-hook 'global-company-mode)
(add-hook 'js-mode-hook 'eglot-ensure)
(add-hook 'typescript-mode-hook 'eglot-ensure)
(add-hook 'js-mode-hook 'copilot-mode)
(add-hook 'typescript-mode-hook 'copilot-mode)
(require 'lsp-mode)
(add-to-list 'auto-mode-alist '("Pulumi.*\\.yaml\\'" . pulumi-yaml-mode))
(add-to-list 'auto-mode-alist '("Pulumi.*\\.yml\\'" . pulumi-yaml-mode))
(add-hook 'pulumi-yaml-mode-hook #'lsp-mode)