summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--emacs/custom/my-lang-go.el13
-rw-r--r--emacs/custom/my-lang-nix.el18
-rw-r--r--emacs/custom/my-lang-python.el15
-rw-r--r--emacs/custom/my-lsp.el41
-rw-r--r--emacs/custom/my-packages.el4
-rw-r--r--emacs/custom/my-prog.el3
6 files changed, 33 insertions, 61 deletions
diff --git a/emacs/custom/my-lang-go.el b/emacs/custom/my-lang-go.el
index aa9f43b..fdfb8ee 100644
--- a/emacs/custom/my-lang-go.el
+++ b/emacs/custom/my-lang-go.el
@@ -7,23 +7,16 @@
(require 'go-mode)
(require 'gotest)
-(require 'lsp-mode)
-
-(add-hook 'go-mode-hook #'lsp-deferred)
-
-(defun my/lsp-go-install-save-hooks ()
- "Set up before-save hooks to format buffer and add/delete imports."
- (add-hook 'before-save-hook #'lsp-format-buffer t t)
- (add-hook 'before-save-hook #'lsp-organize-imports t t))
+(require 'eglot)
(defun my/go-mode-setup ()
"Hooks for `go-mode'."
(setq tab-width 4)
(setq go-test-verbose t))
-(add-hook 'go-mode-hook #'my/lsp-go-install-save-hooks)
+(add-hook 'go-mode-hook 'eglot-ensure)
+(add-hook 'nix-mode-hook #'(lambda() (add-hook 'before-save-hook 'eglot-format-buffer nil t)))
(add-hook 'go-mode-hook #'my/go-mode-setup)
-(add-hook 'go-mode-hook #'yas-minor-mode)
(provide 'my-lang-go)
diff --git a/emacs/custom/my-lang-nix.el b/emacs/custom/my-lang-nix.el
index 7d197e2..6e17ee3 100644
--- a/emacs/custom/my-lang-nix.el
+++ b/emacs/custom/my-lang-nix.el
@@ -5,21 +5,11 @@
;;; Code:
-(require 'lsp-mode)
+(require 'eglot)
+(require 'nix-mode)
-(add-to-list 'lsp-language-id-configuration '(nix-mode . "nix"))
-(lsp-register-client
- (make-lsp-client :new-connection
- (lsp-stdio-connection '("rnix-lsp"))
- :major-modes '(nix-mode)
- :server-id 'nix))
-
-(defun my/lsp-nix-install-save-hooks ()
- "Set up before-save hooks to format buffer."
- (add-hook 'before-save-hook #'lsp-format-buffer t t))
-
-(add-hook 'nix-mode-hook #'my/lsp-nix-install-save-hooks)
-(add-hook 'nix-mode-hook #'lsp-deferred)
+(add-hook 'nix-mode-hook 'eglot-ensure)
+(add-hook 'nix-mode-hook #'(lambda() (add-hook 'before-save-hook 'eglot-format-buffer nil t)))
(provide 'my-lang-nix)
diff --git a/emacs/custom/my-lang-python.el b/emacs/custom/my-lang-python.el
index c5f612a..04f3d00 100644
--- a/emacs/custom/my-lang-python.el
+++ b/emacs/custom/my-lang-python.el
@@ -6,14 +6,25 @@
;;; Code:
(require 'python)
-(require 'python-mode)
+(setq python-shell-interpreter "python3")
+(setq python-shell-interpreter-args "-i")
+
+;;; bindings
+(define-key python-mode-map (kbd "C-h f") 'python-eldoc-at-point)
+
+;;; hooks
;; if black is present, enable it
(when (executable-find "black")
(require 'blacken)
(add-hook 'python-mode-hook 'blacken-mode))
-(setq python-shell-interpreter "python3")
+(when (executable-find "pylsp")
+ (add-hook 'python-mode-hook 'eglot-ensure)
+ ;; https://github.com/python-lsp/python-lsp-server/blob/develop/CONFIGURATION.md
+ (setq-default eglot-workspace-configuration
+ '((pylsp (plugins (flake8 (enabled . :json-false))
+ (pycodestyle (enabled . :json-false)))))))
(provide 'my-lang-python)
diff --git a/emacs/custom/my-lsp.el b/emacs/custom/my-lsp.el
index c10e06c..40ba785 100644
--- a/emacs/custom/my-lsp.el
+++ b/emacs/custom/my-lsp.el
@@ -5,35 +5,18 @@
;;; Code:
-(require 'lsp-mode)
-(require 'lsp-ui)
-(require 'lsp-diagnostics)
-(require 'consult-lsp)
-(require 'lsp-completion)
-
-(setq lsp-ui-doc-enable t) ;; Enable documentation
-(setq lsp-ui-doc-position 'at-point) ;; Show the documentation at point
-(setq lsp-ui-doc-header t)
-(setq lsp-ui-doc-include-signature t)
-(setq lsp-ui-peek-enable t) ;; Enable `lsp-ui-peek'.
-(setq lsp-ui-peek-show-directory t) ;; Show the directory of files.
-(setq lsp-ui-sideline-enable nil) ;; Don't enable `lsp-ui-sideline'.
-
-(add-hook 'lsp-mode-hook #'lsp-ui-mode)
-
-;; Enable `completion-at-point' integration.
-(setq lsp-completion-enable t)
-
-;; The default is to use flycheck
-(setq lsp-diagnostics-provider :flymake)
-
-(define-key lsp-mode-map [remap xref-find-apropos] #'consult-lsp-symbols)
-
-;; Configure the completion to be corfu
-(setq lsp-completion-provider :none)
-(add-hook 'lsp-completion-mode-hook
- (lambda ()
- (setf (alist-get 'lsp-capf completion-category-defaults) '((styles . (orderless flex))))))
+(require 'eglot)
+
+;; settings related to performance
+;; https://emacs-lsp.github.io/lsp-mode/page/performance/
+(setq read-process-output-max (* 1024 1024)) ;; 1mb
+(setq gc-cons-threshold 100000000) ;; 100mb
+
+(global-set-key (kbd "C-c l e") #'eglot)
+(define-key eglot-mode-map (kbd "C-c l s") #'eglot-shutdown)
+(define-key eglot-mode-map (kbd "C-c l r") #'eglot-rename)
+(define-key eglot-mode-map (kbd "C-c l a") #'eglot-code-actions)
+(define-key eglot-mode-map (kbd "C-c l o") #'eglot-code-action-organize-imports)
(provide 'my-lsp)
diff --git a/emacs/custom/my-packages.el b/emacs/custom/my-packages.el
index 99cf01b..a31b5ee 100644
--- a/emacs/custom/my-packages.el
+++ b/emacs/custom/my-packages.el
@@ -8,8 +8,7 @@
(require 'straight)
;; packages needed for LSP
-(straight-use-package 'lsp-mode)
-(straight-use-package 'lsp-ui)
+(straight-use-package 'eglot)
;; packages needed for python
(straight-use-package 'blacken)
@@ -62,7 +61,6 @@
;; packages for navigation
(straight-use-package 'cape)
(straight-use-package 'consult)
-(straight-use-package 'consult-lsp)
(straight-use-package 'corfu)
(straight-use-package 'corfu-doc)
(straight-use-package 'marginalia)
diff --git a/emacs/custom/my-prog.el b/emacs/custom/my-prog.el
index a8ecf45..8314ab9 100644
--- a/emacs/custom/my-prog.el
+++ b/emacs/custom/my-prog.el
@@ -40,9 +40,6 @@
(add-hook 'sh-mode-hook 'my/sh-mode-hook)
-;; set the indent level for python
-(customize-set-variable 'python-indent-offset 4)
-
(defun my/makefile-mode-hook ()
"Hooks for `makefile-mode'."
;; I want small tabs when working in a Makefile