emacs-lsp / lsp-java

lsp-mode :heart: java
https://emacs-lsp.github.io/lsp-java
GNU General Public License v3.0
650 stars 90 forks source link

After saving a file for the fisrt time, syntax errors will not be highlight omitted till the next save. also autocompleteing will not work. #389

Open masalkhi opened 2 years ago

masalkhi commented 2 years ago

Everything is working perfectly, until saving a file for the first time, the syntax errors will not be highlight or omitted until typing C-x C-s . also the auto-completion will not work after the first save. any any suggestions how I to solve this.

before the first save, everything is good: Screenshot from 2022-05-04 10-24-08

now saving for the fist time and after that removing the text, the highlighting will not be omitted: Screenshot from 2022-05-04 10-26-06

typing C-x C-s and after that the highlighted syntax errors will be omitted: Screenshot from 2022-05-04 10-26-19

writing some text (no syntax error will show) Screenshot from 2022-05-04 10-26-40

typing C-x C-s again and all the syntax errors will be highlighted

Screenshot from 2022-05-04 10-26-51

The workspace directory of the jdtls is the same for the eclipse IDE installed on my PC.

and if there is a way to import an already existed maven project to lsp-java I would appreciate.

GNU Emacs 26.3

Linux 5.13.0-40-generic #45~20.04.1-Ubuntu SMP x86_64 GNU/Linux

the init.el file:


;; inhibit the splash screen
(setq inhibit-splash-screen t)

;; setting the window in the middle but wider
(setq initial-frame-alist '((top . 10) (left . 185)
                           (width . 110) (height . 50)))

;;hiding the tool bar
(tool-bar-mode -1)

;; auto-closing brackets 
(electric-pair-mode 1)

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(c-default-style
   (quote
    ((c-mode . "linux")
     (java-mode . "linux")
     (awk-mode . "awk")
     (other . "gnu"))))
 '(lsp-java-workspace-dir "/home/abd/eclipse-workspace/")
 '(package-selected-packages
   (quote
    (helm-lsp which-key lsp-ui company flycheck projectile use-package web-mode prettier mvn multiple-cursors lsp-javacomp lsp-java js2-mode gradle-mode emmet-mode eclim))))

(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t)
(package-initialize)

;; Add color formatting to *compilation* buffer
(add-hook 'compilation-filter-hook
   (lambda () (ansi-color-apply-on-region (point-min) (point-max))))

