Giter Site home page Giter Site logo

emacs-lsp / lsp-ui Goto Github PK

View Code? Open in Web Editor NEW
1.0K 33.0 141.0 8.53 MB

UI integrations for lsp-mode

Home Page: https://emacs-lsp.github.io/lsp-ui

License: GNU General Public License v3.0

Emacs Lisp 98.48% Makefile 0.46% HTML 1.06%
emacs-lsp lsp ui lsp-ui peek xref sideline flycheck-diagnostics flycheck

lsp-ui's Introduction

lsp-ui

MELPA MELPA Stable Build Status

Table of Contents

Intro

This package contains all the higher level UI modules of lsp-mode, like flycheck support and code lenses.

By default, lsp-mode automatically activates lsp-ui unless lsp-auto-configure is set to nil.

You only have to put (use-package lsp-ui) in your config and the package will work out of the box. (use-package)

Or use the builtin package manager.

M-x package-install [RET] lsp-ui [RET]

lsp-ui-sideline:

Show informations of the symbols on the current line. It also show flycheck diagnostics and LSP code actions lsp-line

Customization:

  • lsp-ui-sideline-show-diagnostics show diagnostics messages in sideline
  • lsp-ui-sideline-show-hover show hover messages in sideline
  • lsp-ui-sideline-show-code-actions show code actions in sideline
  • lsp-ui-sideline-update-mode When set to 'line' the information will be updated when user changes current line otherwise the information will be updated when user changes current point
  • lsp-ui-sideline-delay seconds to wait before showing sideline

lsp-ui-peek:

Add peek feature lsp-xref

You may remap xref-find-{definitions,references} (bound to M-. M-? by default):

