Skip to content

Commit 39f64e6

Browse files
Debug: Add README for nvim LSP debug instructions
1 parent fa561be commit 39f64e6

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

server/README-DEVELOPER.md

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Bitbake Language Server Developer README
2+
3+
# Neovim Debug Instructions
4+
5+
Install the Bitbake language server globally as instructed in the
6+
[README.md](./README.md).
7+
8+
To use the `node inspect` CLI debugger to debug the server, place `debugger`
9+
keywords for breakpoints in the code to debug (make sure to recompile the
10+
Typescript back to Javascript after changing any Typescript).
11+
12+
Use the minimal `init.lua` from the [README.md](./README.md) (The `-u` nvim
13+
flag can be used to specify a path different from `~/.config/nvim/init.lua`).
14+
15+
Change the `cmd` field for something like this:
16+
```lua
17+
cmd = {
18+
'node',
19+
'--inspect',
20+
'/path/to/vscode-bitbake/server/out/server.js',
21+
'--stdio',
22+
},
23+
```
24+
This will make the process expose a web socket on 127.0.0.1:9229 for debugging
25+
(See [node.js debugging](https://nodejs.org/en/learn/getting-started/debugging)).
26+
27+
Add the following line to the `init.lua` to enable Neovim debug logging:
28+
```lua
29+
-- Set debug logging (See :help set_log_level and :help vim.log.levels)
30+
vim.lsp.set_log_level(vim.log.levels.DEBUG)
31+
32+
-- Or for more recent nvim builds:
33+
-- vim.lsp.log.set_level(vim.log.levels.DEBUG)
34+
```
35+
This will enable LSP logs to be sent to `~/.local/state/nvim/lsp.log`. But
36+
in case the default path has changed, the command `:=vim.lsp.get_log_path()` can
37+
be used to get the current LSP log path.
38+
39+
Run the following command to launch Neovim:
40+
```sh
41+
nvim --clean -u init.lua src/__tests__/fixtures/completion.bb
42+
```
43+
`--clean` tells Neovim not to use the configuration at
44+
`~/.config/nvim/init.lua` and `-u` tells Neovim to use the local `init.lua`. A
45+
sample Bitbake recipe is passed to launch the Bitbake language server.
46+
47+
Validate that Neovim correctly connected to the language server with the
48+
following command:
49+
```vim
50+
:checkhealth vim.lsp
51+
```
52+
The server successfully connected if `bitbake` is listed under `vim.lsp: Active
53+
Clients`.
54+
55+
To attach to the running process:
56+
```sh
57+
node inspect 127.0.0.1:9229
58+
```
59+
Which will provide a `gdb`-like debugging experience.

0 commit comments

Comments
 (0)