(require 'emmet-mode)

;; Auto-start on any markup modes
(add-hook 'sgml-mode-hook 'emmet-mode)

;; enable Emmet's css abbreviation.
(add-hook 'css-mode-hook  'emmet-mode) 

;; enable Emmet's nxml abbreviation.
(add-hook 'nxml-mode-hook  'emmet-mode) 

(add-hook 'lsp-mode-hook
      (lambda ()
        (local-set-key [?\M-\r] 'lsp-execute-code-action)))

(add-hook 'lsp-mode-hook
      (lambda ()
        (local-set-key [?\M-b] 'lsp-java-build-project)))

(global-set-key [?\M-c] 'compile)

(global-set-key (kbd "<C-dead-circumflex>") 'treemacs)

;; multiple-cursors
(require 'multiple-cursors)

(condition-case nil
    (require 'use-package)
  (file-error
   (require 'package)
   (add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/"))
   (package-initialize)
   (package-refresh-contents)
   (package-install 'use-package)
   (setq use-package-always-ensure t)
   (require 'use-package)))

(use-package projectile)
(use-package flycheck)
(use-package yasnippet :config (yas-global-mode))
(use-package lsp-mode :hook ((lsp-mode . lsp-enable-which-key-integration))
  :config (setq lsp-completion-enable-additional-text-edit nil))
(use-package hydra)
(use-package company)
(use-package lsp-ui)
(use-package which-key :config (which-key-mode))
(use-package lsp-java :config (add-hook 'java-mode-hook 'lsp))
(use-package dap-mode :after lsp-mode :config (dap-auto-configure-mode))
(use-package dap-java :ensure nil)
(use-package helm-lsp)
(use-package helm
  :config (helm-mode))
(use-package lsp-treemacs)
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )
yyoncho commented 2 years ago

is it reproducible after M-x lsp-start-plain?

masalkhi commented 2 years ago

after typing the the command, a new frame was opened:

I got the following in the *Compile-Log* buffer:

In php-project-project-find-function:
php-project.el:293:21:Warning: reference to free variable ‘root’

In end of data:
php-project.el:314:1:Warning: the following functions are not known to be
    defined: when-let, root

I got the following in the *Backtrace* buffer:

Debugger entered--Lisp error: (void-function rx-let)
  (rx-let ((numeric-literal (| number hex-number)) (number (: (| (: (1+ digit) (32 (: 46 ...))) (: 46 (1+ digit))) (32 exponent))) (exponent (: (| 101 69) (32 (| 43 45)) (1+ digit))) (hex-number (: 48 (| 120 88) (1+ hex-digit)))) (rx bow numeric-literal eow))
  (defvar dart--numeric-literal-re (rx-let ((numeric-literal (| number hex-number)) (number (: (| (: (1+ digit) (32 ...)) (: 46 (1+ digit))) (32 exponent))) (exponent (: (| 101 69) (32 (| 43 45)) (1+ digit))) (hex-number (: 48 (| 120 88) (1+ hex-digit)))) (rx bow numeric-literal eow)))
  eval-buffer(#<buffer  *load*-88128> nil "/tmp/lsp-tmp-elpawF9WWF/dart-mode-20220401.0/dart-mode.el" nil t)  ; Reading at buffer position 5682
  load-with-code-conversion("/tmp/lsp-tmp-elpawF9WWF/dart-mode-20220401.0/dart-mode.el" "/tmp/lsp-tmp-elpawF9WWF/dart-mode-20220401.0/dart-mode.el" nil t)
  require(dart-mode)
  (closure ((pkg-list lsp-mode lsp-ui yasnippet lsp-java lsp-python-ms lsp-haskell helm-lsp lsp-treemacs dap-mode lsp-origami lsp-dart company flycheck lsp-pyright rust-mode php-mode scala-mode dart-mode clojure-mode typescript-mode csharp-mode) t) (pkg) (if (package-installed-p pkg) nil (package-install pkg)) (require pkg))(dart-mode)
  mapc((closure ((pkg-list lsp-mode lsp-ui yasnippet lsp-java lsp-python-ms lsp-haskell helm-lsp lsp-treemacs dap-mode lsp-origami lsp-dart company flycheck lsp-pyright rust-mode php-mode scala-mode dart-mode clojure-mode typescript-mode csharp-mode) t) (pkg) (if (package-installed-p pkg) nil (package-install pkg)) (require pkg)) (lsp-mode lsp-ui yasnippet lsp-java lsp-python-ms lsp-haskell helm-lsp lsp-treemacs dap-mode lsp-origami lsp-dart company flycheck lsp-pyright rust-mode php-mode scala-mode dart-mode clojure-mode typescript-mode csharp-mode))
  (let* ((pkg-list (quote (lsp-mode lsp-ui yasnippet lsp-java lsp-python-ms lsp-haskell helm-lsp lsp-treemacs dap-mode lsp-origami lsp-dart company flycheck lsp-pyright rust-mode php-mode scala-mode dart-mode clojure-mode typescript-mode csharp-mode)))) (package-initialize) (package-refresh-contents) (mapc (function (lambda (pkg) (if (package-installed-p pkg) nil (package-install pkg)) (require pkg))) pkg-list) (yas-global-mode) (add-hook (quote prog-mode-hook) (quote lsp)) (add-hook (quote kill-emacs-hook) (list (quote lambda) nil (cons (quote delete-directory) (cons package-user-dir (quote (t)))))))
  eval-buffer(#<buffer  *load*> nil "/tmp/plainG9XmHn.el" nil t)  ; Reading at buffer position 2298
  load-with-code-conversion("/tmp/plainG9XmHn.el" "/tmp/plainG9XmHn.el" nil t)
  load("/tmp/plainG9XmHn.el" nil t)
  command-line-1(("-l" "/tmp/plainG9XmHn.el" "/home/masalkhi/java-project/lsp/debugging/src/main/java/com/example/debugging/DemoApplication.java"))
  command-line()
  normal-top-level()
yyoncho commented 2 years ago

Press c - you can ignore that error

yyoncho commented 2 years ago

@ericdallo seems like lsp-dart does not work on 26.3

ericdallo commented 2 years ago

CI seems to compile it properly, why do you think this @yyoncho ?

yyoncho commented 2 years ago

Debugger entered--Lisp error: (void-function rx-let)

Ah, it is dart-mode actually causing the trouble.

masalkhi commented 2 years ago

I have installed 26.1 from the source code, I have typed the the command, no errors was shown and it opened a new frame. I had to specify my lisp file with the command load-file because it did not load my init.el file. then I have entered the command lsp-mode, it tells me that it Disconnected. and in the other frame is just the same.

and I have installed the 27.1 too I got the following in the *ERROR* buffer, when typing lsp-start-plain


Failed to verify signature spinner-1.7.4.tar.sig:
Bad signature from 066DAFCB81E42C40 GNU ELPA Signing Agent (2019) <elpasign@elpa.gnu.org>
Command output:
gpg: Signature made Fr 02 Jul 2021 11:10:02 CEST
gpg:                using RSA key C433554766D3DDC64221BFAA066DAFCB81E42C40
gpg: BAD signature from "GNU ELPA Signing Agent (2019) <elpasign@elpa.gnu.org>" [unknown]