NeNe Nib

Language servers

A language server is a separate app, made for one programming language, that reads the source code you write and reports errors, offers completions (suggestions for the rest of a name you have started typing), shows where things are defined, and more. When NeNe Nib is connected to a language server, it shows this information right in the text. Language servers are not included with Nib, so you install the one for your language separately. This chapter uses clangd (the language server for C and C++) as an example to show how to connect a language server and use it.

Language servers are off by default, so installing one has no effect until you turn them on. Turn on language servers in Settings, and choose a server for your language.

Connect a language server

The easiest way is from Settings, which opens on the right when you press Ctrl+,.

  1. Install the language server for your language. For C and C++, that is clangd.
  2. In Nib, press Ctrl+, to open Settings.
  3. In the Features section, turn on Language Server (LSP).
  4. The Language Server section lists one row for each language. When Nib finds an installed language server, the row shows Found. Click Use on the right.
  5. Close Settings. Your settings are saved when you close it.
  6. Open a file in that language. The language server starts.

Each row in the Language Server section shows one of these states.

State Meaning
Searching… Nib is still searching your PC.
Found The language server is installed. Click Use to use it for this language.
Not found The language server was not found. The second line shows the command that installs it. For Lua and Markdown, instead of a command, you see a note such as "Install …, then reopen the settings to list it here".
Configured A language server is set for this language. Click Remove to stop using it.
Starting The language server is starting.
● Running The language server is running.
Stopped The language server failed to start several times in a row, so Nib stopped it. You can start it again with :set lsp.

The right side of the status bar shows the language of the open document. While a language server is starting, the status bar also shows its progress.

See errors and warnings (diagnostics)

When a language server finds an error or a warning, a wavy underline appears at that place in the text. These are called diagnostics.

To do this Basic mode Vim mode What happens
Go to the next diagnostic F8 F8 or ]d Moves to the next error or warning.
Go to the previous diagnostic Shift+F8 Shift+F8 or [d Moves to the previous error or warning.
See the whole diagnostic message Show diagnostic in All Commands (F1) gl Shows the diagnostic message at the caret in a small box.
See a list of diagnostics List diagnostics in All Commands (F1) Same as Basic mode Lists the diagnostics of the open tabs in the Files and Tabs list (Ctrl+P).

You can also open the list of diagnostics by pressing Ctrl+P and typing ^.

Complete names

You can choose the rest of a name you have started typing from a list of suggestions. The language server's suggestions come first, followed by words in the open documents. When language servers are off, only the words in the documents are listed.

Basic mode

To do this Do this What happens
Open the list of suggestions Ctrl+Space (or Ctrl+I) Lists suggestions that match the partial name before the caret.
Choose a suggestion ↑ / ↓ The chosen suggestion is highlighted. The text does not change yet.
Insert the chosen suggestion Enter or Tab Replaces the partial name with the chosen suggestion.
Close the list Esc Closes the list without inserting anything.

Vim mode

Use these keys in INSERT.

To do this Do this What happens
Open the list of suggestions and insert the next one Ctrl+N Opens the list and inserts the suggestions one by one.
Insert the previous suggestion Ctrl+P Inserts the suggestions in reverse order.
Accept the current suggestion Ctrl+Y Closes the list.
Cancel Ctrl+E Restores the partial name and closes the list.

See information about a name and go to its definition

To do this Basic mode Vim mode What happens
See information about a name Show information in All Commands (F1) K Shows the type and description of the name at the caret in a small box.
Go to the definition F12 F12 or gd Moves to where the name at the caret is defined. If it is in another file, that file opens.
See parameter info Show parameter info in All Commands (F1) Same as Basic mode Shows the parameters of the function call above the caret line.

Find where a name is used (references)

To do this Basic mode Vim mode What happens
See a list of the places that use a name Shift+F12 Shift+F12 or grr Lists the places that use the name at the caret in the Files and Tabs list.

Choose a place in the list and press Enter to go there. The list shows up to 1,000 items. To see the list from your last reference search again, press Ctrl+P and type &.

See a list of functions and types (symbols)

To do this Basic mode Vim mode What happens
See a list of the functions and types in the current document List symbols in All Commands (F1) gO Lists the functions, types, and other symbols of the current document in the Files and Tabs list.

Choose an item in the list and press Enter to go there. The list shows up to 1,000 items. You can also open the list of symbols by pressing Ctrl+P and typing %.

Rename a symbol

You can rename a function or variable, together with every place that uses it, in one step.

To do this Basic mode Vim mode What happens
Rename a symbol F2 F2 or grn "New name:" appears at the bottom of the window. Type the new name and press Enter to rename it.

Format code

You can ask the language server to tidy up the indentation and spacing. There are no keys for this, so choose it from All Commands (F1).

To do this Do this What happens
Format the whole document Format document in All Commands (F1) Formats the whole document.
Format the selection Format selection in All Commands (F1) Formats the selected text. If nothing is selected, formats the caret line.

You can undo the formatting with one Ctrl+Z (u in Vim mode). In Vim mode, formatting is not done in INSERT.

Fix problems with a language server

Going further: Set up language servers in the settings file

Clicking Use in Settings writes lines like these to the settings file settings.v6 (see the end of the Installing and first start chapter). You can also write them by hand.

lsp=on
lsp.cpp.command=C:\llvm\bin\clangd.exe

The Language Server section of Settings lists language servers for C / C++, Python, TypeScript / JavaScript, Rust, Go, C#, Lua, shell, JSON, CSS, HTML, YAML, Dockerfile, PHP, and Markdown. The ones that have been tested are clangd, rust-analyzer, gopls, and pyright.

One language server runs for each language, and it keeps running when you switch tabs. C and C++, and TypeScript and JavaScript, which run with the same command, share one language server within the same project. The extent of a project is decided by searching upward from the document's folder for a marker file such as .git or Cargo.toml.

Renaming has these limits.

Next: Themes and appearance covers how to change colors, fonts, and display.

Source of this manual: nene-nib / docs/manual/en(179fe3be)