From 13f705dc0e4115009deeca18bd1436f8445d843d Mon Sep 17 00:00:00 2001 From: Oleksii Filonenko Date: Fri, 29 Mar 2019 03:19:11 +0200 Subject: [PATCH 1/4] Add Kotlin module --- modules/lang/kotlin/autoload.el | 15 +++++++++++++++ modules/lang/kotlin/config.el | 16 ++++++++++++++++ modules/lang/kotlin/doctor.el | 4 ++++ modules/lang/kotlin/packages.el | 7 +++++++ 4 files changed, 42 insertions(+) create mode 100644 modules/lang/kotlin/autoload.el create mode 100644 modules/lang/kotlin/config.el create mode 100644 modules/lang/kotlin/doctor.el create mode 100644 modules/lang/kotlin/packages.el diff --git a/modules/lang/kotlin/autoload.el b/modules/lang/kotlin/autoload.el new file mode 100644 index 000000000..a15620fed --- /dev/null +++ b/modules/lang/kotlin/autoload.el @@ -0,0 +1,15 @@ +;;; lang/kotlin/autoload.el -*- lexical-binding: t; -*- + +;;;autoload +(defun +kotlin/locate-gradlew-file () + "Gradlew file location for this project." + (locate-dominating-file buffer-file-name "gradlew")) + +;;;###autoload +(defun +kotlin/run-gradlew (command) + "Run gradlew in this project." + (interactive "sCommand: ") + (let ((default-directory (+kotlin/locate-gradlew-file)) + (compilation-read-command nil) + (compile-command (format "sh gradlew %s" command))) + (call-interactively #'compile))) diff --git a/modules/lang/kotlin/config.el b/modules/lang/kotlin/config.el new file mode 100644 index 000000000..dc02f1035 --- /dev/null +++ b/modules/lang/kotlin/config.el @@ -0,0 +1,16 @@ +;;; lang/kotlin/config.el -*- lexical-binding: t; -*- + +(after! kotlin-mode + (set-docsets! 'kotlin-mode "Kotlin") + + (map! :map kotlin-mode-map + :localleader + :prefix ("b" . "build") + :desc "gradlew assemble" "a" (λ! (+kotlin/run-gradlew "assemble")) + :desc "gradlew build" "b" (λ! (+kotlin/run-gradlew "build")) + :desc "gradlew test" "t" (λ! (+kotlin/run-gradlew "test")))) + +(def-package! flycheck-kotlin + :when (featurep! :tools flycheck) + :after kotlin-mode + :config (add-hook 'kotlin-mode-hook #'flycheck-kotlin-setup)) diff --git a/modules/lang/kotlin/doctor.el b/modules/lang/kotlin/doctor.el new file mode 100644 index 000000000..7dd70d076 --- /dev/null +++ b/modules/lang/kotlin/doctor.el @@ -0,0 +1,4 @@ +;;; lang/kotlin/doctor.el -*- lexical-binding: t; -*- + +(unless (executable-find "ktlint") + (warn "ktlint not found. flycheck-kotlin won't work.")) diff --git a/modules/lang/kotlin/packages.el b/modules/lang/kotlin/packages.el new file mode 100644 index 000000000..f7c3361dc --- /dev/null +++ b/modules/lang/kotlin/packages.el @@ -0,0 +1,7 @@ +;; -*- no-byte-compile: t; -*- +;;; lang/kotlin/packages.el + +(package! kotlin-mode) + +(when (featurep! :tools flycheck) + (package! flycheck-kotlin)) From 1c14b0bf17df3429cba89b03ba38ea94b201fffb Mon Sep 17 00:00:00 2001 From: Oleksii Filonenko Date: Fri, 29 Mar 2019 03:27:39 +0200 Subject: [PATCH 2/4] Add lang/kotlin entry to init.example.el --- init.example.el | 1 + 1 file changed, 1 insertion(+) diff --git a/init.example.el b/init.example.el index beeddd51d..73638e4ca 100644 --- a/init.example.el +++ b/init.example.el @@ -102,6 +102,7 @@ ;;(java +meghanada) ; the poster child for carpal tunnel syndrome ;;javascript ; all(hope(abandon(ye(who(enter(here)))))) ;;julia ; a better, faster MATLAB + ;;kotlin ; a better, slicker Java(Script) ;;latex ; writing papers in Emacs has never been so fun ;;ledger ; an accounting system in Emacs ;;lua ; one-based indices? one-based indices From 0c0aff60a1fead73070797307332f0c0b5861c90 Mon Sep 17 00:00:00 2001 From: Oleksii Filonenko Date: Thu, 11 Apr 2019 10:16:10 +0300 Subject: [PATCH 3/4] [lang/kotlin] Use `warn!` macro in doctor.el --- modules/lang/kotlin/doctor.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/lang/kotlin/doctor.el b/modules/lang/kotlin/doctor.el index 7dd70d076..63eabc017 100644 --- a/modules/lang/kotlin/doctor.el +++ b/modules/lang/kotlin/doctor.el @@ -1,4 +1,4 @@ ;;; lang/kotlin/doctor.el -*- lexical-binding: t; -*- (unless (executable-find "ktlint") - (warn "ktlint not found. flycheck-kotlin won't work.")) + (warn! "ktlint not found. flycheck-kotlin won't work.")) From 76fb819dfb8d838ec7796e87b332f19b23d7c70d Mon Sep 17 00:00:00 2001 From: Oleksii Filonenko Date: Thu, 11 Apr 2019 10:16:53 +0300 Subject: [PATCH 4/4] Rename non-interactive function `+kotlin-locate-gradlew-file` --- modules/lang/kotlin/autoload.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/lang/kotlin/autoload.el b/modules/lang/kotlin/autoload.el index a15620fed..2eee6cd90 100644 --- a/modules/lang/kotlin/autoload.el +++ b/modules/lang/kotlin/autoload.el @@ -1,7 +1,7 @@ ;;; lang/kotlin/autoload.el -*- lexical-binding: t; -*- ;;;autoload -(defun +kotlin/locate-gradlew-file () +(defun +kotlin-locate-gradlew-file () "Gradlew file location for this project." (locate-dominating-file buffer-file-name "gradlew")) @@ -9,7 +9,7 @@ (defun +kotlin/run-gradlew (command) "Run gradlew in this project." (interactive "sCommand: ") - (let ((default-directory (+kotlin/locate-gradlew-file)) + (let ((default-directory (+kotlin-locate-gradlew-file)) (compilation-read-command nil) (compile-command (format "sh gradlew %s" command))) (call-interactively #'compile)))