Skip to content

Neo emacs is a configuration framework for GNU Emacs which is based on doom emacs and focuses on the java web application coding environment.

License

Notifications You must be signed in to change notification settings

sincebyte/neo-emacs

Repository files navigation

Table of Contents

  1. About
  2. How to install
    1. Install emacs
    2. Clone project
    3. Doom Install
  3. How to update
    1. For brew
    2. For doom project
  4. Patches
    1. transparent patch
    2. cursor animation
    3. how to
  5. Private setting
    1. Font setting
    2. Basic setting
  6. Neoemacs modules
    1. Lsp Java
    2. Vterm Shell
    3. Ejc Sql
    4. Emacs Rime
    5. Org mode
    6. Restclient
    7. Verb
    8. iredis
    9. Bookmark
    10. Elpa Offline
    11. Vue
    12. startup workspace
  7. About the Release
  8. Customize Farther

img img img img
img img

img

About

Neo emacs is a configuration framework for GNU Emacs which is based on doom emacs and focuses on the java web application coding environment. Neo emacs has the following features:

  • Code completion: Lsp-java supports maven and gradle project.
  • Program debugging: Dap-java supports program debugging.
  • Http client: Rest-client is a tool to manually explore and test HTTP REST webservices just like Postman.
  • Http client*: verb a package for Emacs which allows you to organize and send HTTP requests.
  • SQL client: Ejc-sql turns Emacs into a simple SQL client which supports various databases.
  • Redis client: IRedis is a terminal client for redis with auto-completion and syntax highlighting.
  • Terminal emulator: Emacs-libvterm (vterm) is fully-fledged terminal emulator inside GNU Emacs based on libvterm.
  • Knowledge management system: Org-roam borrows principles from the Zettelkasten method, providing a solution for non-hierarchical note-taking.

How to install

Install emacs

Most of the time, for safety you should install emacs by brew or complie it from source ,that will give you a better compatibility.
In other words, try not to install emacs throuht Free installation package like Gnu Emacs below.

There have many emacs distribution,just choose one and install it.

  • EmacsPorts is the best choice to run NeoEmcas on macos now.

    brew tap railwaycat/emacsmacport
    brew install emacs-mac --with-natural-title-bar --with-mac-metal \
    --with-librsvg --with-starter --with-emacs-big-sur-icon --with-native-comp \
    defaults write org.gnu.Emacs TransparentTitleBar DARK \
    defaults write org.gnu.Emacs HideDocumentIcon kES
    
  • Emacs-plus which I used for a long time once.

    brew tap d12frosted/emacs-plus
    brew install emacs-mac --with-natural-title-bar \
    --with-mac-metal --with-librsvg --with-starter \
    --with-emacs-big-sur-icon --
    
  • Gnu-Emacs is the official emacs client which I used for windows platform.

  • Source Code Building form source which I use rarely.
    building emacs with with source code

    1    git clone git://git.savannah.gnu.org/emacs.git
    2    cd emacs
    3    git checkout emacs-28
    4    brew install libxml2
    5    make configure
    6    ./configure --with-native-compilation --with-modern-papirus-icon --with-no-titlebar
    7    make -j4
    8    make install
    9    open nextstep/Emacs.app
    

After emacs installation, set environment variables which names EMACS ,this depends on your emacs exec path.

export EMACS=/Applications/Emacs.app/Contents/MacOS/Emacs

Clone project

clone doom-emacs and neo-emacs from github.

git clone --depth 1 https://github.com/doomemacs/doomemacs ~/.emacs.d
git clone --depth 1 https://github.com/vanniuner/neo-emacs.git ~/.doom.d/

Doom Install

Set up a vpn if you need it.

export http_proxy="ip:port"
export https_proxy="ip:port"

Set your emacs cmd for doom install.

export EMACS= $YOUR EMACS CMD PATH$

Make sure there have Cmake lib or install it.

  • Ubuntu

    sudo apt install cmake
    sudo apt install libtool-bin
    
  • MacOs

    brew install cmake libtool gnuplot d2 ripgrep fzf terrastruct/tap/tala graphviz
    

At last run below, this will take few minutes. And it depends on the quality of your network.

~/.emacs.doom/bin/doom install
~/.emacs.doom/bin/doom.cmd install

How to update

For brew

brew upgrade
brew update && brew upgrade emacs-mac && brew cleanup emacs-mac

For doom project

export EMACS=/Applications/Emacs.app/Contents/MacOS/EMACS
sh ~/.emacs.d/bin/doom upgrade
sh ~/.emacs.d/bin/doom install
sh ~/.emacs.d/bin/doom sync

