Add java and yasnippet cubes

This commit is contained in:
Sameer Rahmani 2021-05-23 16:54:27 +01:00
parent 9fd18ecf9c
commit b3d5cd422d
10 changed files with 173 additions and 2 deletions

View File

@ -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.

67
core/cubes/java.el Normal file
View File

@ -0,0 +1,67 @@
;;; JavaCubes --- The Java cubes for FG42 -*- lexical-binding: t; -*-
;;
;; Copyright (c) 2010-2021 Sameer Rahmani & Contributors
;;
;; Author: Sameer Rahmani <lxsameer@gnu.org>
;; 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 <http://www.gnu.org/licenses/>.
;;
;;; 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

49
core/cubes/snippets.el Normal file
View File

@ -0,0 +1,49 @@
;;; JavaCubes --- The Java cubes for FG42 -*- lexical-binding: t; -*-
;;
;; Copyright (c) 2010-2021 Sameer Rahmani & Contributors
;;
;; Author: Sameer Rahmani <lxsameer@gnu.org>
;; 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 <http://www.gnu.org/licenses/>.
;;
;;; 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

View File

@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# contributor: lxsameer <lxsameer@gnu.org>
# name: Latex begin block
# key: al*
# --
\begin{align*}
$0
\end{align*}

View File

@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# contributor: lxsameer <lxsameer@gnu.org>
# name: Latex begin block
# key: begin
# --
\begin{$1}
$0
\end{$1}

View File

@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# contributor: lxsameer <lxsameer@gnu.org>
# name: Latex begin block
# key: block
# --
#+BEGIN_{$1}
$0
#+END_{$1}

View File

@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# contributor: lxsameer <lxsameer@gnu.org>
# name: Latex equation* block
# key: eq*
# --
\begin{equation*}
$0
\end{equation*}

View File

@ -0,0 +1,9 @@
# -*- mode: snippet -*-
# contributor: lxsameer <lxsameer@gnu.org>
# name: Latex Definition box
# key: def
# --
#+attr_latex: :options {Definition}
#+BEGIN_infobox
$0
#+END_infobox

View File

@ -0,0 +1,6 @@
# -*- mode: snippet -*-
# contributor: lxsameer <lxsameer@gnu.org>
# name: Latex \prod
# key: prod
# --
\prod ^{$1} _{$2} $0

View File

@ -0,0 +1,6 @@
# -*- mode: snippet -*-
# contributor: lxsameer <lxsameer@gnu.org>
# name: Latex \sum
# key: sum
# --
\sum ^{$1} _{$2} $0