Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
mopemope committed Apr 26, 2019
2 parents 7ea4885 + a2678e4 commit 8914cf1
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 52 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ byte-compile.el
*.jar
meghanada-autoloads.el
meghanada-pkg.el
*.txt
72 changes: 44 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
## A Better Java Development Environment for Emacs

`Meghanada` is a new minor-mode (`meghanada-mode`) that aims at improving the editing
experience for the Java. It works by using a combination of an Emacs
experience for Java. It works by using a combination of an Emacs
package and [meghanada-server][].

**Features:**

* Easy install
* Auto update server module
* Auto-update server module
* [Gradle][] and [Maven][] and Eclipse project support
* No need build tool's plugin
* Run build tool task
Expand All @@ -21,13 +21,13 @@ package and [meghanada-server][].
* Code completion with [company-mode][] (`company-meghanada`)
* Optimize import and sort
* Jump declaration
* Run [Junit][] test (include test runner)
* Run [JUnit][] test (include test runner)
* Diagnostic reporting with [flycheck][] (`flycheck-meghanada`)
* Show symbol's type info with `el-doc`
* Search references
* Full-featured text search

`Meghanada` is tested under `linux`, `Windows` and `macOS`.
`Meghanada` is tested under `Linux`, `Windows` and `macOS`.

(Welcome contributions !)

Expand All @@ -48,12 +48,12 @@ Meghanada has been developed Emacs 25.1.1

`meghanada-mode` require [meghanada-server][] and JDK (not JRE).
[meghanada-server][] provides an interface to `meghanada-mode`. It uses a simple protocol
based on S-expressions. This server, written in java, requires the following
based on S-expressions. This server, written in Java, requires the following
packages to be installed on your system:

* JDK 1.8 or later

The Meghanada architecture is almost the same as `ensime`. It is client server model.
The Meghanada architecture is almost the same as `ensime`. It is a client-server model.

Meghanada updates any information when saving and compile the java file.

Expand Down Expand Up @@ -94,25 +94,41 @@ If you open a java file and set `meghanada-mode`, a [meghanada-server][] process

### Updating

The server will be automatically updated.To manually update bellows, type
The server will be automatically updated. To manually update bellows, type

```
M-x meghanada-update-server
```

## Auto completion
### Manual Server Installation

Auto completion is supported by `comapany-mode`.
The server will be installed and updated automatically.

If you set it up manually, please follow the instructions below.

#### Download meghanada-setup.jar

A meghanada-setup.jar is a small program that automatically updates the server.

This can be downloaded from:

https://github.com/mopemope/meghanada-server/releases/download/v1.0.13/meghanada-setup-0.0.2.jar

Move the downloaded setup.jar to .emacs.d/meghanada/.
Start Emacs and enable meghanada-mode.

## Autocompletion

Auto-completion is supported by `company-mode`.

Completion matcher is selectable. see type `M-x customize-group RET meghanada`.

## Syntax/error checking

Error checking is supported by `flycheck`.

## Customize

To customize other aspects of its behavior, type `M-x customize-group RET meghanada` .
To customize other aspects of its behavior, type `M-x customize-group RET meghanada`.

## Usage

Expand All @@ -124,11 +140,11 @@ Download and install [meghanada-server] jar.

### meghanada-update-server

Download and update [meghanada-server] jar. and restart server process.
Download and update [meghanada-server] jar. and restart the server process.

### meghanada-server-start

Start [meghanada-server][] process and connect to server.
Start [meghanada-server][] process and connect to the server.

`meghanada-mode` call this function by default. when open java file and set `meghanada-mode`.

Expand Down Expand Up @@ -192,7 +208,7 @@ Compile project (full build and reindex).

### meghanada-switch-testcase (C-M-,)

Switch testcase or source.
Switch test case or source.

### meghanada-exec-main

Expand All @@ -208,11 +224,11 @@ Find usage (method call, field access, class).

### meghanada-search-everywhere

It does a full text search based search (class, method, symbol (field)).
It does a full-text search based search (class, method, symbol (field)).

### meghanada-search-everywhere-ex

It does a full text search expert-mode (Enter a query for Lucene).
It does a full-text search expert-mode (Enter a query for Lucene).

Here is a list of fields that can be used in the search.

Expand All @@ -221,9 +237,9 @@ Here is a list of fields that can be used in the search.
* method
* symbol
* usage
* dc (method's or field's declaringClass)
* dc (method's or field's declaring class)

ex. Seach class name contains `Search` .
ex. Seach class name contains `Search`.

