• This repository has been archived on 08/May/2022
  • Stars
    star
    206
  • Rank 190,504 (Top 4 %)
  • Language
    Emacs Lisp
  • Created over 4 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Nox is a lightweight, high-performance LSP client for Emacs

NOTE

Thanks to all users who support Nox, I have develop new LSP client lsp-bridge -- the fastest LSP client for Emacs.

The issue and PR of current project will no longer reply, thank you! ;)

Nox

Nox is a LSP client for Emacs, code fork from eglot.

The project has three goals:

  1. Function: only provide core functions, include code completion, jump definition, code references and rename
  2. Design: Keep UX simple and clean, does not interfere user
  3. Performance: cutting useless functions, optimizing code efficiency, ensure coding fluency

Why named Nox?

The Nox are considered to be a member of the Alliance of Four Great Races", along with the Alterans, Asgard, and Furlings.

My favorite a word from Nox:

Maybe one day you will learn, that your way is not the only way -- Anteaus

Install dependences

Nox depend on company-mode and posframe

Install Nox

  1. Clone this repository and put nox.el in your load-path

  2. Add below configure in your ~/.emacs

(require 'nox)

(dolist (hook (list
               'js-mode-hook
               'rust-mode-hook
               'python-mode-hook
               'ruby-mode-hook
               'java-mode-hook
               'sh-mode-hook
               'php-mode-hook
               'c-mode-common-hook
               'c-mode-hook
               'csharp-mode-hook
               'c++-mode-hook
               'haskell-mode-hook
               ))
  (add-hook hook '(lambda () (nox-ensure))))
  1. Open file, that's all.

Note: suggestion upgrade emacs to 27.x or 28.x, JSON parser much faster, and Nox completion will much smooth.

Connecting to a server

M-x nox can guess and work out-of-the-box with these servers:

I'll add to this list as I test more servers. In the meantime you can customize nox-server-programs:

(add-to-list 'nox-server-programs '(foo-mode . ("foo-language-server" "--args")))

Let me know how well it works and we can add it to the list.

To skip the guess and always be prompted use C-u M-x nox.

Connecting via TCP

The examples above use a "pipe" to talk to the server, which works fine on Linux and OSX but in some cases may not work on Windows.

To circumvent this limitation, or if the server doesn't like pipes, you can use C-u M-x nox and give it server:port pattern to connect to a previously started TCP server serving LSP information.

If you don't want to start it manually every time, you can configure Nox to start it and immediately connect to it. Ruby's solargraph server already works this way out-of-the-box.

For another example, suppose you also wanted start Python's pyls this way:

(add-to-list 'nox-server-programs
             `(python-mode . ("pyls" "-v" "--tcp" "--host"
                              "localhost" "--port" :autoport)))

You can see that the element associated with python-mode is now a more complicated invocation of the pyls program, which requests that it be started as a server. Notice the :autoport symbol in there: it is replaced dynamically by a local port believed to be vacant, so that the ensuing TCP connection finds a listening server.

Per-project server configuration

Most servers can guess good defaults and will operate nicely out-of-the-box, but some need to be configured specially via LSP interfaces. Additionally, in some situations, you may also want a particular server to operate differently across different projects.

Per-project settings are realized with Emacs's directory variables and the Elisp variable nox-workspace-configuration. To make a particular Python project always enable Pyls's snippet support, put a file named .dir-locals.el in the project's root:

((python-mode
  . ((nox-workspace-configuration
      . ((:pyls . (:plugins (:jedi_completion (:include_params t)))))))))

This tells Emacs that any python-mode buffers in that directory should have a particular buffer-local value of nox-workspace-configuration. That variable's value should be association list of parameter sections which are presumably understood by the server. In this example, we associate section pyls with the parameters object (:plugins (:jedi_completion (:include_params t))).

Now, supposing that you also had some Go code in the very same project, you can configure the Gopls server in the same file. Adding a section for go-mode, the file's contents become:

((python-mode
  . ((nox-workspace-configuration
      . ((:pyls . (:plugins (:jedi_completion (:include_params t))))))))
 (go-mode
  . ((nox-workspace-configuration
      . ((:gopls . (:usePlaceholders t)))))))

If you can't afford an actual .dir-locals.el file, or if managing these files becomes cumbersome, the Emacs manual teaches you programmatic ways to leverage per-directory local variables.

Handling quirky servers

Some servers need even more special hand-holding to operate correctly. If your server has some quirk or non-conformity, it's possible to extend Nox via Elisp to adapt to it. Here's an example on how to get cquery working:

(add-to-list 'nox-server-programs '((c++ mode c-mode) . (nox-cquery "cquery")))

(defclass nox-cquery (nox-lsp-server) ()
  :documentation "A custom class for cquery's C/C++ langserver.")

(cl-defmethod nox-initialization-options ((server nox-cquery))
  "Passes through required cquery initialization options"
  (let* ((root (car (project-roots (nox--project server))))
         (cache (expand-file-name ".cquery_cached_index/" root)))
    (list :cacheDirectory (file-name-as-directory cache)
          :progressReportFrequencyMs -1)))

See nox.el's section on Java's JDT server for an even more sophisticated example.

Reporting bugs

Having trouble connecting to a server? Expected to have a certain capability supported by it (e.g. completion) but nothing happens? Or do you get spurious and annoying errors in an otherwise smooth operation? We may have help, so open a new issue and try to be as precise and objective about the problem as you can:

  1. Try to replicate the problem with as clean an Emacs run as possible. This means an empty .emacs init file or close to it (just loading nox.el, company.el and yasnippet.el for example, and you don't even need use-package.el to do that).

  2. Include the log of LSP events and the stderr output of the server (if any). You can find the former with M-x nox-events-buffer and the latter with M-x nox-stderr-buffer. You run these commands in the buffer where you enabled Nox, but if you didn't manage to enable Nox at all (because of some bootstrapping problem), you can still find these buffers in your buffer list: they're named like *NOX <project>/<major-mode> events* and *NOX <project>/<major-mode> stderr*.

  3. If Emacs errored (you saw -- and possibly heard -- an error message), make sure you repeat the process using M-x toggle-debug-on-error so you get a backtrace of the error that you should also attach to the bug report.

Some more notes: it's understandable that you report it to Nox first, because that's the user-facing side of the LSP experience in Emacs, but the outcome may well be that you will have to report the problem to the server's developers, as is often the case. But the problem can very well be on Nox's side, of course, and in that case we want to fix it! Also bear in mind that Nox's developers have limited resources and no way to test all the possible server combinations, so you'll have to do most of the testing.

Commands and keybindings

Here's a summary of available commands:

  • M-x nox, as described above;

  • M-x nox-reconnect reconnects to the server;

  • M-x nox-shutdown says bye-bye to the server;

  • M-x nox-rename ask the server to rename the symbol at point, if rename work, please use command nox-stderr-buffer, must something rename tool not install, sch as python need rope for rename operation;

  • M-x nox-format asks the server to format buffer or the active region;

  • M-x nox-show-doc show documentation for symbol at point.

  • M-x nox-events-buffer jumps to the events buffer for debugging communication with the server.

  • M-x nox-stderr-buffer if the LSP server is printing useful debug information in stderr, jumps to a buffer with these contents.

  • M-x nox-signal-didChangeConfiguration updates the LSP server configuration according to the value of the variable nox-workspace-configuration, which you may be set in a .dir-locals file, for example.

  • M-x xref-find-definitions find the definition of the identifier at point.

  • M-x xref-find-definitions-other-window find the definition of the identifier at point in other window.

  • M-x xref-pop-marker-stack pop bck to where xref-find-definitions last invoked.

  • M-x xref-find-references find references to the identifier at point.

Customization

Here's a quick summary of the customization options. In Nox's customization group (M-x customize-group) there is more documentation on what these do.

  • nox-doc-tooltip-font: The font for documentation tooltip, font format follow rule fontname-fontsize.

  • nox-doc-tooltip-border-width: The border width of documentation tooltip.

  • nox-doc-tooltip-timeout: The timeout of documentation tooltip show time, default is 30 seconds, tooltip will hide after you change cursor point.

  • nox-doc-name: The name of documentation tooltip.

  • nox-candidate-annotation-limit: The width limit of candidate annotation.

  • nox-autoreconnect: Control ability to reconnect automatically to the LSP server;

  • nox-connect-timeout: Number of seconds before timing out LSP connection attempts;

  • nox-sync-connect: Control blocking of LSP connection attempts;

  • nox-events-buffer-size: Control the size of the Nox events buffer;

  • nox-ignored-server-capabilites: LSP server capabilities that Nox could use, but won't;

  • nox-confirm-server-initiated-edits: If non-nil, ask for confirmation before allowing server to edit the source buffer's text;

There are a couple more variables that you can customize via Emacs lisp:

  • nox-server-programs: as described above;

  • nox-strict-mode: Set to nil by default, meaning Nox is generally lenient about non-conforming servers. Set this to (disallow-non-standard-keys enforce-required-keys) when debugging servers.

  • nox-server-initialized-hook: Hook run after server is successfully initialized;

  • nox-managed-mode-hook: Hook run after Nox started or stopped managing a buffer. Use nox-managed-p to tell if current buffer is still being managed.

  • nox-php-server: Language server for PHP, default is intelephense, you can set with other value: php-language-server

  • nox-omni-sharp-path: Language server path for OmniSharp, default is ~/.emacs.d/.cache/omnisharp/server/v1.34.5/OmniSharp.exe, you can set with other value.

  • nox-python-server: Language server for Python, default is mspyls, you can set with other value: pyls or pyright.

If you choose mspyls:

  1. Execute command nox-print-mspyls-download-url get download url of mspyls.
  2. Then extract to the directory ~/.emacs.d/nox/mspyls/
  3. Permission: ```sudo chmod -R +x ~/.emacs.d/nox/mspyls/

Note mspyls need index file before respond completion request, so please don't test single file under HOME directory, that will cost few minutes to index file, and pyls haven't this problem.

  • nox-optimization-p: Improve performance by adjust GC limit and disable bidi-display-reordering. If you don't need Nox set this, change this option to nil.

More Repositories

1

lazycat-emacs

Andy Stewart's emacs
Emacs Lisp
425
star
2

aweshell

Awesome shell extension base on eshell with wonderful features!
Emacs Lisp
395
star
3

snails

A modern, easy-to-expand fuzzy search framework
Emacs Lisp
386
star
4

awesome-tab

Emacs package to provide out-of-the-box configuration to use tabs.
Emacs Lisp
364
star
5

deepin-terminal

Deepin Terminal written by vala
Vala
257
star
6

awesome-tray

Hide mode-line, display necessary information at right of minibuffer.
Emacs Lisp
233
star
7

color-rg

Search and refactoring tool based on ripgrep.
Emacs Lisp
149
star
8

popweb

Show popup web window for Emacs
JavaScript
142
star
9

mind-wave

Emacs AI plugin based on ChatGPT API
Emacs Lisp
137
star
10

company-english-helper

English helper base on Emacs company-mode
Emacs Lisp
99
star
11

insert-translated-name

Insert translated string as variable or function name
Emacs Lisp
87
star
12

awesome-pair

Auto parenthesis pairing with syntax table
Emacs Lisp
76
star
13

auto-save

Automatically save files without temporary files to protect your finger. ;)
Emacs Lisp
73
star
14

blink-search

In the blink of an eye, the search is complete
Emacs Lisp
72
star
15

sdcv

Emacs interface for sdcv (Stardict console version)
Emacs Lisp
64
star
16

deno-bridge

Build bridge between Emacs and Deno, execution of JavaScript and Typescript within Emacs.
Emacs Lisp
59
star
17

deepin-software-center

Software center for linux deepin.
Python
51
star
18

manateelazycat.github.io

My personal blog
HTML
50
star
19

deepin-screen-recorder

Deepin screen recorder
C++
50
star
20

holo-layer

HoloLayer is a multimedia layer plugin designed specifically for Emacs
Emacs Lisp
48
star
21

grammatical-edit

Grammatical edit base on tree-sitter
Emacs Lisp
47
star
22

hammerspoon-config

My config for Hammerspoon Window Manager
Lua
46
star
23

thing-edit

Copy and paste anything under cursor.
Emacs Lisp
46
star
24

sort-tab

Smarter tab solution for Emacs, sort tab with using frequency.
Emacs Lisp
44
star
25

deepin-system-monitor

System monitor for deepin
C++
41
star
26

instant-rename-tag

Instant rename tag
Emacs Lisp
32
star
27

python-bridge

Write Emacs Plugin by Python, split code from EAF.
Emacs Lisp
32
star
28

lazy-load

Lazy load keys for speed ​​up Emacs startup.
Emacs Lisp
30
star
29

deepin-pinyin-assistant

Deepin pinyin assistant
C
27
star
30

fingertip

Fingertip is struct edit plugin that base on treesit
Emacs Lisp
26
star
31

deepin-editor

Simple note application for deepin
C++
24
star
32

markmacro

Keyboard macro for marked regions
Emacs Lisp
21
star
33

one-key

Many commands share one key.
Emacs Lisp
20
star
34

mrkeyboard

Mr. Keyboard
Vala
17
star
35

grep-dired

Find name with given regexp, and show in dired.
Emacs Lisp
16
star
36

lazycat-theme

Cool hacker's emacs theme, but won't hurt your eye
Emacs Lisp
16
star
37

nova

Nova is a multi-threaded remote access plugin designed specifically for Emacs, with outstanding file synchronization performance.
Emacs Lisp
16
star
38

multi-term

Managing multiple terminal buffers in Emacs.
Emacs Lisp
15
star
39

corfu-english-helper

English helper for Emacs, base on corfu-mode
Emacs Lisp
15
star
40

deepin-voice-recorder

Voice recorder application for deepin
C++
15
star
41

lazy-search

Mark current symbol and jump in all matching symbols.
Emacs Lisp
15
star
42

lsp-bridge

Fastest LSP client for Emacs, work in progress...
Python
14
star
43

deepin-picker

Color picker tool for deepin
C++
13
star
44

css-sort

An Emacs extension you can sort CSS attributables automatically.
Emacs Lisp
13
star
45

tower-ng

Use rails write web todo-list tool like https://tower.im, this project is just a learning project
Ruby
12
star
46

smart-align

Smart align block around cursor
Emacs Lisp
11
star
47

delete-block

Delete block effectively
Emacs Lisp
10
star
48

recursive-search-references

Find function references in directory
Emacs Lisp
9
star
49

deepin-desktop-monitor

Deepin Desktop Monitor
C++
8
star
50

key-echo

Key-Echo is an Emacs plugin that uses XRecord technology to listen to system key events
Emacs Lisp
8
star
51

highlight-matching-tag

This plugin will highlight matching tag instantaneously.
Emacs Lisp
8
star
52

bison

Mode to editing bision source code in Emacs
Emacs Lisp
8
star
53

wraplish

Wraplish 是一个在 Unicode 与英文之间加上空格的Emacs插件,
Emacs Lisp
7
star
54

duplicate-line

Duplicate line or region, don't need move cursor.
Emacs Lisp
7
star
55

flex

It's a mode for flex files that provide better syntax highlight than flex-mode.el
Emacs Lisp
7
star
56

watch-other-window

Scroll other window and keep current window's position.
Emacs Lisp
7
star
57

find-define

Jump to the definition of a function or variable
Emacs Lisp
6
star
58

deepin-gnome-shell-3.4.1

Deepin gnome shell 3.4.1
C
6
star
59

move-text

Move current line or region
Emacs Lisp
6
star
60

deepin-translate-tools

Translate tools for deepin linux.
Python
6
star
61

vi-navigate

Navigate read-only buffer like vi behavior.
Emacs Lisp
6
star
62

html-to-word

This is a HTML to Word conversion library for Rails.
Ruby
6
star
63

manateelazycat

Github profile repo
5
star
64

cache-path-from-shell

Provide a chache mechanism make sure exec-path-from-shell just execute once.
Emacs Lisp
5
star
65

find-orphan

Find orphan function that need remove
Emacs Lisp
5
star
66

open-newline

Open newline like vi.
Emacs Lisp
4
star
67

toggle-one-window

Toggle between window layout and one window.
Emacs Lisp
4
star
68

lazycat-gs-theme

Gnome shell for my own use
Shell
3
star
69

manatee

Manatee Integrate Live Environment
Haskell
3
star
70

deb2po

Convert format between *.debian and *.po file.
Python
3
star
71

effortless-indent

Indent paste code without additional selection operations
Emacs Lisp
3
star
72

lazycat-emacs-time-machine

The elisp code that has been tossed, no longer used, archived to commemorate
Emacs Lisp
3
star
73

deno-bridge-ts

Build bridge between Emacs and Deno, execution of JavaScript and Typescript within Emacs, this repo is TypeScript part for deno-bridge
TypeScript
1
star