Skip to content

Commit

Permalink
lsp-bridge; straight
Browse files Browse the repository at this point in the history
  • Loading branch information
JJPandari committed May 7, 2023
1 parent 8f6a8af commit 009d343
Show file tree
Hide file tree
Showing 24 changed files with 142 additions and 57 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,4 @@ site-lisp/package/
/places
/games
/eaf
/straight/
1 change: 1 addition & 0 deletions early-init.el
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(setq package-enable-at-startup nil)
14 changes: 9 additions & 5 deletions init.el
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@
;; Bootstrap config
;;----------------------------------------------------------------------------
;; Calls (package-initialize)
(require 'init-elpa) ;; Machinery for installing required packages
(require 'init-elpa)
(require 'init-straight)
(require 'init-utils)
(require 'init-exec-path) ;; Set up $PATH
(require 'init-exec-path)

;;----------------------------------------------------------------------------
;; Load configs for specific features and modes
Expand Down Expand Up @@ -66,8 +67,11 @@
;; (require 'init-helm)
(require 'init-ivy)
;; (require 'init-selectrum)
(require 'init-company)

;; (require 'init-company)
(require 'init-lsp-bridge)
(require 'init-yas)

(require 'init-windows)
(require 'init-mode-line)
(require 'init-sessions)
Expand All @@ -76,7 +80,7 @@
(require 'init-help)
(require 'init-read)

(require 'init-flycheck)
;; (require 'init-flycheck)
(require 'init-vc)
(require 'init-git)
(require 'init-compile)
Expand All @@ -92,7 +96,7 @@
;; (require 'init-common-lisp)

(require 'init-projects)
(require 'init-lsp)
;; (require 'init-lsp)
(require 'init-jump)
(require 'init-text)
(require 'init-org)
Expand Down
3 changes: 2 additions & 1 deletion modes/init-chinese.el
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
(push (expand-file-name "popweb/extension/dict" jester-submodules-dir) load-path)
(use-package popweb-dict
:ensure nil
:straight nil
:commands popweb-dict-bing-pointer)


Expand Down Expand Up @@ -45,6 +46,6 @@
:demand t
:after pyim
:config
(pyim-wbdict-v98-enable))
(pyim-wbdict-v86-enable))

(provide 'init-chinese)
1 change: 1 addition & 0 deletions modes/init-company.el
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ In that case, insert the number."
(push (expand-file-name "company-anywhere" jester-submodules-dir) load-path)
(use-package company-anywhere
:ensure nil
:straight nil
:after company
:demand t)

Expand Down
1 change: 1 addition & 0 deletions modes/init-eaf.el
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
(use-package deferred :defer t)
(use-package epc :defer t)
:ensure nil
:straight nil
:demand t
:custom
(eaf-browser-continue-where-left-off t)
Expand Down
1 change: 1 addition & 0 deletions modes/init-editing-utils.el
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@

(use-package subword
:ensure nil
:straight nil
:init
(general-define-key
:states '(operator)
Expand Down
3 changes: 0 additions & 3 deletions modes/init-elpa.el
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,8 @@ locate PACKAGE."


;;; Fire up package.el

(setq package-enable-at-startup nil)
(package-initialize)



(require-package 'fullframe)
(fullframe list-packages quit-window)
Expand Down
11 changes: 5 additions & 6 deletions modes/init-emacs-server.el
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
(server-start))
;; when opened as maid, start server with name "maid"
(when (string= (getenv "EMACS_SOCKET") "maid")
(unless (server-running-p "maid")
(setq server-name "maid")
(setq frame-title-format "maid")
(setq desktop-base-file-name ".emacs.maid.desktop"
desktop-base-lock-name ".emacs.maid.desktop.lock")
(server-start)))
(setq server-name "maid")
(setq frame-title-format "maid")
(setq desktop-base-file-name ".emacs.maid.desktop"
desktop-base-lock-name ".emacs.maid.desktop.lock")
(server-start))

(provide 'init-emacs-server)
8 changes: 4 additions & 4 deletions modes/init-evil.el
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@
:keymaps 'evil-snipe-local-mode-map
"g s" 'evil-snipe-s
"g S" 'evil-snipe-S
"g t" 'evil-snipe-x
"g T" 'evil-snipe-X)
"g c" 'evil-snipe-x
"g C" 'evil-snipe-X)
(define-key evil-normal-state-map (kbd "DEL") 'evil-snipe-repeat-reverse))


Expand Down Expand Up @@ -243,7 +243,7 @@
(general-define-key
:states '(insert emacs)
:keymaps 'evil-multiedit-mode-map
"<tab>" 'jester/yas-or-company-or-hippie
"<tab>" 'jester/start-complete
"C-a" 'evil-multiedit-beginning-of-line
"C-e" 'evil-multiedit-end-of-line)
)
Expand Down Expand Up @@ -768,7 +768,7 @@
(when (bolp) (evil-first-non-blank) (cl-return-from 'my-return)) ; at very beg of line
(evil-first-non-blank)))
(general-define-key
:states '(normal visual operator)
:states '(normal visual operator motion)
"0" 'jester/cycle-line-beginning-end)

;; TODO try citre-read or clue
Expand Down
21 changes: 3 additions & 18 deletions modes/init-face.el
Original file line number Diff line number Diff line change
Expand Up @@ -53,27 +53,12 @@
(general-define-key
:states '(normal visual motion)
:keymaps '(prog-mode-map css-mode yaml-mode conf-mode markdown-mode help-mode)
"<tab>" 'jester/probably-symbol-overlay-put
"<tab>" 'symbol-overlay-put
"H-n" 'symbol-overlay-jump-next
"H-p" 'symbol-overlay-jump-prev)
(jester/with-leader "o p" 'jester/probably-symbol-overlay-put)
(jester/with-leader "o p" 'symbol-overlay-put)
;; don't bind any key
(setq symbol-overlay-map (make-sparse-keymap))

;; TODO off when region active. maybe PR?
(defun jester/probably-symbol-overlay-put ()
"Probably highlight region or symbol at point with symbol-overlay, but:
toggle file when peeking definitions with lsp-ui."
(interactive)
(if (and (featurep 'lsp-ui) lsp-ui-peek-mode)
(call-interactively 'lsp-ui-peek--toggle-file)
(if (region-active-p)
(progn
(symbol-overlay-put-all
(regexp-quote (buffer-substring-no-properties (region-beginning) (region-end)))
symbol-overlay-scope)
(deactivate-mark))
(symbol-overlay-put)))))
(setq symbol-overlay-map (make-sparse-keymap)))

;;----------------------------------------------------------------------------
;; Set fonts.
Expand Down
2 changes: 1 addition & 1 deletion modes/init-file.el
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"Save all buffers."
;; yas overlay and company-select-next has problem with this.
(when (and (not yas--active-snippets)
(not company-candidates)
;; (not company-candidates)
(not (eq major-mode 'snippet-mode)))
;; https://github.com/manateelazycat/lazycat-emacs/commit/da13a688ef89f8ab2c577a3e9d2a7bcf0ef9b71d
;; https://emacs-china.org/t/topic/7687/30?u=jjpandari
Expand Down
1 change: 1 addition & 0 deletions modes/init-formatter.el
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(push (expand-file-name "apheleia" jester-submodules-dir) load-path)
(use-package apheleia
:ensure nil
:straight nil
:init
(jester/with-major-leader '(js2-mode-map web-mode-map typescript-mode-map)
"f" 'apheleia-format-buffer)
Expand Down
21 changes: 16 additions & 5 deletions modes/init-jump.el
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,23 @@
:states '(normal motion)
"g d" 'xref-find-definitions
"g p" 'xref-pop-marker-stack)

(general-define-key
:states '(normal motion)
:keymaps '(typescript-mode-map web-mode-map)
"g d" 'lsp-bridge-find-def
"g p" 'lsp-bridge-find-def-return)
(general-define-key
:definer 'minor-mode
:states 'normal
:keymaps 'lsp-mode
"g r" 'jester/xref-find-references-at-point)
:keymaps '(typescript-mode-map web-mode-map)
"g r" 'lsp-bridge-find-references
"g t" 'lsp-bridge-find-type-def)
(jester/with-major-leader '(typescript-mode-map web-mode-map)
"r" 'lsp-bridge-rename)
(jester/with-leader
"e l" 'lsp-bridge-diagnostic-list
"e n" 'lsp-bridge-diagnostic-jump-next
"e p" 'lsp-bridge-diagnostic-jump-prev)


;; TODO xref-ring
Expand Down Expand Up @@ -55,8 +67,7 @@

(use-package citre
:custom ((citre-enable-imenu-integration nil)
(citre-update-tags-file-when-no-definitions nil)
(citre-tags-files '("tagz" ".tags" "tags")))
(citre-tags-file-names '("tagz" ".tags" "tags")))
:init
(require 'citre-config))
;; TODO try `citre-peek'
Expand Down
2 changes: 1 addition & 1 deletion modes/init-keyfreq.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(when (string= server-name "server")
(when (and (boundp 'server-name) (string= server-name "maid"))
(use-package keyfreq
:hook (after-init . keyfreq-mode)
:config
Expand Down
1 change: 1 addition & 0 deletions modes/init-lisp.el
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
(push (expand-file-name "elispfl" jester-submodules-dir) load-path)
(use-package elispfl
:ensure nil
:straight nil
:demand t
:config (elispfl-mode 1))

Expand Down
63 changes: 63 additions & 0 deletions modes/init-lsp-bridge.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
;; -*- lexical-binding: t -*-
(use-package lsp-bridge
:ensure nil
:straight (lsp-bridge :type git :host github :repo "manateelazycat/lsp-bridge"
:files ("*" (:exclude ".git" "test")))
:init
(setq acm-enable-tabnine nil
;; TODO acm-enable-codeium
acm-enable-yas nil
;; TODO acm-enable-citre
acm-candidate-match-function 'orderless-flex
acm-enable-quick-access t ; only decides whether indexes are shown
lsp-bridge-signature-show-function 'lsp-bridge-signature-posframe
lsp-bridge-enable-hover-diagnostic t)
:demand t
:config
(plist-put lsp-bridge-signature-posframe-params :poshandler 'posframe-poshandler-frame-top-center)

(global-lsp-bridge-mode)

(general-define-key
:states '(insert emacs)
"<tab>" 'jester/start-complete-or-yas)
(general-define-key
:states '(insert emacs)
:definer 'minor-mode
:keymaps 'acm-mode
"TAB" nil
"<tab>" 'jester/do-complete-or-yas
"<C-m>" 'acm-insert-common
"RET" nil
"<return>" nil)
(dotimes (i 10)
(general-define-key
:keymaps 'acm-mode-map
(number-to-string i) 'acm-complete-quick-access)
(general-define-key
:keymaps 'acm-mode-map
(format "M-%d" i) (eval `(lambda! (insert ,(number-to-string i)))))))

;; https://emacs.stackexchange.com/a/7925/12854
(defun jester/do-complete-or-yas ()
"`yas-expand' or complete the symbol."
(interactive)
(when (or (not yas-minor-mode)
(null (jester/yas-expand-no-prompt)))
(call-interactively 'acm-complete)))

(defun jester/start-complete-or-yas ()
(interactive)
(when (or (not yas-minor-mode)
(null (jester/yas-expand-no-prompt)))
(lsp-bridge-popup-complete-menu)))



(use-package orderless
:autoload (orderless-initialism orderless-flex))

;; TODO flycheck


(provide 'init-lsp-bridge)
1 change: 1 addition & 0 deletions modes/init-paredit.el
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
(push (expand-file-name "awesome-pair" jester-submodules-dir) load-path)
(use-package awesome-pair
:ensure nil
:straight nil
:commands (awesome-pair-kill
awesome-pair-backward-delete awesome-pair-forward-delete
awesome-pair-equal awesome-pair-double-quote awesome-pair-space
Expand Down
1 change: 1 addition & 0 deletions modes/init-sessions.el
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
;;----------------------------------------------------------------------------
(use-package saveplace
:ensure nil
:straight nil
:hook (after-init . save-place-mode))


Expand Down
18 changes: 18 additions & 0 deletions modes/init-straight.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
(setq straight-use-package-by-default nil
straight-use-version-specific-build-dir t)

(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))


(provide 'init-straight)
2 changes: 1 addition & 1 deletion modes/init-themes.el
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

;; If you don't customize it, this is the theme you get.
(setq custom-enabled-themes (if (string= (getenv "EMACS_SOCKET") "maid")
'(doom-tomorrow-night)
'(doom-tomorrow-day)
'(solarized-light)))

;; Ensure that themes will be applied even if they have not been customized
Expand Down
1 change: 1 addition & 0 deletions modes/init-vc.el
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(use-package smerge-mode
:ensure nil
:straight nil
:init
(jester/with-leader
"m u" 'smerge-keep-upper
Expand Down
17 changes: 7 additions & 10 deletions modes/init-web.el
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@
(modify-syntax-entry ?# "_" web-mode-syntax-table)
(modify-syntax-entry ?+ "." web-mode-syntax-table)

(define-key web-mode-map (kbd "TAB") nil)
(define-key web-mode-map (kbd "<tab>") nil)
(evil-define-key 'insert web-mode-map (kbd "TAB") #'jester/yas-or-company-or-hippie)
(evil-define-key 'insert web-mode-map (kbd "<tab>") #'jester/yas-or-company-or-hippie)
;; (evil-define-key 'insert web-mode-map (kbd "<tab>") #'jester/start-complete)

(add-hook 'web-mode-hook 'jester/web-mode-maybe-setup-vue)
(defun jester/web-mode-maybe-setup-vue ()
Expand All @@ -63,12 +60,12 @@
(defun jester/web-mode-maybe-setup-tsx ()
"Do something if it's a .tsx file."
(when (string-equal (file-name-extension (buffer-name)) "tsx")
(lsp-diagnostics--enable)
(flycheck-add-next-checker 'javascript-eslint 'lsp)
(lsp)
;; lsp sets checker to lsp, set it back
;; `flycheck-add-next-checker'
(setq flycheck-checker 'javascript-eslint)
;; (lsp-diagnostics--enable)
;; (flycheck-add-next-checker 'javascript-eslint 'lsp)
;; (lsp)
;; ;; lsp sets checker to lsp, set it back
;; ;; `flycheck-add-next-checker'
;; (setq flycheck-checker 'javascript-eslint)
(jester/make-default-evil-markers-for-js)
(setq-local emmet-expand-jsx-className? t
web-mode-auto-quote-style 3)
Expand Down
Loading

0 comments on commit 009d343

Please sign in to comment.