Set pop-up display for Java language in vim.

First of all, I'm a temporary worker. Therefore, the sales staff will be present at the time of the interview with the dispatched company. Since the sales person ignores my opinion and proceeds without permission, the dispatch destination may be decided regardless of the situation. Since I became a temporary worker, I have abandoned humans, but I would like you to forgive me for a moment.

With that said, the next may be a Java language project. That means I had to re-learn the Java language. However, I thought I wouldn't use books related to the Java language, so I left them at my parents' house. I couldn't help it, so I decided to buy more from the first school book. How many books and how many kinds of elementary books should I buy ... I'm planning to buy a Kindle book if possible, but it's hard to see, so it's definitely a paper book. There will be no good measures.

Main subject

If you're programming for beginners, you definitely don't need a big IDE. If I have time to build such an environment, I would like to devote even a little time to study. How is it? Because I couldn't master Vim, I still couldn't build it like an IDE. Taking this opportunity, I would like to introduce Language Server Protocol (abbreviation: LSP).

What is LSP?

I think it's a function that completes the input process with auto-completion. With that in mind, I decided to introduce it.

I don't want to be difficult

It's a hassle to prepare an IDE environment, so I'd like to build an environment just by slightly modifying the already installed Vim. Therefore, I don't want to be difficult or time consuming. So, I decided to use mattn's Plug-in to reduce installation cost.

Actual LSP introduction

Since it is easy to do, I decided to proceed as explained by Mr. mattn.

Premise

Plugin management uses minpac.

Plug-in introduction

I thought it would be easy to introduce, for the time being, whether one line would be enough or two lines would be needed.

vimrc


call minpac#add('prabirshrestha/vim-lsp')
call minpac#add('mattn/vim-lsp-settings')

Then, on the ex command line,

command


call minpac#update()

Type in. By doing so, the plugin will be introduced. This alone makes it very convenient.

Rewriting the configuration file

You also need to write to vimrc.

vimrc


"Ability to display errors in real time as files change
let g:lsp_diagnostics_enabled = 1
let g:lsp_diagnostics_echo_cursor = 1

"Setting to automatically display the input completion pop-up
let g:asyncomplete_auto_popup = 1
let g:asyncomplete_auto_completeopt = 1

"Delay until pop-up is displayed
let g:asyncomplete_popup_delay = 200

"Setting to enable textEdit, which is a specification of LSP
let g:lsp_text_edit_enabled = 1

let g:lsp_signs_enabled = 1
let g:lsp_diagnostics_echo_cursor = 1

