From b3d5cd422d758ec1d946f048b8da794965628eba Mon Sep 17 00:00:00 2001 From: Sameer Rahmani Date: Sun, 23 May 2021 16:54:27 +0100 Subject: [PATCH] Add java and yasnippet cubes --- config/fg42.user.v3.el | 6 ++- core/cubes/java.el | 67 +++++++++++++++++++++++++++ core/cubes/snippets.el | 49 ++++++++++++++++++++ core/cubes/snippets/org-mode/align | 8 ++++ core/cubes/snippets/org-mode/begin | 8 ++++ core/cubes/snippets/org-mode/block | 8 ++++ core/cubes/snippets/org-mode/equation | 8 ++++ core/cubes/snippets/org-mode/infobox | 9 ++++ core/cubes/snippets/org-mode/prod | 6 +++ core/cubes/snippets/org-mode/sum | 6 +++ 10 files changed, 173 insertions(+), 2 deletions(-) create mode 100644 core/cubes/java.el create mode 100644 core/cubes/snippets.el create mode 100644 core/cubes/snippets/org-mode/align create mode 100644 core/cubes/snippets/org-mode/begin create mode 100644 core/cubes/snippets/org-mode/block create mode 100644 core/cubes/snippets/org-mode/equation create mode 100644 core/cubes/snippets/org-mode/infobox create mode 100644 core/cubes/snippets/org-mode/prod create mode 100644 core/cubes/snippets/org-mode/sum diff --git a/config/fg42.user.v3.el b/config/fg42.user.v3.el index 2e930ad..864f1b0 100644 --- a/config/fg42.user.v3.el +++ b/config/fg42.user.v3.el @@ -34,7 +34,8 @@ (require 'cubes/project) (require 'cubes/irc) (require 'cubes/terminal) - +(require 'cubes/java) +(require 'cubes/snippets) ;; ============== MY STUFF ============================== (custom-set-faces @@ -125,7 +126,8 @@ ("irc.oftc.net" :channels ("#llvm") :nick "lxsameer"))) (fg42/vterm-cube) - +(fg42/java-cube) +(fg42/yasnippet-cube) ;; Themes should be the last cube and anything that wants to manipulate a face ;; has to use either `fg42/before-initializing-theme-hook' or ;; `fg42/after-initializing-theme-hook' hooks. diff --git a/core/cubes/java.el b/core/cubes/java.el new file mode 100644 index 0000000..ddd8af0 --- /dev/null +++ b/core/cubes/java.el @@ -0,0 +1,67 @@ +;;; JavaCubes --- The Java cubes for FG42 -*- lexical-binding: t; -*- +;; +;; Copyright (c) 2010-2021 Sameer Rahmani & Contributors +;; +;; Author: Sameer Rahmani +;; URL: https://gitlab.com/FG42/FG42 +;; Version: 3.0.0 +;; +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . +;; +;;; Commentary: +;;; Code: +(require 'fpkg) +(require 'fg42/cube) + + +(defcube fg42/gradle-cube + (:docs "cubes/fg42/java-cube.org" + :flag gradle + :flag-default t) + + (fpkg/use groovy-mode + :mode "\\.gradle\\'") + + (fpkg/use gradle-mode + :hook (java-mode-hook . gradle-mode)) + + (when-flag flycheck + (fpkg/use flycheck-gradle))) + + +(defcube fg42/java-cube + (:docs "cubes/fg42/java-cube.org" + :flag java + :flag-default t) + + (add-hook 'java-mode-hook + (lambda() + ;; To fix the indentation of function arguments + (c-set-offset 'arglist-intro '+) + (setq java-basic-offset 2) + (setq c-basic-offset 2) + (when-flag lsp-java + (setq lsp-java-server-install-dir fg42-tmp) + (lsp)))) + + (when-flag gradle + (fg42/gradle-cube)) + + (when-flag lsp + (fpkg/use lsp-java))) + + + +(provide 'cubes/java) +;;; java.el ends here diff --git a/core/cubes/snippets.el b/core/cubes/snippets.el new file mode 100644 index 0000000..2f4ffab --- /dev/null +++ b/core/cubes/snippets.el @@ -0,0 +1,49 @@ +;;; JavaCubes --- The Java cubes for FG42 -*- lexical-binding: t; -*- +;; +;; Copyright (c) 2010-2021 Sameer Rahmani & Contributors +;; +;; Author: Sameer Rahmani +;; URL: https://gitlab.com/FG42/FG42 +;; Version: 3.0.0 +;; +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . +;; +;;; Commentary: +;;; Code: +(require 'fpkg) +(require 'fg42/cube) + +(defcube fg42/yasnippet-cube + (:docs "cubes/fg42/yasnippet-cube.org" + :flag yasnippet + :flag-default t) + + (fpkg/use yasnippet-snippets) + + (fpkg/use yasnippet + :init + (let* ((snippet-home (expand-file-name "snippets" + (file-name-directory (locate-library "yasnippet-snippets")))) + (local-snippet (expand-file-name "core/cubes/snippets" fg42-home)) + (user-snippets (or (plist-get fg42/yasnippet-cube-params :snippets-dir) + ;; Just to make sure that we don't return nil. Since + ;; yas-snippet-dirs shoud not contain nil value + local-snippet))) + + (setq yas-snippet-dirs `(,user-snippets ,local-snippet ,snippet-home)) + (yas-global-mode 1)))) + + +(provide 'cubes/snippets) +;;; snippets.el ends here diff --git a/core/cubes/snippets/org-mode/align b/core/cubes/snippets/org-mode/align new file mode 100644 index 0000000..20c4416 --- /dev/null +++ b/core/cubes/snippets/org-mode/align @@ -0,0 +1,8 @@ +# -*- mode: snippet -*- +# contributor: lxsameer +# name: Latex begin block +# key: al* +# -- +\begin{align*} +$0 +\end{align*} diff --git a/core/cubes/snippets/org-mode/begin b/core/cubes/snippets/org-mode/begin new file mode 100644 index 0000000..064fc99 --- /dev/null +++ b/core/cubes/snippets/org-mode/begin @@ -0,0 +1,8 @@ +# -*- mode: snippet -*- +# contributor: lxsameer +# name: Latex begin block +# key: begin +# -- +\begin{$1} +$0 +\end{$1} \ No newline at end of file diff --git a/core/cubes/snippets/org-mode/block b/core/cubes/snippets/org-mode/block new file mode 100644 index 0000000..ae8f54e --- /dev/null +++ b/core/cubes/snippets/org-mode/block @@ -0,0 +1,8 @@ +# -*- mode: snippet -*- +# contributor: lxsameer +# name: Latex begin block +# key: block +# -- +#+BEGIN_{$1} + $0 +#+END_{$1} \ No newline at end of file diff --git a/core/cubes/snippets/org-mode/equation b/core/cubes/snippets/org-mode/equation new file mode 100644 index 0000000..b14a93e --- /dev/null +++ b/core/cubes/snippets/org-mode/equation @@ -0,0 +1,8 @@ +# -*- mode: snippet -*- +# contributor: lxsameer +# name: Latex equation* block +# key: eq* +# -- +\begin{equation*} +$0 +\end{equation*} diff --git a/core/cubes/snippets/org-mode/infobox b/core/cubes/snippets/org-mode/infobox new file mode 100644 index 0000000..6ca253c --- /dev/null +++ b/core/cubes/snippets/org-mode/infobox @@ -0,0 +1,9 @@ +# -*- mode: snippet -*- +# contributor: lxsameer +# name: Latex Definition box +# key: def +# -- +#+attr_latex: :options {Definition} +#+BEGIN_infobox +$0 +#+END_infobox \ No newline at end of file diff --git a/core/cubes/snippets/org-mode/prod b/core/cubes/snippets/org-mode/prod new file mode 100644 index 0000000..63f061b --- /dev/null +++ b/core/cubes/snippets/org-mode/prod @@ -0,0 +1,6 @@ +# -*- mode: snippet -*- +# contributor: lxsameer +# name: Latex \prod +# key: prod +# -- +\prod ^{$1} _{$2} $0 \ No newline at end of file diff --git a/core/cubes/snippets/org-mode/sum b/core/cubes/snippets/org-mode/sum new file mode 100644 index 0000000..fe64b7a --- /dev/null +++ b/core/cubes/snippets/org-mode/sum @@ -0,0 +1,6 @@ +# -*- mode: snippet -*- +# contributor: lxsameer +# name: Latex \sum +# key: sum +# -- +\sum ^{$1} _{$2} $0 \ No newline at end of file