(define-key lsp-ui-mode-map [remap xref-find-definitions] #'lsp-ui-peek-find-definitions)
(define-key lsp-ui-mode-map [remap xref-find-references] #'lsp-ui-peek-find-references)

There is a window-local jump list dedicated to cross references:

(lsp-ui-peek-jump-backward)
(lsp-ui-peek-jump-forward)

Other cross references:

(lsp-ui-peek-find-workspace-symbol "pattern 0")
;; If the server supports custom cross references
(lsp-ui-peek-find-custom 'base "$cquery/base")

Customization:

  • lsp-ui-peek-enable enable ‘lsp-ui-peek’
  • lsp-ui-peek-show-directory show the directory of files

lsp-ui-doc

Show object documentation at point in a child frame. lsp-ui-doc

Show documentation in a WebKit widget lsp-ui-doc-webkit

Focus into lsp-ui-doc-frame lsp-ui-doc-focus-frame

Customization:

  • lsp-ui-doc-enable Enable lsp-ui-doc
  • lsp-ui-doc-position Where to display the doc (top, bottom or at-point)
  • lsp-ui-doc-side Where to display the doc (left or right)
  • lsp-ui-doc-delay Number of seconds before showing the doc
  • lsp-ui-doc-show-with-cursor When non-nil, move the cursor over a symbol to show the doc
  • lsp-ui-doc-show-with-mouse When non-nil, move the mouse pointer over a symbol to show the doc

lsp-ui-imenu

Show imenu entries.

lsp-ui-doc

Customization:

  • lsp-ui-imenu-kind-position place to show entries kind
  • lsp-ui-imenu-buffer-position place to show the buffer window
  • lsp-ui-imenu-window-width set window width
  • lsp-ui-imenu-window-fix-width when non-nil, the window will not be resizable (eg. unaffected by balance-windows)
  • lsp-ui-imenu--custom-mode-line-format mode line format
  • lsp-ui-imenu-auto-refresh auto refresh when necessary
  • lsp-ui-imenu-refresh-delay delay to refresh imenu

Contributing

Any kind of help is appreciated. If you want to help us maintaining this package, leave a note.

lsp-ui's People

Contributors

alanz avatar alexmurray avatar brotzeit avatar chaoyi avatar cireu avatar d4ncer avatar danielmartin avatar declspeck avatar divvycr avatar ericdallo avatar jcs090218 avatar jiegec avatar kiennq avatar kljohann avatar kurnevsky avatar lenbok avatar leungbk avatar maskray avatar matthewzmd avatar phst avatar russell avatar scturtle avatar seagle0128 avatar sebastiencs avatar tigersoldier avatar topisani avatar twlz0ne avatar vibhavp avatar wyuenho avatar yyoncho avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lsp-ui's Issues

Fix: `lsp-flycheck` fail to show errors due to not setting buffer.

Original code:

(defun lsp-flycheck--start (checker callback)
  "Start an LSP syntax check with CHECKER.

CALLBACK is the status callback passed by Flycheck."
  ;; Turn all errors from lsp--diagnostics into flycheck-error objects and pass
  ;; them immediately to the callback
  (let ((errors))
    (maphash (lambda (file diagnostics)
               (dolist (diag diagnostics)
                 (push (flycheck-error-new
                        :checker checker
                        :filename file
                        :line (1+ (lsp-diagnostic-line diag))
                        :column (1+ (lsp-diagnostic-column diag))
                        :message (lsp-diagnostic-message diag)
                        :level (pcase (lsp-diagnostic-severity diag)
                                 (1 'error)
                                 (2 'warning)
                                 (_ 'info))
                        :id (lsp-diagnostic-code diag))
                       errors)))
             lsp--diagnostics)
    (funcall callback 'finished errors)))

The (current-buffer) is not passed to flycheck-error-new, then the error will be rejected later in flycheck-relevant-error-p:

(defun flycheck-relevant-error-p (err)
  "Determine whether ERR is relevant for the current buffer.

Return t if ERR may be shown for the current buffer, or nil
otherwise."
  (flycheck-error-with-buffer err
    (let ((file-name (flycheck-error-filename err))
          (message (flycheck-error-message err)))
      (and
       ;; The error is relevant for the current buffer if it's got no file-name
       ;; and the current buffer has no file name, too, or if it refers to the
       ;; same file as the current buffer.
       (or (and (not file-name) (not buffer-file-name))
           (and buffer-file-name file-name
                (flycheck-same-files-p file-name buffer-file-name)))
       message
       (not (string-empty-p message))
       (flycheck-error-line err)))))

In the macro flycheck-error-with-buffer, the buffer is set locally to the one bound in err, which is nil in this case.
Simple fix:

(defun lsp-flycheck--start (checker callback)
  "Start an LSP syntax check with CHECKER.

CALLBACK is the status callback passed by Flycheck."
  ;; Turn all errors from lsp--diagnostics into flycheck-error objects and pass
  ;; them immediately to the callback
  (let ((errors))
    (maphash (lambda (file diagnostics)
               (dolist (diag diagnostics)
                 (push (flycheck-error-new
                        :buffer (current-buffer)
                        :checker checker
                        :filename file
                        :line (1+ (lsp-diagnostic-line diag))
                        :column (1+ (lsp-diagnostic-column diag))
                        :message (lsp-diagnostic-message diag)
                        :level (pcase (lsp-diagnostic-severity diag)
                                 (1 'error)
                                 (2 'warning)
                                 (_ 'info))
                        :id (lsp-diagnostic-code diag))
                       errors)))
             lsp--diagnostics)
    (funcall callback 'finished errors)))

Just too lazy for a pull-request because fix is trivial and shorter than explanation ;)
P.S. edebug is really helpful

Support multi-line textDocument/hover

Currently textDocument/hover is implemented via

(setq-local eldoc-documentation-function #'lsp--on-hover)

For multi-line macro/struct/class declaration and comment support (see jacobdufault/cquery#29 for cquery's ongoing support), this UI may be infeasible. We might need to provide an alternative UI.

Melpa

i think its time we put this on melpa, it already has a few cool features.
I am not familiar with the procedure, so maybe someone who is could take a look at it?

[lsp-ui-peek] keys in lsp-ui-peek-mode-map are overriden by evil-mode

In a buffer, when lsp-ui-peek-find-references is called for the first time, the focus is not in the peek "window" and keys like q are overriden those from evil-mode (evil-record-macro). After clicking on the peek "window", the subsequent lsp-ui-peek-find-references have the focus.

This has been fixed by f441403

lsp-ui assumes it is run in a GUI frame

lsp-ui causes Emacs 26.0.91 to crash. Through the debugging process, a developer pointed out:

It is now clear what happens. As I guessed,
lsp-ui assumes it is run in a GUI frame, so it calls functions that
make no sense on TTY frames. I suggest to communicate this to the
developers of that package.

I am a terminal-mode Emacs user and I'd like to make use of lsp-ui's sideline and documentation.

Use major-mode other than markdown-view-mode in lsp-ui-doc--render-buffer

lsp-ui-doc.el sends textDocument/hover requests to language servers and
renders the response with (markdown-view-mode) (see the demo at #17 (comment)).

cquery emits two MarkedString where the first is "language":"text" while the second may be "language":"cpp"/"c"/"objc".

{"jsonrpc":"2.0","id":770,"result":{"contents":[{"language":"text","value":"/**< key size if this is a LEAF2 page */"},{"language":"c","value":"uint16_t MDB_page::mp_pad"}],"range":{
"start":{"line":967,"character":10},"end":{"line":967,"character":16}}}}

For C/C++, maybe we could use (delay-mode-hooks (c++-mode)) in lsp-ui-doc--render-buffer to render the response. (markdown-view-mode) is undesirable because /** * */ comments and underscores have peculiar appearance (asterisks and underscores in markdown affect styles)

This function from lsp-ui-sideline can be used to retrieve the language-id:

(defun lsp-ui-sideline--get-language ()
  "Return the language of the buffer."
  (thread-first lsp--cur-workspace
    lsp--workspace-client
    lsp--client-language-id
    (funcall (current-buffer))))

top right: lsp-ui-doc, right: lsp-ui-sideline. lsp-ui-sideline should also be updated to filter out "language":"text" so that comments do not mess up the display.
top right: lsp-ui-doc, right: lsp-ui-sideline

Reload flycheck in lsp-line

flycheck with cquery (and probably most lsp servers) is blazing fast - so fast that i get a new error every time i type a character, which is great, no problem there, but lsp-line doesnt update its flycheck message, leaving me with an error even when the red line disappears.

I assume there must be some flycheck update hook we could hook into?

Make lsp-ui-imenu hierarchical

lsp--imenu-create-index from lsp-imenu.el (in lsp-mode) does not take hierarchy into consideration. I think it might be useful if it can be used to visualize arbitrary symbol hierarchy, where the most common ones are:

  • member hierarchy: members of a type (e.g. members of a class/struct; enumeration constants in an enum; members in a module/namespace) are recursively expanded
struct B { B* x; int b; };
struct A { B b;  int c; };

may expand to

A
  B b
    int b
    B* x    // pointer types can optionally be expanded
      int b
      B* x   // but the client needs to explicitly trigger the expansion to avoid infinite recursion
        int b
        B* x
  int c
  • caller tree of a callable (e.g. function,method,...). (may be generalized to reference tree)
void foo() { bar(); quz(); foo(); }
void bar() { quz(); }

is visualized as:

quz
  foo
    foo   // explicit expansion to avoid infinite recursion
  bar
    foo
      foo
  • inheritance hierarchy (e.g. all derived classes of a C++ base class, or overriden virtual functions of a base function; Rust trait/impl; Java interface...)
struct B : A {};
struct C : B {};
struct D : B {};

is visualized as:

A
  B
    C
    D

LSP spec

interface SymbolInformation {
	name: string;
        // id is missing; name may be insufficient to identify a symbol
	kind: number;
	location: Location;
	containerName?: string;  // containerName is a string. If it was an identifier, it could be used to describe a parent pointer tree
}

When the point is at a reference of a symbol, textDocument/documentHighlight or other mechanism can be employed to highlight the imenu entry and there can be some keys to trigger these different kinds of hierarchies.

I'd like to know if such extensions have been implemented in other servers. We should unify these server API interfaces and even standardize it.

Isolate the UI code in a separate library

LSP UI has UI components which can be reused by non-LSP packages in many different contexts.

For example,
Sideline: Can be used as ElDoc/Flycheck front-end.
Peek: XRef front-end.

Since lsp-mode already integrates with above packages, it could be great if the UI part of this package can be released separately.

lsp-ui should not require markdown-view-mode

markdown-view-mode isn't yet in the last stable markdown-mode release, so lsp-ui shouldn't have a hard dependency on it. Rather, it should fallback to markdown-mode if markdown-view-mode isn't available.

Workaround for child-frame's bad behavior under macOS.

I am using Emacs 26 pretest (i.e. 26.0.90) and lsp-ui-doc.el is really amazing.
However, similar to what I have run across when debugging pyim's child-frame support for choosing Chinese characters, the child frame might not show any more after a make-frame-invisible call. Tested make-frame-visible and set-frame-parameter with visibility, but to no avail. I think this should be a BUG somewhere in Emacs itself, but I hadn't send a bug report to bug-gnu-emacs. My temporary fix for lsp-ui:

diff --git a/lsp-ui-doc.el b/lsp-ui-doc.el
index 358a051..a8c4fa6 100644
--- a/lsp-ui-doc.el
+++ b/lsp-ui-doc.el
@@ -224,7 +224,11 @@ BUFFER is the buffer where the request has been made."
   (when (lsp-ui-doc--get-frame)
     (lsp-ui-doc--with-buffer
      (erase-buffer))
-    (make-frame-invisible (lsp-ui-doc--get-frame))))
+    (lsp-ui-doc--render-buffer "Hover on symbols to see document." "")
+    (lsp-ui-doc--move-frame (lsp-ui-doc--get-frame))
+    (set-frame-parameter (lsp-ui-doc--get-frame) 'alpha '(0 . 0))
+    ;; (make-frame-invisible (lsp-ui-doc--get-frame))
+    ))
 
 (defun lsp-ui-doc--buffer-width ()
   "Calcul the max width of the buffer."
@@ -312,6 +316,7 @@ SYMBOL STRING."
     (unless (frame-live-p (lsp-ui-doc--get-frame))
       (lsp-ui-doc--set-frame (lsp-ui-doc--make-frame)))
     (lsp-ui-doc--move-frame (lsp-ui-doc--get-frame))
+    (set-frame-parameter (lsp-ui-doc--get-frame) 'alpha '(100 . 100))
     (unless (frame-visible-p (lsp-ui-doc--get-frame))
       (make-frame-visible (lsp-ui-doc--get-frame)))))

The problem of this workaround is that, redisplay is too often called, making screen constantly flashing. To refactor this, we need to maintain a visibility state ourselves.

I am writing a PoC for this BUG and will send it to bug-gnu-emacs some time later.

Edit: might be related to calling make-frame-visible from a thread other than main thread, which is not explicitly specified in Emacs docs.

Edit: can't reproduce this in a snippet somehow.

Edit: some log shown in terminal when testing snippet but not the original code:

CoreAnimation: warning, deleted thread with uncommitted CATransaction; set CA_DEBUG_TRANSACTIONS=1 in environment to log backtraces, or set CA_ASSERT_MAIN_THREAD_TRANSACTIONS=1 to abort when an implicit transaction isn't created on a main thread.

Edit: I am mad about this now.

imenu buffer not using menu-mode-map

In imenu buffer, the key binding are identical to normal buffer. I don't think it is using imenu-mode-map.
Pressing q doesn't call lsp-ui-imenu--kill either.

(current-active-map) gives me this:
screen shot 2018-01-22 at 7 21 50 pm

lsp-ui-doc childframe disappears after ~1second

I realise this could be specific to my setup but the lsp-ui-doc childframe always disappears after approx 1 second even with no input / change.

Any tips on how to debug / where to start looking as to what might be causing this?

I am using emacs-snapshot 27.0.50 on Ubuntu 16.04 with gnome-shell as my DE and the latest lsp-ui / lsp-mode etc from melpa.

The below shows that the only way to keep it visible is to keep moving the cursor left / right over the symbol name - as soon as I stop moving the cursor it disappears after about 1 second.

output-2018-02-20-21 27 20

[lsp-ui-peek] Don't [remap xref-find-{definitions,references}] by default

Some users may want to use both lsp-ui-peek and helm-xref (e.g. me)

(defun lsp-ui-peek-enable (enable)
  "ENABLE."
  (interactive)
  (unless (bound-and-true-p lsp-ui-mode-map)
    (user-error "Please load lsp-ui before trying to enable lsp-ui-peek"))
  (if enable
      (progn
        (define-key lsp-ui-mode-map [remap xref-find-definitions] #'lsp-ui-peek-find-definitions)
        (define-key lsp-ui-mode-map [remap xref-find-references] #'lsp-ui-peek-find-references))
    (define-key lsp-ui-mode-map [remap xref-find-definitions] nil)
    (define-key lsp-ui-mode-map [remap xref-find-references] nil)))

cquery and lsp-ui-peek-find-definition

I am not sure whether it is lsp-ui bug or cquery. I was expecting peek-find-definition to show the details in peek window/overlay. What i am finding is it visit the file with definition instead of showing it in peek window.

Conflicts with helm and solarized-theme

Expected Behavior

helm CAN accept user input or keypresses

Actual Behavior

helm CANNOT accept user input or keypresses

Steps to reproduce the behavior

  1. Download gist: test-lsp-ui.el
  2. /path/to/emacs -Q -l /path/to/test-lsp-ui.el, wait for the helm window to appear
  3. Press any key

Environment

  • macOS 10.11.6
  • Emacs 26 / 27
  • Python 3.4.3 / 3.6.1
  • lsp-ui-20180102.1122
  • helm-20180102.2219
  • solarized-theme-20180101.42

Defaults lsp-ui-peek-expand-function to unfold all xref items

It currently displays xref items in the current buffer and folds others. I use (setq lsp-ui-peek-expand-function (lambda (xs) (mapcar #'car xs))) to unfold all files. I wonder if this is a better default to unfold all xref items.

C/C++ has separated header files and .c/.cc/.cpp/.cxx/.... Finding references in C/C++ a.h will likely reveal references in a.cc.

[lsp-ui-peek] Add a bidirectional window-local jump list for lsp-ui-peek--goto-xref

(xref-pop-marker-stack) (xref.el) and <C-t> (Vim) allows users to jump back (jump stack). This is a separate jump list, different from the standard jump list (<C-o> <C-i>).
After {xref,lsp-ui-peek}-find-{references,definitions,workspace-symbol}, it is common to navigate around the jump target and it will be convenient to have a single key to jump back.

rtags.el provides bidirectional rtags-location-stack-{forward,backward}, which is more useful (jump ring buffer).

Making the jump ring buffer window local make different windows independent. If in the future we support lsp-ui-peek-find-{references,definitions,workspace-symbol}, we can make the new window inherit jump lists from the original window.

peek reference errors

I use lsp-ui-peek-find-references to find the references. Then i select a file using [ENTER]. After that using xref-pop-marker-stack gets be back to window with peek window/overlay but not able to close that window.

lsp-xref: Make language server request type more configurable

There are a large number of different types of xrefs that I may want to query, ie, base-callers, derived-callers, variable instantiations, references, etc.

Right now lsp-xref is hard-coded to support textDocument/references and textDocument/definition. It'd be great if this could be easily extended in the user-defined init (or cquery.el).

[lsp-ui-peek] Support lsp-ui-peek-find-workspace-symbol for workspace/symbol

lsp-ui-peek-find-workspace-symbol is to lsp-ui-peek-find-references as xref-find-apropos is to xref-find-references.

Note workspace/symbol functions have different responses

(cl-defmethod xref-backend-references ((_backend (eql xref-lsp)) identifier)
  (let* ((properties (text-properties-at 0 identifier))
         (params (plist-get properties 'ref-params))
         (refs (lsp--send-request (lsp--make-request
                                   "textDocument/references"
                                   (or params (lsp--make-reference-params))))))
    (lsp--locations-to-xref-items refs)))

(cl-defmethod xref-backend-apropos ((_backend (eql xref-lsp)) pattern)
  (let ((symbols (lsp--send-request (lsp--make-request
                                     "workspace/symbol"
                                     `(:query ,pattern)))))
    (mapcar 'lsp--symbol-information-to-xref symbols)))

`lsp-flycheck-enable` requires an arg.

In lsp-ui--toggle, lsp-flycheck-enable is called with an arg:

(defun lsp-ui--toggle (enable)
  "ENABLE."
  (dolist (feature '(lsp-flycheck lsp-xref lsp-line))
    (let* ((sym (intern-soft (concat (symbol-name feature) "-enable")))
           (value (symbol-value sym))
           (fn (symbol-function sym)))
      (when (and (or value (not enable))
                 (functionp fn))
        (funcall fn enable)))))

However, lsp-flycheck-enable is defined as follows:

(defun lsp-flycheck-enable ()
  "Enable flycheck integration for the current buffer."
  (setq-local flycheck-check-syntax-automatically nil)
  (setq-local flycheck-checker 'lsp)
  (lsp-flycheck-add-mode major-mode)
  (add-to-list 'flycheck-checkers 'lsp)
  (add-hook 'lsp-after-diagnostics-hook (lambda ()
                                          (when flycheck-mode
                                            (flycheck-buffer)))))

Should be trivial to fix.

Suggest: predicate for `lsp-flycheck` should check `lsp--cur-workspace`.

The original code:

(flycheck-define-generic-checker 'lsp
  "A syntax checker using the Language Server Protocol (RLS)
provided by lsp-mode.

See https://github.com/emacs-lsp/lsp-mode."
  :start #'lsp-flycheck--start
  :modes '(python-mode) ; Need a default mode
  :predicate (lambda () lsp-mode)
  :error-explainer #'lsp-error-explainer)

I suggest that the predicate checks the lsp--cur-workspace variable to see whether a lsp server is associated with current buffer.

Don't depend on unstable emacs

Is it possible to conditionally enable features which requires emacs 26?
It would be good if we could use lsp-ui with stable emacs.

lsp-ui-peek-find-definition/reference Error

lsp-ui couldn't work as expected, When I call lsp-ui-peek-find-definition or lsp-ui-peek-find-reference in lsp-python or lsp-rust, there is always the same error:

memq: Wrong type argument: arrayp, nil

About my environment:

  • OS: arch linux
  • Emacs version: 25.3
  • lsp-mode version: 20180119
  • lsp-ui version: 20180116

peek 2018-01-20 10-32

[lsp-ui-peek] sanitize lsp-ui-peek-select-{prev,next}-file

file0  # `file*`'s have no text property 'lsp-ui-peek
  file0.line0   # `file*.line*`'s have text property 'lsp-ui-peek
  file0.line1
file1  # folded
file2  # folded
file3
  file2.line0
  file2.line1

Currently defun lsp-ui-peek--navigate moves to the next/prev entry where :file property of lsp-ui-peek text property differs from the current one. If a folded file* is selected and there are several folded file* in below/above, they will be skipped over, because they all have nil as their :file properties. This behavior may be a surprise to the user.

Moreover, file* lines do not have peek info so jumping onto them is not useful. file*.line* lines are useful.

How about changing the behavior to:

  • lsp-ui-peek-select-next-file
    • Jump to the first file*.line* entry of the next file. Unfold if necessary
    • By analogy with Vim's w command.
  • lsp-ui-peek-select-prev-file
    • If on the first entry, jump to the first file*.line* entry of the previous file
    • Otherwise, move to the first entry of the current file
    • By analogy with Vim's b command
    • This makes it an inverse operation of lsp-ui-peek-select-next-file when the cursor is on the first entry of a file

Support key bindings for next/previous reference

It's handy to have bindings for jumping to next/previous reference. This can be used to navigate all references of a symbol. I have a dirty and very low efficient kludge:

(defun my-xref//references-in-pair ()
  (let ((refs (lsp--send-request (lsp--make-request
                                  "textDocument/references"
                                  (lsp--make-reference-params)))))
    (sort
     (mapcar
      (lambda (ref)
        (let* ((filename (string-remove-prefix lsp--uri-file-prefix (gethash "uri" ref)))
               (range (gethash "range" ref))
               (start (gethash "start" range))
               (line (gethash "line" start))
               (column (gethash "character" start)))
          (list filename line column))) refs)
     (lambda (x y)
       (if (not (string= (car x) (car y)))
           (string< (car x) (car y))
         (if (not (= (cadr x) (cadr y)))
             (< (cadr x) (cadr y))
           (< (caddr x) (caddr y))))))))

(defun my-xref/next-reference ()
  (interactive)
  (let* ((line (lsp--cur-line))
         (column (lsp--cur-column))
         (refs (my-xref//references-in-pair))
         (res (-first (lambda (x)
                        (if (not (string= (car x) buffer-file-name))
                            (string> (car x) buffer-file-name)
                          (if (not (= (cadr x) line))
                              (> (cadr x) line)
                            (> (caddr x) column)))) refs)))
    (when res
      (find-file (car res))
      (goto-char 1)
      (forward-line (cadr res))
      (forward-char (caddr res))
      nil)))

(defun my-xref/previous-reference ()
  (interactive)
  (let* ((line (lsp--cur-line))
         (column (lsp--cur-column))
         (refs (my-xref//references-in-pair))
         (res (-last (lambda (x)
                        (if (not (string= (car x) buffer-file-name))
                            (string< (car x) buffer-file-name)
                          (if (not (= (cadr x) line))
                              (< (cadr x) line)
                            (< (caddr x) column)))) refs)))
    (when res
      (find-file (car res))
      (goto-char 1)
      (forward-line (cadr res))
      (forward-char (caddr res))
      nil)))

[lsp-ui-peek] header face applied to non-header parts

If I style lsp-ui-peek-header (see the red outline). It seems to also applied to the symbol representing the lookup target, as well as the currently selected line in the side menu.

I was quite confused with this and didn't understand the feature since my theme really didn't agree with the defaults. So perhaps we could use default colors that fallback to standard faces, if there are any reliable for alternate background colors.

2018-01-15-141958_3190x1006_scrot
2018-01-15-142139_3180x1025_scrot

I think more faces need to be introduced, perhaps:

  • lsp-ui-peek-header for the headers
  • lsp-ui-peek-identifier for the lookup identifier
  • lsp-ui-peek-selection for the currently selected item

flycheck on save

Flycheck on cquery (probably all lsp servers) is too fast. I get an error every time I type a character.
I find this functionality very annoying.
Is there a way to flycheck only on saving the file?

Strange icon in lsp-ui-sideline when showing code actions.

lsp-ui-sideline displays a strange icon when showing code action information. More correctly, lsp-ui-sideline shows what I presume is unicode information for an icon (or character) that is missing. I try to show this in the attached screenshot.

emacs-lsp-ui-strange-icon

The first "character" of the line in yellow on the right side is a small square with unicode information instead of a proper character or icon. Am I missing something in my installation or can it perhaps be a setting somewhere that needs tweeking?

[lsp-ui-doc] Support gfm-view-mode as an alternative to markdown-view-mode

I suppose Rust comments are usually well-organized and rendering all comments a markdown-view-mode is fine. The situation is different for C++, where comments make come in varied styles.

  • Underscores may be used without grave accent (backquote), and they will rendered as italics in markdown-view-mode with underscores disappeared.
  • Asterisks * (dereference) will be rendered as italics.

gfm-view-mode seems to catch these common cases and render them nicely (*foo keeps asterisk, but *foo* is italic; ab_ keeps the underscore while _ab_ is italic). Rendering the comments as markdown instead of text-mode is still appealing because it makes links clickable and probably has other nice features (that I am not aware of).

I don't know much about Rust comments but I think if gfm-view-mode does not have obvious deficiency we can just change markdown-view-mode to gfm-view-mode.

lsp-ui-flycheck is (sometimes) slow

I'm using lsp-ui-flycheck with cquery, which works great most of the time. Sometimes though (and I don't know why this issue seems to pop up so inconsistently) editing slows down to a crawl, with Emacs's profiler telling me that most of the CPU time is spent within flycheck.
For now, I have locally changed lsp-ui-flycheck-enable to mark diagnostics as stale using a global variable and have flycheck constantly check that variable with an idle timeout.

Does anyone else experience this issue or is something wrong with my configuration?

If this is a general performance problem, it might make sense to have lsp-ui-flycheck--start check if the lsp backend has sent any new diagnostics since flycheck had last been run and use flycheck's own timeout mechanism instead of manually invoking it from within lsp-after-diagnostics-hook?

Errors in lsp-ui when finding xrefs and running sideline timer

I made an update of Emacs packages today, after this lsp-ui stopped working and reports a number of errors.

I have lsp-ui-peek-find-xrefs bound to M-. When I try to find symbol definitions I get an error shown below. And instead of showing a sideline lsp-ui shows the second error below.

lsp-ui-peek--find-xrefs: Wrong type argument: number-or-marker-p, (("objectivec" lambda (str) (with-temp-buffer (delay-mode-hooks (objc-mode)) (insert str) (font-lock-ensure) (buffer-string))) ("cpp" lambda (str) (with-temp-buffer (delay-mode-hooks (c++-mode)) (insert str) (font-lock-ensure) (buffer-string))) ("c" lambda (str) (with-temp-buffer (delay-mode-hooks (c-mode)) (insert str) (font-lock-ensure) (buffer-string))))

Error running timer ‘lsp-ui-sideline--run’: (wrong-type-argument number-or-marker-p (("objectivec" lambda (str) (with-temp-buffer (delay-mode-hooks (objc-mode)) (insert str) (font-lock-ensure) (buffer-string))) ("cpp" lambda (str) (with-temp-buffer (delay-mode-hooks (c++-mode)) (insert str) (font-lock-ensure) (buffer-string))) ("c" lambda (str) (with-temp-buffer (delay-mode-hooks (c-mode)) (insert str) (font-lock-ensure) (buffer-string)))))

[lsp-ui-flycheck] unreasonable wrap

emacs-lsp-flycheck-unreasonable-wrap

Expected Behavior

No wrap when moving to <home>.

Actual Behavior

Wrap when moving to <home>.

Steps to reproduce the behavior

  1. Download gist: test-lsp-flychedk.el
  2. /path/to/emacs -Q -l /path/to/test-lsp-flychedk.el

Environment

  • macOS 10.11.6
  • Emacs 26 / 27
  • lsp-mode-20180120.418
  • lsp-ui-20180119.2247

Don’t show doc when window width is less than a threshold

Is there a option like that? Currently if you enable lap-ui-doc and do edit in a narrow window(say 80 char in width), the pop up doc covers most of the window and I can’t see anything.

Even better, lsp-ui can detect the current position of cursor and make sure the doc frame doesn’t cover that position.

frame-live-p "Unprintable entity"

When I restart emacs with desktop-mode enabled it gets unusable if any buffer activates lsp-ui-mode.
Almost every action including M-x, C-x C-f and C-x C-c, shows the *Warning* buffer with

Error (frameset): Wrong type argument: frame-live-p, "Unprintable entity"

Then I have to killall emacs and rerun in with emacs --no-desktop

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.