Language servers
In Advanced and Expert mode, a language server gives TriPad an understanding of your code. It is a separate program that TriPad starts and talks to in the background. TriPad doesn't come with one: for C and C++ it uses clangd if you have it, and nothing changes if you don't.
To get clangd, install LLVM (winget install LLVM.LLVM), or unzip clangd-windows-*.zip from
clangd's releases and put its bin folder on your PATH.
TriPad looks in Preferences > Language Servers, then on your PATH, then in LLVM's folders under
Program Files and %LOCALAPPDATA%\Programs.
clangd has to know how your project is compiled, and it reads that from a compile_commands.json.
TriPad looks for one beside the file and in the folders above it, in a build folder there, and in the
folders of build, taking the newest. CMake writes one with -DCMAKE_EXPORT_COMPILE_COMMANDS=ON, and
TriPad's own build always does. Without one, clangd guesses, so it can show errors that aren't there.
What it shows#
- Errors and warnings as you type: a wavy line under the text and a symbol in the margin, a disc for an error, a triangle for a warning and a ring for information. On the line with the caret the message shows at the end of the line, in place of Git's note, and in the status bar.
- The status bar counts the document's problems:
clangd: 3 errors, 1 warning, indexing 40%. Click it for Restart and Show Log. - Completion: Ctrl+Space, and by itself as you type after
.,::or three letters of a name. If the server hasn't answered Ctrl+Space in about 0.4 s you get word completion, so the key always does something. - Hovers: rest the mouse on a name for what it is, or on a problem for what is wrong.
- The Function List and
@in the command palette use the server's symbols while it is running.
Edit > Code, also on the right-click menu and in the command palette:
| Command | Key | What it does |
|---|---|---|
| Go to Definition | F12 | Goes to where the name at the caret is defined, or lists the places in Find Results if there are several. In a Markdown file F12 stays the Reading View. |
| Find References | Shift+F12 | Lists every use in Find Results. |
| Show Information | Ctrl+Shift+Space | The hover, from the keyboard, also in the status bar for a screen reader. |
| Rename Symbol | Ctrl+R | Renames what is at the caret everywhere it is used. It first shows how many changes in which files. |
| Format | Alt+Shift+F | Formats the selection, or the whole document, in one undo step. clangd follows the project's .clang-format. |
| Quick Fix | Ctrl+. | Shows the fixes the server has for the caret's line. |
| Next Problem, Previous Problem | Alt+F8, Alt+Shift+F8 | Go to the next or previous error or warning, wrapping round, and say what it is in the status bar. |
Rename Symbol never writes to disk. A file that isn't open opens as a changed tab with its own undo, and Save All finishes the job. If any file can't be changed, none are.
When a server isn't there, or stops#
TriPad never waits for a server. Reading and writing happen on threads of their own, so typing, scrolling and closing the window carry on whatever the server is doing.
| What happens | What you see |
|---|---|
| It isn't installed | One message in the status bar each time TriPad runs, and clangd isn't installed beside it. Everything else works as before. |
| It is slow | Completion and hovers simply don't appear. A command says clangd hasn't answered yet after 5 s, and gives up after 30 s. An answer about text that has changed since is dropped. |
| It crashes | It starts again by itself, within a second the first time, and gets your files as they are in the editor, unsaved changes included. |
| It crashes 3 times in 3 minutes | TriPad stops trying. The status bar says clangd stopped, and the marks go, because they can't be kept right. Tools > Language Server > Restart tries again. |
| It hangs | Answers stop, and once a command has waited 5 s clangd isn't answering shows. Restart clears it. |
Tools > Language Server > Show Log shows what the server has written. A server with no documents left stops after 30 seconds, and closing TriPad ends them all.
There are no language servers for an Untitled document, a binary, large-file mode, the hex view or a file over 8 MB. In Simple mode none of this runs, and a window there costs nothing.
What runs#
Opening a file must never run what its folder names, the rule Git follows above. TriPad runs clangd by
its full path, so a clangd.exe beside your file is ignored. clangd doesn't run the compiler that a
compile_commands.json names, because TriPad doesn't give it --query-driver, and it doesn't load a
plug-in that a project's compile flags name. tests\ui\lsp.ps1 checks this on a hostile folder.
Two things to know:
- clangd keeps its index in a
.cache\clangdfolder besidecompile_commands.json, in your project. It needs one for Find References and Rename Symbol to reach other files. With nocompile_commands.jsonit writes nothing there. You may want.cachein your.gitignore. - A
compile_commands.jsoncan name a folder on a network share, so opening a file in that project can make Windows connect to that server and offer your sign-in. No program runs. If that matters where you work, turn off Use language servers for code in Preferences.
Other languages#
Tools > Language Server > Configure Servers (Expert) adds a server: its name, its program, its
arguments and the languages it is for, by their ids, such as rust;toml. It overrides clangd for a
language you give it, and the list is kept in lsp.ini in the settings folder.
Many language servers run a project's code by design, such as rust-analyzer running build scripts, so a server you add never starts by opening a file. The status bar says it is off in that folder, and Tools > Language Server > Start Here turns it on there, and remembers.