Patches

transparent patch

It offer a window transparent solution which could transparent background but the font not.Note after install the patch, here have a alternative package to control the transparent value.

(use-package transwin
  :config
  (setq transwin-delta-alpha 5)
  (setq transwin-parameter-alpha 'alpha-background)
  :bind
  ("C-M-=" . transwin-inc)
  ("C-M--" . transwin-dec)
  ("C-M-0" . transwin-toggle))

cursor animation

The awesome patch could make cursor more funny.But there have a bug,If you shift to full screen from a window state , there will remain a shadow of the current cursor which will stay here forever.I will make cursor in replace mode before shifting to full screen.This might makes it effect less more.

how to

Here have a tutorial to apply patch if you are using emacs plus.

  1. Put the patches file under to `/opt/homebrew/Library/Taps/d12frosted/homebrew-emacs-plus/patches/emacs-30`

  2. Modify `/opt/homebrew/Library/Taps/d12frosted/homebrew-emacs-plus/Formula/[email protected]`, around local_patch.
    There only have two terms to be filled in, one is patch name which referenced to the pathches directory, another is the pathchs `sha256` value.

    #
    # Patches
    #
    opoo "The option --with-no-frame-refocus is not required anymore in emacs-plus@30." if build.with? "no-frame-refocus"
    local_patch "fix-window-role", sha: "1f8423ea7e6e66c9ac6dd8e37b119972daa1264de00172a24a79a710efcb8130"
    local_patch "system-appearance", sha: "9eb3ce80640025bff96ebaeb5893430116368d6349f4eb0cb4ef8b3d58477db6"
    local_patch "poll", sha: "31b76d6a2830fa3b6d453e3bbf5ec7259b5babf1d977b2bf88a6624fa78cb3e6" if build.with? "poll"
    local_patch "round-undecorated-frame", sha: "7451f80f559840e54e6a052e55d1100778abc55f98f1d0c038a24e25773f2874"
    local_patch "cursor-animation", sha: "812a934bd45dd4ee3311c1bc6681605364193bbd14ec05b9b847f9488bf989e2"
    local_patch "ns-alpha-background", sha: "6c174aff2602b64255ce8952f91302ede51e213be090f1b39e06913bbe0b086b"
    
  3. Just install emacs plus, you could use `brew reinstall`

Private setting

Customize your private setting config in the config.el ; use setq

Font setting

Before start up,install fonts in the <./neoemacs/font> directory firstly.
Cause different platform have different font name,after font installed there need a adjustment based on the fact.

  1. setting on macos

    (setq doom-font (font-spec :family "victor Mono" :size 19 ))
    (defun init-cjk-fonts()
      (dolist (charset '(kana han cjk-misc bopomofo))
        (set-fontset-font (frame-parameter nil 'font)
          charset (font-spec :family "HYXinRenWenSongW" :size 20))))
    (add-hook 'doom-init-ui-hook 'init-cjk-fonts)
    
  2. setting on windows

    (setq doom-font (font-spec :family "victor Mono Medium" :size 24))
    (defun init-cjk-fonts()
      (dolist (charset '(kana han cjk-misc bopomofo))
        (set-fontset-font (frame-parameter nil 'font)
          charset (font-spec :family "汉仪新人文宋W" :size 26))))
    (add-hook 'doom-init-ui-hook 'init-cjk-fonts)
    
  3. install all-the-icons

    For the icons font, we need do below

    • M-x install-package all-the-icons
    • M-x all-the-icons-install-fonts
    • M-x nerd-icons-install-fonts

Basic setting

Table 1: neo-emacs basic setting
variable default value config location description
emacs-module-root /opt/homebrew/opt/emacs-plus@28/include config.el emcas module root
display-line-numbers-type nil config.el show line number
org-directory ~/org/ config.el org root path
rg-exec-path system path - -
fd-exec-path system path - -
dot-exec-path /opt/homebrew/bin/dot modules/neo-emacs/org/config.el dot exec path
pdflatex-exec-path /Library/TeX/texbin/pdflatex modules/neo-emacs/org/config.el pdflatex exec path
org-roam-directory ~/org/org-roam modules/neo-emacs/org/config.el org roam root path
lsp-java-jdt-download-url http://1.117.167.195/download modules/neo-emacs/java/config.el jdt-server URL
lsp-java-java-path   modules/neo-emacs/java/config.el java11 exec path
lsp-maven-path ~/.m2/settings.xml modules/neo-emacs/java/config.el maven setting path
rime-user-data-dir ~/Library/Rime/ modules/neo-emacs/rime/config.el rime config input
rime-librime-root ~/.doom.d/myconfig/rime-macos/dist modules/neo-emacs/rime/config.el emacs-rime/blob/master/

recentfile save default dir: ~/.emacs.d/.local/cache/recentf

Neoemacs modules

Lsp Java

futher more java readme
Neo-Emacs will automatically download the jdtls from `lsp-java-jdt-download-url`, and now it’s located at jdt-language-server-1.22.0.After that you could use all the features powered by eclipse.

  • Generate eclipse files
    Execute mvn command for generate eclipse .project & .classpath files on your project root path.

    mvn eclipse:clean eclipse:eclipse
    
  • Support projectlombok plugin
    There have a default lombok.jar in doom-user-dir/neoemacs which you could replace by yourself.

    (setq  lombok-jar-path (expand-file-name (concat doom-user-dir "neoemacs/lombok.jar")
    
  • Shotcuts/Key binding

    Table 2: java mode key binding
    KEY FUNCTION DESCRIPTION
    SPC c i find-implementations find where sub class definition
    SPC c I lsp-java-open-super-implementation find where sub class definition
    SPC t e lsp-treemacs-java-deps-list find projects referenced libs
    SPC c f formart buffer/region goto type definition
    SPC c a lsp-execute-code-action code action
    SPC c d lsp-jump-definition jump to where symbol definition
    SPC c D lsp-jump-reference jump to where symbol referenced
    SPC c o lsp-java-organize-imports import require package
    SPC t s lsp-workspace-restart restart lsp server
  • How to upgrade jdtls

    1. Customization your own eclipse jdtls project version by replace it’s binary pacage.
    2. Download the lastest jdt-language-server from https://download.eclipse.org/jdtls/milestones.
    3. Replace file to ~/.emacs.d/.local/etc/lsp/eclipse.jdt.ls.

Vterm Shell

You’d better install vterm in a terminal environment case there might have error incompatible architecture.

Vterm is not available on windows.
Thus windows user have to use eshell as a downgrade plan.

  1. Install vterm

    You’d better install vterm in a terminal environment case there might have error incompatible architecture.
    If vterm complie failed in emacs, we could complie it manually.

    cd .emacs.d/.local/straight/build/vterm/
    mkdir -p build
    # install cmake and libtool-bin
    brew install cmake libtool
    mkdir -p build
    cd build
    cmake ..
    make
    
  2. Fish shell optimize

    If you are using fish shell ,fortunately there have some optimize config prepared for you.

    • feature:
      • use fish shell on emacs vterm.

      • use command `ff` %anyfile% on vterm will open %anyfile% in a new emacs buffer.It’s very useful.

        if [ "$INSIDE_EMACS" = 'vterm' ]
            function clear
                vterm_printf "51;Evterm-clear-scrollback";
                tput clear;
            end
        end
        function vterm_cmd --description 'Run an Emacs command among the ones been defined in vterm-eval-cmds.'
            set -l vterm_elisp ()
            for arg in $argv
                set -a vterm_elisp (printf '"%s" ' (string replace -a -r '([\\\\"])' '\\\\\\\\$1' $arg))
            end
            vterm_printf '51;E'(string join '' $vterm_elisp)
        end
        function ff
            set -q argv[1]; or set argv[1] "."
            vterm_cmd find-file (realpath "$argv")
        end
        
    • http proxy

    In fact there have two different config ,first one for vterm and another for emacs inner plugins.
    In vterm the http proxy be effected by `~/.config/fish/config.fish`,you could config it like this.

    set -x http_proxy       http://vpn.local.com:10887
    set -x https_proxy      http://vpn.local.com:10887
    set -x no_proxy         ".aliyun.com,192.168.0.0/16,137.239.155.184"
    

    When you are using emacs lisp program such as restclient, you could config proxy like this.
    The difference is wildcard

    (defun convert-to-regex (str)
      (let* ((joined (replace-regexp-in-string "," "\\\\|" str))
             (wrapped (concat "^\\(" joined "\\)")))
        wrapped))
    (setq url-proxy-services `(("http" ."vpn.local.com:10887")
                               ("https" ."vpn.local.com:10887")
                               ("no_proxy" . ,(convert-to-regex ".*aliyun.com,192.168.0.0/16,137.239.155.184"))))
    
  3. Usage

    • Being with eshell
      Eshell have a most wanted feature was quickrun-eshell which have a fast reload function after shell is runinng,you just use C-c C-c to stop it and use r to return you shell script file.It’s pretty convenient.

    • Key Binding

      KEY FUNCTION DESCRIPTION
      SPC v v projectile-run-vterm open vterm window base on the project root path
      SPC v p vterm-send-start enable vterm screen roll
      SPC v s vterm-send-stop disable vterm screen roll

Ejc Sql

  • The privacy configuration
    In here you could save any connections in your setting config.
    But where should the setting located especially for our Emacs config project with a public github repository? There have a privacy path which is excluded in the public repository named user-private-dir, You could config your connection’s account/password here for safely.
    There default load a db-work module which having your privacy config .

    (add-to-list 'load-path user-private-dir )
    (use-package! db-work                    )
    
  • Config your particular db connection

    (use-package ejc-sql
    :commands ejc-sql-mode ejc-connect
    :config
    (setq clomacs-httpd-default-port 18090)
    (ejc-create-connection "connection-name"
            :classpath      "~/.m2/repository/mysql/mysql-connector-java/8.0.17/
                mysql-connector-java-8.0.17.jar"
            :connection-uri "jdbc:mysql://localhost/user?useSSL=false&user=root&password=pwd"
            :separator      "</?\.*>" )
    )
    (provide 'db-work)
    
  • Write Sql file
    Before try to use ejc sql, firstly create a sql file which named with a suffix .sql, cause emacs will turn on the sql minor mode so that ejc-sql could works well. And then use SPC e c to connect a particular database which you have configurated. Emacs will popup a minibuffer listing candidates which show you the connection-name.
    Secondarily, write your testing sql content which surrounded by a tag, cause we have configurated :separator by a syntax meaning tag in order to execute a single sql rather than to choose it.For sure you could make any comment with the tag’s schema.
    Further more, you could use delimiter sign for batch execution. the delimiter could customization by any character.
    Finnaly, use C-c C-c to execute it. It’s just execute the content which surrounded by a tag in your cusor.

    1     <SELECT name='select all org'>
    2     SELECT * FROM TABLE_ORG
    3     </SELECT>
    4  
    5     <SELECT>
    6     delimiter ;
    7     COMMENT ON COLUMN TABLE_ORG.PROJECT_CODE IS '项目编码';
    8     COMMENT ON COLUMN TABLE_ORG.PERIOD IS '期间';
    9     </SELECT>
    
  • key binding

    KEY FUNCTION description
    SPC e c ejc-connection choose connection with ivy
    C-c C-c ejc-execute execute the sql

Emacs Rime

Emacs Rime which makes to embedding an input method be possible whthin the emacs.Emacs could benefit form the flexible configuration of rime.
On macos it’s required to install Squirrel which is one of rime’s distribution. Squirrel is installed in your os system as a input method.
Note that the configuration of rime located at home/Library/Rime/. We want to sharing this configuration between Eamcs rime and os rime.
So there have a variable which named rime-user-data-dir , And another important variable is rime-librime-root which configed the librime location.

variable required
rime-user-data-dir true
rime-librime-root true

futher more rime readme

Org mode

futher more org readme

  1. Install Dependency

    There have some third party lib we need prepare.

    1. d2 diagram

      d2 installation

      alias ds2 "/opt/homebrew/bin//d2 --sketch --animate-interval=1400 -l elk -c --pad 0"
      alias d2 "/opt/homebrew/bin//d2 --pad 0 --layout tala "
      
  2. Image to base64

    No need to sent images files of the source.
    The embedded base64 image make to distribute your html documentation more easily.

  3. Optimize Line Number

    Just hidden the colon after line number character.
    Modify `~/.emacs.d/.local/straight/repos/org/lisp/ox-html.el`.

    1  (let* ((code-lines (split-string code "\n"))
    2     (code-length (length code-lines))
    3     (num-fmt
    4  	(and num-start
    5  	     (format "%%%ds "
    6  	     (format "%(add-hook 'code-review-mode-hook
    7          (lambda ()
    8            ;; include *Code-Review* buffer into current workspace
    9            (persp-add-buffer (current-buffer))))%%ds: "
    
  4. Image Directory

    Cause org mode html export program need a image directory locate at org root directory.
    Highly recommended:
    Use ln making an mirror of the directory.
    Make the image directory as your screenshot file’s saving location.

    ln -s ~/org/org-roam/image any_where/image
    

Restclient

Restclient provide a test suite for HTTP REST in Emacs.The official repository here restclient.el.
Yea, a pretty old old project.Fortunately doom emacs have integrated it.We just need open it with (rest +jq).
+jq makes restclient have the ability to parse a particular response which Content-Type equalable application/json.
The amazing feature is restclient support set variables or make a part of response being a variables which one could as a request part for another HTTP REST.

Here we take the value from results as a variables which named count.

GET https://www.zhihu.com/api/v3/oauth/sms/supported_countries
-> jq-set-var :count .count

Only jq-set-var could works when the content-type equal to application/json MIME type

Fortunately we have solution for other mime type, it’s restclient-set-var, you could use elisp to parse the response;

GET https://www.baidu.com/sugrec
-> run-hook (restclient-set-var ":queryid" (cdr (assq 'queryid (json-read))))
Content-Type: application/x-www-form-urlencoded; charset=utf-8

About the variables infomation in current buffer, we could use C-c Tab to show them.

Verb

Verb is a new package for http client,becase the restclient is out of date and the author no longger maintain it on github.Fortunately there have a alternative one named verb which is more powerful and customizable. Verb support url template which makes you change different environment more conveniently.Also verb supports variables and picture query and upload.In org mode start verb just use `C-c C-r` as a previous command,example `C-c C-r C-f` will execute http request with your config,So verb is really fancy right?

iredis

  1. install

    brew install iredis
    
  2. config

    Here have a template of iredis’ configuration.The essential point is alias_dsn

    1  [alias_dsn]
    2  example_dsn1 = redis://[[username]:[password]]@localhost:6379/0
    3  example_dsn2 = rediss://[[username]:[password]]@localhost:6379/0
    4  example_dsn3 = unix://[[username]:[password]]@/path/to/socket.sock?db=0
    
  3. usage

    Use command to connect redis database.The most convenient thing is you could index your content as iredis have integrated with jq command.

    iredis -d wvp-test
    10.100.10.70:6379[7]> get VMP_MEDIA_SERVER:000000:zlm_fragment | jq .
    

Bookmark

  • set a particular location for bookmark

    (setq bookmark-default-file "~/org/org-roam/command/doom/config/bookmark")
    
  • key binding

    key binding
    Spc-Ent select a bookmark
    Spc b m set a bookmark
    Spc b M delete a bookmark

Elpa Offline

rsync -avz rsync://mirrors.tuna.tsinghua.edu.cn/elpa ~/soft/emacs-elpa

(setq configuration-layer--elpa-archives
      '(("melpa-cn" . "/soft/emacs-elpa/melpa/")
        ("org-cn"   . "/soft/emacs-elpa/org/")
        ("gnu-cn"   . "/soft/emacs-elpa/gnu/")
        ("marmalade-cn"   . "/soft/emacs-elpa//marmalade/")))

Vue

as a full stack developer u need vue support, so here it comes.

npm install vls -g

startup workspace

You could customization startup inital workspace and their buffer.No need to open it every time.

(setq +workspaces-main " SSH")
(defun open-my-workspaces ()
  (interactive)
  (+workspace/new " IDE")
  (find-file "yourexpect.java")
  (+workspace/new " GPT")
  (gptel "wangshenzhi/llama3-8b-chinese-chat-ollama-q8")
  (switch-to-buffer "wangshenzhi/llama3-8b-chinese-chat-ollama-q8")
  (+workspace/new " SQL")
  (find-file "yourexpect.sql")
  (+workspace/new " HTTP")
  (find-file "yourexpect.http")
  (+workspace/new "󱗃 ORG")
  (find-file "yourexpect.org"))
(add-hook 'window-setup-hook #'open-my-workspaces)

About the Release

This step can help you compile neo emacs faster,It only takes 3 minutes to install using the release package on my Mac laptop. Otherwise it would take me 15 minutes. The release installation package is a better choice for users with unstable networks and those who need to frequently reinstall neoemacs.
Release package contains the git repository of related dependencies.The compiled directory files are removed and the .git directory is retained,So that you can perform subsequent upgrades.
I will update the Release package once a month, And test them in advance and revise them for compatibility with upstream projects.

Customize Farther

For customize farther, there have some documentation you need read.
https://github.com/hlissner/doom-emacs/blob/master/docs/getting_started.org
https://github.com/BurntSushi/ripgrep
https://github.com/junegunn/fzf
https://github.com/kostafey/ejc-sql
https://leiningen.org/
https://plantuml.com/
https://github.com/emacs-lsp/lsp-java
https://projectlombok.org/
https://github.com/DogLooksGood/emacs-rime
https://github.com/be5invis/Sarasa-Gothic
https://github.com/akicho8/string-inflection
https://raw.githubusercontent.com/alibaba/p3c/master/p3c-formatter/eclipse-codestyle.xml
https://www.tug.org/mactex/

About

Neo emacs is a configuration framework for GNU Emacs which is based on doom emacs and focuses on the java web application coding environment.

Resources

License

Stars

Watchers

Forks

Packages

No packages published