mattn seems to have [split] the config file (https://mattn.kaoriya.net/software/vim/20191231001537.htm), but I haven't. Therefore, I am writing to vimrc, but I think that there is no problem.

Mother ship is also important

vim-lsp seems to be the mother ship, and if you don't include it, you will get an error.

error


Error detected while processing User Autocommands for "lsp_setup":
E117: Unknown function: lsp#register_server

vim-lsp_Err.jpg

I want to avoid errors

I got an error because I proceeded with the work without installing the plug-in of the mother ship.

error


BufRead Autocommands for "*.java"..FileType Autocommands for "java"..function <SNR>8_vim_lsp_load_or_suggest[105]..
User Autocommands for "lsp_setup"An error was detected during the processing of:
E117:Unknown function: lsp#register_server

lsp-setup-filetype_Err.jpg

Make sure to read the explanation properly.

Other

minpac-update_err.jpg

I'm getting an error in my plugin management plugin, which seems to have already been fixed (https://github.com/k-takata/minpac/issues/1).

Open Java file

Open a file with a * .java extension. And

Ex command


LspInstallServer

installj-eclipse-jdt-ls.jpg

Since the file is installed according to the programming file, you can press Yes and wait until the installation is completed.

java-installer-jdtls.jpg

Completed.

Personally, the character code is strange ... but I'll review it at another time. It should have been UTF-8, but ...

Not compatible with C ++ language

I'm not sure, but it seems that some programming files cannot be installed.

Extension .cpp

Open a C ++ language file

cpp-ls-clangd.jpg

I obediently followed it because it could be introduced.

install-clangd.jpg

Of course yes.

unxz-command-not-found.jpg

However, the installation failed. This seems to be because the required command was not found. Therefore, there may be a problem with my environment, but now I only need to prepare the Java environment, so I postpone it.

Not enjoy the actual benefits.

Strange. Auto-completion doesn't work at all.

Popup is not displayed at all.

Strange.

For mattn's settings,

vimrc


if empty(globpath(&rtp, 'autoload/lsp.vim'))
・
・
・

function! s:on_lsp_buffer_enabled() abort
・
・
・

augroup lsp_install
・
・
・

Was written, but is this there? By describing this, the configuration file was destroyed ...

Solution (pop-up display)

I needed a separate plug-in.

asyncomplete.vim The description is in English, so I didn't think it was the required plugin.

vimrc


"Autocomplete pop-up menu display
call minpac#add('prabirshrestha/asyncomplete.vim')
"Autocomplete source
call minpac#add('prabirshrestha/asyncomplete-lsp.vim')

It seems that these two types are needed.

asyncomplete.jpg

It's a little uncomfortable with an unintended pop-up display. In this example, I would like to enter "System", but when ** S ** is entered, "Saf ~ Nanchara" is automatically entered. Unreasonable inconvenience. What I want to do is, when I enter "S", nothing is entered and the candidates are displayed in a pop-up. I'm in trouble.

asyncomplete.vim As for the display method, nvim seems to be better. I will not change the main body now.

Completed for the time being

Although I have the above complaints, I will say that I have set it for the time being. It's still a long way from studying the Java language with just vim itself, but this article ends. Eventually, I want to be able to execute and debug.

that's all.

Recommended Posts

Set pop-up display for Java language in vim.
[For beginners] Minimum sample to display RecyclerView in Java
Rock-paper-scissors game for beginners in Java
Display Firestore data in RecyclerView [Java]
[For beginners] Run Selenium in Java
thread safe process in java language
Settings for SSL debugging in Java
Handle business logic for a set of Entity in Java class
What is a class in Java language (3 /?)
First steps for deep learning in Java
Key points for introducing gRPC in Java
What is a class in Java language (1 /?)
[Java] Set AdoptOpen JDK in STS (Eclipse)
What is a class in Java language (2 /?)
Display message dialog in java (personal memo)
Check the options set for the running Java process
ChatWork4j for using the ChatWork API in Java
Technology for reading Java source code in Eclipse
How to display a web page in Java
Set HTTP Keep Alive Timeout in Java HTTP Client
Display text as ASCII art in Java (jfiglet)
[Java] (for MacOS) How to set the classpath
Display "Hello World" in the browser using Java
Display "Hello World" in the browser using Java
Introducing NLP4J-[000] Natural Language Processing Index in Java
Compare PDF output in Java for snapshot testing
Enable / disable SNI in Java for each communication
Things to watch out for in Java equals
For JAVA learning (2018-03-16-01)
Partization in Java
Changes in Java 11
2017 IDE for Java
Pi in Java
Java for statement
FizzBuzz in Java
How to set the display time to Japan time in Rails
Set JAVA_HOME for root user in AWS Ubuntu16.04 Server
Things to watch out for in future Java development
A note for Initializing Fields in the Java tutorial
Get Locale objects for all locales available in Java
Introduction to Java for beginners Basic knowledge of Java language ①
This and that for editing ini in Java. : inieditor-java
[Java] Explains ConcurrentModificationException that occurs in java.util.ArrayList for newcomers
I tried using an extended for statement in Java
[memo] Generate RSA key pair for SSH in Java
"The Language Support for Java server crashed 5 times in the last 3 minutes. The server will not be restarted."