Skip to content

Commit

Permalink
Revert to commit: dd4e58f CI: add tests for jumping to external files.
Browse files Browse the repository at this point in the history
  • Loading branch information
manateelazycat committed May 22, 2022
1 parent f545b24 commit c82b451
Show file tree
Hide file tree
Showing 10 changed files with 182 additions and 1,540 deletions.
23 changes: 19 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Lsp-bridge uses python's threading technology to build caches that bridge Emacs

1. Install Python dependencies: [python-epc](https://github.com/tkf/python-epc)
2. Install Elisp dependencies:
+ [corfu](https://github.com/minad/corfu) (for corfu users)
+ [company-mode](https://github.com/company-mode/company-mode), [company-box](https://github.com/sebastiencs/company-box) (for company users)
+ [all-the-icons](https://github.com/domtronn/all-the-icons.el)
+ [orderless](https://github.com/oantolin/orderless)
+ [posframe](https://github.com/tumashu/posframe)
Expand All @@ -28,11 +30,23 @@ Lsp-bridge uses python's threading technology to build caches that bridge Emacs
(require 'lsp-bridge-jdtls) ;; provide Java third-party library jump and -data directory support, optional
(yas-global-mode 1)
(require 'lsp-bridge-ui)
(require 'lsp-bridge-ui-history)
;; For corfu users:
(setq lsp-bridge-completion-provider 'corfu)
(require 'corfu)
(require 'corfu-info)
(require 'corfu-history)
(require 'lsp-bridge-icon) ;; show icons for completion items, optional
(require 'lsp-bridge-orderless) ;; make lsp-bridge support fuzzy match, optional
(global-lsp-bridge-ui-mode) ;; use lsp-bridge-ui as completion ui
(lsp-bridge-ui-history-mode t)
(global-corfu-mode) ;; use corfu as completion ui
(corfu-history-mode t)
(global-lsp-bridge-mode)
;; For company-mode users:
(setq lsp-bridge-completion-provider 'company)
(require 'company)
(require 'company-box)
(require 'lsp-bridge-icon) ;; show icons for completion items, optional
(company-box-mode 1)
(global-lsp-bridge-mode)
;; For Xref support
Expand Down Expand Up @@ -109,6 +123,7 @@ Welcome to send PR to help us improve support for LSP servers, thanks for your c
- [ ] Show signature help with eldoc
- [ ] Code action
- [ ] Inline Value
- [ ] One file open multi-server, and mixed multi-result to corfu menu

### Features that won't be supported

Expand Down
24 changes: 19 additions & 5 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ lsp-bridge使用Python多线程技术在Emacs和LSP服务器之间构建高速

1. 安装Python依赖: [python-epc](https://github.com/tkf/python-epc)
2. 安装Elisp依赖:
+ [corfu](https://github.com/minad/corfu) (使用 corfu 补全)
+ [company-mode](https://github.com/company-mode/company-mode), [company-box](https://github.com/sebastiencs/company-box) (使用 company-mode 补全)
+ [all-the-icons](https://github.com/domtronn/all-the-icons.el)
+ [orderless](https://github.com/oantolin/orderless)
+ [posframe](https://github.com/tumashu/posframe)
Expand All @@ -28,12 +30,23 @@ lsp-bridge使用Python多线程技术在Emacs和LSP服务器之间构建高速
(require 'lsp-bridge-jdtls) ;; provide Java third-party library jump and -data directory support, optional
(yas-global-mode 1)
;; lsp-bridge-ui 配置:
(require 'lsp-bridge-ui)
(require 'lsp-bridge-ui-history)
;; corfu 配置:
(setq lsp-bridge-completion-provider 'corfu)
(require 'corfu)
(require 'corfu-info)
(require 'corfu-history)
(require 'lsp-bridge-icon) ;; show icons for completion items, optional
(require 'lsp-bridge-orderless) ;; make lsp-bridge support fuzzy match, optional
(global-lsp-bridge-ui-mode) ;; use lsp-bridge-ui as completion ui
(lsp-bridge-ui-history-mode t)
(global-corfu-mode) ;; use corfu as completion ui
(corfu-history-mode t)
(global-lsp-bridge-mode)
;; company-mode 配置:
(setq lsp-bridge-completion-provider 'company)
(require 'company)
(require 'company-box)
(require 'lsp-bridge-icon) ;; show icons for completion items, optional
(company-box-mode 1)
(global-lsp-bridge-mode)
;; For Xref support
Expand Down Expand Up @@ -111,6 +124,7 @@ lsp-bridge每种语言的服务器配置存储在[lsp-bridge/langserver](https:/
- [ ] 用eldoc来显示参数信息
- [ ] Code Action: 代码动作, 比如自动修复代码
- [ ] Inline Value: 行类值显示
- [ ] 一个文件支持多个LSP服务器,并混合不同LSP服务器的补全结果

### 不会支持的特性:
lsp-bridge的目标是实现Emacs生态中性能最快的LSP客户端, 但不是实现LSP协议最全的LSP客户端。
Expand Down
107 changes: 107 additions & 0 deletions lsp-bridge-icon.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
;;; lsp-bridge-icon.el -*- lexical-binding: t; -*-

(require 'all-the-icons)
(require 'lsp-bridge)

(defvar lsp-bridge-icon--cache nil
"The cache of styled and padded label (text or icon).
An alist.")

(defun lsp-bridge-icon-reset-cache ()
"Remove all cached icons from `lsp-bridge-icon-mapping'."
(interactive)
(setq lsp-bridge-icon--cache nil))

(defun lsp-bridge-icon--set-default-clear-cache (&rest args)
(lsp-bridge-icon-reset-cache)
(apply #'set-default args))

(defvar lsp-bridge-icon--icons
`((unknown . ,(all-the-icons-material "find_in_page" :height 0.8 :v-adjust -0.15))
(text . ,(all-the-icons-faicon "text-width" :height 0.8 :v-adjust -0.02))
(method . ,(all-the-icons-faicon "cube" :height 0.8 :v-adjust -0.02 :face 'all-the-icons-purple))
(function . ,(all-the-icons-faicon "cube" :height 0.8 :v-adjust -0.02 :face 'all-the-icons-purple))
(fun . ,(all-the-icons-faicon "cube" :height 0.8 :v-adjust -0.02 :face 'all-the-icons-purple))
(constructor . ,(all-the-icons-faicon "cube" :height 0.8 :v-adjust -0.02 :face 'all-the-icons-purple))
(ctor . ,(all-the-icons-faicon "cube" :height 0.8 :v-adjust -0.02 :face 'all-the-icons-purple))
(field . ,(all-the-icons-octicon "tag" :height 0.85 :v-adjust 0 :face 'all-the-icons-lblue))
(variable . ,(all-the-icons-octicon "tag" :height 0.85 :v-adjust 0 :face 'all-the-icons-lblue))
(var . ,(all-the-icons-octicon "tag" :height 0.85 :v-adjust 0 :face 'all-the-icons-lblue))
(class . ,(all-the-icons-material "settings_input_component" :height 0.8 :v-adjust -0.15 :face 'all-the-icons-orange))
(interface . ,(all-the-icons-material "share" :height 0.8 :v-adjust -0.15 :face 'all-the-icons-lblue))
(i/f . ,(all-the-icons-material "share" :height 0.8 :v-adjust -0.15 :face 'all-the-icons-lblue))
(module . ,(all-the-icons-material "view_module" :height 0.8 :v-adjust -0.15 :face 'all-the-icons-lblue))
(mod . ,(all-the-icons-material "view_module" :height 0.8 :v-adjust -0.15 :face 'all-the-icons-lblue))
(property . ,(all-the-icons-faicon "wrench" :height 0.8 :v-adjust -0.02))
(prop . ,(all-the-icons-faicon "wrench" :height 0.8 :v-adjust -0.02))
(unit . ,(all-the-icons-material "settings_system_daydream" :height 0.8 :v-adjust -0.15))
(value . ,(all-the-icons-material "format_align_right" :height 0.8 :v-adjust -0.15 :face 'all-the-icons-lblue))
(enum . ,(all-the-icons-material "storage" :height 0.8 :v-adjust -0.15 :face 'all-the-icons-orange))
(keyword . ,(all-the-icons-material "filter_center_focus" :height 0.8 :v-adjust -0.15))
(k/w . ,(all-the-icons-material "filter_center_focus" :height 0.8 :v-adjust -0.15))
(snippet . ,(all-the-icons-material "format_align_center" :height 0.8 :v-adjust -0.15))
(sn . ,(all-the-icons-material "format_align_center" :height 0.8 :v-adjust -0.15))
(color . ,(all-the-icons-material "palette" :height 0.8 :v-adjust -0.15))
(file . ,(all-the-icons-faicon "file-o" :height 0.8 :v-adjust -0.02))
(reference . ,(all-the-icons-material "collections_bookmark" :height 0.8 :v-adjust -0.15))
(ref . ,(all-the-icons-material "collections_bookmark" :height 0.8 :v-adjust -0.15))
(folder . ,(all-the-icons-faicon "folder-open" :height 0.8 :v-adjust -0.02))
(dir . ,(all-the-icons-faicon "folder-open" :height 0.8 :v-adjust -0.02))
(enum-member . ,(all-the-icons-material "format_align_right" :height 0.8 :v-adjust -0.15))
(enummember . ,(all-the-icons-material "format_align_right" :height 0.8 :v-adjust -0.15))
(member . ,(all-the-icons-material "format_align_right" :height 0.8 :v-adjust -0.15))
(constant . ,(all-the-icons-faicon "square-o" :height 0.8 :v-adjust -0.1))
(const . ,(all-the-icons-faicon "square-o" :height 0.8 :v-adjust -0.1))
(struct . ,(all-the-icons-material "settings_input_component" :height 0.8 :v-adjust -0.15 :face 'all-the-icons-orange))
(event . ,(all-the-icons-octicon "zap" :height 0.8 :v-adjust 0 :face 'all-the-icons-orange))
(operator . ,(all-the-icons-material "control_point" :height 0.8 :v-adjust -0.15))
(op . ,(all-the-icons-material "control_point" :height 0.8 :v-adjust -0.15))
(type-parameter . ,(all-the-icons-faicon "arrows" :height 0.8 :v-adjust -0.02))
(param . ,(all-the-icons-faicon "arrows" :height 0.8 :v-adjust -0.02))
(template . ,(all-the-icons-material "format_align_left" :height 0.8 :v-adjust -0.15))
(t . ,(all-the-icons-material "find_in_page" :height 0.8 :v-adjust -0.15))))


(defsubst lsp-bridge-icon--metadata-get (metadata type-name)
(or
(plist-get completion-extra-properties (intern (format ":%s" type-name)))
(cdr (assq (intern type-name) metadata))))

(defun lsp-bridge-icon-formatted (kind)
"Format icon kind with all-the-icons"
(or (alist-get kind lsp-bridge-icon--cache)
(let ((map (assq kind lsp-bridge-icon--icons)))
(let* ((icon (if map
(cdr map)
(cdr (assq t lsp-bridge-icon--icons))))
(half (/ (default-font-width) 2))
(pad (propertize " " 'display `(space :width (,half))))
(disp (concat pad icon pad)))
(setf (alist-get kind lsp-bridge-icon--cache) disp)
disp))))

(defun lsp-bridge-icon-margin-formatter (metadata)
"Return a margin-formatter function which produces kind icons.
METADATA is the completion metadata supplied by the caller (see
info node `(elisp)Programmed Completion'). To use, add this
function to the relevant margin-formatters list."
(if-let ((kind-func (lsp-bridge-icon--metadata-get metadata "company-kind")))
(lambda (cand)
(if-let ((kind (funcall kind-func cand)))
(lsp-bridge-icon-formatted kind)
(lsp-bridge-icon-formatted t))))) ;; as a backup

(defun lsp-bridge-company-box-icons (candidate)
(when-let* ((item (get-text-property 0 'lsp-bridge--lsp-item candidate))
(kind (plist-get item :kind)))
(intern kind)))

(cl-case lsp-bridge-completion-provider
(company
(if (boundp 'company-box-mode)
(add-to-list 'company-box-icons-functions #'lsp-bridge-company-box-icons)))
(corfu
(add-to-list 'corfu-margin-formatters #'lsp-bridge-icon-margin-formatter)))

(provide 'lsp-bridge-icon)
;;; lsp-bridge-icon.el ends here
8 changes: 4 additions & 4 deletions lsp-bridge-orderless.el
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

;; Filename: lsp-bridge-orderless.el
;; Description: LSP bridge
;; Author: Daniel Mendler <mail@daniel-mendler.de>
;; Author: Andy Stewart <lazycat.manatee@gmail.com>
;; Maintainer: Andy Stewart <lazycat.manatee@gmail.com>
;; Copyright (C) 2022, Daniel Mendler, Andy Stewart, all rights reserved.
;; Created: 2022-05-01 14:10:12
;; Copyright (C) 2018, Andy Stewart, all rights reserved.
;; Created: 2018-06-15 14:10:12
;; Version: 0.5
;; Last-Updated: Sun Nov 21 04:35:02 2022 (-0500)
;; By: Mingde (Matthew) Zeng
Expand Down Expand Up @@ -105,7 +105,7 @@
(orderless-matching-styles '(orderless-initialism orderless-literal orderless-regexp)))

(defun lsp-bridge-orderless-dispatch-flex-first (_pattern index _total)
"orderless-flex for lsp-bridge-ui."
"orderless-flex for corfu."
(and (eq index 0) 'orderless-flex))

(defun lsp-bridge-orderless-setup ()
Expand Down
4 changes: 2 additions & 2 deletions lsp-bridge-ref.el
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
;; Description: Search and refacotry code with rg
;; Author: Andy Stewart <lazycat.manatee@gmail.com>
;; Maintainer: Andy Stewart <lazycat.manatee@gmail.com>
;; Copyright (C) 2022, Andy Stewart, all rights reserved.
;; Created: 2022-05-01 14:22:12
;; Copyright (C) 2018, Andy Stewart, all rights reserved.
;; Created: 2018-08-26 14:22:12
;; Version: 5.6
;; Last-Updated: 2020-05-04 17:52:55
;; By: Andy Stewart
Expand Down
105 changes: 0 additions & 105 deletions lsp-bridge-ui-history.el

This file was deleted.

0 comments on commit c82b451

Please sign in to comment.