Skip to content

Commit ae1801e

Browse files
authored
Minor improvement (#705)
* Clean up util * clean up * remove util * fix * Fix warning * Fix compile * fix * cancel on push * Add checkdoc and lint * Don't lint * checkdoc * Fix install warn
1 parent bc05895 commit ae1801e

File tree

8 files changed

+132
-145
lines changed

8 files changed

+132
-145
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ on:
88
branches:
99
- master
1010

11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
1115
jobs:
1216
test:
1317
runs-on: ${{ matrix.os }}

Makefile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ TEST-FILES := test/windows-bootstrap.el test/test-helper.el \
88
LOAD-FILE = -l $(test-file)
99
LOAD-TEST-FILES := $(foreach test-file, $(TEST-FILES), $(LOAD-FILE))
1010

11-
# FIXME: add `test`
12-
ci: build compile clean
11+
# FIXME: add `test`, and `lint`
12+
ci: clean build compile checkdoc
1313

1414
build:
1515
$(EASK) package
@@ -25,6 +25,14 @@ test:
2525
$(EASK) install-deps --dev
2626
$(EASK) exec ert-runner -L . $(LOAD-TEST-FILES) -t '!no-win' -t '!org'
2727

28+
checkdoc:
29+
@echo "Run checkdoc..."
30+
@$(EASK) checkdoc
31+
32+
lint:
33+
@echo "Run package-lint..."
34+
@$(EASK) lint
35+
2836
clean:
2937
@$(EASK) clean-all
3038

lsp-ui-doc.el

Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030

3131
;;; Code:
3232

33-
(require 'lsp-ui-util)
34-
3533
(require 'lsp-protocol)
3634
(require 'lsp-mode)
3735
(require 'dash)
@@ -54,6 +52,9 @@
5452
(declare-function xwidget-webkit-execute-script-rv "ext:xwidget" (xwidget script &optional default))
5553
(declare-function xwidget-resize "ext:xwidget" (xwidget new-width new-height))
5654

55+
(declare-function lsp-ui-kill-timer 'lsp-ui)
56+
(declare-function lsp-ui-delete-overlay 'lsp-ui)
57+
5758
(defgroup lsp-ui-doc nil
5859
"Display informations of the current line."
5960
:group 'tools
@@ -64,7 +65,8 @@
6465

6566
(defcustom lsp-ui-doc-enable t
6667
"Whether or not to enable lsp-ui-doc.
67-
Displays documentation of the symbol at point on hover. This only takes effect when a buffer is started."
68+
Displays documentation of the symbol at point on hover. This only takes effect
69+
when a buffer is started."
6870
:type 'boolean
6971
:group 'lsp-ui)
7072

@@ -181,31 +183,31 @@ Only the `background' is used in this face."
181183
:group 'lsp-ui-doc)
182184

183185
(defvar lsp-ui-doc-frame-parameters
184-
'((left . -1)
185-
(no-focus-on-map . t)
186-
(min-width . 0)
187-
(width . 0)
188-
(min-height . 0)
189-
(height . 0)
190-
(internal-border-width . 1)
191-
(vertical-scroll-bars . nil)
192-
(horizontal-scroll-bars . nil)
193-
(right-fringe . 0)
194-
(menu-bar-lines . 0)
195-
(tool-bar-lines . 0)
196-
(tab-bar-lines . 0)
186+
'((left . -1)
187+
(no-focus-on-map . t)
188+
(min-width . 0)
189+
(width . 0)
190+
(min-height . 0)
191+
(height . 0)
192+
(internal-border-width . 1)
193+
(vertical-scroll-bars . nil)
194+
(horizontal-scroll-bars . nil)
195+
(right-fringe . 0)
196+
(menu-bar-lines . 0)
197+
(tool-bar-lines . 0)
198+
(tab-bar-lines . 0)
197199
(tab-bar-lines-keep-state . 0)
198-
(line-spacing . 0)
199-
(unsplittable . t)
200-
(undecorated . t)
201-
(top . -1)
202-
(visibility . nil)
203-
(mouse-wheel-frame . nil)
204-
(no-other-frame . t)
200+
(line-spacing . 0)
201+
(unsplittable . t)
202+
(undecorated . t)
203+
(top . -1)
204+
(visibility . nil)
205+
(mouse-wheel-frame . nil)
206+
(no-other-frame . t)
205207
(inhibit-double-buffering . t)
206-
(drag-internal-border . t)
207-
(no-special-glyphs . t)
208-
(desktop-dont-save . t))
208+
(drag-internal-border . t)
209+
(no-special-glyphs . t)
210+
(desktop-dont-save . t))
209211
"Frame parameters used to create the frame.")
210212

211213
(defvar lsp-ui-doc-render-function nil
@@ -244,6 +246,8 @@ Because some variables are buffer local.")
244246
(defvar-local lsp-ui-doc--from-mouse-current nil
245247
"Non nil when the current call is triggered by a mouse event")
246248

249+
(defvar-local lsp-ui-doc--unfocus-frame-timer nil)
250+
247251
(defconst lsp-ui-doc--buffer-prefix " *lsp-ui-doc-")
248252

249253
(defmacro lsp-ui-doc--with-buffer (&rest body)
@@ -422,8 +426,8 @@ We don't extract the string that `lps-line' is already displaying."
422426
"Hide the frame."
423427
(setq lsp-ui-doc--bounds nil
424428
lsp-ui-doc--from-mouse nil)
425-
(lsp-ui-util-safe-delete-overlay lsp-ui-doc--inline-ov)
426-
(lsp-ui-util-safe-delete-overlay lsp-ui-doc--highlight-ov)
429+
(lsp-ui-delete-overlay lsp-ui-doc--inline-ov)
430+
(lsp-ui-delete-overlay lsp-ui-doc--highlight-ov)
427431
(when-let ((frame (lsp-ui-doc--get-frame)))
428432
(when (frame-visible-p frame)
429433
(make-frame-invisible frame))))
@@ -889,15 +893,15 @@ HEIGHT is the documentation number of lines."
889893
(run-hook-with-args 'lsp-ui-doc-frame-hook frame window)
890894
(when lsp-ui-doc-use-webkit
891895
(define-key (current-global-map) [xwidget-event]
892-
(lambda ()
893-
(interactive)
894-
(let ((xwidget-event-type (nth 1 last-input-event)))
895-
;; (when (eq xwidget-event-type 'load-changed)
896-
;; (lsp-ui-doc--move-frame (lsp-ui-doc--get-frame)))
897-
(when (eq xwidget-event-type 'javascript-callback)
898-
(let ((proc (nth 3 last-input-event))
899-
(arg (nth 4 last-input-event)))
900-
(funcall proc arg))))))
896+
(lambda ()
897+
(interactive)
898+
(let ((xwidget-event-type (nth 1 last-input-event)))
899+
;; (when (eq xwidget-event-type 'load-changed)
900+
;; (lsp-ui-doc--move-frame (lsp-ui-doc--get-frame)))
901+
(when (eq xwidget-event-type 'javascript-callback)
902+
(let ((proc (nth 3 last-input-event))
903+
(arg (nth 4 last-input-event)))
904+
(funcall proc arg))))))
901905
(lsp-ui-doc--webkit-run-xwidget))
902906
frame))
903907

@@ -920,7 +924,7 @@ HEIGHT is the documentation number of lines."
920924
(and (looking-at "[[:graph:]]") (cons (point) (1+ (point))))))
921925
(unless (equal lsp-ui-doc--bounds bounds)
922926
(lsp-ui-doc--hide-frame)
923-
(lsp-ui-util-safe-kill-timer lsp-ui-doc--timer)
927+
(lsp-ui-kill-timer lsp-ui-doc--timer)
924928
(setq lsp-ui-doc--timer
925929
(run-with-idle-timer
926930
lsp-ui-doc-delay nil
@@ -1167,7 +1171,6 @@ It is supposed to be called from `lsp-ui--toggle'"
11671171
(interactive)
11681172
(lsp-ui-doc--hide-frame))
11691173

1170-
(defvar-local lsp-ui-doc--unfocus-frame-timer nil)
11711174
(defun lsp-ui-doc--glance-hide-frame ()
11721175
"Hook to hide hover information popup for `lsp-ui-doc-glance'."
11731176
(when (or (overlayp lsp-ui-doc--inline-ov)

lsp-ui-imenu.el

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535

3636
(require 'lsp-mode)
3737
(require 'dash)
38-
(require 'lsp-ui-util)
38+
39+
(declare-function lsp-ui-kill-timer 'lsp-ui)
3940

4041
(defgroup lsp-ui-imenu nil
4142
"Display imenu entries."
@@ -379,7 +380,7 @@ ITEMS are used when the kind position is 'left."
379380

380381
(defun lsp-ui-imenu--start-refresh (&rest _)
381382
"Starts the auto refresh timer."
382-
(lsp-ui-util-safe-kill-timer lsp-ui-imenu--refresh-timer)
383+
(lsp-ui-kill-timer lsp-ui-imenu--refresh-timer)
383384
(setq lsp-ui-imenu--refresh-timer
384385
(run-with-idle-timer lsp-ui-imenu-auto-refresh-delay nil #'lsp-ui-imenu--refresh)))
385386

lsp-ui-peek.el

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
(require 'xref)
4040
(require 'dash)
4141

42+
(declare-function lsp-ui--mute-apply 'lsp-ui)
43+
4244
(defgroup lsp-ui-peek nil
4345
"Improve version of xref with peek feature."
4446
:group 'tools
@@ -181,12 +183,12 @@ will cause performances issues.")
181183
(eval '(progn
182184
(evil-define-motion lsp-ui-peek-jump-backward (count)
183185
(lsp-ui-peek--with-evil-jumps
184-
(evil--jump-backward count)
185-
(run-hooks 'xref-after-return-hook)))
186+
(evil--jump-backward count)
187+
(run-hooks 'xref-after-return-hook)))
186188
(evil-define-motion lsp-ui-peek-jump-forward (count)
187189
(lsp-ui-peek--with-evil-jumps
188-
(evil--jump-forward count)
189-
(run-hooks 'xref-after-return-hook))))
190+
(evil--jump-forward count)
191+
(run-hooks 'xref-after-return-hook))))
190192
t))
191193

192194
(defmacro lsp-ui-peek--prop (prop &optional string)
@@ -346,10 +348,8 @@ XREFS is a list of references/definitions."
346348
(with-temp-buffer
347349
(insert string)
348350
(delay-mode-hooks
349-
(let ((inhibit-message t))
350-
(funcall major))
351-
(ignore-errors
352-
(font-lock-ensure)))
351+
(lsp-ui--mute-apply (funcall major))
352+
(ignore-errors (font-lock-ensure)))
353353
(buffer-string)))
354354

355355
(defun lsp-ui-peek--peek ()
@@ -635,7 +635,8 @@ EXTRA is a plist of extra parameters."
635635
(append extra (lsp--text-document-position-params))))
636636

637637
(defun lsp-ui-peek--extract-chunk-from-buffer (pos start end)
638-
"Return the chunk of code pointed to by POS (a Position object) in the current buffer.
638+
"Return the chunk of code pointed to by POS (a Position object) in the current
639+
buffer.
639640
START and END are delimiters."
640641
(let* ((point (lsp--position-to-point pos))
641642
(inhibit-field-text-motion t)

lsp-ui-sideline.el

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030

3131
;;; Code:
3232

33-
(require 'lsp-ui-util)
3433
(require 'lsp-protocol)
3534
(require 'lsp-mode)
3635
(require 'flycheck nil 'noerror)
@@ -44,6 +43,8 @@
4443
(declare-function flycheck-error-format-message-and-id "ext:flycheck.el")
4544
(declare-function flycheck-error-level "ext:flycheck.el")
4645

46+
(declare-function lsp-ui-line-number-display-width 'lsp-ui)
47+
4748
(defgroup lsp-ui-sideline nil
4849
"Display information for the current line."
4950
:group 'tools
@@ -325,8 +326,8 @@ CURRENT is non-nil when the point is on the symbol."
325326
(propertize str 'display (lsp-ui-sideline--compute-height)))))
326327

327328
(defun lsp-ui-sideline--check-duplicate (symbol info)
328-
"Check if there's already a SYMBOL containing INFO, unless `lsp-ui-sideline-ignore-duplicate'
329-
is set to t."
329+
"Check if there's already a SYMBOL containing INFO, unless
330+
`lsp-ui-sideline-ignore-duplicate' is set to t."
330331
(not (when lsp-ui-sideline-ignore-duplicate
331332
(--any (and (string= (overlay-get it 'symbol) symbol)
332333
(string= (overlay-get it 'info) info))
@@ -349,7 +350,7 @@ is set to t."
349350
(if (< emacs-major-version 27)
350351
;; This was necessary with emacs < 27, recent versions take
351352
;; into account the display-line width with :align-to
352-
(lsp-ui-util-line-number-display-width)
353+
(lsp-ui-line-number-display-width)
353354
0)
354355
(if (or
355356
(bound-and-true-p whitespace-mode)
@@ -363,7 +364,7 @@ is set to t."
363364
(or (and (>= emacs-major-version 27)
364365
;; We still need this number when calculating available space
365366
;; even with emacs >= 27
366-
(lsp-ui-util-line-number-display-width))
367+
(lsp-ui-line-number-display-width))
367368
0)))
368369

369370
(defun lsp-ui-sideline--valid-tag-p (tag mode)
@@ -435,7 +436,8 @@ is set to t."
435436
(lsp-ui-sideline--toggle-current ov nil))))))
436437

437438
(defun lsp-ui-sideline--split-long-lines (lines)
438-
"Fill LINES so that they are not longer than `lsp-ui-sideline-diagnostic-max-line-length' characters."
439+
"Fill LINES so that they are not longer than
440+
`lsp-ui-sideline-diagnostic-max-line-length' characters."
439441
(cl-mapcan (lambda (line)
440442
(if (< (length line) lsp-ui-sideline-diagnostic-max-line-length)
441443
(list line)
@@ -449,7 +451,8 @@ is set to t."
449451
(defun lsp-ui-sideline--diagnostics (buffer bol eol)
450452
"Show diagnostics belonging to the current line.
451453
Loop over flycheck errors with `flycheck-overlay-errors-in'.
452-
Find appropriate position for sideline overlays with `lsp-ui-sideline--find-line'.
454+
Find appropriate position for sideline overlays with
455+
`lsp-ui-sideline--find-line'.
453456
Push sideline overlays on `lsp-ui-sideline--ovs'."
454457
(when (and (bound-and-true-p flycheck-mode)
455458
(bound-and-true-p lsp-ui-sideline-mode)

lsp-ui-util.el

Lines changed: 0 additions & 71 deletions
This file was deleted.

0 commit comments

Comments
 (0)