```
class:*Search*
Expand All @@ -242,19 +258,19 @@ Show type hierarchies and implements interfaces.

### meghanada-run-junit-class (C-c C-c C-t)

Run Junit test class.
Run JUnit test class.

### meghanada-run-junit-test-case (C-c C-c t)

Run Junit testcase (select from imenu).
Run JUnit test case (select from imenu).

### meghanada-debug-junit-class (C-c C-c C-t)

Debug Junit test class.
Debug JUnit test class.

### meghanada-debug-junit-test-case (C-c C-c t)

Debug Junit testcase (select from imenu).
Debug JUnit test case (select from imenu).

### meghanada-run-task (C-c C-v t)

Expand All @@ -276,15 +292,15 @@ Format buffer code. The default formatter is `google-java-format`

`meghanada-mode` uses `google-java-format` by default for formatter.

It also supports eclipse formatter.
If you want to customize the formatter, you uses the exported eclipse format settings.
It also supports Eclipse formatter.
If you want to customize the formatter, you use the exported eclipse format settings.
To import the settings, change the name of the exported file to `meghanadaFormatter.xml` and put it in the `project root` or `subproject root`.

## Debug

`meghanada-mode` has no debugger yet. However, external debugger is supported.
`meghanada-mode` has no debugger yet. However, the external debugger is supported.

if you want to debug your code, execute `meghanada-debug-xxxx` function and then use [realgud][] etc.
if you want to debug your code, execute `meghanada-debug-xxxx` function and then use [realgud][], etc.

```
# in Emacs now:
Expand All @@ -304,7 +320,7 @@ if you want to debug your code, execute `meghanada-debug-xxxx` function and then

## Troubleshooting

See `*meghanada-server-log*` buffer. or `/tmp/meghanada_server.log`.
See `*meghanada-server-log*` buffer. or `(temporary-file-directory)meghanada_server_(user-uid).log`, e.g. `/tmp/meghanada_server_1000.log`.

Please press `C-g` when emacs seems to hang.

Expand Down Expand Up @@ -409,6 +425,6 @@ GPL v3, See [LICENSE](LICENSE) file.
[Gradle]: https://gradle.org
[company-mode]: http://company-mode.github.io/
[flycheck]: http://flycheck.org
[Junit]: http://www.junit.org/
[JUnit]: http://www.junit.org/
[yasnippet]: http://joaotavora.github.io/yasnippet/
[realgud]: https://github.com/realgud/realgud
8 changes: 8 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# Version 1.0.14 (2019-04-26)

* works without the project tool (mvn, gradle, etc).
* support java 12 (experimental).
* add jvm option setting (meghanada-jvm-option).
* support company-box.
* fix some bugs and improve stability.

# Version 1.0.13 (2019-02-25)

* support build.gradle.kts.
Expand Down
32 changes: 18 additions & 14 deletions company-meghanada.el
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
;;; Code:

(eval-when-compile
(require 'cl-lib))
(require 'cl-lib)
(require 'pcase))

(require 'company)
(require 'company-template)
Expand Down Expand Up @@ -61,8 +62,6 @@
(defun meghanada-company-enable ()
"Enable auto completion with company."
(company-mode t)
(set (make-local-variable 'company-backends) nil)
(set (make-local-variable 'company-transformers) nil)
(if company-meghanada-prefix-length
(set (make-local-variable 'company-minimum-prefix-length) company-meghanada-prefix-length)
(set (make-local-variable 'company-meghanada-prefix-length) company-minimum-prefix-length))
Expand All @@ -75,6 +74,17 @@
(yas-minor-mode t)
(make-local-variable 'yas-minor-mode-map))

(defun make-icon-hash (type)
(let ((kind-val (pcase type
("VARIABLE" 6)
("METHOD" 2)
("CONSTRUCTOR" 2)
("FIELD" 5)
("CLASS" 22)))
(ht (make-hash-table :test 'equal)))
(puthash "kind" kind-val ht)
ht))

(defun company-meghanada--to-candidate (result)
(mapcar (lambda (candidate)
(propertize (nth 1 candidate)
Expand All @@ -87,7 +97,9 @@
'return-type
(nth 4 candidate)
'extra
(nth 5 candidate))) result))
(nth 5 candidate)
'lsp-completion-item
(make-icon-hash (nth 0 candidate)))) result))

(defun company-meghanada--to-candidates (output)
(when (> (length output) 0)
Expand Down Expand Up @@ -213,7 +225,6 @@
(concat "*" var "#" prefix)))
(t match))))

;; (message (format "match:%s send-keyword:%s" match keyword))
(setq meghanada--sp-prefix keyword)
(cons symbol t))
symbol)))))
Expand Down Expand Up @@ -285,9 +296,7 @@
(beginning-of-thing 'symbol)
(end-of-thing 'symbol)
(list 'return-type return-t 'meta meta 'type 'method))))

(when anno
(insert anno)
(company-template-c-like-templatify anno)
(when (and
(> (length extra) 1)
Expand Down Expand Up @@ -340,7 +349,6 @@
(meta (get-text-property 0 'meta arg))
(desc (get-text-property 0 'desc arg))
(anno (company-meghanada--annotation arg)))
;;(message (format "@ arg:%s meta:%s desc:%s anno:%s" arg meta desc anno))
(meghanada-autocomplete-resolve-async
type
arg
Expand All @@ -362,8 +370,7 @@
(backward-word)
(insert meta)
(insert ";")
(delete-region (point) (+ (point) (length arg)))
)))))
(delete-region (point) (+ (point) (length arg))))))))

(defun company-meghanada (command &optional arg &rest ignored)
(cl-case command
Expand All @@ -378,10 +385,7 @@
(ignore-case t)
(sorted t)
(no-cache
(unless
(and
(string= "prefix" meghanada-completion-matcher)
(string= "prefix" meghanada-class-completion-matcher))
(unless (and (string= "prefix" meghanada-completion-matcher) (string= "prefix" meghanada-class-completion-matcher))
t))
(require-match 'never)
(post-completion
Expand Down
Loading

0 comments on commit 8914cf1

Please sign in to comment.