A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://github.com/emacs-lsp/lsp-java below:

GitHub - emacs-lsp/lsp-java: lsp-mode java

Emacs Java IDE using Eclipse JDT Language Server.

LSP java mode supports the following JDT Features:

Here it is a demo from EmacsConf2019 https://www.youtube.com/watch?v=Bbjxn9yVNJ8

Here is a tutorial that covers setup and use https://xpressrazor.wordpress.com/2020/11/04/java-programming-in-emacs/

lsp-java is included in spacemacs (for now only on the dev branch). If you are using the development version of spacemacs you can simply add (java :variables java-backend 'lsp) to dotspacemacs-configuration-layers.

The recommended way to install LSP Java is via package.el - the built-in package manager in Emacs. LSP Java is available on the two major package.el community maintained repos - MELPA Stable and MELPA.

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

Then add the following lines to your .emacs and open a file from the any of the specified projects.

(require 'lsp-java)
(add-hook 'java-mode-hook #'lsp)

lsp-java will automatically detect when the server is missing and it will download Eclipse JDT Language Server before the first startup. The server installation will be in lsp-java-server-install-dir. It will detect whether dap-mode is present and it will download the required server side plugins/components. If you want to update the server you can run lsp-java-update-server. To run specific version of Eclipse JDT Language Server use lsp-java-server-install-dir.

Minimal configuration with company-capf and lsp-ui and dap-mode. Set lsp-java-workspace-dir in case you have existing Java projects. Now you can explore the methods under lsp-java-*, dap-java-*, dap-*, and lsp-*.

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

LSP Java provides rich set of refactorings via Eclipse JDT Language Server code actions and some of them are bound to Emacs commands:

STS4 Integration (experimental)

LSP java has integration with STS4 providing the following functionality.

Spring boot support (Experimental)

In addition to the integration with Eclipse JDT Language Server lsp-java provides integration with STS4 which covers Spring Boot application.properties, application.yml and .java files.

Make sure that you have configured JAVA_HOME. lsp-java will automatically download the STS4 when you call lsp-java-update-server. In order to enable STS4 integration add the following lines to your config:

(require 'lsp-java-boot)

;; to enable the lenses
(add-hook 'lsp-mode-hook #'lsp-lens-mode)
(add-hook 'java-mode-hook #'lsp-java-boot-lens-mode)
Navigating the source code - Go to symbol in file/workspace

Easy navigation to Spring-specific elements of your source code.

lsp-workspace-symbol - (works better usign helm-lsp)

Quick-access for running apps

Easy navigation to the provided request mappings of running apps.

lsp-workspace-symbol - (works better usign helm-lsp)

Live application information hovers

STS4 automatically detects JVM processes for running boot applications on your local machine.

For some types of information, STS 4 may also show a 'quick summary' as a codelens.

If there are multiple instances of the app running on your machine, the live data from all those instances will show up in the hover information.

(add-hook 'java-mode-hook #'lsp-java-boot-lens-mode)

Write Spring code with templates, available via regular code completion.

Additional code completions for Spring-specific annotations

Functionality for .properties and .yml

This extension analyzes your project's classpath and parses and indexes any Spring Boot Properties Metadata it finds. Both Maven and Gradle projects are supported.

The data in the index is used to provide validation, code completions and information hovers while editing Spring Boot Properties in either .properties or .yml format.

Validation and code completion in properties file

Validation and code completion in yaml file

lsp-java provides a frontend for Spring Initializr which simplifies the creation of Spring Boot projects directly from Emacs via lsp-java-spring-initializr.

(setq lsp-inhibit-message t)
(setq lsp-ui-sideline-update-mode 'point)

When particular file is not part of imported project Eclipse JDT Language Server could not calculate the current classpath.

Have a look at ~/.emacs.d/workspace/.metadata/.plugins/org.eclipse.jdt.launching/libraryInfos.xml. If you updated your local java path and want LSP to use the new version, try removing the ~/.emacs.d/workspace/ directory and relaunch LSP. Also see #114. If you have multiple java JDK versions installed and want to change the version of java used by LSP, also need to set lsp-java-configuration-runtimes. An example for setting lsp-java-configuration-runtimes:

(setq lsp-java-configuration-runtimes '[(:name "JavaSE-1.8"
						:path "/home/kyoncho/jdk1.8.0_201.jdk/")
					(:name "JavaSE-11"
						:path "/home/kyoncho/jdk-11.0.1.jdk/"
						:default t)])
;; current VSCode defaults
(setq lsp-java-vmargs '("-XX:+UseParallelGC" "-XX:GCTimeRatio=4" "-XX:AdaptiveSizePolicyWeight=90" "-Dsun.zip.disableMemoryMapping=true" "-Xmx2G" "-Xms100m"))

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4