Kakoune-java.kak : Java SE 14; operators, keywords, module system, throwables, and static word completion

kakoune-java.kak. If you have a Github account feel free to clone it, change what you want, and open a pull request for Kakoune.

Java SE 14; operators, keywords, module system, throwables, and static word completion

References:
Oracle 2020, The Java Language Specification, Java SE 14 Edition, viewed 31 August 2020, https://docs.oracle.com/javase/specs/jls/se14/html/index.html
Oracle 2020, 3.9 Keywords, Chapter 3. Lexical Structure, Java Language Specification, Java SE 14, viewed 29 August 2020, https://docs.oracle.com/javase/specs/jls/se14/html/jls-3.html#jls-3.9

provide-module -override java
---------------^^^^^^^^^  

‘allow the module to replace an existing one with the same name.’
@see Module commands

For the original kakoune/rc/filetype/java.kak


Install

mv java.kak ~/.config/kak/autoload/java.kak

plug.kak

plug "KJ_Duncan/kakoune-java.kak" domain "bitbucket.org"

Kakoune General Information

Work done? Have some fun. Share any improvements, ideas or thoughts with the community on discuss.kakoune.

Kakoune is an open source modal editor. The source code lives on github mawww/kakoune.
A discussion on the repository structure of community plugins for Kakoune can be reviewed here: Standardi(s|z)ation of plugin file-structure layout #2402.
Read the Kakoune wiki for information on install options via a Plugin Manager.

Thank you to the Kakoune community 210+ contributors for a great modal editor in the terminal. I use it daily for the keyboard shortcuts.


That’s it for the readme, anything else you may need to know just pick up a book and read it Polar Bookshelf. Thanks all. Bye.

1 Like

Java SE 15 language changes; sealed, permits, and records.
JavaPolicy file syntax and static completions.

plug "KJ_Duncan/kakoune-java.kak" domain "bitbucket.org"
# or
$ mv java.kak javaPolicy.kak $XDG_CONFIG_HOME/kak/autoload/
# or
$ mv java.kak javaPolicy.kak $HOME/.config/kak/autoload/
# and your good to go.

I’m continuously updating this, if you want anything that will make your life easier just post it here or hit me with a message or email.

Lots of ways to communicate: love the internet. Bye. :wave:

Three new files provide custom completers for import statements; javaClassHierarchy.kak, javaInterfaceHierarchy.kak, javaAnnotationEnumHierarchy.kak


Usage Completers
import<space>object<tab>
import java.lang.Object;

import<space>basicfileattributeview<tab>
import java.nio.file.attribute.BasicFileAttributeView;

References

Completers

The scaffolding for custom completions @Screwtapello and community any improvements you can see are welcome (awk was necessary due to hang/parse-time).

Small additional benefit is a list of unknown/unfamiliar or what was it again? Close match imports that can be reviewed or copied onto system clipboard and pasted into the java api search field to read the documentation. https://docs.oracle.com/en/java/javase/15/docs/api/index.html

import file

hook global WinSetOption filetype=java %{
  require-module java

  declare-option -hidden completions java_annotation_enum_hierarchy_completions

  set-option window completers option=java_annotation_enum_hierarchy_completions %opt{completers}

  hook -group java-import-statements window InsertIdle .* %{
    try %{
      execute-keys -draft 2b s \A^import<space>\z<ret>

      evaluate-commands -draft %{
        execute-keys h <a-i>w <a-semicolon>

        set-option window java_annotation_enum_hierarchy_completions \
          "%val{cursor_line}.%val{cursor_column}+%val{selection_length}@%val{timestamp}"
      }

      evaluate-commands %sh{
        exec awk -f - <<'EOF'
        BEGIN {
          split("java.beans.BeanProperty java.beans.ConstructorProperties ...", annotationTypeHierarchy);
        }
        
        function print_import_statement(imports) { for (i in imports) { printf(" %s\\;||%s", imports[i], imports[i]); } }
        
        BEGIN {
          printf("set-option -add window java_annotation_enum_hierarchy_completions ");
          print_import_statement(annotationTypeHierarchy);
          printf("\n");
        }
EOF
      }
    } catch %{
      set-option window java_annotation_enum_hierarchy_completions
    }
  }
  hook -once -always window WinSetOption filetype=.* %{ remove-hooks window java-import-statements }
}

EXPLICIT LANGUAGE WARNING on Spotify:
This Is The New Sht | Marilyn Manson or youtube.

Thanks guys. Bye :wave:.

Constant field values are populated immediately and removed subsequently from namespace dependant on fully quailified imports:

import java.lang.Character;

BYTES
CURRENCY_SYMBOL
[...]

Jumping in-and-out of kak’s ‘insert’ mode twice updates any removals from "$kak_opt_static_words", you do this anyway to jump around in the kakoune editor. I’m ok with that and I welcome any improvements.

References:


On to the next job. Bye :wave:
Yo Mama | Butterfingers or youtube

Will update any/all Java 16 Language features in the coming weeks.

Meanwhile closer to home: Interfacing Kakoune with external programs

UNIX domain socket channels have been integrated into JDK 16. See JEP 380: Unix-Domain Socket Channels and Internet Protocol and UNIX Domain Sockets NIO Example in Java Platform, Standard Edition Core Libraries.

The above linked ‘Example’ mimics some of the capabilities of the socat command-line utility.

EXPLICIT LANGUAGE WARNING:
L7 Bricks are Heavy | spotify or youtube.

Yes, I have been up all night coding and now I have to give the computer back. Bye :wave:


Java SE 16 done. Also reworked the kak’s %sh{} block for the completers.

Let me know what I missed or any troubles you are having. Bye :wave:

2 Likes