Skip to main content

Emacs configuration may 2023

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)

  

Popular posts from this blog

npm run build base-href

Using NPM to specify base-href When building an Angular application, people usually use "ng" and pass arguments to that invocation. Typically, when wanting to hard code "base-href" in "index.html", one will issue: ng build --base-href='https://ngx.rktmb.org/foo' I used to build my angular apps through Bamboo or Jenkins and they have a "npm" plugin. I got the habit to build the application with "npm run build" before deploying it. But the development team once asked me to set the "--base-href='https://ngx.rktmb.org/foo'" parameter. npm run build --base-href='https://ngx.rktmb.org/foo did not set the base href in indext.html After looking for a while, I found https://github.com/angular/angular-cli/issues/13560 where it says: You need to use −− to pass arguments to npm scripts. This did the job! The command to issue is then: npm run build -- --base-href='https://ngx.rktmb.org/foo&

emacs29 intelephense

Emacs 29 and PHP Intelephense I use to use Emacs and PHP Intelephense for PHP development. I recently upgraded to Emacs 29 and PHP Intelephense stopped working. I found a solution on Reddit Based on that, I rewrote my .emacs file to use eglot instead of lsp-mode, and this is the result. (use-package eglot :ensure t) (add-hook 'php-mode-hook 'eglot-ensure) (use-package php-mode :ensure t :mode ("\\.php\\'" . php-mode)) (add-to-list 'auto-mode-alist '("\\.php$" . php-mode)) (provide 'lang-php) (use-package company :ensure t :config (setq company-idle-delay 0.3) (global-company-mode 1) (global-set-key (kbd "M- ") 'company-complete)) (require 'eglot) (add-to-list 'eglot-server-programs '((php-mode :language-id "php") . ("intelephense" "--stdio" :initializationOptions (:licenseKey "98989898989898989898"

Jenkins invalid privatekey

Publish over SSH, Message "invalid privatekey:" With quite recent (June-July 2020) installations of Jenkins and OpenSSH, I have the following error message when using the "Deploy overs SSH" Jenkins plug-in and publishing artifacts to the target overs SSH: jenkins.plugins.publish_over.BapPublisherException: Failed to add SSH key. Message [invalid privatekey: [B@d8d395a] This problem seems to be referenced here: https://issues.jenkins-ci.org/browse/JENKINS-57495 Just regenerate a key with the right parameters To solve it: ssh-keygen -t rsa -b 4096 Or ssh-keygen -t rsa -b 4096 -m PEM